Mercurial > hg > tilerswift
changeset 95:98d2871df3bf
ColourButton: tighten space between the buttons
Turns out that it was possible to resize the dialogue box and have the
buttons move away. I also want them to be all close together in a
tight little palette widget on the ad-hoc toolbar for the ROM viewer
widget.
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Thu, 12 Sep 2019 07:57:08 -0400 |
parents | 7646ea81988f |
children | a7e744200920 |
files | tilerswift |
diffstat | 1 files changed, 16 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/tilerswift +++ b/tilerswift @@ -334,9 +334,12 @@ button.pressed.connect(lambda c=colour_idx: self.colour_picked(c)) layout.addWidget(button, i, j) colours = QW.QWidget() + layout.setSizeConstraint(QW.QLayout.SetFixedSize) colours.setLayout(layout) vlayout = QW.QVBoxLayout() + vlayout.setSpacing(0) + vlayout.setSizeConstraint(QW.QLayout.SetFixedSize) vlayout.addWidget(colours) transparent_button = QW.QPushButton("Transparent") @@ -408,6 +411,7 @@ quit_action.triggered.connect(app.quit) self.tile_picker = TilePicker() + self.colour_picker = ColourPicker() scroll = QW.QScrollArea() scroll.setWidget(self.tile_picker) @@ -426,13 +430,19 @@ scroll = QW.QScrollArea() scroll.setWidget(self.grid_widget) - self.colour_picker = ColourPicker() + self.toolbar = QW.QHBoxLayout() - self.toolbar = QW.QHBoxLayout() + palette_layout = QW.QHBoxLayout() + palette_layout.setSpacing(0) + 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.toolbar.addWidget(button) + palette_layout.addWidget(button) + palette_layout.setSizeConstraint(QW.QLayout.SetFixedSize) + self.palette = QW.QWidget() + self.palette.setLayout(palette_layout) + self.toolbar.addWidget(self.palette) for icon, tooltip, function in [ ("zoom-in", "Zoom in", "zoomIn"), @@ -450,6 +460,8 @@ button.pressed.connect(getattr(self.grid_widget, function)) self.toolbar.addWidget(button) + self.toolbar.addStretch() + left = QW.QVBoxLayout() left.addWidget(scroll) romWidget = QW.QWidget() @@ -478,7 +490,7 @@ def pick_palette_colour(self, palette_idx): if self.colour_picker.exec_(): new_colour_idx = self.colour_picker.picked_idx - self.toolbar.itemAt(palette_idx).widget().set_colour(new_colour_idx) + self.palette.layout().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