package com.imyeyu.fx.ui.examples.view.pages.component;

import com.imyeyu.fx.ui.TimiFXUI;
import com.imyeyu.fx.ui.components.SelectableLabel;
import com.imyeyu.fx.ui.examples.component.AbstractDemoPane;
import com.imyeyu.fx.ui.examples.component.sidebar.SidebarItem;
import com.imyeyu.inject.annotation.Component;
import javafx.geometry.Insets;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;

/**
 * 可选标签
 *
 * @author 夜雨
 * @since 2022-08-29 21:50
 */
@Component
public class SelectableLabelDemo extends AbstractDemoPane {

	public SelectableLabelDemo() {
		title.setText(SidebarItem.SELECTABLE_LABEL.getText());
		document.sync("https://doc.imyeyu.net/timi-fx/net/imyeyu/timifx/component/SelectableLabel.html");
		source.sync("https://git.imyeyu.net/Timi/timi-fx/src/master/src/main/java/net/imyeyu/timifx/component/SelectableLabel.java");
		tips.setText(TimiFXUI.MULTILINGUAL.text("fx.example.selectable_label.tips"));

		// 宽度调整
		Label labelWidth = TimiFXUI.label(TimiFXUI.MULTILINGUAL.text("width"));
		Slider width = new Slider();
		width.setValue(50);

		// 标签
		SelectableLabel selectableLabel = new SelectableLabel(TimiFXUI.MULTILINGUAL.text("fx.example.demo.text_long"));
		selectableLabel.setMinWidth(64);
		selectableLabel.maxWidthProperty().bind(widthProperty().subtract(40).multiply(width.valueProperty().multiply(.01)));

		setCenter(new VBox() {{
			setSpacing(32);
			setPadding(new Insets(20));
			getChildren().addAll(new HBox() {{
				setSpacing(5);
				getChildren().addAll(labelWidth, width);
			}}, selectableLabel);
		}});
	}
}
