Skip to content

Commit

Permalink
Remove goxel.tool_drag_mode
Browse files Browse the repository at this point in the history
This is not useful now that we can move the selection with the gizmos.
  • Loading branch information
guillaumechereau committed Jul 2, 2024
1 parent b5b3247 commit 81e3761
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 46 deletions.
3 changes: 2 additions & 1 deletion src/box_edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ static int on_drag(gesture3d_t *gest)

static int on_gizmo_hover(gesture3d_t *gest)
{
goxel_set_help_text("Drag to move");
g_data.snap_face = gest->user_key;
g_data.flags |= FLAG_SNAP_GIZMO;
return 0;
Expand All @@ -159,7 +160,7 @@ static int on_gizmo_drag(gesture3d_t *gest)
int face = gest->user_key;
float box[4][4];

goxel_set_help_text("Drag to move face");
goxel_set_help_text("Drag to move");
g_data.flags |= FLAG_MOVING;

if (gest->state == GESTURE3D_STATE_BEGIN) {
Expand Down
3 changes: 0 additions & 3 deletions src/goxel.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,6 @@ typedef struct goxel
float tool_radius;
bool pathtrace; // Render pathtraced mode.

// Some state for the tool iter functions.
int tool_drag_mode; // 0: move, 1: resize.

float selection[4][4]; // The selection box.
volume_t *mask; // Global selection mask volume.
int mask_mode;
Expand Down
1 change: 0 additions & 1 deletion src/gui/layers_panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ void gui_layers_panel(void)
gui_bbox(layer->box);

if (layer->shape) {
tool_gui_drag_mode(&goxel.tool_drag_mode);
tool_gui_shape(&layer->shape);
gui_color("##color", layer->color);
}
Expand Down
22 changes: 0 additions & 22 deletions src/tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,25 +186,3 @@ int tool_gui_color(void)
}
return 0;
}

int tool_gui_drag_mode(int *mode)
{
int ret = 0;
bool b;

gui_group_begin(_(ADJUSTEMENTS));
gui_row_begin(2);
b = *mode == 0;
if (gui_selectable(_(MOVE), &b, NULL, 0)) {
*mode = 0;
ret = 1;
}
b = *mode == 1;
if (gui_selectable(_(RESIZE), &b, NULL, 0)) {
*mode = 1;
ret = 1;
}
gui_row_end();
gui_group_end();
return ret;
}
1 change: 0 additions & 1 deletion src/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,5 @@ int tool_gui_shape(const shape_t **shape);
int tool_gui_radius(void);
int tool_gui_smoothness(void);
int tool_gui_color(void);
int tool_gui_drag_mode(int *mode);

#endif // TOOLS_H
13 changes: 3 additions & 10 deletions src/tools/move.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,19 @@ static void update_view(void)
bool first;
uint8_t color[4] = {255, 0, 0, 255};
float box[4][4];
int drag_mode = DRAG_MOVE;

layer_t *layer = goxel.image->active_layer;

if (layer_is_volume(layer)) {
goxel.tool_drag_mode = DRAG_MOVE;
}
if (layer->shape) drag_mode = DRAG_RESIZE;

volume_get_box(goxel.image->active_layer->volume, true, box);
// Fix problem with shape layer box.
if (goxel.image->active_layer->shape) {
normalize_box(goxel.image->active_layer->mat, box);
}

if (box_edit(box, goxel.tool_drag_mode, transf, &first)) {
if (box_edit(box, drag_mode, transf, &first)) {
if (first) image_history_push(goxel.image);
do_move(layer, transf, VEC(0, 0, 0), false);
}
Expand Down Expand Up @@ -152,12 +151,6 @@ static int gui(tool_t *tool)
update_view();

layer = goxel.image->active_layer;
if (layer->shape) {
tool_gui_drag_mode(&goxel.tool_drag_mode);
} else {
goxel.tool_drag_mode = DRAG_MOVE;
}

x = (int)round(layer->mat[3][0]);
y = (int)round(layer->mat[3][1]);
z = (int)round(layer->mat[3][2]);
Expand Down
9 changes: 1 addition & 8 deletions src/tools/selection.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ enum {
DRAG_MOVE,
};

static int g_drag_mode = 0;

typedef struct {
tool_t tool;

Expand Down Expand Up @@ -95,8 +93,7 @@ static int iter(tool_t *tool, const painter_t *painter,
snap_mask |= SNAP_ROUNDED;
snap_mask &= ~(SNAP_SELECTION_IN | SNAP_SELECTION_OUT);

if (box_edit(goxel.selection, g_drag_mode == DRAG_RESIZE ? 1 : 0,
transf, NULL)) {
if (box_edit(goxel.selection, 1, transf, NULL)) {
mat4_mul(transf, goxel.selection, goxel.selection);
return 0;
}
Expand Down Expand Up @@ -141,10 +138,6 @@ static int gui(tool_t *tool)
float (*box)[4][4] = &goxel.selection;
if (box_is_null(*box)) return 0;

gui_text("Drag mode");
gui_combo("##drag_mode", &g_drag_mode,
(const char*[]) {"Resize", "Move"}, 2);

gui_group_begin(NULL);
if (gui_action_button(ACTION_reset_selection, "Reset", 1.0)) {
gui_group_end();
Expand Down

0 comments on commit 81e3761

Please sign in to comment.