创建工具箱窗口,优化代码

This commit is contained in:
yang 2022-10-06 17:20:52 +08:00
parent fe3f0d40a4
commit 8c3bf899ae
7 changed files with 91 additions and 7 deletions

View File

@ -74,7 +74,9 @@ public class MainWindow extends Application {
// 设置窗口透明
stage.initStyle(StageStyle.TRANSPARENT);
// 将窗口显示出来
stage.show();
// stage.show();
new ToolsWindow().show();
} catch (
IOException e) {
e.printStackTrace();

View File

@ -34,7 +34,7 @@ public class SettingWindow extends Application {
// 加载FXML文件
FXMLLoader fxmlLoader = new FXMLLoader(SettingWindow.class.getResource("fxml/settingWindow.fxml"));
Scene scene = new Scene(fxmlLoader.load());
// 场景填充白色背景
// 场景填充透明背景
scene.setFill(Paint.valueOf("#00000000"));
// 设置场景
stage.setScene(scene);

View File

@ -0,0 +1,52 @@
package org.rococy.roomit;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;
import java.io.IOException;
/**
* 工具箱
*
* @author Rococy
* @date 2022/10/6
*/
public class ToolsWindow extends Application {
private final Stage stage = new Stage();
{
// 设置标题
stage.setTitle("Roomit-工具箱");
// 居中
stage.centerOnScreen();
// 只有一个x的任务栏
stage.setResizable(false);
stage.initModality(Modality.APPLICATION_MODAL);
// 置顶
stage.setAlwaysOnTop(true);
}
@Override
public void start(Stage stage) throws IOException {
// 加载FXML文件
FXMLLoader fxmlLoader = new FXMLLoader(SettingWindow.class.getResource("fxml/toolsWindow.fxml"));
Scene scene = new Scene(fxmlLoader.load());
// 设置场景
stage.setScene(scene);
// 将窗口显示出来
stage.show();
}
public void show() {
try {
start(stage);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -5,6 +5,7 @@ import javafx.scene.Parent;
import javafx.scene.input.MouseEvent;
import javafx.scene.shape.Ellipse;
import org.rococy.roomit.config.ConfigurationManager;
import org.rococy.roomit.constant.GlobalConsts;
import org.rococy.roomit.control.base.Resizer;
import org.rococy.roomit.domain.EllipseConfiguration;
import org.rococy.roomit.util.ReactStyleMap;
@ -20,7 +21,6 @@ public class ResizableEllipseWrapper extends Resizer {
*/
private static final int BORDER_WIDTH = 3;
private static final double BORDER_RADIUS = 1;
private static final String BORDER_COLOR = "linear-gradient(to bottom, #f64f5988, #c471ed88, #12c2e988);";
/**
* 内部椭圆
@ -47,7 +47,7 @@ public class ResizableEllipseWrapper extends Resizer {
// 设置样式
styleMap.addStyle("-fx-border-width", BORDER_WIDTH);
styleMap.addStyle("-fx-border-style", "solid");
styleMap.addStyle("-fx-border-color", BORDER_COLOR);
styleMap.addStyle("-fx-border-color", GlobalConsts.THEME_COLOR);
styleMap.addReactStyle("-fx-border-radius", BORDER_RADIUS);
// 添加内椭圆

View File

@ -0,0 +1,9 @@
package org.rococy.roomit.controller;
/**
* @author Rococy
* @date 2022/10/6
*/
public class ToolsWindowController {
}

View File

@ -2,15 +2,15 @@
"shape": {
"brush": {
"transparent": false,
"strokeColor": "#ffffffff",
"strokeColor": "linear-gradient(to bottom, #f64f59, #c471ed, #12c2e9)",
"lineWidth": 4.0
},
"rectangle": {
"borderColor": "#ff0000ff",
"borderColor": "linear-gradient(to bottom, #f64f59, #c471ed, #12c2e9)",
"borderWidth": 5.0
},
"ellipse": {
"borderColor": "#ff0000ff",
"borderColor": "linear-gradient(to bottom, #f64f59, #c471ed, #12c2e9)",
"borderWidth": 5.0
}
},

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.*?>
<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="org.rococy.roomit.controller.ToolsWindowController">
<!--
brush
rectangle
ellipse
tools
colorPicker
expendMouse
clear
screenshotAndCopy
openOrClose
-->
</AnchorPane>