Page MenuHome

toggle_drag_v2.diff

toggle_drag_v2.diff

Index: source/blender/editors/include/UI_interface.h
===================================================================
--- source/blender/editors/include/UI_interface.h (revision 54587)
+++ source/blender/editors/include/UI_interface.h (working copy)
@@ -273,6 +273,13 @@
#define UI_GRAD_V_ALT 9
+/* toggle_drag */
+enum {
+ UI_TOGGLE_DRAG = (1 << 0),
+ UI_TOGGLE_DRAG_LOCK_X = (1 << 1),
+ UI_TOGGLE_DRAG_LOCK_Y = (1 << 2)
+};
+
/* Drawing
*
* Functions to draw various shapes, taking theme settings into account.
@@ -436,7 +443,10 @@
void uiButSetDragValue(uiBut *but);
void uiButSetDragImage(uiBut *but, const char *path, int icon, struct ImBuf *ima, float scale);
+void uiButSetDragToggle(uiBut *but, int flag);
+
int UI_but_active_drop_name(struct bContext *C);
+struct uiBut *ui_but_find_mouse_over(struct ARegion *ar, int x, int y);
void uiButSetFlag(uiBut *but, int flag);
void uiButClearFlag(uiBut *but, int flag);
@@ -447,7 +457,9 @@
/* special button case, only draw it when used actively, for outliner etc */
int uiButActiveOnly(const struct bContext *C, uiBlock *block, uiBut *but);
+void uiButExecute(const struct bContext *C, uiBut *but);
+
/* Buttons
*
* Functions to define various types of buttons in a block. Postfixes:
Index: source/blender/editors/interface/interface.c
===================================================================
--- source/blender/editors/interface/interface.c (revision 54587)
+++ source/blender/editors/interface/interface.c (working copy)
@@ -713,6 +713,12 @@
return 1;
}
+/* simulate button click */
+void uiButExecute(const bContext *C, uiBut *but)
+{
+ ui_button_execute_do((bContext *)C, CTX_wm_region(C), but);
+}
+
/* use to check if we need to disable undo, but don't make any changes
* returns FALSE if undo needs to be disabled. */
static int ui_but_is_rna_undo(uiBut *but)
@@ -1394,6 +1400,18 @@
return 0;
}
+int ui_is_but_bool(uiBut *but)
+{
+ if (ELEM5(but->type, TOG, TOGN, TOGR, ICONTOG, ICONTOGN))
+ return 1;
+
+ if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_BOOLEAN)
+ return 1;
+
+ return 0;
+}
+
+
int ui_is_but_unit(uiBut *but)
{
UnitSettings *unit = but->block->unit;
@@ -3540,6 +3558,12 @@
but->imb_scale = scale;
}
+void uiButSetDragToggle(uiBut *but, int flag)
+{
+ BLI_assert(ui_is_but_bool(but) == true);
+ but->toggle_drag = flag;
+}
+
PointerRNA *uiButGetOperatorPtrRNA(uiBut *but)
{
if (but->optype && !but->opptr) {
Index: source/blender/editors/interface/interface_handlers.c
===================================================================
--- source/blender/editors/interface/interface_handlers.c (revision 54587)
+++ source/blender/editors/interface/interface_handlers.c (working copy)
@@ -85,6 +85,7 @@
/* proto */
static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to);
static void ui_add_link(bContext *C, uiBut *from, uiBut *to);
+static int ui_do_but_EXIT(bContext *C, uiBut *but, struct uiHandleButtonData *data, const wmEvent *event);
/***************** structs and defines ****************/
@@ -761,14 +762,29 @@
WM_gestures_remove(C);
if (ABS(data->dragstartx - event->x) + ABS(data->dragstarty - event->y) > U.dragthreshold) {
- wmDrag *drag;
-
+
button_activate_state(C, but, BUTTON_STATE_EXIT);
data->cancel = TRUE;
- drag = WM_event_start_drag(C, but->icon, but->dragtype, but->dragpoin, ui_get_but_val(but));
- if (but->imb)
- WM_event_drag_image(drag, but->imb, but->imb_scale, BLI_rctf_size_x(&but->rect), BLI_rctf_size_y(&but->rect));
+ if (but->toggle_drag & UI_TOGGLE_DRAG) {
+ const bool is_set = (ui_get_but_val(but) != 0.0);
+ PointerRNA ptr;
+ WM_operator_properties_create(&ptr, "UI_OT_drag_toggle");
+ RNA_boolean_set(&ptr, "state", !is_set);
+ RNA_int_set(&ptr, "last_x", data->dragstartx);
+ RNA_int_set(&ptr, "last_y", data->dragstarty);
+ RNA_boolean_set(&ptr, "lock_x", but->toggle_drag & UI_TOGGLE_DRAG_LOCK_X);
+ RNA_boolean_set(&ptr, "lock_y", but->toggle_drag & UI_TOGGLE_DRAG_LOCK_Y);
+ WM_operator_name_call(C, "UI_OT_drag_toggle", WM_OP_INVOKE_DEFAULT, &ptr);
+ WM_operator_properties_free(&ptr);
+ }
+ else {
+ wmDrag *drag;
+
+ drag = WM_event_start_drag(C, but->icon, but->dragtype, but->dragpoin, ui_get_but_val(but));
+ if (but->imb)
+ WM_event_drag_image(drag, but->imb, but->imb_scale, BLI_rctf_size_x(&but->rect), BLI_rctf_size_y(&but->rect));
+ }
return 1;
}
@@ -2472,6 +2488,13 @@
static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
{
if (data->state == BUTTON_STATE_HIGHLIGHT) {
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS && but->toggle_drag) {
+ button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
+ data->dragstartx = event->x;
+ data->dragstarty = event->y;
+ return WM_UI_HANDLER_CONTINUE;
+ }
+
if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) {
data->togdual = event->ctrl;
data->togonly = !event->shift;
@@ -2479,6 +2502,10 @@
return WM_UI_HANDLER_BREAK;
}
}
+ else if (data->state == BUTTON_STATE_WAIT_DRAG) {
+ /* note: the 'BUTTON_STATE_WAIT_DRAG' part of 'ui_do_but_EXIT' could be refactored into its own function */
+ return ui_do_but_EXIT(C, but, data, event);
+ }
return WM_UI_HANDLER_CONTINUE;
}
@@ -2499,6 +2526,12 @@
return WM_UI_HANDLER_CONTINUE;
}
}
+ if (event->type == LEFTMOUSE && but->toggle_drag) {
+ button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
+ data->dragstartx = event->x;
+ data->dragstarty = event->y;
+ return WM_UI_HANDLER_CONTINUE;
+ }
if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) {
int ret = WM_UI_HANDLER_BREAK;
@@ -3215,6 +3248,12 @@
return WM_UI_HANDLER_BREAK;
}
}
+ if (event->type == LEFTMOUSE && but->toggle_drag) {
+ button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
+ data->dragstartx = event->x;
+ data->dragstarty = event->y;
+ return WM_UI_HANDLER_CONTINUE;
+ }
/* regular open menu */
if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) {
@@ -5397,7 +5436,7 @@
return 1;
}
-static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y)
+uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y)
{
uiBlock *block;
uiBut *but, *butover = NULL;
@@ -5766,8 +5805,10 @@
ED_region_tag_redraw(data->region);
/* clean up button */
- MEM_freeN(but->active);
- but->active = NULL;
+ if (but->active) {
+ MEM_freeN(but->active);
+ but->active = NULL;
+ }
but->flag &= ~(UI_ACTIVE | UI_SELECT);
but->flag |= UI_BUT_LAST_ACTIVE;
if (!onfree)
@@ -6016,6 +6057,20 @@
ui_do_button(C, but->block, but, &event);
}
+void ui_button_execute_do(struct bContext *C, struct ARegion *ar, uiBut *but)
+{
+ /* note: ideally we would not have to change 'but->active' howevwer
+ * some functions we call don't use data (as they should be doing) */
+ void *active_back = but->active;
+ uiHandleButtonData *data = MEM_callocN(sizeof(uiHandleButtonData), "uiHandleButtonData_Fake");
+ but->active = data;
+ data->region = ar;
+ ui_apply_button(C, but->block, but, data, true);
+ /* use onfree event so undo is handled by caller and apply is already done above */
+ button_activate_exit((bContext *)C, data, but, false, true);
+ but->active = active_back;
+}
+
static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type)
{
uiBut *oldbut;
Index: source/blender/editors/interface/interface_intern.h
===================================================================
--- source/blender/editors/interface/interface_intern.h (revision 54587)
+++ source/blender/editors/interface/interface_intern.h (working copy)
@@ -235,7 +235,8 @@
char changed; /* could be made into a single flag */
unsigned char unit_type; /* so buttons can support unit systems which are not RNA */
short modifier_key;
- short iconadd;
+ char iconadd;
+ char toggle_drag;
/* IDPOIN data */
uiIDPoinFuncFP idpoin_func;
@@ -406,6 +407,7 @@
extern void ui_check_but(uiBut *but);
extern int ui_is_but_float(uiBut *but);
+extern int ui_is_but_bool(uiBut *but);
extern int ui_is_but_unit(uiBut *but);
extern int ui_is_but_rna_valid(uiBut *but);
extern int ui_is_but_utf8(uiBut *but);
@@ -509,6 +511,7 @@
/* interface_handlers.c */
extern void ui_pan_to_scroll(const struct wmEvent *event, int *type, int *val);
extern void ui_button_activate_do(struct bContext *C, struct ARegion *ar, uiBut *but);
+extern void ui_button_execute_do(struct bContext *C, struct ARegion *ar, uiBut *but);
extern void ui_button_active_free(const struct bContext *C, uiBut *but);
extern int ui_button_is_active(struct ARegion *ar);
extern int ui_button_open_menu_direction(uiBut *but);
Index: source/blender/editors/interface/interface_layout.c
===================================================================
--- source/blender/editors/interface/interface_layout.c (revision 54587)
+++ source/blender/editors/interface/interface_layout.c (working copy)
@@ -397,6 +397,7 @@
but = uiDefAutoButR(block, ptr, prop, a + b * colbuts, "", icon, x + butw * a, y + buth, butw, buth);
if (subtype == PROP_LAYER_MEMBER)
uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a + b * colbuts));
+ uiButSetDragToggle(but, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_Y);
}
for (a = 0; a < colbuts; a++) {
if (layer_used & (1 << (a + len / 2 + b * colbuts))) icon = ICON_LAYER_USED;
@@ -405,6 +406,7 @@
but = uiDefAutoButR(block, ptr, prop, a + len / 2 + b * colbuts, "", icon, x + butw * a, y, butw, buth);
if (subtype == PROP_LAYER_MEMBER)
uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a + len / 2 + b * colbuts));
+ uiButSetDragToggle(but, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_Y);
}
uiBlockEndAlign(block);
Index: source/blender/editors/interface/interface_ops.c
===================================================================
--- source/blender/editors/interface/interface_ops.c (revision 54587)
+++ source/blender/editors/interface/interface_ops.c (working copy)
@@ -1071,6 +1071,141 @@
ot->exec = reloadtranslation_exec;
}
+
+/* -------------------------------------------------------------------- */
+/* Toggle Drag Operator */
+
+typedef struct DragOpPlotData {
+ bContext *C;
+ ARegion *ar;
+ bool is_set;
+ bool do_draw;
+ const uiBut *but_prev;
+} DragOpPlotData;
+
+static const uiBut *ui_but_set_xy(bContext *C, ARegion *ar, const bool is_set, const int xy[2], const uiBut *but_prev)
+{
+ uiBut *but = ui_but_find_mouse_over(ar, xy[0], xy[1]);
+
+ if (but_prev == but) {
+ return but_prev;
+ }
+
+ if (but && but->toggle_drag & UI_TOGGLE_DRAG) {
+ /* is it pressed? */
+ bool is_set_but = (ui_get_but_val(but) != 0.0);
+ BLI_assert(ui_is_but_bool(but) == true);
+ if (is_set_but != is_set) {
+ uiButExecute(C, but);
+ return but;
+ }
+ }
+
+ return but_prev;
+}
+
+static int ui_but_set_cb(int x, int y, void *data_v)
+{
+ DragOpPlotData *data = data_v;
+ int xy[2] = {x, y};
+ data->but_prev = ui_but_set_xy(data->C, data->ar, data->is_set, xy, data->but_prev);
+ return 1; /* keep going */
+}
+
+/* operates on buttons between 2 mouse-points */
+static bool ui_but_set_xy_xy(bContext *C, ARegion *ar, const bool is_set,
+ const int xy_src[2], const int xy_dst[2])
+{
+ DragOpPlotData data;
+ data.C = C;
+ data.ar = ar;
+ data.is_set = is_set;
+ data.do_draw = false;
+ data.but_prev = NULL;
+
+ /* prevent dragging too fast loosing buttons */
+ plot_line_v2v2i(xy_src, xy_dst, ui_but_set_cb, &data);
+
+ return data.do_draw;
+}
+
+static void ui_drag_but_set(bContext *C, wmOperator *op, const int xy_input[2])
+{
+ ARegion *ar = CTX_wm_region(C);
+ bool do_draw = false;
+
+ const bool is_set = RNA_boolean_get(op->ptr, "state");
+ const int xy_last[2] = {RNA_int_get(op->ptr, "last_x"),
+ RNA_int_get(op->ptr, "last_y")};
+ const bool xy_lock[2] = {RNA_boolean_get(op->ptr, "lock_x"),
+ RNA_boolean_get(op->ptr, "lock_y")};
+
+ int xy[2];
+
+ xy[0] = (xy_lock[0] == false) ? xy_input[0] : xy_last[0];
+ xy[1] = (xy_lock[1] == false) ? xy_input[1] : xy_last[1];
+
+
+ /* touch all buttons between last mouse coord and this one */
+ do_draw = ui_but_set_xy_xy(C, ar, is_set, xy_last, xy);
+
+ if (do_draw) {
+ ED_region_tag_redraw(ar);
+ }
+
+ RNA_int_set(op->ptr, "last_x", xy[0]);
+ RNA_int_set(op->ptr, "last_y", xy[1]);
+}
+
+static int ui_drag_toggle_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ int xy_last[2] = {RNA_int_get(op->ptr, "last_x"),
+ RNA_int_get(op->ptr, "last_y")};
+
+ /* set the initial button */
+ ui_drag_but_set(C, op, xy_last);
+ ui_drag_but_set(C, op, &event->x);
+
+ WM_event_add_modal_handler(C, op);
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int ui_drag_toggle_modal(bContext *C, wmOperator *op, wmEvent *event)
+{
+ if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+ return OPERATOR_FINISHED;
+ }
+ else if (event->type == MOUSEMOVE) {
+ ui_drag_but_set(C, op, &event->x);
+ }
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static void UI_OT_drag_toggle(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Button Drag Toggle";
+ ot->description = "";
+ ot->idname = "UI_OT_drag_toggle";
+
+ /* api callbacks */
+ ot->invoke = ui_drag_toggle_invoke;
+ ot->modal = ui_drag_toggle_modal;
+
+ //ot->poll = ED_operator_outliner_active;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
+
+ /* properties */
+ RNA_def_boolean(ot->srna, "state", true, "State", "");
+ RNA_def_boolean(ot->srna, "lock_x", false, "Lock X", "");
+ RNA_def_boolean(ot->srna, "lock_y", false, "Lock X", "");
+ RNA_def_int(ot->srna, "last_x", 0, 0, INT_MAX, "X", "", 0, INT_MAX);
+ RNA_def_int(ot->srna, "last_y", 0, 0, INT_MAX, "Y", "", 0, INT_MAX);
+}
+
/* ********************************************************* */
/* Registration */
@@ -1088,5 +1223,6 @@
WM_operatortype_append(UI_OT_edittranslation_init);
#endif
WM_operatortype_append(UI_OT_reloadtranslation);
+ WM_operatortype_append(UI_OT_drag_toggle);
}
Index: source/blender/editors/interface/interface_templates.c
===================================================================
--- source/blender/editors/interface/interface_templates.c (revision 54587)
+++ source/blender/editors/interface/interface_templates.c (working copy)
@@ -2347,6 +2347,7 @@
but = uiDefAutoButR(block, ptr, prop, layer, "", icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2);
uiButSetFunc(but, handle_layer_buttons, but, SET_INT_IN_POINTER(layer));
but->type = TOG;
+ uiButSetDragToggle(but, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_Y);
}
}
}
@@ -2416,6 +2417,7 @@
state, 0, 0, -1, -1, sca_state_name_get(ob, state));
uiButSetFunc(but, handle_layer_buttons, but, SET_INT_IN_POINTER(state));
but->type = TOG;
+ uiButSetDragToggle(but, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_Y);
}
}
}
Index: source/blender/editors/space_outliner/outliner_draw.c
===================================================================
--- source/blender/editors/space_outliner/outliner_draw.c (revision 54587)
+++ source/blender/editors/space_outliner/outliner_draw.c (working copy)
@@ -424,16 +424,19 @@
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
&ptr, "hide", -1, 0, 0, -1, -1, NULL);
uiButSetFunc(bt, restrictbutton_view_cb, scene, ob);
+ uiButSetDragToggle(bt, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_X);
bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
&ptr, "hide_select", -1, 0, 0, -1, -1, NULL);
uiButSetFunc(bt, restrictbutton_sel_cb, scene, ob);
+ uiButSetDragToggle(bt, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_X);
bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
&ptr, "hide_render", -1, 0, 0, -1, -1, NULL);
uiButSetFunc(bt, restrictbutton_rend_cb, scene, ob);
+ uiButSetDragToggle(bt, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_X);
uiBlockSetEmboss(block, UI_EMBOSS);
@@ -449,18 +452,21 @@
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
NULL, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
uiButSetFunc(bt, restrictbutton_gr_restrict_view, scene, gr);
+ uiButSetDragToggle(bt, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_X);
restrict_bool = group_restrict_flag(gr, OB_RESTRICT_SELECT);
bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
NULL, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View");
uiButSetFunc(bt, restrictbutton_gr_restrict_select, scene, gr);
+ uiButSetDragToggle(bt, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_X);
restrict_bool = group_restrict_flag(gr, OB_RESTRICT_RENDER);
bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
NULL, 0, 0, 0, 0, "Restrict/Allow renderability");
uiButSetFunc(bt, restrictbutton_gr_restrict_render, scene, gr);
+ uiButSetDragToggle(bt, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_X);
uiBlockSetEmboss(block, UI_EMBOSS);
}
@@ -472,6 +478,7 @@
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
te->directdata, 0, 0, 0, 0, "Render this RenderLayer");
uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL);
+ uiButSetDragToggle(bt, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_X);
uiBlockSetEmboss(block, UI_EMBOSS);
}
@@ -486,6 +493,7 @@
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
layflag, 0, 0, 0, 0, "Render this Pass");
uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL);
+ uiButSetDragToggle(bt, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_X);
layflag++; /* is lay_xor */
if (ELEM8(passflag, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT,
@@ -496,6 +504,7 @@
layflag, 0, 0, 0, 0, "Exclude this Pass from Combined");
}
uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL);
+ uiButSetDragToggle(bt, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_X);
uiBlockSetEmboss(block, UI_EMBOSS);
}
@@ -508,11 +517,13 @@
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
&(md->mode), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob);
+ uiButSetDragToggle(bt, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_X);
bt = uiDefIconButBitI(block, ICONTOGN, eModifierMode_Render, 0, ICON_RESTRICT_RENDER_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
&(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability");
uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob);
+ uiButSetDragToggle(bt, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_X);
}
else if (tselem->type == TSE_POSE_CHANNEL) {
bPoseChannel *pchan = (bPoseChannel *)te->directdata;
@@ -523,11 +534,13 @@
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
&(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
uiButSetFunc(bt, restrictbutton_bone_cb, NULL, bone);
+ uiButSetDragToggle(bt, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_X);
bt = uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
&(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View");
uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL);
+ uiButSetDragToggle(bt, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_X);
}
else if (tselem->type == TSE_EBONE) {
EditBone *ebone = (EditBone *)te->directdata;
@@ -537,11 +550,13 @@
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
&(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, ebone);
+ uiButSetDragToggle(bt, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_X);
bt = uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
&(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View");
uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, NULL);
+ uiButSetDragToggle(bt, UI_TOGGLE_DRAG | UI_TOGGLE_DRAG_LOCK_X);
}
}

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0c/54/5982ff3d9ca102d578aab876b9e5

Event Timeline