Skip to content

Commit

Permalink
add option "open topic attributes by double clicking" for mind map
Browse files Browse the repository at this point in the history
  • Loading branch information
mindolph committed Dec 20, 2024
1 parent 0483dfb commit fd549fc
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public final class MindMapConfig implements EditorConfig, Serializable {
private boolean unfoldCollapsedTarget = false;
private boolean copyColorInfoToNewChild = false;
private boolean smartTextPaste = false;
private boolean topicAttrByDblClicking = true;
private int maxRedoUndo = 20;

public MindMapConfig(MindMapConfig cfg) {
Expand Down Expand Up @@ -155,6 +156,14 @@ public void setCopyColorInfoToNewChild(boolean copyColorInfoToNewChild) {
this.copyColorInfoToNewChild = copyColorInfoToNewChild;
}

public boolean isTopicAttrByDblClicking() {
return topicAttrByDblClicking;
}

public void setTopicAttrByDblClicking(boolean topicAttrByDblClicking) {
this.topicAttrByDblClicking = topicAttrByDblClicking;
}

public int getMaxRedoUndo() {
return maxRedoUndo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,12 +802,12 @@ public void startEdit(BaseElement element) {
}
else {
this.elementUnderEdit = element;
log.info("Start edit with: " + RectangleUtils.rectangleInStr(element.getBounds()));
log.info("Start edit with: %s".formatted(RectangleUtils.rectangleInStr(element.getBounds())));
Font font = element.getTextBlock().getFont();
Rectangle2D bounds = element.getBounds();
Point2D p = super.withViewportPadding(bounds.getMinX(), bounds.getMinY());
Rectangle2D b = new Rectangle2D(p.getX(), p.getY(), bounds.getWidth(), bounds.getHeight());
log.debug("topic bounds: " + RectangleUtils.rectangleInStr(b));
log.debug("topic bounds: %s".formatted(RectangleUtils.rectangleInStr(b)));
topicEditEventHandler.startEdit(element.getText(), font, b);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public class MindMapViewSkin<T extends MindMapView> extends BaseScalableViewSkin
// used to calculate the position of topic editor and limit the topic editor's min bounds after editing stated.
private Rectangle2D originalEditingBounds;

private MindMapCanvas mindMapCanvas;
private final MindMapCanvas mindMapCanvas;

private CanvasGraphicsWrapper graphicsWrapper;
private final CanvasGraphicsWrapper graphicsWrapper;

/**
* Constructor for all SkinBase instances.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ private static List<MenuItem> findPopupMenuItems(

@Override
protected void onClickOnExtra(TopicNode topic, int clicks, Extra<?> extra) {
if (clicks == 2) {
int clicksWanted = config.isTopicAttrByDblClicking() ? 2 : 1;
if (clicks == clicksWanted) {
switch (extra.getType()) {
case FILE -> {
MMapURI uri = (MMapURI) extra.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ public class MmdPreferencesPane extends BasePrefsPane implements Initializable {
@FXML
private CheckBox ckbSmartTextPaste;
@FXML
private CheckBox ckbTopicAttrByDblClicking;
@FXML
private Spinner<Integer> spnUndRedo;

private final Pair<ThemeKey, String> THEME_ITEM_CLASSIC;
Expand Down Expand Up @@ -316,6 +318,8 @@ private void bindAll() {
super.bindPreference(ckbUnfoldCollapsedDropTarget.selectedProperty(), PrefConstants.PREF_KEY_MMD_UNFOLD_COLLAPSED_TARGET, false);
super.bindPreference(ckbCopyParentColorToNewChild.selectedProperty(), PrefConstants.PREF_KEY_MMD_COPY_COLOR_INFO_TO_NEW_CHILD, false);
this.bindPreference(ckbSmartTextPaste.selectedProperty(), mindMapConfig::setSmartTextPaste);
// super.bindPreference(ckbTopicAttrByDblClicking.selectedProperty(), PrefConstants.PREF_KEY_MMD_OPEN_TOPIC_ATTR_BY_DBL_CLICKING, true);
this.bindPreference(ckbTopicAttrByDblClicking.selectedProperty(), mindMapConfig::setTopicAttrByDblClicking);
}

/**
Expand Down Expand Up @@ -396,6 +400,7 @@ protected void initControlsFromPreferences() {
spnSelectionWidth.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(1f, 4f, theme.getSelectLineWidth()));
spnSelectionGap.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(1f, 8f, theme.getSelectLineGap()));
ckbSmartTextPaste.setSelected(mindMapConfig.isSmartTextPaste());
ckbTopicAttrByDblClicking.setSelected(mindMapConfig.isTopicAttrByDblClicking());
spnUndRedo.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(10, 50, mindMapConfig.getMaxRedoUndo()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
<PreferenceItem name="Add default comment to root node">
<CheckBox fx:id="ckbAddDefaultCommentToRoot"/>
</PreferenceItem>
<PreferenceItem name="Trim topic text before set:">
<PreferenceItem name="Trim topic text before pasting:">
<CheckBox fx:id="ckbTrimTopicText"/>
</PreferenceItem>
<PreferenceItem name="Show collapsator when mouse hover">
Expand All @@ -177,6 +177,9 @@
<PreferenceItem name="Smart text paste:">
<CheckBox fx:id="ckbSmartTextPaste"/>
</PreferenceItem>
<PreferenceItem name="Open topic attributes by double clicking:">
<CheckBox fx:id="ckbTopicAttrByDblClicking"/>
</PreferenceItem>
<PreferenceItem name="Max size of undo/redo history(10-50):">
<Spinner fx:id="spnUndRedo" editable="true"/>
</PreferenceItem>
Expand Down

0 comments on commit fd549fc

Please sign in to comment.