1010 QFormLayout ,
1111 QGridLayout ,
1212 QGroupBox ,
13+ QButtonGroup ,
1314 QPushButton ,
1415 QFileDialog ,
1516 QSpinBox ,
@@ -144,8 +145,9 @@ class SpritePlacement(QFormLayout):
144145 h_dir = QRadioButton ("Horizontal" )
145146 v_dir = QRadioButton ("Vertical" )
146147
147- columns = QSpinBox (value = DEFAULT_SPACE , minimum = DEFAULT_SPACE )
148- rows = QSpinBox (value = DEFAULT_SPACE , minimum = DEFAULT_SPACE )
148+ columns = QRadioButton ("Columns" )
149+ rows = QRadioButton ("Rows" )
150+ size = QSpinBox (value = DEFAULT_SPACE , minimum = DEFAULT_SPACE )
149151
150152 def __init__ (self ):
151153 super ().__init__ ()
@@ -156,47 +158,42 @@ def __init__(self):
156158 self .h_dir .setToolTip ("Order the sprites horizontally" )
157159 self .v_dir .setToolTip ("Order the sprites vertically" )
158160
159- self .columns .setSpecialValueText ("Auto" )
160- self .columns .setToolTip ("Number of columns in the spritesheet" )
161+ self .size .setSpecialValueText ("Auto" )
162+ self .size .setToolTip ("Number of columns or rows in the spritesheet" )
161163
162- self .rows .setEnabled (False )
163- self .rows .setSpecialValueText ("Auto" )
164- self .rows .setToolTip ("Number of rows in the spritesheet" )
164+ self .columns .setChecked (True )
165165
166- self .h_dir .toggled .connect (self .toggle_horizontal )
167- self .v_dir .toggled .connect (self .toggle_vertical )
166+ dirs = QVBoxLayout ()
167+ dirs .addWidget (self .h_dir )
168+ dirs .addWidget (self .v_dir )
169+ dirs_buttons = QButtonGroup ()
170+ dirs_buttons .addButton (self .h_dir )
171+ dirs_buttons .addButton (self .v_dir )
168172
169- col_layout = QFormLayout ()
170- col_layout .setHorizontalSpacing (4 )
171- col_layout .addRow ("Columns:" , self .columns )
173+ sizes = QHBoxLayout ()
172174
173- row_layout = QFormLayout ()
174- row_layout .setHorizontalSpacing (4 )
175- row_layout .addRow ("Rows:" , self .rows )
175+ size_buttons_box = QVBoxLayout ()
176+ size_buttons_box .addWidget (self .columns )
177+ size_buttons_box .addWidget (self .rows )
178+ size_buttons = QButtonGroup (size_buttons_box )
179+ size_buttons .addButton (self .columns )
180+ size_buttons .addButton (self .rows )
176181
177- field = QGridLayout ()
178- field .addWidget (self .h_dir , 0 , 0 )
179- field .addWidget (self .v_dir , 0 , 1 )
180- field .addLayout (col_layout , 1 , 0 )
181- field .addLayout (row_layout , 1 , 1 )
182+ sizes .addLayout (size_buttons_box )
183+ sizes .addWidget (self .size )
182184
183- self .addRow ("Sprite placement:" , field )
184-
185- def toggle_horizontal (self , checked : bool ):
186- self .columns .setEnabled (checked )
187- self .rows .setEnabled (not checked )
188-
189- def toggle_vertical (self , checked : bool ):
190- self .columns .setEnabled (not checked )
191- self .rows .setEnabled (checked )
185+ self .addRow ("Sprite placement:" , dirs )
186+ self .addRow ("Spritesheet size:" , sizes )
192187
193188 def apply_settings (self , exporter : SpritesheetExporter ):
194- if self .h_dir .isChecked ():
195- exporter .horizontal = True
196- exporter .size = self .columns .value ()
189+ exporter .horizontal = self .h_dir .isChecked ()
190+
191+ if self .columns .isChecked ():
192+ exporter .columns = self .size .value ()
193+ exporter .rows = DEFAULT_SPACE
197194 else :
198- exporter .horizontal = False
199- exporter .size = self .rows .value ()
195+ exporter .columns = DEFAULT_SPACE
196+ exporter .rows = self .size .value ()
200197
201198
202199class SpinBoxes (QFormLayout ):
0 commit comments