Skip to content

Commit 2e489a7

Browse files
authored
Merge pull request #80 from mfl28/feature/make-drawing-mode-selection-toggle-more-compact
Make drawing mode selection toggles more compact
2 parents 6f8a666 + 07e88af commit 2e489a7

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

src/main/java/com/github/mfl28/boundingboxeditor/controller/Controller.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,11 +1618,11 @@ public static class KeyCombinations {
16181618
new KeyCodeCombination(KeyCode.F, KeyCombination.SHORTCUT_DOWN, KeyCombination.ALT_DOWN);
16191619
public static final KeyCombination deleteSelectedBoundingShape = new KeyCodeCombination(KeyCode.DELETE);
16201620
public static final KeyCombination selectRectangleDrawingMode =
1621-
new KeyCodeCombination(KeyCode.K, KeyCombination.SHORTCUT_DOWN);
1621+
new KeyCodeCombination(KeyCode.DIGIT1, KeyCombination.SHORTCUT_DOWN);
16221622
public static final KeyCombination selectPolygonDrawingMode =
1623-
new KeyCodeCombination(KeyCode.P, KeyCombination.SHORTCUT_DOWN);
1623+
new KeyCodeCombination(KeyCode.DIGIT2, KeyCombination.SHORTCUT_DOWN);
16241624
public static final KeyCombination selectFreehandDrawingMode =
1625-
new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN);
1625+
new KeyCodeCombination(KeyCode.DIGIT3, KeyCombination.SHORTCUT_DOWN);
16261626
public static final KeyCombination removeEditingVerticesWhenBoundingPolygonSelected =
16271627
new KeyCodeCombination(KeyCode.DELETE, KeyCombination.SHIFT_DOWN);
16281628
public static final KeyCombination addVerticesToPolygon =

src/main/java/com/github/mfl28/boundingboxeditor/ui/EditorToolBarView.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,25 @@ public class EditorToolBarView extends ToolBar implements View {
7272
private static final String SHOW_BOUNDING_BOXES_ICON_BUTTON_ID = "show-bounding-boxes-icon";
7373
private static final String HIDE_BOUNDING_BOXES_ICON_BUTTON_ID = "hide-bounding-boxes-icon";
7474
private static final String RESET_IMAGE_SIZE_ICON_BUTTON_ID = "reset-image-size-icon";
75-
private static final String RECTANGLE_MODE_BUTTON_TEXT = "Rectangle";
76-
private static final String POLYGON_MODE_BUTTON_TEXT = "Polygon";
77-
private static final String FREEHAND_MODE_BUTTON_TEXT = "Freehand";
7875
private static final String RECTANGLE_MODE_BUTTON_ICON_ID = "rectangle-mode-button-icon";
7976
private static final String FREEHAND_MODE_BUTTON_ICON_ID = "freehand-mode-button-icon";
8077
private static final String POLYGON_MODE_BUTTON_ICON_ID = "polygon-mode-button-icon";
8178
private static final String PREDICT_BUTTON_TEXT = "Predict";
8279
private static final String PREDICT_BUTTON_ID = "predict-button";
8380
private static final String FREEHAND_DRAWING_MODE = "Select Freehand Drawing-Mode";
8481
private static final String FREEHAND_DRAWING_MODE_TOOLTIP_TEXT = FREEHAND_DRAWING_MODE;
82+
private static final String DRAWING_MODE_TOOLBOX_ID = "drawing-mode-toolbox";
8583

8684
private final IconButton showBoundingShapesButton =
8785
new IconButton(SHOW_BOUNDING_BOXES_ICON_BUTTON_ID, IconButton.IconType.BACKGROUND);
8886
private final IconButton hideBoundingShapesButton =
8987
new IconButton(HIDE_BOUNDING_BOXES_ICON_BUTTON_ID, IconButton.IconType.BACKGROUND);
9088
private final ToggleButton rectangleModeButton =
91-
createDrawModeButton(RECTANGLE_MODE_BUTTON_TEXT, RECTANGLE_MODE_BUTTON_ICON_ID);
89+
createDrawModeButton("", RECTANGLE_MODE_BUTTON_ICON_ID);
9290
private final ToggleButton polygonModeButton =
93-
createDrawModeButton(POLYGON_MODE_BUTTON_TEXT, POLYGON_MODE_BUTTON_ICON_ID);
91+
createDrawModeButton("", POLYGON_MODE_BUTTON_ICON_ID);
9492
private final ToggleButton freehandModeButton =
95-
createDrawModeButton(FREEHAND_MODE_BUTTON_TEXT, FREEHAND_MODE_BUTTON_ICON_ID);
93+
createDrawModeButton("", FREEHAND_MODE_BUTTON_ICON_ID);
9694
private final ToggleGroup modeToggleGroup = new ToggleGroup();
9795

9896
private final IconButton resetSizeAndCenterImageButton =
@@ -300,7 +298,7 @@ private ToggleButton createDrawModeButton(String text, String iconCssId) {
300298
button.textFillProperty()));
301299

302300
button.setGraphic(icon);
303-
button.setContentDisplay(ContentDisplay.RIGHT);
301+
button.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
304302

305303
button.setFocusTraversable(false);
306304
button.setPickOnBounds(true);
@@ -351,6 +349,8 @@ private void setUpButtonsAndLabels() {
351349
modeToggleGroup.selectToggle(rectangleModeButton);
352350

353351
predictButton.setId(PREDICT_BUTTON_ID);
352+
353+
drawingModeToolBox.setId(DRAWING_MODE_TOOLBOX_ID);
354354
}
355355

356356
private void setUpInternalListeners() {

src/main/resources/stylesheets/scss/styles.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,12 @@ $base-separator-line-color: derive($base-background-color, -15%);
697697
-fx-background-color: $base-background-light-color;
698698
}
699699

700+
#drawing-mode-toolbox {
701+
-fx-border-radius: 3px;
702+
-fx-background-radius: 3px;
703+
-fx-border-color: $base-alt-accent-color;
704+
}
705+
700706
#bounding-box-explorer-top-panel {
701707
-fx-spacing: 10px;
702708
}

src/test/java/com/github/mfl28/boundingboxeditor/controller/SceneKeyShortcutTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ private void testHideSelectedBoundingShapeKeyEvent(BoundingPolygonView polygon)
257257
}
258258

259259
private void testSelectPolygonModeKeyEvent() {
260-
KeyEvent selectPolygonModeEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "", "", KeyCode.P, false, true,false, false);
260+
KeyEvent selectPolygonModeEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "", "", KeyCode.DIGIT2, false, true,false, false);
261261
Platform.runLater(() -> controller.onRegisterSceneKeyPressed(selectPolygonModeEvent));
262262
WaitForAsyncUtils.waitForFxEvents();
263263

@@ -298,15 +298,15 @@ private void testFocusCategorySearchFieldKeyEvent() {
298298
}
299299

300300
private void testSelectRectangleModeKeyEvent() {
301-
KeyEvent selectRectangleModeEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "", "", KeyCode.K, false, true,false, false);
301+
KeyEvent selectRectangleModeEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "", "", KeyCode.DIGIT1, false, true,false, false);
302302
Platform.runLater(() -> controller.onRegisterSceneKeyPressed(selectRectangleModeEvent));
303303
WaitForAsyncUtils.waitForFxEvents();
304304

305305
verifyThat(controller.getView().getEditor().getEditorToolBar().getRectangleModeButton().isSelected(), Matchers.is(true));
306306
}
307307

308308
private void testSelectFreehandDrawingModeKeyEvent() {
309-
KeyEvent selectFreehandDrawingModeEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "", "", KeyCode.S, false, true,false, false);
309+
KeyEvent selectFreehandDrawingModeEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "", "", KeyCode.DIGIT3, false, true,false, false);
310310
Platform.runLater(() -> controller.onRegisterSceneKeyPressed(selectFreehandDrawingModeEvent));
311311
WaitForAsyncUtils.waitForFxEvents();
312312

src/test/java/com/github/mfl28/boundingboxeditor/ui/BoundingPolygonDrawingTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void onOpeningNewImageFolder_WhenBoundingPolygonsExist_ShouldResetCorrectly(FxRo
7878
saveScreenshot(testinfo));
7979

8080
// Select polygon drawing mode:
81-
timeOutClickOn(robot, "Polygon", testinfo);
81+
timeOutClickOn(robot, "#polygon-mode-button-icon", testinfo);
8282
WaitForAsyncUtils.waitForFxEvents();
8383

8484
// Draw a bounding polygon.
@@ -291,7 +291,7 @@ void onOpeningNewImageFolder_WhenBoundingPolygonsExist_ShouldResetCorrectly(FxRo
291291
WaitForAsyncUtils.waitForFxEvents();
292292

293293
// Change drawing mode while construction is in progress.
294-
timeOutClickOn(robot, "Rectangle", testinfo);
294+
timeOutClickOn(robot, "#rectangle-mode-button-icon", testinfo);
295295
WaitForAsyncUtils.waitForFxEvents();
296296

297297
verifyThat(mainView.getCurrentBoundingShapes(), Matchers.hasSize(1), saveScreenshot(testinfo));
@@ -378,7 +378,7 @@ void onFreehandDrawing_WhenImageFolderLoaded_ShouldCorrectlyCreatePolygons(FxRob
378378
WaitForAsyncUtils.waitForFxEvents();
379379

380380
// Select polygon drawing mode:
381-
timeOutClickOn(robot, "Freehand", testinfo);
381+
timeOutClickOn(robot, "#freehand-mode-button-icon", testinfo);
382382
WaitForAsyncUtils.waitForFxEvents();
383383

384384
// Draw a bounding polygon.

0 commit comments

Comments
 (0)