change to drag-lock behavior, only use with outliner (this way layers can be changed...
authorCampbell Barton <ideasman42@gmail.com>
Mon, 13 May 2013 06:51:13 +0000 (06:51 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 13 May 2013 06:51:13 +0000 (06:51 +0000)
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface_handlers.c
source/blender/editors/space_outliner/outliner_draw.c

index d8d9c56bed34fa35411a4e1d71e3925602f53be7..ea05fc6166acef66fcc36d19ff95202d888ec58c 100644 (file)
@@ -149,7 +149,7 @@ typedef struct uiLayout uiLayout;
 #define UI_TEXT_RIGHT       1024
 #define UI_BUT_NODE_LINK    2048
 #define UI_BUT_NODE_ACTIVE  4096
-#define UI_FLAG_UNUSED      8192
+#define UI_BUT_DRAG_LOCK    8192
 
 /* button align flag, for drawing groups together */
 #define UI_BUT_ALIGN        (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_RIGHT | UI_BUT_ALIGN_DOWN)
index 1f0d4799e3ee3837679759db27ae5caaf678a266..e46def3be6fb83ce983072ce8f04f030b1d47eb5 100644 (file)
@@ -756,6 +756,7 @@ static void ui_apply_but_CHARTAB(bContext *C, uiBut *but, uiHandleButtonData *da
 
 typedef struct uiDragToggleHandle {
        /* init */
+       bool is_init;
        bool is_set;
        float but_cent_start[2];
        eButType but_type_start;
@@ -820,24 +821,31 @@ static void ui_drag_toggle_set(bContext *C, uiDragToggleHandle *drag_info, const
         * Check if we need to initialize the lock axis by finding if the first
         * button we mouse over is X or Y aligned, then lock the mouse to that axis after.
         */
-       if (drag_info->xy_lock[0] == false && drag_info->xy_lock[1] == false) {
+       if (drag_info->is_init == false) {
                /* first store the buttons original coords */
                uiBut *but = ui_but_find_mouse_over(ar, xy_input[0], xy_input[1]);
-               if (but) {
-                       const float but_cent_new[2] = {BLI_rctf_cent_x(&but->rect),
-                                                      BLI_rctf_cent_y(&but->rect)};
 
-                       /* check if this is a different button, chances are high the button wont move about :) */
-                       if (len_manhattan_v2v2(drag_info->but_cent_start, but_cent_new) > 1.0f) {
-                               if (fabsf(drag_info->but_cent_start[0] - but_cent_new[0]) <
-                                   fabsf(drag_info->but_cent_start[1] - but_cent_new[1]))
-                               {
-                                       drag_info->xy_lock[0] = true;
-                               }
-                               else {
-                                       drag_info->xy_lock[1] = true;
+               if (but) {
+                       if (but->flag & UI_BUT_DRAG_LOCK) {
+                               const float but_cent_new[2] = {BLI_rctf_cent_x(&but->rect),
+                                                              BLI_rctf_cent_y(&but->rect)};
+
+                               /* check if this is a different button, chances are high the button wont move about :) */
+                               if (len_manhattan_v2v2(drag_info->but_cent_start, but_cent_new) > 1.0f) {
+                                       if (fabsf(drag_info->but_cent_start[0] - but_cent_new[0]) <
+                                           fabsf(drag_info->but_cent_start[1] - but_cent_new[1]))
+                                       {
+                                               drag_info->xy_lock[0] = true;
+                                       }
+                                       else {
+                                               drag_info->xy_lock[1] = true;
+                                       }
+                                       drag_info->is_init = true;
                                }
                        }
+                       else {
+                               drag_info->is_init = true;
+                       }
                }
        }
        /* done with axis locking */
index f2d85c33f98635b1d1190f8b48f0c0b939ab6547..46feea6a5533eb7c097af54b01b6dccb69797c50 100644 (file)
@@ -543,18 +543,21 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                                   &ptr, "hide", -1, 0, 0, -1, -1,
                                                   TIP_("Restrict viewport visibility (Ctrl - Recursive)"));
                                uiButSetFunc(bt, restrictbutton_view_cb, scene, ob);
+                               uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
                                
                                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,
                                                   TIP_("Restrict viewport selection (Ctrl - Recursive)"));
                                uiButSetFunc(bt, restrictbutton_sel_cb, scene, ob);
+                               uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
                                
                                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,
                                                   TIP_("Restrict rendering (Ctrl - Recursive)"));
                                uiButSetFunc(bt, restrictbutton_rend_cb, scene, ob);
+                               uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
                                
                                uiBlockSetEmboss(block, UI_EMBOSS);
                                
@@ -570,18 +573,21 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                                  (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)te->ys, UI_UNIT_X, UI_UNIT_Y,
                                                  NULL, 0, 0, 0, 0, TIP_("Restrict/Allow visibility in the 3D View"));
                                uiButSetFunc(bt, restrictbutton_gr_restrict_view, scene, gr);
+                               uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
 
                                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, TIP_("Restrict/Allow selection in the 3D View"));
                                uiButSetFunc(bt, restrictbutton_gr_restrict_select, scene, gr);
+                               uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
 
                                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, TIP_("Restrict/Allow renderability"));
                                uiButSetFunc(bt, restrictbutton_gr_restrict_render, scene, gr);
+                               uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
 
                                uiBlockSetEmboss(block, UI_EMBOSS);
                        }
@@ -593,6 +599,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                                      (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)te->ys, UI_UNIT_X,
                                                      UI_UNIT_Y, te->directdata, 0, 0, 0, 0, TIP_("Render this RenderLayer"));
                                uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL);
+                               uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
                                
                                uiBlockSetEmboss(block, UI_EMBOSS);
                        }
@@ -607,6 +614,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                                      (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)te->ys, UI_UNIT_X,
                                                      UI_UNIT_Y, layflag, 0, 0, 0, 0, TIP_("Render this Pass"));
                                uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL);
+                               uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
                                
                                layflag++;  /* is lay_xor */
                                if (ELEM8(passflag, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT,
@@ -615,8 +623,9 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                        bt = uiDefIconButBitI(block, TOG, passflag, 0, (*layflag & passflag) ? ICON_DOT : ICON_BLANK1,
                                                              (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)te->ys, UI_UNIT_X,
                                                              UI_UNIT_Y, layflag, 0, 0, 0, 0, TIP_("Exclude this Pass from Combined"));
+                                       uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL);
+                                       uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
                                }
-                               uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL);
                                
                                uiBlockSetEmboss(block, UI_EMBOSS);
                        }
@@ -630,11 +639,13 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                                      UI_UNIT_Y, &(md->mode), 0, 0, 0, 0,
                                                      TIP_("Restrict/Allow visibility in the 3D View"));
                                uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob);
+                               uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
                                
                                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, TIP_("Restrict/Allow renderability"));
                                uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob);
+                               uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
 
                                uiBlockSetEmboss(block, UI_EMBOSS);
                        }
@@ -649,12 +660,14 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                                      UI_UNIT_Y, &(bone->flag), 0, 0, 0, 0,
                                                      TIP_("Restrict/Allow visibility in the 3D View"));
                                uiButSetFunc(bt, restrictbutton_bone_visibility_cb, ob->data, bone);
+                               uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
                                
                                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,
                                                      TIP_("Restrict/Allow selection in the 3D View"));
                                uiButSetFunc(bt, restrictbutton_bone_select_cb, ob->data, bone);
+                               uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
 
                                uiBlockSetEmboss(block, UI_EMBOSS);
                        }
@@ -667,12 +680,14 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                                      UI_UNIT_Y, &(ebone->flag), 0, 0, 0, 0,
                                                      TIP_("Restrict/Allow visibility in the 3D View"));
                                uiButSetFunc(bt, restrictbutton_ebone_visibility_cb, NULL, ebone);
+                               uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
                                
                                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,
                                                      TIP_("Restrict/Allow selection in the 3D View"));
                                uiButSetFunc(bt, restrictbutton_ebone_select_cb, NULL, ebone);
+                               uiButSetFlag(bt, UI_BUT_DRAG_LOCK);
 
                                uiBlockSetEmboss(block, UI_EMBOSS);
                        }