4848import org .jackhuang .hmcl .task .Task ;
4949import org .jackhuang .hmcl .ui .Controllers ;
5050import org .jackhuang .hmcl .ui .FXUtils ;
51+ import org .jackhuang .hmcl .ui .SVG ;
5152import org .jackhuang .hmcl .ui .WeakListenerHolder ;
5253import org .jackhuang .hmcl .ui .construct .*;
5354import org .jackhuang .hmcl .ui .decorator .DecoratorPage ;
@@ -254,62 +255,66 @@ protected ModDownloadListPageSkin(DownloadListPage control) {
254255
255256 BorderPane pane = new BorderPane ();
256257
257- GridPane searchPane = new GridPane ( );
258+ VBox searchPane = new VBox ( 8 );
258259 pane .setTop (searchPane );
259260 searchPane .getStyleClass ().addAll ("card" );
260261 BorderPane .setMargin (searchPane , new Insets (10 , 10 , 0 , 10 ));
261262
262- ColumnConstraints nameColumn = new ColumnConstraints ();
263- nameColumn .setMinWidth (USE_PREF_SIZE );
264- ColumnConstraints column1 = new ColumnConstraints ();
265- column1 .setHgrow (Priority .ALWAYS );
266- ColumnConstraints column2 = new ColumnConstraints ();
267- column2 .setHgrow (Priority .ALWAYS );
268- searchPane .getColumnConstraints ().setAll (nameColumn , column1 , nameColumn , column2 );
269-
270- searchPane .setHgap (16 );
271- searchPane .setVgap (10 );
263+ searchPane .setMaxWidth (Double .MAX_VALUE );
272264
273265 {
274- int rowIndex = 0 ;
275-
276- if (control .versionSelection ) {
277- searchPane .addRow (rowIndex );
278- int columns = 0 ;
279- Node lastNode = null ;
280-
281- JFXComboBox <String > versionsComboBox = new JFXComboBox <>();
282- versionsComboBox .setMaxWidth (Double .MAX_VALUE );
283- Bindings .bindContent (versionsComboBox .getItems (), control .versions );
284- selectedItemPropertyFor (versionsComboBox ).bindBidirectional (control .selectedVersion );
266+ BooleanProperty isExpanded = new SimpleBooleanProperty (false );
285267
286- searchPane .add (new Label (i18n ("version" )), columns ++, rowIndex );
287- searchPane .add (lastNode = versionsComboBox , columns ++, rowIndex );
288-
289- if (columns == 2 ) {
290- GridPane .setColumnSpan (lastNode , 3 );
291- }
292-
293- rowIndex ++;
294- }
268+ HBox rowBox1 = new HBox (16 );
269+ rowBox1 .setAlignment (Pos .CENTER_LEFT );
270+ rowBox1 .setMaxWidth (Double .MAX_VALUE );
271+ GridPane .setHgrow (rowBox1 , Priority .ALWAYS );
295272
296273 JFXTextField nameField = new JFXTextField ();
274+ HBox .setHgrow (nameField , Priority .ALWAYS );
275+ nameField .setMaxWidth (Double .MAX_VALUE );
297276 nameField .setPromptText (getSkinnable ().supportChinese .get () ? i18n ("search.hint.chinese" ) : i18n ("search.hint.english" ));
298277 if (getSkinnable ().supportChinese .get ()) {
299278 FXUtils .installFastTooltip (nameField , i18n ("search.hint.chinese" ));
300279 } else {
301280 FXUtils .installFastTooltip (nameField , i18n ("search.hint.english" ));
302281 }
303282
283+ JFXButton btnExpend = FXUtils .newToggleButton4 (SVG .ARROW_DROP_DOWN );
284+ btnExpend .setOnAction (e -> {
285+ isExpanded .set (!isExpanded .get ());
286+ btnExpend .setGraphic (isExpanded .get () ? FXUtils .newToggleButton4 (SVG .ARROW_DROP_UP ) : FXUtils .newToggleButton4 (SVG .ARROW_DROP_DOWN ));
287+ });
288+
289+ if (control .versionSelection ) {
290+ JFXComboBox <String > versionsComboBox = new JFXComboBox <>();
291+ versionsComboBox .setPrefWidth (200 );
292+ Bindings .bindContent (versionsComboBox .getItems (), control .versions );
293+ selectedItemPropertyFor (versionsComboBox ).bindBidirectional (control .selectedVersion );
294+
295+ rowBox1 .getChildren ().addAll (new Label (i18n ("version" )), versionsComboBox , new Label (i18n ("mods.name" )), nameField , btnExpend );
296+ } else {
297+ rowBox1 .getChildren ().addAll (new Label (i18n ("mods.name" )), nameField , btnExpend );
298+ }
299+
300+ searchPane .getChildren ().add (rowBox1 );
301+
302+ HBox rowBox2 = new HBox (16 );
303+ rowBox2 .setAlignment (Pos .CENTER_LEFT );
304+ GridPane .setHgrow (rowBox2 , Priority .ALWAYS );
305+
306+ rowBox2 .visibleProperty ().bind (isExpanded );
307+ rowBox2 .managedProperty ().bind (isExpanded );
308+
304309 JFXComboBox <String > gameVersionField = new JFXComboBox <>();
305- gameVersionField .setMaxWidth ( Double . MAX_VALUE );
310+ gameVersionField .setPrefWidth ( 100 );
306311 gameVersionField .setEditable (true );
307312 gameVersionField .getItems ().setAll (GameVersionNumber .getDefaultGameVersions ());
308313 Label lblGameVersion = new Label (i18n ("world.game_version" ));
309- searchPane . addRow ( rowIndex ++, new Label ( i18n ( "mods.name" )), nameField , lblGameVersion , gameVersionField );
314+ lblGameVersion . setMinWidth ( USE_PREF_SIZE );
310315
311316 ObjectBinding <Boolean > hasVersion = BindingMapping .of (getSkinnable ().instanceReference )
312- .map (instanceReference -> instanceReference .instanceId () == null );
317+ .map (instanceReference -> instanceReference .instanceId () == null );
313318 lblGameVersion .managedProperty ().bind (hasVersion );
314319 lblGameVersion .visibleProperty ().bind (hasVersion );
315320 gameVersionField .managedProperty ().bind (hasVersion );
@@ -325,6 +330,7 @@ protected ModDownloadListPageSkin(DownloadListPage control) {
325330 });
326331
327332 StackPane categoryStackPane = new StackPane ();
333+ categoryStackPane .setPrefWidth (100 );
328334 JFXComboBox <CategoryIndented > categoryComboBox = new JFXComboBox <>();
329335 categoryComboBox .getItems ().setAll (CategoryIndented .ALL );
330336 categoryStackPane .getChildren ().setAll (categoryComboBox );
@@ -354,14 +360,23 @@ protected ModDownloadListPageSkin(DownloadListPage control) {
354360 });
355361
356362 StackPane sortStackPane = new StackPane ();
363+ sortStackPane .setPrefWidth (100 );
357364 JFXComboBox <RemoteAddonRepository .SortType > sortComboBox = new JFXComboBox <>();
358365 sortStackPane .getChildren ().setAll (sortComboBox );
359366 sortComboBox .prefWidthProperty ().bind (sortStackPane .widthProperty ());
360367 sortComboBox .getStyleClass ().add ("fit-width" );
361368 sortComboBox .setConverter (stringConverter (sortType -> i18n ("curse.sort." + sortType .name ().toLowerCase (Locale .ROOT ))));
362369 sortComboBox .getItems ().setAll (RemoteAddonRepository .SortType .values ());
363370 sortComboBox .getSelectionModel ().select (0 );
364- searchPane .addRow (rowIndex ++, new Label (i18n ("addon.category" )), categoryStackPane , new Label (i18n ("search.sort" )), sortStackPane );
371+
372+ Label categoryLabel = new Label (i18n ("addon.category" ));
373+ categoryLabel .setMinWidth (Region .USE_PREF_SIZE );
374+ Label sortLabel = new Label (i18n ("search.sort" ));
375+ sortLabel .setMinWidth (Region .USE_PREF_SIZE );
376+
377+ rowBox2 .getChildren ().addAll (lblGameVersion , gameVersionField , categoryLabel , categoryStackPane , sortLabel , sortStackPane );
378+
379+ searchPane .getChildren ().add (rowBox2 );
365380
366381 IntegerProperty filterID = new SimpleIntegerProperty (this , "Filter ID" , 0 );
367382 IntegerProperty currentFilterID = new SimpleIntegerProperty (this , "Current Filter ID" , -1 );
@@ -393,7 +408,6 @@ protected ModDownloadListPageSkin(DownloadListPage control) {
393408 ));
394409
395410 HBox actionsBox = new HBox (8 );
396- GridPane .setColumnSpan (actionsBox , 4 );
397411 actionsBox .setAlignment (Pos .CENTER );
398412 {
399413 AggregatedObservableList <Node > actions = new AggregatedObservableList <>();
@@ -489,7 +503,7 @@ protected ModDownloadListPageSkin(DownloadListPage control) {
489503 Bindings .bindContent (actionsBox .getChildren (), actions .getAggregatedList ());
490504 }
491505
492- searchPane .addRow ( rowIndex ++, actionsBox );
506+ searchPane .getChildren (). add ( actionsBox );
493507
494508 FXUtils .onChange (control .downloadSource , v -> searchAction .handle (null ));
495509 nameField .setOnAction (searchAction );
0 commit comments