Skip to content

Commit

Permalink
ui layout
Browse files Browse the repository at this point in the history
  • Loading branch information
leewyatt committed Dec 30, 2022
1 parent 8ef313a commit 063a2fa
Show file tree
Hide file tree
Showing 22 changed files with 263 additions and 59 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<dependency>
<groupId>com.github.leewyatt</groupId>
<artifactId>rxcontrols</artifactId>
<version>11.0.2</version>
<version>11.0.3</version>
</dependency>
<dependency>
<groupId>org.controlsfx</groupId>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/leewyatt/fxtools/FXToolsApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.PerspectiveCamera;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.stage.Stage;
Expand Down Expand Up @@ -56,6 +57,7 @@ public void start(Stage primaryStage) throws Exception {
scene.getStylesheets().add(ResourcesUtil.cssExternalForm("main-stage-" + skinStyle + ".css"));
loadMainPane();
scene.setFill(Color.TRANSPARENT);
scene.setCamera(new PerspectiveCamera());
primaryStage.initStyle(StageStyle.TRANSPARENT);
primaryStage.setScene(scene);
primaryStage.setTitle("FXTools");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.leewyatt.fxtools.ui.alert;


import com.leewyatt.fxtools.utils.OSUtil;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
/**
* @author LeeWyatt
*/
public class DonateAlertController {

@FXML
void onClickDonorListBtn(ActionEvent event) {
OSUtil.showDoc("https://gitee.com/leewyatt/FXTools#%E6%89%93%E8%B5%8F%E5%88%97%E8%A1%A8");
}

}
20 changes: 7 additions & 13 deletions src/main/java/com/leewyatt/fxtools/ui/cells/ImageListCell.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.leewyatt.fxtools.ui.cells;

import com.google.common.eventbus.Subscribe;
import com.leewyatt.fxtools.event.SkinChangedEvent;
import com.leewyatt.fxtools.model.ImageInfo;
import com.leewyatt.fxtools.ui.alert.ConfirmationAlert;
import com.leewyatt.fxtools.utils.ImageUtil;
Expand Down Expand Up @@ -61,7 +59,7 @@ public ImageListCell() {
}
if (event.isControlDown()) {
OSUtil.openAndSelectedFile(getItem().getPath());
}else {
} else {
OSUtil.showDoc(getItem().getPath());
}
event.consume();
Expand Down Expand Up @@ -129,39 +127,39 @@ public String toString(ImageInfo object) {
ImageInfo item = getItem();
String name = "";
if (item != null) {
name=item.getName();
name = item.getName();
}
return name;
}

@Override
public ImageInfo fromString(String string) {
ImageInfo item = getItem();
Optional<ImageInfo> first = getListView().getItems().stream().filter(temp -> temp!=item && temp.getName().equals(string)).findFirst();
Optional<ImageInfo> first = getListView().getItems().stream().filter(temp -> temp != item && temp.getName().equals(string)).findFirst();
if (first.isPresent()) {
boolean b = new ConfirmationAlert("已存在同名图片.确定要修改吗").showAndGetResult();
if (b) {
if (item != null) {
item.setName(string);
}
}
}else {
} else {
if (item != null) {
item.setName(string);
}
}
return item;
}
});
MenuItem deleteBtn = new MenuItem(message("listCell.menu.delete"),getRegion("delete-region"));
MenuItem deleteBtn = new MenuItem(message("listCell.menu.delete"), getRegion("delete-region"));
deleteBtn.setOnAction(event -> {
getListView().getItems().remove(getItem());
});
MenuItem editBtn = new MenuItem(message("listCell.menu.edit"),getRegion("edit-region"));
MenuItem editBtn = new MenuItem(message("listCell.menu.edit"), getRegion("edit-region"));
editBtn.setOnAction(event -> {
startEdit();
});
setContextMenu(new ContextMenu(editBtn,deleteBtn));
setContextMenu(new ContextMenu(editBtn, deleteBtn));
}

private Region getRegion(String styleClass) {
Expand Down Expand Up @@ -210,8 +208,4 @@ public void updateItem(ImageInfo item, boolean empty) {
}
}

@Subscribe
public void skinChangedHandler(SkinChangedEvent event) {
updateItem(getItem(), isEmpty());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import com.leewyatt.fxtools.ui.alert.InformationAlert;
import com.leewyatt.fxtools.ui.cells.ImageListCell;
import com.leewyatt.fxtools.utils.ToolSettingsUtil;
import com.leewyatt.rxcontrols.pane.RXCarouselPane;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.CheckBox;
import javafx.scene.control.RadioButton;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.ToggleGroup;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;

Expand Down Expand Up @@ -64,6 +64,8 @@ public class ImageCutterPageController extends ImageTaskController {
@FXML
private ToggleGroup sourceImageGroup;



public ImageCutterPageController() {
importEventType = ImageEventType.CUTTER_IMPORT;
exportEventType = ImageEventType.CUTTER_EXPORT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.leewyatt.fxtools.ui.paintpicker.DoubleTextField;
import com.leewyatt.fxtools.utils.ImageUtil;
import com.leewyatt.fxtools.utils.ToolSettingsUtil;
import com.leewyatt.rxcontrols.pane.RXCarouselPane;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
Expand All @@ -31,7 +30,7 @@
/**
* @author LeeWyatt
*/
public class ImageFormatPageController extends ImageTaskController{
public class ImageFormatPageController extends ImageTaskController {

@FXML
private ResourceBundle resources;
Expand All @@ -51,13 +50,8 @@ public class ImageFormatPageController extends ImageTaskController{
@FXML
private Pane centerPane;

@FXML
private RXCarouselPane formatPage;

private DoubleTextField scaleField;



public ImageFormatPageController() {
EventBusUtil.getDefault().register(this);
importEventType = ImageEventType.FORMAT_IMPORT;
Expand Down Expand Up @@ -87,7 +81,7 @@ void initialize() {
imageListView.setOnDragOver(this::onDragOverImage);
imageListView.setEditable(true);

convertComboBox.getItems().addAll(ImageUtil.FORMAT_PNG, ImageUtil.FORMAT_JPG, ImageUtil.FORMAT_GIF,ImageUtil.FORMAT_BMP, ImageUtil.FORMAT_ICO);
convertComboBox.getItems().addAll(ImageUtil.FORMAT_PNG, ImageUtil.FORMAT_JPG, ImageUtil.FORMAT_GIF, ImageUtil.FORMAT_BMP, ImageUtil.FORMAT_ICO);
convertComboBox.getSelectionModel().select(0);
convertComboBox.getSelectionModel().selectedItemProperty().addListener((ob, ov, nv) ->
qualityComboBox.setDisable(!ImageUtil.FORMAT_JPG.equals(nv))
Expand All @@ -96,7 +90,6 @@ void initialize() {
qualityComboBox.getSelectionModel().select(0);
}


@FXML
void onConvertImageFormatAction(ActionEvent event) throws IOException {
ObservableList<ImageInfo> items = imageListView.getItems();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ public void pageJumpHandler(PageJumpEvent pageJumpEvent) {
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
import com.leewyatt.fxtools.ui.paintpicker.IntegerTextField;
import com.leewyatt.fxtools.utils.AlphanumComparator;
import com.leewyatt.fxtools.utils.ImageUtil;
import com.leewyatt.fxtools.utils.ToolSettingsUtil;
import com.leewyatt.fxtools.utils.OSUtil;
import com.leewyatt.fxtools.utils.ToolSettingsUtil;
import com.leewyatt.rxcontrols.pane.RXCarouselPane;
import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
Expand Down Expand Up @@ -58,6 +59,9 @@ public class ImageTaskController {
@FXML
protected MaskerPane maskerPane;

@FXML
private RXCarouselPane carouselPane;

protected IntegerTextField colNumField;

protected String[] supportedExtensions;
Expand Down Expand Up @@ -151,14 +155,17 @@ protected File chooseExportDir(int size) {
protected void onDragDroppedImage(DragEvent event) {
Dragboard db = event.getDragboard();
boolean success = false;
List<File> result = null;
if (db.hasFiles()) {
List<File> files = event.getDragboard().getFiles();
files = files.stream().filter(this::isImageCompliantFormat).collect(Collectors.toList());
startLoadImageService(files);
result = files.stream().filter(this::isImageCompliantFormat).collect(Collectors.toList());
success = true;
}
event.setDropCompleted(success);
event.consume();
if (result != null) {
startLoadImageService(result);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ void initialize() throws IOException {
}
carousel.setSelectedIndex(menuGroup.getToggles().indexOf(nv));
});
if (OSUtil.getOS() != OSUtil.OS.WINDOWS) {
snapshotBtn.setManaged(false);
colorPickerBtn.setManaged(false);
snapshotBtn.setVisible(false);
colorPickerBtn.setVisible(false);
}
}

@FXML
Expand Down Expand Up @@ -226,8 +232,6 @@ void onClickIvBtn(ActionEvent event) {
contentPane.setClip(null);
toggleBtn.setRotate(0);
toggleBtn.setDisable(false);
carousel.getSubScene().getRoot().applyCss();
carousel.getSubScene().getRoot().requestLayout();
});
tl.play();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ private void initSvgPreviewPane() {
svgRegion.setStyle(DEFAULT_BLACK_GROUND);
svgRegion.setShape(svgPath);
svgPreviewPane.getChildren().add(svgRegion);
svgPreviewPane.setOnDragDropped(this::onDragDroppedSvg);
svgPreviewPane.setOnDragOver(this::onDragOverSvg);
svgPreviewPane.setOnScroll(event -> {
if (!verifiedPath()) {
return;
Expand All @@ -184,17 +186,16 @@ private void initSvgPreviewPane() {
regionContextMenu = createRegionContextMenu();
svgPreviewPane.setOnMousePressed(event -> {
if (event.getButton() == MouseButton.PRIMARY) {
if (regionContextMenu.isShowing()) {
regionContextMenu.hide();
}
if (event.isControlDown() && lastFilePath != null) {
openAndSelectedFile(lastFilePath);
event.consume();
return;
}
openSvgFile();
event.consume();
}
if (event.getButton() == MouseButton.SECONDARY) {
} else if (event.getButton() == MouseButton.SECONDARY) {
regionContextMenu.show(svgPreviewPane, event.getScreenX(), event.getScreenY());
}
event.consume();
});
}

Expand All @@ -208,18 +209,16 @@ private void initImagePreviewPane() {
webViewContextMenu = createWebViewContextMenu();
imagePreviewPane.setOnMousePressed(event -> {
if (event.getButton() == MouseButton.PRIMARY) {
if (webViewContextMenu.isShowing()) {
webViewContextMenu.hide();
}
if (event.isControlDown() && lastFilePath != null) {
openAndSelectedFile(lastFilePath);
event.consume();
return;
}
openSvgFile();
event.consume();
}
if (event.getButton() == MouseButton.SECONDARY) {
} else if (event.getButton() == MouseButton.SECONDARY) {
webViewContextMenu.show(imagePreviewPane, event.getScreenX(), event.getScreenY());
}

event.consume();
});
}

Expand Down Expand Up @@ -334,18 +333,22 @@ private void initCodeComboBox(PaintPicker paintPicker) {
private void onDragDroppedSvg(DragEvent event) {
Dragboard db = event.getDragboard();
boolean success = false;
File svgFile = null;
if (db.hasFiles()) {
List<File> files = event.getDragboard().getFiles();
for (File file : files) {
if (isSvgFile(file)) {
setXMLData(file);
svgFile = file;
success = true;
break;
}
}
success = true;
}
event.setDropCompleted(success);
event.consume();
if (svgFile != null) {
setXMLData(svgFile);
}
}

void onDragOverSvg(DragEvent event) {
Expand Down Expand Up @@ -398,18 +401,15 @@ private void heightChanged() {
svgRegion.setMaxSize(newWidth * rate, newHeight * rate);
reSelectedCodeCombobox();
}

private void widthChanged() {
Bounds bounds = svgPath.getLayoutBounds();
double regionWidth = svgRegion.getWidth();
double regionHeight = svgRegion.getHeight();
double scaleX = bounds.getWidth() / regionWidth;
double scaleY = bounds.getHeight() / regionHeight;
double width = bounds.getWidth();
double height = bounds.getHeight();
double newWidth = widthFiled.getValue();
double scale = newWidth / scaleX;
double newHeight = scaleY * scale;
double scale = newWidth / width;
double newHeight= height * scale;
heightField.setText(newHeight + "");
double rate = NumberUtil.computeScaleRate(scaleX, scaleY, 128);
double rate = NumberUtil.computeScaleRate(width, height, 128);
svgRegion.setMaxSize(newWidth * rate, newHeight * rate);
reSelectedCodeCombobox();
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/resources/css/about-alert-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,19 @@
}
.url-label:hover {
-fx-underline: true;
}
.donor-list-btn {
-fx-border-color:#75A4EB;
-fx-border-radius: 16px;
-fx-background-radius: 16px;
-fx-background-color: null;
-fx-font-size: 16px;
}
.donor-list-btn:hover {
-fx-background-color: rgba(232, 232, 232, 0.1);;
}

.donor-list-btn:pressed {
-fx-background-color: rgba(255, 255, 255, 0.2);
-fx-text-fill:white;
}
Loading

0 comments on commit 063a2fa

Please sign in to comment.