把设置按钮放到侧边栏
This commit is contained in:
parent
60e4eb3f22
commit
4abe8b7a35
@ -2,11 +2,14 @@ package org.jcnc.jnotepad.root;
|
||||
|
||||
import org.jcnc.jnotepad.root.bottom.RootBottomSideBarVBox;
|
||||
import org.jcnc.jnotepad.root.center.main.MainBorderPane;
|
||||
import org.jcnc.jnotepad.root.left.sidebar.RootLeftSideBarVBox;
|
||||
import org.jcnc.jnotepad.root.left.sidebar.tools.ToolHBox;
|
||||
import org.jcnc.jnotepad.root.right.RootRightSideBarVBox;
|
||||
import org.jcnc.jnotepad.root.top.RootTopSideBarVBox;
|
||||
import org.jcnc.jnotepad.root.top.RootTopBorderPane;
|
||||
import org.jcnc.jnotepad.ui.module.AbstractBorderPane;
|
||||
|
||||
/*
|
||||
* 根舞台下的Root主布局
|
||||
* */
|
||||
public class RootBorderPane extends AbstractBorderPane {
|
||||
|
||||
private static final RootBorderPane INSTANCE = new RootBorderPane();
|
||||
@ -16,11 +19,11 @@ public class RootBorderPane extends AbstractBorderPane {
|
||||
}
|
||||
|
||||
private void initRootBorderPane() {
|
||||
setCenterComponent(MainBorderPane.getInstance());
|
||||
setLeftComponent(RootLeftSideBarVBox.getInstance());
|
||||
setRightComponent(RootRightSideBarVBox.getInstance());
|
||||
setTopComponent(RootTopSideBarVBox.getInstance());
|
||||
setBottomComponent(RootBottomSideBarVBox.getInstance());
|
||||
setCenterComponent(MainBorderPane.getInstance()); //中间,用于显示Main主布局
|
||||
setLeftComponent(ToolHBox.getInstance()); //主布局的左边
|
||||
setRightComponent(RootRightSideBarVBox.getInstance()); //主布局的右边
|
||||
setTopComponent(RootTopBorderPane.getInstance()); //主布局的上面
|
||||
setBottomComponent(RootBottomSideBarVBox.getInstance());//主布局的下面
|
||||
}
|
||||
|
||||
public static RootBorderPane getInstance() {
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
package org.jcnc.jnotepad.root.center.main;
|
||||
|
||||
import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTabPane;
|
||||
import org.jcnc.jnotepad.root.center.main.top.MainTopVBox;
|
||||
import org.jcnc.jnotepad.ui.module.AbstractBorderPane;
|
||||
|
||||
/*
|
||||
* MainBorderPane区域,用于显示文本框以及文本框周边
|
||||
* */
|
||||
public class MainBorderPane extends AbstractBorderPane {
|
||||
|
||||
private static final MainBorderPane INSTANCE = new MainBorderPane();
|
||||
@ -13,11 +15,9 @@ public class MainBorderPane extends AbstractBorderPane {
|
||||
}
|
||||
|
||||
private void initRootBorderPane() {
|
||||
//setBottomComponent(JNotepadStatusBox.getInstance());
|
||||
|
||||
setCenter(JNotepadTabPane.getInstance());
|
||||
setCenterComponent(JNotepadTabPane.getInstance()); //文本框
|
||||
|
||||
setTopComponent(MainTopVBox.getInstance());
|
||||
}
|
||||
|
||||
public static MainBorderPane getInstance() {
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
package org.jcnc.jnotepad.root.center.main.top;
|
||||
|
||||
import javafx.scene.layout.VBox;
|
||||
import org.jcnc.jnotepad.root.center.main.top.menu.JNotepadMenuBar;
|
||||
import org.jcnc.jnotepad.root.center.main.top.tools.ToolHBox;
|
||||
|
||||
public class MainTopVBox extends VBox {
|
||||
private static final MainTopVBox INSTANCE = new MainTopVBox();
|
||||
|
||||
private MainTopVBox() {
|
||||
// 在构造函数中初始化
|
||||
getChildren().add(JNotepadMenuBar.getInstance());
|
||||
getChildren().add(ToolHBox.getInstance());
|
||||
}
|
||||
|
||||
public static MainTopVBox getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
package org.jcnc.jnotepad.root.left.sidebar;
|
||||
|
||||
import org.jcnc.jnotepad.ui.module.AbstractVBox;
|
||||
|
||||
public class RootLeftSideBarVBox extends AbstractVBox {
|
||||
|
||||
private static final RootLeftSideBarVBox INSTANCE = new RootLeftSideBarVBox();
|
||||
|
||||
private RootLeftSideBarVBox() {
|
||||
initSidebarVBox();
|
||||
}
|
||||
|
||||
private void initSidebarVBox() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static RootLeftSideBarVBox getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.root.center.main.top.tools;
|
||||
package org.jcnc.jnotepad.root.left.sidebar.tools;
|
||||
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ToolBar;
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.root.center.main.top.tools;
|
||||
package org.jcnc.jnotepad.root.left.sidebar.tools;
|
||||
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Priority;
|
||||
@ -0,0 +1,26 @@
|
||||
package org.jcnc.jnotepad.root.top;
|
||||
|
||||
import org.jcnc.jnotepad.root.top.menu.JNotepadMenuBar;
|
||||
import org.jcnc.jnotepad.ui.module.AbstractBorderPane;
|
||||
|
||||
/*
|
||||
* MainBorderPane区域,用于显示文本框以及文本框周边
|
||||
* */
|
||||
public class RootTopBorderPane extends AbstractBorderPane {
|
||||
|
||||
private static final RootTopBorderPane INSTANCE = new RootTopBorderPane();
|
||||
|
||||
private RootTopBorderPane() {
|
||||
initRootBorderPane();
|
||||
}
|
||||
|
||||
private void initRootBorderPane() {
|
||||
setTopComponent(JNotepadMenuBar.getInstance()); //文本框上面
|
||||
}
|
||||
|
||||
public static RootTopBorderPane getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
package org.jcnc.jnotepad.root.top;
|
||||
|
||||
import org.jcnc.jnotepad.ui.module.AbstractVBox;
|
||||
|
||||
public class RootTopSideBarVBox extends AbstractVBox {
|
||||
|
||||
private static final RootTopSideBarVBox INSTANCE = new RootTopSideBarVBox();
|
||||
|
||||
private RootTopSideBarVBox() {
|
||||
initSidebarVBox();
|
||||
}
|
||||
|
||||
private void initSidebarVBox() {
|
||||
|
||||
}
|
||||
|
||||
public static RootTopSideBarVBox getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package org.jcnc.jnotepad.root.center.main.top.menu;
|
||||
package org.jcnc.jnotepad.root.top.menu;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.scene.control.*;
|
||||
@ -12,7 +12,7 @@ import org.jcnc.jnotepad.controller.event.handler.tool.SetBtn;
|
||||
import org.jcnc.jnotepad.controller.i18n.LocalizationController;
|
||||
import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTabPane;
|
||||
import org.jcnc.jnotepad.root.center.main.top.tools.JNotepadToolBar;
|
||||
import org.jcnc.jnotepad.root.left.sidebar.tools.JNotepadToolBar;
|
||||
import org.jcnc.jnotepad.tool.LogUtil;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -6,7 +6,7 @@ import org.jcnc.jnotepad.constants.AppConstants;
|
||||
import org.jcnc.jnotepad.root.center.main.bottom.status.JNotepadStatusBox;
|
||||
import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTab;
|
||||
import org.jcnc.jnotepad.root.center.main.center.tab.JNotepadTabPane;
|
||||
import org.jcnc.jnotepad.root.center.main.top.menu.JNotepadMenuBar;
|
||||
import org.jcnc.jnotepad.root.top.menu.JNotepadMenuBar;
|
||||
import org.jcnc.jnotepad.ui.setStage.SetStage;
|
||||
import org.jcnc.jnotepad.view.manager.ViewManager;
|
||||
|
||||
|
||||
@ -0,0 +1,82 @@
|
||||
package org.jcnc.jnotepad.view.manager;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class CustomTitleBar extends HBox {
|
||||
private static CustomTitleBar instance;
|
||||
|
||||
private CustomTitleBar() {
|
||||
// 设置样式和布局
|
||||
this.setAlignment(Pos.CENTER);
|
||||
|
||||
// 左侧图标
|
||||
ImageView iconView = new ImageView(new Image("icon.png"));
|
||||
iconView.setFitWidth(30);
|
||||
iconView.setFitHeight(30);
|
||||
|
||||
Label titleLabel = new Label("自定义标题栏");
|
||||
titleLabel.setStyle("-fx-font-size: 18px;");
|
||||
|
||||
// 右侧按钮区域
|
||||
HBox buttonBox = new HBox(5);
|
||||
buttonBox.setAlignment(Pos.CENTER_RIGHT);
|
||||
|
||||
Button minimizeButton = new Button("-");
|
||||
minimizeButton.setStyle("-fx-background-color: transparent; ");
|
||||
minimizeButton.setOnAction(event -> {
|
||||
Stage stage = (Stage) this.getScene().getWindow();
|
||||
stage.setIconified(true); // 最小化窗口
|
||||
});
|
||||
|
||||
Button maximizeButton = new Button("□");
|
||||
maximizeButton.setStyle("-fx-background-color: transparent;");
|
||||
maximizeButton.setOnAction(event -> {
|
||||
Stage stage = (Stage) this.getScene().getWindow();
|
||||
stage.setMaximized(!stage.isMaximized()); // 最大化/还原窗口
|
||||
});
|
||||
|
||||
Button closeButton = new Button("X");
|
||||
closeButton.setStyle("-fx-background-color: transparent;");
|
||||
closeButton.setOnAction(event -> {
|
||||
Stage stage = (Stage) this.getScene().getWindow();
|
||||
stage.close();
|
||||
});
|
||||
|
||||
buttonBox.getChildren().addAll(minimizeButton, maximizeButton, closeButton);
|
||||
|
||||
this.getChildren().addAll(iconView, titleLabel, buttonBox);
|
||||
}
|
||||
|
||||
public static CustomTitleBar getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new CustomTitleBar();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void makeDraggable(Stage stage) {
|
||||
final Delta dragDelta = new Delta();
|
||||
|
||||
// 当鼠标按下时记录初始偏移量
|
||||
this.setOnMousePressed(mouseEvent -> {
|
||||
dragDelta.x = stage.getX() - mouseEvent.getScreenX();
|
||||
dragDelta.y = stage.getY() - mouseEvent.getScreenY();
|
||||
});
|
||||
|
||||
// 当鼠标拖动时,根据偏移量更新舞台的位置
|
||||
this.setOnMouseDragged(mouseEvent -> {
|
||||
stage.setX(mouseEvent.getScreenX() + dragDelta.x);
|
||||
stage.setY(mouseEvent.getScreenY() + dragDelta.y);
|
||||
});
|
||||
}
|
||||
|
||||
private static class Delta {
|
||||
double x, y;
|
||||
}
|
||||
}
|
||||
BIN
src/main/resources/icon.png
Normal file
BIN
src/main/resources/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 381 B |
Loading…
x
Reference in New Issue
Block a user