Search in sources :

Example 1 with GeneralMarker

use of com.helospark.tactview.core.timeline.marker.markers.GeneralMarker in project tactview by helospark.

the class TimelineCanvasTimelineHeaderClickHandler method onHeaderClick.

public void onHeaderClick(TimelineCanvasTimelineHeaderClickHandlerRequest request) {
    MouseEvent event = request.event;
    boolean isControlDown = event.isControlDown();
    if (event.getButton().equals(MouseButton.PRIMARY) && !isControlDown) {
        uiTimelineManager.jumpAbsolute(request.position.getSeconds());
    } else if (event.getButton().equals(MouseButton.PRIMARY) && isControlDown) {
        markerRepository.addMarker(request.position, new GeneralMarker(""));
    } else if (event.getButton().equals(MouseButton.SECONDARY)) {
        boolean addedMarkerContextMenu = false;
        for (var marker : markerRepository.getMarkers().entrySet()) {
            double markerPosition = timelineState.secondsToPixelsWithZoom(marker.getKey());
            double mousePosition = request.event.getX();
            if (Math.abs(markerPosition - mousePosition) < 5) {
                ContextMenu contextMenu = createContextMenuForMarker(marker);
                contextMenu.show(request.parentWindow, event.getScreenX(), event.getScreenY());
                addedMarkerContextMenu = true;
                break;
            }
        }
        if (!addedMarkerContextMenu) {
            showContextMenuOnEmptyArea(request);
        }
    }
}
Also used : MouseEvent(javafx.scene.input.MouseEvent) ContextMenu(javafx.scene.control.ContextMenu) GeneralMarker(com.helospark.tactview.core.timeline.marker.markers.GeneralMarker)

Example 2 with GeneralMarker

use of com.helospark.tactview.core.timeline.marker.markers.GeneralMarker in project tactview by helospark.

the class TimelineCanvasTimelineHeaderClickHandler method populateGeneralMenuItem.

private void populateGeneralMenuItem(Menu convertMarker, TimelinePosition position) {
    MenuItem menuItem = new MenuItem("General marker");
    menuItem.setOnAction(e -> {
        Optional<String> result = dialogFactory.showTextInputDialog("Add marker", "label", "Something interesting");
        if (result.isPresent()) {
            markerRepository.addMarker(position, new GeneralMarker(result.get()));
        }
    });
    convertMarker.getItems().add(menuItem);
}
Also used : MenuItem(javafx.scene.control.MenuItem) GeneralMarker(com.helospark.tactview.core.timeline.marker.markers.GeneralMarker)

Example 3 with GeneralMarker

use of com.helospark.tactview.core.timeline.marker.markers.GeneralMarker in project tactview by helospark.

the class DefaultEditMenuItemConfiguration method addGeneralMarkerMenuItem.

@Bean
@Order(1942)
public SelectableMenuContribution addGeneralMarkerMenuItem(AlertDialogFactory dialogFactory, TimelineState timelineState, MarkerRepository markerRepository) {
    String name = "Add marker";
    KeyCodeCombination combination = hotKeyRepository.registerOrGetHotKey(name, new KeyCodeCombination(KeyCode.M, KeyCodeCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN), name).getCombination();
    return new DefaultMenuContribution(List.of(EDIT_ROOT, MARKER, name), event -> {
        TimelinePosition position = timelineState.getPlaybackPosition();
        Optional<String> result = dialogFactory.showTextInputDialog("Add marker", "Label of marker", "Something interesting");
        if (result.isPresent()) {
            markerRepository.addMarker(position, new GeneralMarker(result.get()));
        }
    }, combination);
}
Also used : DefaultMenuContribution(com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) GeneralMarker(com.helospark.tactview.core.timeline.marker.markers.GeneralMarker) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) Order(com.helospark.lightdi.annotation.Order) Bean(com.helospark.lightdi.annotation.Bean)

Example 4 with GeneralMarker

use of com.helospark.tactview.core.timeline.marker.markers.GeneralMarker in project tactview by helospark.

the class TimelineCanvasTimelineHeaderClickHandler method changeGeneralTextMenuItem.

private MenuItem changeGeneralTextMenuItem(Entry<TimelinePosition, Marker> marker) {
    MenuItem changeText = new MenuItem("Change label");
    changeText.setOnAction(e -> {
        Optional<String> result = dialogFactory.showTextInputDialog("Change label", "Label of the marker", "Something interesting");
        if (result.isPresent()) {
            markerRepository.addMarker(marker.getKey(), new GeneralMarker(result.get()));
        }
    });
    return changeText;
}
Also used : MenuItem(javafx.scene.control.MenuItem) GeneralMarker(com.helospark.tactview.core.timeline.marker.markers.GeneralMarker)

Aggregations

GeneralMarker (com.helospark.tactview.core.timeline.marker.markers.GeneralMarker)4 MenuItem (javafx.scene.control.MenuItem)2 Bean (com.helospark.lightdi.annotation.Bean)1 Order (com.helospark.lightdi.annotation.Order)1 TimelinePosition (com.helospark.tactview.core.timeline.TimelinePosition)1 DefaultMenuContribution (com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution)1 ContextMenu (javafx.scene.control.ContextMenu)1 KeyCodeCombination (javafx.scene.input.KeyCodeCombination)1 MouseEvent (javafx.scene.input.MouseEvent)1