changeset 93:7d2fcc60e24e

RomWidget: add column increase/decrease buttons It now looks more like a toolbar than a palette, so I'm also changing its name.
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Tue, 10 Sep 2019 22:52:50 -0400
parents 0a7156615d04
children 7646ea81988f
files img/darkside/decreaseCols.svg img/darkside/increaseCols.svg img/lightside/decreaseCols.svg img/lightside/increaseCols.svg tilerswift
diffstat 5 files changed, 31 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/img/darkside/decreaseCols.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
+    <path d="M3 7h10v2H3z" style="marker:none" color="#bebebe" overflow="visible" fill="#d1cbc9"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/img/darkside/increaseCols.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
+    <path style="marker:none" d="M7 3v4H3v2h4v4h2V9h4V7H9V3z" color="#bebebe" overflow="visible" fill="#d1cbc9"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/img/lightside/decreaseCols.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
+    <path d="M3 7h10v2H3z" style="marker:none" color="#bebebe" overflow="visible" fill="#2e3436"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/img/lightside/increaseCols.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
+    <path style="marker:none" d="M7 3v4H3v2h4v4h2V9h4V7H9V3z" color="#bebebe" overflow="visible" fill="#2e3436"/>
+</svg>
--- a/tilerswift
+++ b/tilerswift
@@ -428,28 +428,34 @@
 
         self.colour_picker = ColourPicker()
 
-        self.palette = QW.QHBoxLayout()
+        self.toolbar = QW.QHBoxLayout()
         for button_idx, color_idx in enumerate(Tile.default_palette):
             button = PaletteButton(button_idx, color_idx)
             button.pressed.connect(lambda idx=button_idx: self.pick_palette_colour(idx))
-            self.palette.addWidget(button)
+            self.toolbar.addWidget(button)
 
-        for zoom in ["in", "out", "original"]:
-            zoomButton = QW.QPushButton("")
-            iconpath = widget_icon_path(zoomButton)
-            zoomButton.setIcon(QG.QIcon(f"img/{iconpath}/zoom-{zoom}.svg"))
-            zoomButton.setFixedSize(QC.QSize(48, 48))
-            zoomButton.setIconSize(QC.QSize(32, 32))
-            zoomButton.setToolTip(f"Zoom {zoom}")
-            zoomButton.pressed.connect(getattr(self.grid_widget, f"zoom{zoom.capitalize()}"))
-            self.palette.addWidget(zoomButton)
+        for icon, tooltip, function in [
+            ("zoom-in", "Zoom in", "zoomIn"),
+            ("zoom-out", "Zoom out", "zoomOut"),
+            ("zoom-original", "Restore zoom", "zoomOriginal"),
+            ("increaseCols", "Increase number of columns", "increaseCols"),
+            ("decreaseCols", "Decrease number of columns", "decreaseCols"),
+        ]:
+            button = QW.QPushButton("")
+            iconpath = widget_icon_path(button)
+            button.setIcon(QG.QIcon(f"img/{iconpath}/{icon}.svg"))
+            button.setFixedSize(QC.QSize(32, 32))
+            button.setIconSize(QC.QSize(24, 24))
+            button.setToolTip(tooltip)
+            button.pressed.connect(getattr(self.grid_widget, function))
+            self.toolbar.addWidget(button)
 
         left = QW.QVBoxLayout()
         left.addWidget(scroll)
         romWidget = QW.QWidget()
         romWidget.setLayout(left)
         paletteWidget = QW.QWidget()
-        paletteWidget.setLayout(self.palette)
+        paletteWidget.setLayout(self.toolbar)
         left.addWidget(paletteWidget)
 
         left_dock = QW.QDockWidget("ROM tiles", self)
@@ -472,7 +478,7 @@
     def pick_palette_colour(self, palette_idx):
         if self.colour_picker.exec_():
             new_colour_idx = self.colour_picker.picked_idx
-            self.palette.itemAt(palette_idx).widget().set_colour(new_colour_idx)
+            self.toolbar.itemAt(palette_idx).widget().set_colour(new_colour_idx)
             for tile in self.grid_widget.tiles:
                 palette = tile.palette
                 palette[palette_idx] = new_colour_idx