Skip to content

Commit

Permalink
color picker layout.
Browse files Browse the repository at this point in the history
  • Loading branch information
leewyatt committed Dec 30, 2022
1 parent 063a2fa commit 7de9b22
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import com.leewyatt.fxtools.ui.paintpicker.colorpicker.ColorPicker;
import com.leewyatt.fxtools.ui.stages.ScreenColorPickerStage;
import com.leewyatt.fxtools.utils.OSUtil;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ReadOnlyBooleanProperty;
import javafx.geometry.Insets;
Expand Down Expand Up @@ -83,6 +84,11 @@ public PaintPicker(Delegate delegate) {
button.setOnAction(event -> {
new ScreenColorPickerStage().showStage();
});
//如果不是windows操作系统,那么不显示
if (OSUtil.getOS() != OSUtil.OS.WINDOWS) {
button.setVisible(false);
button.setManaged(false);
}
root_vbox = new VBox(hBox);
//*<VBox fx:id="root_vbox" alignment="CENTER" minHeight="-1.0" prefHeight="-1.0" prefWidth="-1.0" spacing="5.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.oracle.javafx.scenebuilder.kit.util.control.paintpicker.PaintPickerController">
root_vbox.setAlignment(Pos.CENTER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ScrollPane;
import javafx.scene.input.MouseEvent;
Expand Down Expand Up @@ -48,6 +49,8 @@ public class ColorPageController {
private ComboBox<String> colorCombobox;
@FXML
private Rectangle previewRect;
@FXML
private Button pickerBtn;
private AnchorPane colorHorPage;

private ScrollPane lineGradientPage;
Expand Down Expand Up @@ -86,7 +89,11 @@ public ColorPageController() {

@FXML
void initialize() {

if (OSUtil.getOS() != OSUtil.OS.WINDOWS) {
pickerBtn.setVisible(false);
pickerBtn.setManaged(false);
previewRect.setWidth(62);
}
ColorHorCanvas colorHorCanvas = new ColorHorCanvas();
colorHorPage = new AnchorPane(colorHorCanvas);
LineGradientCanvas lineGradientCanvas = new LineGradientCanvas();
Expand Down
23 changes: 12 additions & 11 deletions src/main/java/com/leewyatt/fxtools/utils/OSUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,19 @@ public static void openAndSelectedFile(String filePath) {
} else {
cmd = "explorer /select," + filePath;
}
} else if (currentOS ==OS.MAC) {
cmd = "xdg-open " + filePath;
} else if (currentOS == OS.LINUX) {
cmd = "open -R " + filePath;
}
try {
Runtime.getRuntime().exec(cmd);
} catch (IOException exception) {
Logger logger = Logger.getLogger("com.leewyatt.fxtools.utils.OSUtil");
logger.severe("IOException: openAndSelectedFile failed.\t"+exception);
exception.printStackTrace();
try {
Runtime.getRuntime().exec(cmd);
} catch (IOException exception) {
Logger logger = Logger.getLogger("com.leewyatt.fxtools.utils.OSUtil");
logger.severe("IOException: openAndSelectedFile failed.\t"+exception);
exception.printStackTrace();
}
} else if (currentOS ==OS.MAC || currentOS == OS.LINUX) {
//cmd = "open " + filePath; mac
//cmd = "open -R " + filePath; linux
showDoc(file.toURI().toString());
}

}

public static void openAndSelectedFile(File file) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fxml/color-page.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.shape.Rectangle?>

<RXCarouselPane fx:id="carouselPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="574.0" prefWidth="263.0" styleClass="tool-pane" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.leewyatt.fxtools.uicontroller.ColorPageController">
<RXCarouselPane fx:id="carouselPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="574.0" prefWidth="263.0" styleClass="tool-pane" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.leewyatt.fxtools.uicontroller.ColorPageController">
<top>
<VBox prefHeight="80.0" prefWidth="261.0" BorderPane.alignment="CENTER">
<children>
Expand All @@ -36,7 +36,7 @@
</HBox>
<HBox id="control-btn-box" alignment="CENTER" prefHeight="38.0" prefWidth="261.0" spacing="1.0" styleClass="copy-box">
<children>
<Button mnemonicParsing="false" onAction="#pickerColorAction">
<Button fx:id="pickerBtn" mnemonicParsing="false" onAction="#pickerColorAction">
<graphic>
<Region prefHeight="200.0" prefWidth="200.0" />
</graphic>
Expand Down

0 comments on commit 7de9b22

Please sign in to comment.