Skip to content

Commit

Permalink
Don't show the selection box by default
Browse files Browse the repository at this point in the history
Only show it for certain tools, or if we snap to it.
  • Loading branch information
guillaumechereau committed Jul 7, 2024
1 parent d7f3726 commit da706e5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/goxel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1059,8 +1059,10 @@ void goxel_render_view(const float viewport[4], bool render_mode)
render_img(rend, layer->image, layer->mat, EFFECT_NO_SHADING);
}

render_box(rend, goxel.image->selection_box, NULL,
EFFECT_STRIP | EFFECT_WIREFRAME);
if (goxel.tool->flags & TOOL_SHOW_SELECTION_BOX) {
render_box(rend, goxel.image->selection_box, NULL,
EFFECT_STRIP | EFFECT_WIREFRAME);
}

if (goxel.tool->flags & TOOL_SHOW_MASK) {
render_volume(rend, goxel.image->selection_mask, NULL,
Expand Down
9 changes: 5 additions & 4 deletions src/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ enum {

enum {
// Tools flags.
TOOL_REQUIRE_CAN_EDIT = 1 << 0, // Set to tools that can edit the layer.
TOOL_REQUIRE_CAN_MOVE = 1 << 1, // Set to tools that can move the layer.
TOOL_ALLOW_PICK_COLOR = 1 << 2, // Ctrl switches to pick color tool.
TOOL_SHOW_MASK = 1 << 3,
TOOL_REQUIRE_CAN_EDIT = 1 << 0, // Set to tools that can edit the layer.
TOOL_REQUIRE_CAN_MOVE = 1 << 1, // Set to tools that can move the layer.
TOOL_ALLOW_PICK_COLOR = 1 << 2, // Ctrl switches to pick color tool.
TOOL_SHOW_MASK = 1 << 3,
TOOL_SHOW_SELECTION_BOX = 1 << 4,
};

// Tools
Expand Down
5 changes: 5 additions & 0 deletions src/tools/brush.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ static int iter(tool_t *tool, const painter_t *painter,
tool_brush_t *brush = (tool_brush_t*)tool;
float snap_offset;

if (goxel.snap_mask & (SNAP_SELECTION_IN | SNAP_SELECTION_OUT)) {
render_box(&goxel.rend, goxel.image->selection_box, NULL,
EFFECT_STRIP | EFFECT_WIREFRAME);
}

if (!brush->volume_orig)
brush->volume_orig = volume_copy(goxel.image->active_layer->volume);
if (!brush->volume)
Expand Down
2 changes: 1 addition & 1 deletion src/tools/selection.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,5 @@ TOOL_REGISTER(TOOL_SELECTION, selection, tool_selection_t,
.iter_fn = iter,
.gui_fn = gui,
.default_shortcut = "R",
.flags = TOOL_SHOW_MASK,
.flags = TOOL_SHOW_MASK | TOOL_SHOW_SELECTION_BOX,
)
5 changes: 5 additions & 0 deletions src/tools/shape.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ static int iter(tool_t *tool, const painter_t *painter,
tool_shape_t *shape = (tool_shape_t*)tool;
float snap_offset;

if (goxel.snap_mask & (SNAP_SELECTION_IN | SNAP_SELECTION_OUT)) {
render_box(&goxel.rend, goxel.image->selection_box, NULL,
EFFECT_STRIP | EFFECT_WIREFRAME);
}

snap_offset = (painter->mode == MODE_OVER) ? 0.5 : -0.5;

if (!shape->volume_orig)
Expand Down

0 comments on commit da706e5

Please sign in to comment.