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);
}
}
}
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);
}
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);
}
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;
}
Aggregations