use of com.helospark.tactview.ui.javafx.tiwulfx.com.panemu.tiwulfx.control.DetachableTabPaneLoadModel in project tactview by helospark.
the class JavaFXUiMain method start.
@Override
public void start(Stage stage) throws IOException {
DirtyRepository dirtyRepository = lightDi.getBean(DirtyRepository.class);
ExitWithSaveService exitWithSaveService = lightDi.getBean(ExitWithSaveService.class);
StylesheetAdderService styleSheetAdder = lightDi.getBean(StylesheetAdderService.class);
styleSheetAdder.setTactviewIconForStage(stage);
JavaFXUiMain.STAGE = stage;
lightDi.getListOfBeans(MainWindowStageAware.class).forEach(listener -> listener.setMainWindowStage(stage));
NotificationPane notificationPane = new NotificationPane();
BorderPane root = new BorderPane();
Scene scene = new Scene(root, 650, 550, Color.GREY);
styleSheetAdder.addStyleSheets(root, "stylesheet.css");
MenuBar menuBar = lightDi.getBean(MenuProcessor.class).createMenuBar();
if (SystemUtils.IS_OS_MAC_OSX) {
// https://stackoverflow.com/a/28874063
menuBar.useSystemMenuBarProperty().set(true);
}
stage.setOnCloseRequest(e -> {
exitApplication(exitWithSaveService, e);
});
root.setTop(menuBar);
stage.setScene(scene);
stage.setTitle("TactView - Video editor");
dirtyRepository.addUiChangeListener(value -> {
Platform.runLater(() -> {
String title = "";
if (value) {
title += "* ";
}
title += "TactView - Video editor";
stage.setTitle(title);
});
});
stage.setMaximized(true);
if (SystemUtils.IS_OS_MAC) {
SwingFXUtils.toFXImage(new BufferedImage(100, 100, TYPE_INT_BGR), null);
}
// spacing between child nodes only.
SplitPane mainContentPane = new SplitPane();
mainContentPane.setId("content-area");
mainContentPane.setPrefWidth(scene.getWidth());
// space between vbox border and child nodes column
mainContentPane.setPadding(new Insets(1));
mainContentPane.setDividerPositions(0.6);
canvas = new Canvas();
lightDi.getBean(CanvasStateHolder.class).setCanvas(canvas);
lightDi.getBean(DefaultCanvasTranslateSetter.class).setDefaultCanvasTranslate(uiProjectRepository.getPreviewWidth(), uiProjectRepository.getPreviewHeight());
InputModeRepository inputModeRepository = lightDi.getBean(InputModeRepository.class);
inputModeRepository.setCanvas(canvas);
displayUpdateService.setCanvas(canvas);
displayUpdateService.updateCurrentPositionWithInvalidatedCache();
Tooltip tooltip = new Tooltip();
StringProperty statusTextProperty = lightDi.getBean(VideoStatusBarUpdater.class).getTextProperty();
tooltip.textProperty().bind(statusTextProperty);
tooltip.setHideOnEscape(false);
tooltip.setAutoHide(false);
tooltip.setAnchorLocation(AnchorLocation.CONTENT_TOP_LEFT);
statusTextProperty.addListener((e, oldV, newV) -> {
if (newV.length() > 0) {
Bounds canvasBottom = canvas.localToScene(canvas.getBoundsInLocal());
double x = canvasBottom.getMinX();
double y = canvasBottom.getMaxY() + 60;
tooltip.show(canvas, x, y);
} else {
tooltip.hide();
}
});
tooltip.setWrapText(true);
HBox upperPane = new HBox();
upperPane.setId("upper-content-area");
upperPane.setMinHeight(300);
upperPane.setFillHeight(true);
DetachableTabPaneLoadModel layoutToLoad = lightDi.getBean(DefaultLayoutProvider.class).provideDefaultLayout();
DockableTabRepository dockableTabRepository = lightDi.getBean(DockableTabRepository.class);
dockableTabRepository.setParentPane(upperPane);
dockableTabRepository.loadAndSetModelToParent(layoutToLoad);
TiwulFXUtil.setTiwulFXStyleSheet(scene);
VBox lower = new VBox(5);
lower.setPrefWidth(scene.getWidth());
lower.setPrefHeight(300);
lower.setId("timeline-view");
BorderPane timeline = uiTimeline.createTimeline(lower, root);
lower.getChildren().add(timeline);
VBox.setVgrow(timeline, Priority.ALWAYS);
mainContentPane.getItems().add(upperPane);
mainContentPane.getItems().add(lower);
mainContentPane.setOrientation(Orientation.VERTICAL);
root.setCenter(mainContentPane);
notificationPane.setContent(root);
inputModeRepository.registerInputModeChangeConsumerr(onClassChangeDisableTabs());
inputModeRepository.registerInputModeChangeConsumerr(onClassChange(timeline));
lightDi.getListOfBeans(ScenePostProcessor.class).stream().forEach(processor -> processor.postProcess(scene));
lightDi.getListOfBeans(PostInitializationArgsCallback.class).forEach(postInitCallback -> postInitCallback.call(mainArgs));
if (splashStage.isShowing()) {
stage.show();
splashStage.toFront();
FadeTransition fadeSplash = new FadeTransition(Duration.seconds(0.5), splasViewh);
fadeSplash.setDelay(Duration.millis(800));
fadeSplash.setFromValue(1.0);
fadeSplash.setToValue(0.0);
fadeSplash.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
splashStage.hide();
}
});
fadeSplash.play();
}
}
use of com.helospark.tactview.ui.javafx.tiwulfx.com.panemu.tiwulfx.control.DetachableTabPaneLoadModel in project tactview by helospark.
the class DefaultWindowMenuItemConfiguration method saveLayoutMenuItem.
@Bean
@Order(3997)
public SelectableMenuContribution saveLayoutMenuItem(MessagingService messagingService, QuerySaveFilenameService querySaveFilenameService, @Value("${tactview.homedirectory}") String homeDirectory, AlertDialogFactory alertDialogFactory) {
return new DefaultMenuContribution(List.of(WINDOW_MENU_ITEM, "Save layout"), e -> {
QuerySaveFileNameRequest request = QuerySaveFileNameRequest.builder().withInitialDirectory(homeDirectory).withTitle("Save layout file").build();
Optional<String> optionalFileName = querySaveFilenameService.queryUserAboutFileName(request);
if (optionalFileName.isPresent()) {
try {
String fileName = optionalFileName.get();
if (!fileName.endsWith("." + TACTVIEW_LAYOUT_EXTENSION)) {
fileName += ("." + TACTVIEW_LAYOUT_EXTENSION);
}
DetachableTabPaneLoadModel data = dockableTabRepository.extractLoadModel();
String result = objectMapper.writeValueAsString(data);
try (FileOutputStream fos = new FileOutputStream(new File(fileName))) {
fos.write(result.getBytes(StandardCharsets.UTF_8));
}
} catch (Exception e1) {
alertDialogFactory.showExceptionDialog("Unable to save layout", e1);
LOGGER.error("Unable to save layout", e1);
}
}
});
}
use of com.helospark.tactview.ui.javafx.tiwulfx.com.panemu.tiwulfx.control.DetachableTabPaneLoadModel in project tactview by helospark.
the class DefaultLayoutProvider method provideDefaultLayout.
public DetachableTabPaneLoadModel provideDefaultLayout() {
SplitPaneElement splitPaneElement = new SplitPaneElement();
splitPaneElement.isVertical = false;
splitPaneElement.size = new double[] { 0.2, 0.6, 0.2 };
DetachableTab propertyEditorTab = propertyEditorDockableTabFactory.createTab();
DetachableTab addableContentEditorTab = addableContentDockableTabFactory.createTab();
DetachableTab curveEditorTab = curveEditorDockableTabFactory.createTab();
DetachableTab previewTab = previewDockableTabFactory.createTab();
splitPaneElement.children.add(new LeafElement(List.of(propertyEditorTab)));
splitPaneElement.children.add(new LeafElement(List.of(addableContentEditorTab, curveEditorTab)));
splitPaneElement.children.add(new LeafElement(List.of(previewTab)));
return new DetachableTabPaneLoadModel(splitPaneElement);
}
use of com.helospark.tactview.ui.javafx.tiwulfx.com.panemu.tiwulfx.control.DetachableTabPaneLoadModel in project tactview by helospark.
the class DefaultWindowMenuItemConfiguration method loadLayoutMenuItem.
@Bean
@Order(3998)
public SelectableMenuContribution loadLayoutMenuItem(MessagingService messagingService, AlertDialogFactory alertDialogFactory) {
return new DefaultMenuContribution(List.of(WINDOW_MENU_ITEM, "Load layout"), e -> {
try {
FileChooser fileChooser = new FileChooser();
fileChooser.setSelectedExtensionFilter(new ExtensionFilter("TactView layout file", TACTVIEW_LAYOUT_EXTENSION));
fileChooser.setTitle("Open Layout");
File file = fileChooser.showOpenDialog(JavaFXUiMain.STAGE);
if (file != null) {
try (var inputStream = new FileInputStream(file)) {
DetachableTabPaneLoadModel result = objectMapper.readValue(inputStream, DetachableTabPaneLoadModel.class);
dockableTabRepository.loadAndSetModelToParent(result);
}
}
} catch (Exception e1) {
alertDialogFactory.showExceptionDialog("Unable to load layout", e1);
LOGGER.error("Unable to load layout", e1);
}
});
}
Aggregations