refactor css file
This commit is contained in:
@@ -23,10 +23,10 @@ public interface TimiFXUI {
|
||||
String RESOURCE = "/timifx/";
|
||||
|
||||
/** 样式文件 */
|
||||
String CSS_STYLE = RESOURCE + "style.css";
|
||||
String CSS_STYLE = RESOURCE + "style/style.css";
|
||||
|
||||
/** 全局字体替换 */
|
||||
String CSS_FONT = RESOURCE + "font.css";
|
||||
String CSS_FONT = RESOURCE + "style/font.css";
|
||||
|
||||
ResourcesMultilingual MULTILINGUAL = new ResourcesMultilingual();
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@ import java.time.LocalTime;
|
||||
public class DateTimePicker extends Region implements TimiFXUI, TimiFXUI.Colorful {
|
||||
|
||||
private static final String STYLE_CLASS = "date-time-picker";
|
||||
private static final String STYLE_CLASS_TIME_PANE = "date-time-picker-time-pane";
|
||||
private static final String STYLE_CLASS_TIME_BOX = "date-time-picker-time-box";
|
||||
private static final String STYLE_CLASS_NOW = "date-time-picker-now";
|
||||
private static final String STYLE_CLASS_CLEAR = "date-time-picker-clear";
|
||||
|
||||
/** 日期选择器 */
|
||||
@Getter
|
||||
@@ -49,6 +53,8 @@ public class DateTimePicker extends Region implements TimiFXUI, TimiFXUI.Colorfu
|
||||
|
||||
/** 默认构造器 */
|
||||
public DateTimePicker() {
|
||||
getStylesheets().add(DateTimePicker.class.getResource(RESOURCE + "style/components/date-time-picker.css").toExternalForm());
|
||||
|
||||
value = new SimpleLongProperty(-1);
|
||||
|
||||
// 时间选择
|
||||
@@ -61,17 +67,17 @@ public class DateTimePicker extends Region implements TimiFXUI, TimiFXUI.Colorfu
|
||||
second.getStyleClass().add(CSS.BORDER_B);
|
||||
|
||||
GridPane hmsPane = new GridPane();
|
||||
hmsPane.getStyleClass().add(STYLE_CLASS_TIME_BOX);
|
||||
hmsPane.addRow(0, hour, minute, second);
|
||||
|
||||
Button now = new Button(TimiFXUI.MULTILINGUAL.text("now_tick"));
|
||||
now.getStyleClass().add(CSS.BORDER_L);
|
||||
now.getStyleClass().add(STYLE_CLASS_NOW);
|
||||
|
||||
timePane = new BorderPane(hmsPane);
|
||||
timePane.setBorder(Stroke.EX_LEFT);
|
||||
timePane.setEffect(Shadow.IMAGE);
|
||||
timePane.getStylesheets().add(DateTimePicker.class.getResource(RESOURCE + "style/components/date-time-picker.css").toExternalForm());
|
||||
timePane.getStyleClass().add(STYLE_CLASS_TIME_PANE);
|
||||
timePane.setPrefWidth(140);
|
||||
timePane.setBackground(BG.DEFAULT);
|
||||
timePane.setTranslateY(-1);
|
||||
timePane.setBottom(now);
|
||||
BorderPane.setAlignment(now, Pos.CENTER_RIGHT);
|
||||
|
||||
@@ -107,6 +113,7 @@ public class DateTimePicker extends Region implements TimiFXUI, TimiFXUI.Colorfu
|
||||
};
|
||||
IconButton clear = new IconButton(TimiFXIcon.fromName("FAIL", GRAY));
|
||||
clear.getStyleClass().add(CSS.BORDER_ALL);
|
||||
clear.getStyleClass().add(STYLE_CLASS_CLEAR);
|
||||
clear.translateXProperty().bind(widthProperty().subtract(40));
|
||||
clear.setTranslateY(15);
|
||||
clear.visibleProperty().bind(valueProperty().isNotNull());
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class Hyperlink extends Label implements TimiFXUI, TimiFXUI.Colorful {
|
||||
|
||||
private static final String STYLE_CLASS = "x-hyperlink";
|
||||
private static final Pattern URL_PATTERN = Pattern.compile("https?://(www\\.)?[-a-zA-Z\\d@:%._+~#=]{1,256}\\.[a-zA-Z\\d()]{1,6}\\b([-a-zA-Z\\d()@:%_+.~#?&/=]*)");
|
||||
|
||||
/** 链接监听 */
|
||||
@@ -70,10 +71,9 @@ public class Hyperlink extends Label implements TimiFXUI, TimiFXUI.Colorful {
|
||||
|
||||
this.url = new SimpleStringProperty(url);
|
||||
|
||||
getStyleClass().add(STYLE_CLASS);
|
||||
setCursor(Cursor.HAND);
|
||||
setGraphic(icon);
|
||||
setTextFill(FOCUSED_DEFAULT);
|
||||
underlineProperty().bind(hoverProperty());
|
||||
|
||||
addEventFilter(MouseEvent.MOUSE_CLICKED, e -> {
|
||||
if (e.getButton() == MouseButton.PRIMARY) {
|
||||
@@ -130,4 +130,9 @@ public class Hyperlink extends Label implements TimiFXUI, TimiFXUI.Colorful {
|
||||
public StringProperty urlProperty() {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserAgentStylesheet() {
|
||||
return Hyperlink.class.getResource(RESOURCE + "style/components/hyperlink.css").toExternalForm();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,4 +205,9 @@ public class IconButton extends Button implements TimiFXUI, TimiFXUI.Colorful {
|
||||
iconTextPadding = new Insets(tv, h, tv, h);
|
||||
return defaultSkin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserAgentStylesheet() {
|
||||
return IconButton.class.getResource(RESOURCE + "style/components/icon-button.css").toExternalForm();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.imyeyu.fx.ui.components;
|
||||
|
||||
import com.imyeyu.fx.ui.TimiFXUI;
|
||||
import com.imyeyu.java.bean.CallbackArgReturn;
|
||||
import javafx.beans.property.DoubleProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
@@ -16,7 +17,7 @@ import lombok.Setter;
|
||||
* @since 2022-08-09 10:48
|
||||
*/
|
||||
@Getter
|
||||
public class LabelProgressBar extends StackPane {
|
||||
public class LabelProgressBar extends StackPane implements TimiFXUI {
|
||||
|
||||
private static final String STYLE_CLASS = "label-progress-bar";
|
||||
|
||||
@@ -32,6 +33,8 @@ public class LabelProgressBar extends StackPane {
|
||||
|
||||
/** 默认构造 */
|
||||
public LabelProgressBar() {
|
||||
getStylesheets().add(LabelProgressBar.class.getResource(RESOURCE + "style/components/label-progress-bar.css").toExternalForm());
|
||||
|
||||
label = new Label();
|
||||
bar = new ProgressBar();
|
||||
bar.prefWidthProperty().bind(widthProperty());
|
||||
|
||||
@@ -59,6 +59,8 @@ public class Pagination extends HBox implements TimiFXUI {
|
||||
|
||||
/** 默认构造 */
|
||||
public Pagination() {
|
||||
getStylesheets().add(Pagination.class.getResource(RESOURCE + "style/components/pagination.css").toExternalForm());
|
||||
|
||||
// 基本参数
|
||||
lp = new SimpleLongProperty();
|
||||
ip = new SimpleIntegerProperty();
|
||||
|
||||
@@ -52,4 +52,9 @@ public class ProgressSlider extends Slider implements TimiFXUI {
|
||||
}
|
||||
return skin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserAgentStylesheet() {
|
||||
return ProgressSlider.class.getResource(RESOURCE + "style/components/progress-slider.css").toExternalForm();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,365 @@
|
||||
package com.imyeyu.fx.ui.components;
|
||||
|
||||
import com.imyeyu.fx.ui.TimiFXUI;
|
||||
import javafx.beans.property.*;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Control;
|
||||
import javafx.scene.control.Skin;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.control.ToggleGroup;
|
||||
|
||||
/**
|
||||
* 分段按钮组组件,使用单选模式组织多个切换按钮
|
||||
*
|
||||
* @author 夜雨
|
||||
* @since 2026-06-25
|
||||
*/
|
||||
public class SegmentedButtonGroup extends Control {
|
||||
|
||||
/** 根样式 */
|
||||
public static final String STYLE_CLASS = "segmented-button-group";
|
||||
|
||||
/** 按钮容器样式 */
|
||||
public static final String STYLE_CLASS_BOX = "segmented-button-group-box";
|
||||
|
||||
/** 按钮样式 */
|
||||
public static final String STYLE_CLASS_BUTTON = "segmented-button-group-button";
|
||||
|
||||
/** 首按钮样式 */
|
||||
public static final String STYLE_CLASS_FIRST = "first";
|
||||
|
||||
/** 中间按钮样式 */
|
||||
public static final String STYLE_CLASS_MIDDLE = "middle";
|
||||
|
||||
/** 末按钮样式 */
|
||||
public static final String STYLE_CLASS_LAST = "last";
|
||||
|
||||
/** 单按钮样式 */
|
||||
public static final String STYLE_CLASS_SINGLE = "single";
|
||||
|
||||
/** 按钮列表 */
|
||||
private final ObservableList<ToggleButton> buttons;
|
||||
|
||||
/** 按钮组 */
|
||||
private final ToggleGroup toggleGroup;
|
||||
|
||||
/** 当前选中按钮 */
|
||||
private final ReadOnlyObjectWrapper<ToggleButton> selectedButton;
|
||||
|
||||
/** 当前选中下标 */
|
||||
private final IntegerProperty selectedIndex;
|
||||
|
||||
/** 按钮间距 */
|
||||
private final DoubleProperty spacing;
|
||||
|
||||
/** 布局对齐方式 */
|
||||
private final ObjectProperty<Pos> alignment;
|
||||
|
||||
/** true 为允许清空选中 */
|
||||
private final BooleanProperty allowClearSelection;
|
||||
|
||||
/**
|
||||
* 默认构造器
|
||||
*/
|
||||
public SegmentedButtonGroup() {
|
||||
buttons = FXCollections.observableArrayList();
|
||||
toggleGroup = new ToggleGroup();
|
||||
selectedButton = new ReadOnlyObjectWrapper<>();
|
||||
selectedIndex = new SimpleIntegerProperty(-1);
|
||||
spacing = new SimpleDoubleProperty();
|
||||
alignment = new SimpleObjectProperty<>(Pos.CENTER_LEFT);
|
||||
allowClearSelection = new SimpleBooleanProperty();
|
||||
|
||||
getStyleClass().add(STYLE_CLASS);
|
||||
setFocusTraversable(false);
|
||||
|
||||
initSelectionSync();
|
||||
initButtonsListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化选中同步
|
||||
*/
|
||||
private void initSelectionSync() {
|
||||
toggleGroup.selectedToggleProperty().addListener((obs, o, toggle) -> {
|
||||
if (toggle instanceof ToggleButton button) {
|
||||
selectedButton.set(button);
|
||||
selectedIndex.set(buttons.indexOf(button));
|
||||
return;
|
||||
}
|
||||
selectedButton.set(null);
|
||||
selectedIndex.set(-1);
|
||||
});
|
||||
selectedIndex.addListener((obs, o, newIndex) -> {
|
||||
int index = newIndex == null ? -1 : newIndex.intValue();
|
||||
if (index < 0) {
|
||||
if (isAllowClearSelection()) {
|
||||
toggleGroup.selectToggle(null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (index < buttons.size()) {
|
||||
toggleGroup.selectToggle(buttons.get(index));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化按钮监听
|
||||
*/
|
||||
private void initButtonsListener() {
|
||||
buttons.addListener((ListChangeListener<ToggleButton>) change -> {
|
||||
while (change.next()) {
|
||||
if (change.wasRemoved()) {
|
||||
for (ToggleButton button : change.getRemoved()) {
|
||||
detachButton(button);
|
||||
}
|
||||
}
|
||||
if (change.wasAdded()) {
|
||||
for (ToggleButton button : change.getAddedSubList()) {
|
||||
attachButton(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
syncSelectionState();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂载按钮到当前组件
|
||||
*
|
||||
* @param button 按钮
|
||||
*/
|
||||
private void attachButton(ToggleButton button) {
|
||||
if (button == null) {
|
||||
throw new IllegalArgumentException("button must not be null");
|
||||
}
|
||||
button.setToggleGroup(toggleGroup);
|
||||
button.addEventFilter(javafx.scene.input.MouseEvent.MOUSE_PRESSED, SegmentedButtonGroupSkin.EVENT_KEEP_SELECTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* 卸载按钮
|
||||
*
|
||||
* @param button 按钮
|
||||
*/
|
||||
private void detachButton(ToggleButton button) {
|
||||
button.removeEventFilter(javafx.scene.input.MouseEvent.MOUSE_PRESSED, SegmentedButtonGroupSkin.EVENT_KEEP_SELECTED);
|
||||
if (button.getToggleGroup() == toggleGroup) {
|
||||
button.setToggleGroup(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步当前选中状态
|
||||
*/
|
||||
private void syncSelectionState() {
|
||||
ToggleButton currentSelectedButton = getSelectedButton();
|
||||
if (currentSelectedButton != null && !buttons.contains(currentSelectedButton)) {
|
||||
if (isAllowClearSelection()) {
|
||||
toggleGroup.selectToggle(null);
|
||||
} else if (!buttons.isEmpty()) {
|
||||
toggleGroup.selectToggle(buttons.getFirst());
|
||||
}
|
||||
return;
|
||||
}
|
||||
int index = selectedIndex.get();
|
||||
if (index < 0 || buttons.size() <= index) {
|
||||
if (!buttons.isEmpty() && !isAllowClearSelection() && toggleGroup.getSelectedToggle() == null) {
|
||||
toggleGroup.selectToggle(buttons.getFirst());
|
||||
}
|
||||
return;
|
||||
}
|
||||
toggleGroup.selectToggle(buttons.get(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Skin<?> createDefaultSkin() {
|
||||
return new SegmentedButtonGroupSkin(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserAgentStylesheet() {
|
||||
return SegmentedButtonGroup.class.getResource(TimiFXUI.RESOURCE + "style/components/segmented-button-group.css").toExternalForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取按钮列表
|
||||
*
|
||||
* @return 按钮列表
|
||||
*/
|
||||
public ObservableList<ToggleButton> getButtons() {
|
||||
return buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加按钮
|
||||
*
|
||||
* @param buttons 按钮列表
|
||||
*/
|
||||
public void addButton(ToggleButton... buttons) {
|
||||
getButtons().addAll(buttons);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加文本按钮
|
||||
*
|
||||
* @param text 按钮文本
|
||||
* @return 新增按钮
|
||||
*/
|
||||
public ToggleButton addButton(String text) {
|
||||
ToggleButton button = new ToggleButton(text);
|
||||
getButtons().add(button);
|
||||
return button;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前选中按钮
|
||||
*
|
||||
* @param button 当前选中按钮
|
||||
*/
|
||||
public void setSelectedButton(ToggleButton button) {
|
||||
if (button == null) {
|
||||
if (isAllowClearSelection()) {
|
||||
toggleGroup.selectToggle(null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!buttons.contains(button)) {
|
||||
throw new IllegalArgumentException("button must belong to current group");
|
||||
}
|
||||
toggleGroup.selectToggle(button);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前选中按钮
|
||||
*
|
||||
* @return 当前选中按钮
|
||||
*/
|
||||
public ToggleButton getSelectedButton() {
|
||||
return selectedButton.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前选中按钮属性
|
||||
*
|
||||
* @return 当前选中按钮属性
|
||||
*/
|
||||
public ReadOnlyObjectProperty<ToggleButton> selectedButtonProperty() {
|
||||
return selectedButton.getReadOnlyProperty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前选中下标
|
||||
*
|
||||
* @param selectedIndex 当前选中下标
|
||||
*/
|
||||
public void setSelectedIndex(int selectedIndex) {
|
||||
this.selectedIndex.set(selectedIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前选中下标
|
||||
*
|
||||
* @return 当前选中下标
|
||||
*/
|
||||
public int getSelectedIndex() {
|
||||
return selectedIndex.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前选中下标属性
|
||||
*
|
||||
* @return 当前选中下标属性
|
||||
*/
|
||||
public IntegerProperty selectedIndexProperty() {
|
||||
return selectedIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置按钮间距
|
||||
*
|
||||
* @param spacing 按钮间距
|
||||
*/
|
||||
public void setSpacing(double spacing) {
|
||||
this.spacing.set(Math.max(0, spacing));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取按钮间距
|
||||
*
|
||||
* @return 按钮间距
|
||||
*/
|
||||
public double getSpacing() {
|
||||
return spacing.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取按钮间距属性
|
||||
*
|
||||
* @return 按钮间距属性
|
||||
*/
|
||||
public DoubleProperty spacingProperty() {
|
||||
return spacing;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置布局对齐方式
|
||||
*
|
||||
* @param alignment 布局对齐方式
|
||||
*/
|
||||
public void setAlignment(Pos alignment) {
|
||||
this.alignment.set(alignment);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取布局对齐方式
|
||||
*
|
||||
* @return 布局对齐方式
|
||||
*/
|
||||
public Pos getAlignment() {
|
||||
return alignment.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取布局对齐方式属性
|
||||
*
|
||||
* @return 布局对齐方式属性
|
||||
*/
|
||||
public ObjectProperty<Pos> alignmentProperty() {
|
||||
return alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否允许清空选中
|
||||
*
|
||||
* @param allowClearSelection true 为允许清空选中
|
||||
*/
|
||||
public void setAllowClearSelection(boolean allowClearSelection) {
|
||||
this.allowClearSelection.set(allowClearSelection);
|
||||
if (!allowClearSelection && toggleGroup.getSelectedToggle() == null && !buttons.isEmpty()) {
|
||||
toggleGroup.selectToggle(buttons.getFirst());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否允许清空选中
|
||||
*
|
||||
* @return true 为允许清空选中
|
||||
*/
|
||||
public boolean isAllowClearSelection() {
|
||||
return allowClearSelection.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否允许清空选中属性
|
||||
*
|
||||
* @return 是否允许清空选中属性
|
||||
*/
|
||||
public BooleanProperty allowClearSelectionProperty() {
|
||||
return allowClearSelection;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.imyeyu.fx.ui.components;
|
||||
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.scene.control.SkinBase;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.HBox;
|
||||
|
||||
/**
|
||||
* 分段按钮组皮肤
|
||||
*
|
||||
* @author 夜雨
|
||||
* @since 2026-06-25
|
||||
*/
|
||||
public class SegmentedButtonGroupSkin extends SkinBase<SegmentedButtonGroup> {
|
||||
|
||||
/** 保持当前选中状态 */
|
||||
static final javafx.event.EventHandler<MouseEvent> EVENT_KEEP_SELECTED = event -> {
|
||||
if (event.getSource() instanceof ToggleButton button && button.isSelected()) {
|
||||
event.consume();
|
||||
}
|
||||
};
|
||||
|
||||
/** 按钮容器 */
|
||||
private final HBox box;
|
||||
|
||||
/**
|
||||
* 构造按钮组皮肤
|
||||
*
|
||||
* @param control 按钮组控件
|
||||
*/
|
||||
public SegmentedButtonGroupSkin(SegmentedButtonGroup control) {
|
||||
super(control);
|
||||
|
||||
box = new HBox();
|
||||
box.getStyleClass().add(SegmentedButtonGroup.STYLE_CLASS_BOX);
|
||||
box.spacingProperty().bind(control.spacingProperty());
|
||||
box.alignmentProperty().bind(control.alignmentProperty());
|
||||
|
||||
getChildren().add(box);
|
||||
|
||||
rebuildButtons();
|
||||
control.getButtons().addListener((ListChangeListener<ToggleButton>) change -> rebuildButtons());
|
||||
}
|
||||
|
||||
/**
|
||||
* 重建按钮结构
|
||||
*/
|
||||
private void rebuildButtons() {
|
||||
box.getChildren().setAll(getSkinnable().getButtons());
|
||||
syncButtonStyleClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步按钮样式
|
||||
*/
|
||||
private void syncButtonStyleClass() {
|
||||
int size = getSkinnable().getButtons().size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
ToggleButton button = getSkinnable().getButtons().get(i);
|
||||
button.setMaxWidth(Double.MAX_VALUE);
|
||||
button.getStyleClass().removeAll(
|
||||
SegmentedButtonGroup.STYLE_CLASS_BUTTON,
|
||||
SegmentedButtonGroup.STYLE_CLASS_FIRST,
|
||||
SegmentedButtonGroup.STYLE_CLASS_MIDDLE,
|
||||
SegmentedButtonGroup.STYLE_CLASS_LAST,
|
||||
SegmentedButtonGroup.STYLE_CLASS_SINGLE
|
||||
);
|
||||
button.getStyleClass().add(SegmentedButtonGroup.STYLE_CLASS_BUTTON);
|
||||
|
||||
if (size == 1) {
|
||||
button.getStyleClass().add(SegmentedButtonGroup.STYLE_CLASS_SINGLE);
|
||||
continue;
|
||||
}
|
||||
if (i == 0) {
|
||||
button.getStyleClass().add(SegmentedButtonGroup.STYLE_CLASS_FIRST);
|
||||
continue;
|
||||
}
|
||||
if (i == size - 1) {
|
||||
button.getStyleClass().add(SegmentedButtonGroup.STYLE_CLASS_LAST);
|
||||
continue;
|
||||
}
|
||||
button.getStyleClass().add(SegmentedButtonGroup.STYLE_CLASS_MIDDLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -102,6 +102,11 @@ public class SelectableLabel extends TextArea implements TimiFXUI, TimiFXUI.Colo
|
||||
return defaultSkin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserAgentStylesheet() {
|
||||
return SelectableLabel.class.getResource(RESOURCE + "style/components/selectable-label.css").toExternalForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定文本样式
|
||||
*
|
||||
|
||||
@@ -26,6 +26,11 @@ import java.util.List;
|
||||
@Getter
|
||||
public class TabPane extends javafx.scene.control.TabPane implements TimiFXUI, TimiFXUI.Colorful {
|
||||
|
||||
@Override
|
||||
public String getUserAgentStylesheet() {
|
||||
return TabPane.class.getResource(RESOURCE + "style/components/tab-pane.css").toExternalForm();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Skin<?> createDefaultSkin() {
|
||||
Skin<?> skin = super.createDefaultSkin();
|
||||
|
||||
@@ -51,6 +51,7 @@ import lombok.Getter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 复杂文本域编辑器,显示按钮操作文本域,文本域显示行号,可自定义操作功能
|
||||
@@ -258,6 +259,11 @@ public class TextAreaEditor extends TextArea implements TimiFXUI {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserAgentStylesheet() {
|
||||
return Objects.requireNonNull(TextAreaEditor.class.getResource(RESOURCE + "style/components/text-area-editor.css")).toExternalForm();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Skin<?> createDefaultSkin() {
|
||||
TextAreaEditSkin skin = new TextAreaEditSkin(this);
|
||||
|
||||
@@ -29,6 +29,9 @@ import java.time.LocalDateTime;
|
||||
public class TimePicker extends HBox implements TimiFXUI {
|
||||
|
||||
private static final String STYLE_CLASS = "time-picker";
|
||||
private static final String STYLE_CLASS_POPUP = "time-picker-popup";
|
||||
private static final String STYLE_CLASS_TIME_BOX = "time-picker-time-box";
|
||||
private static final String STYLE_CLASS_NOW = "time-picker-now";
|
||||
|
||||
private final Popup popup;
|
||||
private final TextField textField;
|
||||
@@ -39,6 +42,8 @@ public class TimePicker extends HBox implements TimiFXUI {
|
||||
|
||||
/** 默认构造器 */
|
||||
public TimePicker() {
|
||||
getStylesheets().add(TimePicker.class.getResource(RESOURCE + "style/components/time-picker.css").toExternalForm());
|
||||
|
||||
value = new SimpleIntegerProperty(-1);
|
||||
|
||||
textField = new TextField();
|
||||
@@ -61,14 +66,16 @@ public class TimePicker extends HBox implements TimiFXUI {
|
||||
// 此刻
|
||||
Button now = new Button(TimiFXUI.MULTILINGUAL.text("now"));
|
||||
now.getStyleClass().add(CSS.BORDER_L);
|
||||
now.getStyleClass().add(STYLE_CLASS_NOW);
|
||||
|
||||
HBox timeBox = new HBox(hour, minute, second);
|
||||
timeBox.getStyleClass().add(STYLE_CLASS_TIME_BOX);
|
||||
BorderPane root = new BorderPane();
|
||||
root.getStylesheets().add(TimePicker.class.getResource(RESOURCE + "style/components/time-picker.css").toExternalForm());
|
||||
root.getStyleClass().add(STYLE_CLASS_POPUP);
|
||||
BorderPane.setAlignment(now, Pos.CENTER_RIGHT);
|
||||
root.setEffect(Shadow.POPUP);
|
||||
root.setBorder(Stroke.DEFAULT);
|
||||
root.setPrefSize(140, 211);
|
||||
root.setBackground(BG.DEFAULT);
|
||||
root.setCenter(new HBox(hour, minute, second));
|
||||
root.setCenter(timeBox);
|
||||
root.setBottom(now);
|
||||
|
||||
popup = new Popup();
|
||||
|
||||
@@ -139,6 +139,11 @@ public class ToggleIcon extends ToggleButton implements TimiFXUI {
|
||||
}, textProperty(), autoSize, skinProperty()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserAgentStylesheet() {
|
||||
return ToggleIcon.class.getResource(RESOURCE + "style/components/toggle-icon.css").toExternalForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加按钮背景
|
||||
*
|
||||
|
||||
@@ -106,7 +106,7 @@ public final class TrayFX implements TimiFXUI {
|
||||
root = new StackPane();
|
||||
|
||||
Scene scene = new Scene(root);
|
||||
scene.getStylesheets().addAll(CSS_STYLE, CSS_FONT);
|
||||
scene.getStylesheets().addAll(CSS_STYLE, CSS_FONT, RESOURCE + "style/components/tray-menu.css");
|
||||
scene.setFill(null);
|
||||
stage = new Stage();
|
||||
stage.setWidth(1);
|
||||
|
||||
@@ -79,12 +79,15 @@ public class Navigation extends ScrollPane implements TimiFXUI {
|
||||
initItemsListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserAgentStylesheet() {
|
||||
return Navigation.class.getResource(RESOURCE + "style/components/navigation.css").toExternalForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
private void initView() {
|
||||
contentBox.setBorder(Stroke.BOTTOM);
|
||||
|
||||
getStyleClass().addAll("navigation", "sp-border");
|
||||
setMaxWidth(Double.MAX_VALUE);
|
||||
setVbarPolicy(ScrollBarPolicy.NEVER);
|
||||
|
||||
@@ -54,6 +54,7 @@ public class NavigationGroup extends TitledPane {
|
||||
structureChangedAction = () -> {};
|
||||
rawTitle = "";
|
||||
|
||||
getStylesheets().add(NavigationGroup.class.getResource("/timifx/style/components/navigation.css").toExternalForm());
|
||||
contentBox.setPadding(Insets.EMPTY);
|
||||
setContent(contentBox);
|
||||
getStyleClass().add("group-pane");
|
||||
|
||||
Reference in New Issue
Block a user