完善配置功能
This commit is contained in:
parent
222dacfb68
commit
fe3f0d40a4
|
@ -16,8 +16,8 @@ ext {
|
|||
junitVersion = '5.9.0'
|
||||
}
|
||||
|
||||
sourceCompatibility = "11"
|
||||
targetCompatibility = "11"
|
||||
sourceCompatibility = "17"
|
||||
targetCompatibility = "17"
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
|
@ -25,7 +25,7 @@ tasks.withType(JavaCompile) {
|
|||
|
||||
application {
|
||||
mainModule = 'org.rococy.roomit'
|
||||
mainClass = 'org.rococy.roomit.HelloApplication'
|
||||
mainClass = 'org.rococy.roomit.MainWindow'
|
||||
}
|
||||
|
||||
javafx {
|
||||
|
|
|
@ -1 +1 @@
|
|||
rootProject.name = "roomIt"
|
||||
rootProject.name = "roomIt"
|
||||
|
|
|
@ -39,7 +39,6 @@ public class MainWindow extends Application {
|
|||
if (type.equals(KeyBoardConsts.OPEN_OR_CLOSE)) {
|
||||
Platform.runLater(MainWindow::toggleDisplay);
|
||||
}
|
||||
|
||||
});
|
||||
// 初始化托盘图标
|
||||
initTrayIcon();
|
||||
|
@ -55,7 +54,6 @@ public class MainWindow extends Application {
|
|||
launch(stage);
|
||||
}
|
||||
|
||||
|
||||
public static void launch(Stage stage) {
|
||||
try {
|
||||
MainWindow.stage = stage;
|
||||
|
|
|
@ -7,11 +7,14 @@ import javafx.scene.paint.Paint;
|
|||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Rococy
|
||||
* @date 2022/9/26
|
||||
*/
|
||||
public class SettingWindow extends Application {
|
||||
|
||||
private final Stage stage = new Stage();
|
||||
|
||||
{
|
||||
|
@ -27,7 +30,7 @@ public class SettingWindow extends Application {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) throws Exception {
|
||||
public void start(Stage stage) throws IOException {
|
||||
// 加载FXML文件
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(SettingWindow.class.getResource("fxml/settingWindow.fxml"));
|
||||
Scene scene = new Scene(fxmlLoader.load());
|
||||
|
@ -42,7 +45,7 @@ public class SettingWindow extends Application {
|
|||
public void show() {
|
||||
try {
|
||||
start(stage);
|
||||
} catch (Exception e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,8 @@ public class TrayWindow extends Application {
|
|||
stage.setScene(scene);
|
||||
// 场景填充透明背景
|
||||
scene.setFill(Paint.valueOf("#00000000"));
|
||||
|
||||
// 置顶
|
||||
stage.setAlwaysOnTop(true);
|
||||
// 取消任务栏
|
||||
stage.initStyle(StageStyle.TRANSPARENT);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public class ResizableRectangle extends Resizer {
|
|||
/**
|
||||
* 配置项
|
||||
*/
|
||||
private final RectangleConfiguration rectangleConfiguration = ConfigurationManager.getRectangleConfiguration();
|
||||
private final RectangleConfiguration rectangleConfiguration;
|
||||
|
||||
/**
|
||||
* 样式集合
|
||||
|
@ -35,6 +35,7 @@ public class ResizableRectangle extends Resizer {
|
|||
*/
|
||||
public ResizableRectangle(double originX, double originY) {
|
||||
super(originX, originY);
|
||||
rectangleConfiguration = ConfigurationManager.getRectangleConfiguration();
|
||||
|
||||
// 填充颜色、边框颜色、边框宽度、圆角
|
||||
styleMap.addStyle("-fx-fill", "#00000000");
|
||||
|
|
|
@ -39,7 +39,7 @@ public abstract class Resizer extends Pane {
|
|||
/**
|
||||
* 边框宽度
|
||||
*/
|
||||
private final double borderWidth = this.getBorderWidth();
|
||||
private Double borderWidth;
|
||||
|
||||
/**
|
||||
* @param originX 在整个屏幕内的初始x值
|
||||
|
@ -102,8 +102,12 @@ public abstract class Resizer extends Pane {
|
|||
private void bindMouseEnterEvent() {
|
||||
this.addEventHandler(MouseEvent.MOUSE_ENTERED, e -> {
|
||||
this.requestFocus();
|
||||
|
||||
this.hideDefaultCursor();
|
||||
|
||||
// 初始化边框宽度
|
||||
if (borderWidth == null) {
|
||||
borderWidth = this.getBorderWidth();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public class MainWindowController implements Initializable {
|
|||
/**
|
||||
* 装载鼠标logo的临时变量,默认为画笔
|
||||
*/
|
||||
private static Shape mouseLogo = BRUSH_SYMBOL;
|
||||
private Shape mouseLogo = BRUSH_SYMBOL;
|
||||
|
||||
/**
|
||||
* 全局x,y轴
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.rococy.roomit.cursor;
|
||||
|
||||
import javafx.scene.shape.SVGPath;
|
||||
import org.rococy.roomit.config.ConfigurationManager;
|
||||
import org.rococy.roomit.constant.GlobalConsts;
|
||||
import org.rococy.roomit.symbol.BrushSymbol;
|
||||
import org.rococy.roomit.symbol.RectangleSymbol;
|
||||
|
@ -99,17 +100,29 @@ public class RoomItCursor extends SVGPath {
|
|||
|
||||
public void setCursorLogo(MouseSymbol mouseSymbol) {
|
||||
this.mouseSymbol = mouseSymbol;
|
||||
setCursorLogoPosition(this.x, this.y, sizeLevelMap.get(sizeLevel));
|
||||
this.initCursorColor();
|
||||
this.setCursorLogoPosition(this.x, this.y, sizeLevelMap.get(sizeLevel));
|
||||
}
|
||||
|
||||
private void initCursorColor() {
|
||||
// 设置logo颜色
|
||||
if (this.mouseSymbol instanceof BrushSymbol) {
|
||||
this.mouseSymbol.fillColor(ConfigurationManager.getBrushConfiguration().getStrokeColor());
|
||||
} else if (this.mouseSymbol instanceof RectangleSymbol) {
|
||||
this.mouseSymbol.fillColor(ConfigurationManager.getRectangleConfiguration().getBorderColor());
|
||||
} else {
|
||||
this.mouseSymbol.fillColor(ConfigurationManager.getEllipseConfiguration().getBorderColor());
|
||||
}
|
||||
}
|
||||
|
||||
private void setCursorLogoPosition(double x, double y, Size size) {
|
||||
// 设置logo位置
|
||||
if (mouseSymbol instanceof BrushSymbol) {
|
||||
mouseSymbol.position(x + size.logoPosition.bx, y + size.logoPosition.by);
|
||||
} else if (mouseSymbol instanceof RectangleSymbol) {
|
||||
mouseSymbol.position(x + size.logoPosition.rx, y + size.logoPosition.ry);
|
||||
if (this.mouseSymbol instanceof BrushSymbol) {
|
||||
this.mouseSymbol.position(x + size.logoPosition.bx, y + size.logoPosition.by);
|
||||
} else if (this.mouseSymbol instanceof RectangleSymbol) {
|
||||
this.mouseSymbol.position(x + size.logoPosition.rx, y + size.logoPosition.ry);
|
||||
} else {
|
||||
mouseSymbol.position(x + size.logoPosition.ex, y + size.logoPosition.ey);
|
||||
this.mouseSymbol.position(x + size.logoPosition.ex, y + size.logoPosition.ey);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,4 +25,12 @@ public class RectangleConfiguration {
|
|||
public void setBorderWidth(double borderWidth) {
|
||||
this.borderWidth = borderWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RectangleConfiguration{" +
|
||||
"borderColor='" + borderColor + '\'' +
|
||||
", borderWidth=" + borderWidth +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
"shape": {
|
||||
"brush": {
|
||||
"transparent": false,
|
||||
"strokeColor": "#ff0000ff",
|
||||
"strokeColor": "#ffffffff",
|
||||
"lineWidth": 4.0
|
||||
},
|
||||
"rectangle": {
|
||||
"borderColor": "linear-gradient(to bottom, #f64f59, #c471ed, #12c2e9)",
|
||||
"borderWidth": 3.0
|
||||
"borderColor": "#ff0000ff",
|
||||
"borderWidth": 5.0
|
||||
},
|
||||
"ellipse": {
|
||||
"borderColor": "linear-gradient(to bottom, #f64f59, #c471ed, #12c2e9)",
|
||||
"borderWidth": 3.0
|
||||
"borderColor": "#ff0000ff",
|
||||
"borderWidth": 5.0
|
||||
}
|
||||
},
|
||||
"keyboard": {
|
||||
|
@ -23,7 +23,7 @@
|
|||
"expendMouse": "CTRL+E",
|
||||
"clear": "CTRL+C",
|
||||
"screenshotAndCopy": "CTRL+B",
|
||||
"openOrClose": "CTRL+O",
|
||||
"openOrClose": "CTRL+SHIFT+O",
|
||||
"back": "CTRL+Z"
|
||||
}
|
||||
}
|
|
@ -35,8 +35,10 @@
|
|||
<fx:define>
|
||||
<ToggleGroup fx:id="transparentGroup"/>
|
||||
</fx:define>
|
||||
<RadioButton fx:id="transparentRadioBtn" text="是" userData="true" toggleGroup="$transparentGroup" selected="true"/>
|
||||
<RadioButton fx:id="notTransparentRadioBtn" text="否" userData="false" toggleGroup="$transparentGroup"/>
|
||||
<RadioButton fx:id="transparentRadioBtn" text="是" userData="true"
|
||||
toggleGroup="$transparentGroup" selected="true"/>
|
||||
<RadioButton fx:id="notTransparentRadioBtn" text="否" userData="false"
|
||||
toggleGroup="$transparentGroup"/>
|
||||
</HBox>
|
||||
|
||||
<HBox style="-fx-spacing: 10px">
|
||||
|
@ -109,48 +111,42 @@
|
|||
<Label styleClass="label" GridPane.rowIndex="1" GridPane.columnIndex="1">切换为画笔:</Label>
|
||||
<JFXTextField fx:id="brushKeyboard" userData="brush" editable="false"
|
||||
onKeyPressed="#keyboardTextFieldKeyPress"
|
||||
onMouseClicked="#keyboardTextFieldMouseClick" promptText="选中并按下快捷键进行设置"
|
||||
onMouseClicked="#keyboardTextFieldMouseClick"
|
||||
styleClass="jfx-text-field" GridPane.rowIndex="1" GridPane.columnIndex="2"/>
|
||||
|
||||
<Label styleClass="label" GridPane.rowIndex="2" GridPane.columnIndex="1">切换为矩形:</Label>
|
||||
<JFXTextField fx:id="rectangleKeyboard" userData="rectangle" editable="false"
|
||||
onKeyPressed="#keyboardTextFieldKeyPress"
|
||||
promptText="选中并按下快捷键进行设置"
|
||||
onMouseClicked="#keyboardTextFieldMouseClick" GridPane.rowIndex="2"
|
||||
GridPane.columnIndex="2"/>
|
||||
|
||||
<Label styleClass="label" GridPane.rowIndex="3" GridPane.columnIndex="1">切换为椭圆:</Label>
|
||||
<JFXTextField fx:id="ellipseKeyboard" userData="ellipse" editable="false"
|
||||
onKeyPressed="#keyboardTextFieldKeyPress"
|
||||
promptText="选中并按下快捷键进行设置"
|
||||
onMouseClicked="#keyboardTextFieldMouseClick" GridPane.rowIndex="3"
|
||||
GridPane.columnIndex="2"/>
|
||||
|
||||
<Label styleClass="label" GridPane.rowIndex="4" GridPane.columnIndex="1">弹出工具箱:</Label>
|
||||
<JFXTextField fx:id="toolsKeyboard" userData="tools" editable="false"
|
||||
onKeyPressed="#keyboardTextFieldKeyPress"
|
||||
promptText="选中并按下快捷键进行设置"
|
||||
onMouseClicked="#keyboardTextFieldMouseClick" GridPane.rowIndex="4"
|
||||
GridPane.columnIndex="2"/>
|
||||
|
||||
<Label styleClass="label" GridPane.rowIndex="5" GridPane.columnIndex="1">弹出颜色框:</Label>
|
||||
<JFXTextField fx:id="colorPickerKeyboard" userData="colorPicker" editable="false"
|
||||
onKeyPressed="#keyboardTextFieldKeyPress"
|
||||
promptText="选中并按下快捷键进行设置"
|
||||
onMouseClicked="#keyboardTextFieldMouseClick" GridPane.rowIndex="5"
|
||||
GridPane.columnIndex="2"/>
|
||||
|
||||
<Label styleClass="label" GridPane.rowIndex="6" GridPane.columnIndex="1">放大鼠标:</Label>
|
||||
<JFXTextField fx:id="expendMouseKeyboard" userData="expendMouse" editable="false"
|
||||
onKeyPressed="#keyboardTextFieldKeyPress"
|
||||
promptText="选中并按下快捷键进行设置"
|
||||
onMouseClicked="#keyboardTextFieldMouseClick" GridPane.rowIndex="6"
|
||||
GridPane.columnIndex="2"/>
|
||||
|
||||
<Label styleClass="label" GridPane.rowIndex="7" GridPane.columnIndex="1">清空画板:</Label>
|
||||
<JFXTextField fx:id="clearKeyboard" userData="clear" editable="false"
|
||||
onKeyPressed="#keyboardTextFieldKeyPress"
|
||||
promptText="选中并按下快捷键进行设置"
|
||||
onMouseClicked="#keyboardTextFieldMouseClick" GridPane.rowIndex="7"
|
||||
GridPane.columnIndex="2"/>
|
||||
|
||||
|
@ -158,13 +154,11 @@
|
|||
<JFXTextField fx:id="screenshotAndCopyKeyboard" userData="screenshotAndCopy" editable="false"
|
||||
onKeyPressed="#keyboardTextFieldKeyPress"
|
||||
onMouseClicked="#keyboardTextFieldMouseClick"
|
||||
promptText="选中并按下快捷键进行设置"
|
||||
GridPane.rowIndex="8" GridPane.columnIndex="2"/>
|
||||
|
||||
<Label styleClass="label" GridPane.rowIndex="9" GridPane.columnIndex="1">启动或关闭:</Label>
|
||||
<JFXTextField fx:id="openOrCloseKeyboard" userData="openOrClose" editable="false"
|
||||
onKeyPressed="#keyboardTextFieldKeyPress"
|
||||
promptText="选中并按下快捷键进行设置"
|
||||
onMouseClicked="#keyboardTextFieldMouseClick" GridPane.rowIndex="9"
|
||||
GridPane.columnIndex="2"/>
|
||||
</GridPane>
|
||||
|
|
Loading…
Reference in New Issue