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

import com.imyeyu.fx.ui.TimiFXUI;
import com.imyeyu.fx.ui.components.TabPane;
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.Button;
import javafx.scene.control.Tab;
import javafx.scene.layout.BorderPane;

/**
 * 标签面板
 *
 * @author 夜雨
 * @since 2022-08-30 09:36
 */
@Component
public class XTabPaneDemo extends AbstractDemoPane {

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

		Button add = new Button(TimiFXUI.MULTILINGUAL.text("add"));

		TabPane tabPane = new TabPane();
		tabPane.setTabClosingPolicy(javafx.scene.control.TabPane.TabClosingPolicy.ALL_TABS);

		setCenter(new BorderPane() {{
			setMargin(add, new Insets(0, 0, 20, 0));
			setPadding(new Insets(20));
			setTop(add);
			setBottom(tabPane);
		}});
		add.setOnAction(e -> tabPane.getTabs().add(new Tab("test顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶")));
	}
}
