feat: clicking blanks area also controls the toggle button.
This commit is contained in:
@@ -137,6 +137,9 @@ public class ComponentList extends Control {
|
|||||||
if (node.getProperties().containsKey("ComponentList.vgrow")) {
|
if (node.getProperties().containsKey("ComponentList.vgrow")) {
|
||||||
VBox.setVgrow(cell, (Priority) node.getProperties().get("ComponentList.vgrow"));
|
VBox.setVgrow(cell, (Priority) node.getProperties().get("ComponentList.vgrow"));
|
||||||
}
|
}
|
||||||
|
if (node.getProperties().containsKey("ComponentList.noPadding")) {
|
||||||
|
cell.getStyleClass().add("no-padding");
|
||||||
|
}
|
||||||
return cell;
|
return cell;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
* Hello Minecraft! Launcher
|
||||||
|
* Copyright (C) 2021 huangyuhui <huanghongxun2008@126.com> and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.jackhuang.hmcl.ui.construct;
|
||||||
|
|
||||||
|
import com.jfoenix.controls.JFXToggleButton;
|
||||||
|
import javafx.beans.property.BooleanProperty;
|
||||||
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.beans.property.StringProperty;
|
||||||
|
import javafx.geometry.Insets;
|
||||||
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.layout.BorderPane;
|
||||||
|
import javafx.scene.layout.StackPane;
|
||||||
|
import org.jackhuang.hmcl.ui.FXUtils;
|
||||||
|
|
||||||
|
public class OptionToggleButton extends StackPane {
|
||||||
|
private final StringProperty title = new SimpleStringProperty();
|
||||||
|
private final BooleanProperty selected = new SimpleBooleanProperty();
|
||||||
|
|
||||||
|
public OptionToggleButton() {
|
||||||
|
getProperties().put("ComponentList.noPadding", true);
|
||||||
|
|
||||||
|
BorderPane pane = new BorderPane();
|
||||||
|
pane.setPadding(new Insets(8, 8, 8, 16));
|
||||||
|
RipplerContainer container = new RipplerContainer(pane);
|
||||||
|
getChildren().setAll(container);
|
||||||
|
|
||||||
|
Label label = new Label();
|
||||||
|
label.setMouseTransparent(true);
|
||||||
|
label.textProperty().bind(title);
|
||||||
|
pane.setLeft(label);
|
||||||
|
BorderPane.setAlignment(label, Pos.CENTER_LEFT);
|
||||||
|
|
||||||
|
JFXToggleButton toggleButton = new JFXToggleButton();
|
||||||
|
pane.setRight(toggleButton);
|
||||||
|
toggleButton.selectedProperty().bindBidirectional(selected);
|
||||||
|
toggleButton.setSize(8);
|
||||||
|
FXUtils.setLimitHeight(toggleButton, 30);
|
||||||
|
|
||||||
|
container.setOnMouseClicked(e -> {
|
||||||
|
toggleButton.setSelected(!toggleButton.isSelected());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringProperty titleProperty() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title.set(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSelected() {
|
||||||
|
return selected.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BooleanProperty selectedProperty() {
|
||||||
|
return selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelected(boolean selected) {
|
||||||
|
this.selected.set(selected);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -89,11 +89,11 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
|||||||
private final JFXComboBox<LauncherVisibility> cboLauncherVisibility;
|
private final JFXComboBox<LauncherVisibility> cboLauncherVisibility;
|
||||||
private final JFXCheckBox chkAutoAllocate;
|
private final JFXCheckBox chkAutoAllocate;
|
||||||
private final JFXCheckBox chkFullscreen;
|
private final JFXCheckBox chkFullscreen;
|
||||||
private final JFXToggleButton chkNoJVMArgs;
|
private final OptionToggleButton noJVMArgsPane;
|
||||||
private final JFXToggleButton chkNoGameCheck;
|
private final OptionToggleButton noGameCheckPane;
|
||||||
private final JFXToggleButton chkNoJVMCheck;
|
private final OptionToggleButton noJVMCheckPane;
|
||||||
private final JFXToggleButton chkUseNativeGLFW;
|
private final OptionToggleButton useNativeGLFWPane;
|
||||||
private final JFXToggleButton chkUseNativeOpenAL;
|
private final OptionToggleButton useNativeOpenALPane;
|
||||||
private final MultiFileItem<JavaVersion> javaItem;
|
private final MultiFileItem<JavaVersion> javaItem;
|
||||||
private final MultiFileItem.FileOption<JavaVersion> javaCustomOption;
|
private final MultiFileItem.FileOption<JavaVersion> javaCustomOption;
|
||||||
private final MultiFileItem<GameDirectoryType> gameDirItem;
|
private final MultiFileItem<GameDirectoryType> gameDirItem;
|
||||||
@@ -101,7 +101,7 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
|||||||
private final MultiFileItem<NativesDirectoryType> nativesDirItem;
|
private final MultiFileItem<NativesDirectoryType> nativesDirItem;
|
||||||
private final MultiFileItem.FileOption<NativesDirectoryType> nativesDirCustomOption;
|
private final MultiFileItem.FileOption<NativesDirectoryType> nativesDirCustomOption;
|
||||||
private final JFXComboBox<ProcessPriority> cboProcessPriority;
|
private final JFXComboBox<ProcessPriority> cboProcessPriority;
|
||||||
private final JFXToggleButton chkShowLogs;
|
private final OptionToggleButton showLogsPane;
|
||||||
private final ImagePickerItem iconPickerItem;
|
private final ImagePickerItem iconPickerItem;
|
||||||
private final JFXCheckBox chkEnableSpecificSettings;
|
private final JFXCheckBox chkEnableSpecificSettings;
|
||||||
private final BorderPane settingsTypePane;
|
private final BorderPane settingsTypePane;
|
||||||
@@ -328,17 +328,8 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BorderPane showLogsPane = new BorderPane();
|
showLogsPane = new OptionToggleButton();
|
||||||
{
|
showLogsPane.setTitle(i18n("settings.show_log"));
|
||||||
Label label = new Label(i18n("settings.show_log"));
|
|
||||||
showLogsPane.setLeft(label);
|
|
||||||
BorderPane.setAlignment(label, Pos.CENTER_LEFT);
|
|
||||||
|
|
||||||
chkShowLogs = new JFXToggleButton();
|
|
||||||
showLogsPane.setRight(chkShowLogs);
|
|
||||||
chkShowLogs.setSize(8);
|
|
||||||
FXUtils.setLimitHeight(chkShowLogs, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
BorderPane processPriorityPane = new BorderPane();
|
BorderPane processPriorityPane = new BorderPane();
|
||||||
{
|
{
|
||||||
@@ -459,65 +450,20 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
|||||||
nativesDirCustomOption
|
nativesDirCustomOption
|
||||||
));
|
));
|
||||||
|
|
||||||
BorderPane noJVMArgsPane = new BorderPane();
|
noJVMArgsPane = new OptionToggleButton();
|
||||||
{
|
noJVMArgsPane.setTitle(i18n("settings.advanced.no_jvm_args"));
|
||||||
Label label = new Label(i18n("settings.advanced.no_jvm_args"));
|
|
||||||
noJVMArgsPane.setLeft(label);
|
|
||||||
BorderPane.setAlignment(label, Pos.CENTER_LEFT);
|
|
||||||
|
|
||||||
chkNoJVMArgs = new JFXToggleButton();
|
noGameCheckPane = new OptionToggleButton();
|
||||||
noJVMArgsPane.setRight(chkNoJVMArgs);
|
noGameCheckPane.setTitle(i18n("settings.advanced.dont_check_game_completeness"));
|
||||||
chkNoJVMArgs.setSize(8);
|
|
||||||
FXUtils.setLimitHeight(chkNoJVMArgs, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
BorderPane noGameCheckPane = new BorderPane();
|
noJVMCheckPane = new OptionToggleButton();
|
||||||
{
|
noJVMCheckPane.setTitle(i18n("settings.advanced.dont_check_jvm_validity"));
|
||||||
Label label = new Label(i18n("settings.advanced.dont_check_game_completeness"));
|
|
||||||
noGameCheckPane.setLeft(label);
|
|
||||||
BorderPane.setAlignment(label, Pos.CENTER_LEFT);
|
|
||||||
|
|
||||||
chkNoGameCheck = new JFXToggleButton();
|
useNativeGLFWPane = new OptionToggleButton();
|
||||||
noGameCheckPane.setRight(chkNoGameCheck);
|
useNativeGLFWPane.setTitle(i18n("settings.advanced.use_native_glfw"));
|
||||||
chkNoGameCheck.setSize(8);
|
|
||||||
FXUtils.setLimitHeight(chkNoGameCheck, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
BorderPane noJVMCheckPane = new BorderPane();
|
useNativeOpenALPane = new OptionToggleButton();
|
||||||
{
|
useNativeOpenALPane.setTitle(i18n("settings.advanced.use_native_openal"));
|
||||||
Label label = new Label(i18n("settings.advanced.dont_check_jvm_validity"));
|
|
||||||
noJVMCheckPane.setLeft(label);
|
|
||||||
BorderPane.setAlignment(label, Pos.CENTER_LEFT);
|
|
||||||
|
|
||||||
chkNoJVMCheck = new JFXToggleButton();
|
|
||||||
noJVMCheckPane.setRight(chkNoJVMCheck);
|
|
||||||
chkNoJVMCheck.setSize(8);
|
|
||||||
FXUtils.setLimitHeight(chkNoJVMCheck, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
BorderPane useNativeGLFWPane = new BorderPane();
|
|
||||||
{
|
|
||||||
Label label = new Label(i18n("settings.advanced.use_native_glfw"));
|
|
||||||
useNativeGLFWPane.setLeft(label);
|
|
||||||
BorderPane.setAlignment(label, Pos.CENTER_LEFT);
|
|
||||||
|
|
||||||
chkUseNativeGLFW = new JFXToggleButton();
|
|
||||||
useNativeGLFWPane.setRight(chkUseNativeGLFW);
|
|
||||||
chkUseNativeGLFW.setSize(8);
|
|
||||||
FXUtils.setLimitHeight(chkUseNativeGLFW, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
BorderPane useNativeOpenALPane = new BorderPane();
|
|
||||||
{
|
|
||||||
Label label = new Label(i18n("settings.advanced.use_native_openal"));
|
|
||||||
useNativeOpenALPane.setLeft(label);
|
|
||||||
BorderPane.setAlignment(label, Pos.CENTER_LEFT);
|
|
||||||
|
|
||||||
chkUseNativeOpenAL = new JFXToggleButton();
|
|
||||||
useNativeOpenALPane.setRight(chkUseNativeOpenAL);
|
|
||||||
chkUseNativeOpenAL.setSize(8);
|
|
||||||
FXUtils.setLimitHeight(chkUseNativeOpenAL, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
workaroundPane.getContent().setAll(nativesDirItem, noJVMArgsPane, noGameCheckPane, noJVMCheckPane, useNativeGLFWPane, useNativeOpenALPane);
|
workaroundPane.getContent().setAll(nativesDirItem, noJVMArgsPane, noGameCheckPane, noJVMCheckPane, useNativeGLFWPane, useNativeOpenALPane);
|
||||||
}
|
}
|
||||||
@@ -614,12 +560,12 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
|||||||
FXUtils.unbindString(txtServerIP, lastVersionSetting.serverIpProperty());
|
FXUtils.unbindString(txtServerIP, lastVersionSetting.serverIpProperty());
|
||||||
FXUtils.unbindBoolean(chkAutoAllocate, lastVersionSetting.autoMemoryProperty());
|
FXUtils.unbindBoolean(chkAutoAllocate, lastVersionSetting.autoMemoryProperty());
|
||||||
FXUtils.unbindBoolean(chkFullscreen, lastVersionSetting.fullscreenProperty());
|
FXUtils.unbindBoolean(chkFullscreen, lastVersionSetting.fullscreenProperty());
|
||||||
FXUtils.unbindBoolean(chkNoGameCheck, lastVersionSetting.notCheckGameProperty());
|
noGameCheckPane.selectedProperty().unbindBidirectional(lastVersionSetting.notCheckGameProperty());
|
||||||
FXUtils.unbindBoolean(chkNoJVMCheck, lastVersionSetting.notCheckJVMProperty());
|
noJVMCheckPane.selectedProperty().unbindBidirectional(lastVersionSetting.notCheckJVMProperty());
|
||||||
FXUtils.unbindBoolean(chkNoJVMArgs, lastVersionSetting.noJVMArgsProperty());
|
noJVMArgsPane.selectedProperty().unbindBidirectional(lastVersionSetting.noJVMArgsProperty());
|
||||||
FXUtils.unbindBoolean(chkShowLogs, lastVersionSetting.showLogsProperty());
|
showLogsPane.selectedProperty().unbindBidirectional(lastVersionSetting.showLogsProperty());
|
||||||
FXUtils.unbindBoolean(chkUseNativeGLFW, lastVersionSetting.useNativeGLFWProperty());
|
useNativeGLFWPane.selectedProperty().unbindBidirectional(lastVersionSetting.useNativeGLFWProperty());
|
||||||
FXUtils.unbindBoolean(chkUseNativeOpenAL, lastVersionSetting.useNativeOpenALProperty());
|
useNativeOpenALPane.selectedProperty().unbindBidirectional(lastVersionSetting.useNativeOpenALProperty());
|
||||||
FXUtils.unbindEnum(cboLauncherVisibility);
|
FXUtils.unbindEnum(cboLauncherVisibility);
|
||||||
FXUtils.unbindEnum(cboProcessPriority);
|
FXUtils.unbindEnum(cboProcessPriority);
|
||||||
|
|
||||||
@@ -653,12 +599,12 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
|||||||
FXUtils.bindString(txtServerIP, versionSetting.serverIpProperty());
|
FXUtils.bindString(txtServerIP, versionSetting.serverIpProperty());
|
||||||
FXUtils.bindBoolean(chkAutoAllocate, versionSetting.autoMemoryProperty());
|
FXUtils.bindBoolean(chkAutoAllocate, versionSetting.autoMemoryProperty());
|
||||||
FXUtils.bindBoolean(chkFullscreen, versionSetting.fullscreenProperty());
|
FXUtils.bindBoolean(chkFullscreen, versionSetting.fullscreenProperty());
|
||||||
FXUtils.bindBoolean(chkNoGameCheck, versionSetting.notCheckGameProperty());
|
noGameCheckPane.selectedProperty().bindBidirectional(versionSetting.notCheckGameProperty());
|
||||||
FXUtils.bindBoolean(chkNoJVMCheck, versionSetting.notCheckJVMProperty());
|
noJVMCheckPane.selectedProperty().bindBidirectional(versionSetting.notCheckJVMProperty());
|
||||||
FXUtils.bindBoolean(chkNoJVMArgs, versionSetting.noJVMArgsProperty());
|
noJVMArgsPane.selectedProperty().bindBidirectional(versionSetting.noJVMArgsProperty());
|
||||||
FXUtils.bindBoolean(chkShowLogs, versionSetting.showLogsProperty());
|
showLogsPane.selectedProperty().bindBidirectional(versionSetting.showLogsProperty());
|
||||||
FXUtils.bindBoolean(chkUseNativeGLFW, versionSetting.useNativeGLFWProperty());
|
useNativeGLFWPane.selectedProperty().bindBidirectional(versionSetting.useNativeGLFWProperty());
|
||||||
FXUtils.bindBoolean(chkUseNativeOpenAL, versionSetting.useNativeOpenALProperty());
|
useNativeOpenALPane.selectedProperty().bindBidirectional(versionSetting.useNativeOpenALProperty());
|
||||||
FXUtils.bindEnum(cboLauncherVisibility, versionSetting.launcherVisibilityProperty());
|
FXUtils.bindEnum(cboLauncherVisibility, versionSetting.launcherVisibilityProperty());
|
||||||
FXUtils.bindEnum(cboProcessPriority, versionSetting.processPriorityProperty());
|
FXUtils.bindEnum(cboProcessPriority, versionSetting.processPriorityProperty());
|
||||||
|
|
||||||
|
|||||||
@@ -831,6 +831,10 @@
|
|||||||
-fx-font-size: 12;
|
-fx-font-size: 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.options-list-item.no-padding {
|
||||||
|
-fx-padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.no-padding .options-list-item {
|
.no-padding .options-list-item {
|
||||||
-fx-padding: 0;
|
-fx-padding: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user