Experimental Drivers UI Tweak: Use icons for variable types
authorJoshua Leung <aligorith@gmail.com>
Sat, 16 Apr 2016 15:27:26 +0000 (03:27 +1200)
committerJoshua Leung <aligorith@gmail.com>
Sat, 16 Apr 2016 15:29:28 +0000 (03:29 +1200)
This commit aims to streamline the driver variables layout a bit
* Each variable type now has an icon. (The loc diff and rot diff ones are placeholders,
  which could deserve something better/dedicated if we continue to use this)
* Instead of taking up an entire row, the variable type dropdown now only shows
  an icon, and is located before the variable name field.

Feedback wanted: Is this more/less confusing than it was?

source/blender/editors/space_graph/graph_buttons.c
source/blender/makesrna/intern/rna_fcurve.c

index 8230ba27db2947085ca7ad3094d57105ed62956b..a9ab1502e16794969dc33d06e645c6f60e8d3d0c 100644 (file)
@@ -851,21 +851,34 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
        for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
                PointerRNA dvar_ptr;
                uiLayout *box, *row;
+               uiLayout *subrow, *sub;
                
                /* sub-layout column for this variable's settings */
                col = uiLayoutColumn(pa->layout, true);
                
-               /* header panel */
+               /* 1) header panel */
                box = uiLayoutBox(col);
-               /* first row context info for driver */
                RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr);
                
                row = uiLayoutRow(box, false);
                block = uiLayoutGetBlock(row);
-               /* variable name */
-               uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE);
                
-               /* invalid name? */
+               /* 1.1) variable type and name */
+               subrow = uiLayoutRow(row, true);
+               
+               /* 1.1.1) variable type */
+               sub = uiLayoutRow(subrow, true);                     /* HACK: special group just for the enum, otherwise we */
+               uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT);  /*       we get ugly layout with text included too...  */
+               
+               uiItemR(sub, &dvar_ptr, "type", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
+               
+               /* 1.1.2) variable name */
+               sub = uiLayoutRow(subrow, true);                       /* HACK: special group to counteract the effects of the previous */
+               uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_EXPAND);  /*       enum, which now pushes everything too far right         */
+               
+               uiItemR(sub, &dvar_ptr, "name", 0, "", ICON_NONE);
+               
+               /* 1.2) invalid name? */
                UI_block_emboss_set(block, UI_EMBOSS_NONE);
                
                if (dvar->flag & DVAR_FLAG_INVALID_NAME) {
@@ -874,17 +887,14 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
                        UI_but_func_set(but, driver_dvar_invalid_name_query_cb, dvar, NULL); // XXX: reports?
                }
                
-               /* remove button */
+               /* 1.3) remove button */
                but = uiDefIconBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y,
                                   NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable"));
                UI_but_func_set(but, driver_delete_var_cb, driver, dvar);
                UI_block_emboss_set(block, UI_EMBOSS);
                
-               /* variable type */
-               row = uiLayoutRow(box, false);
-               uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE);
-                               
-               /* variable type settings */
+               
+               /* 2) variable type settings */
                box = uiLayoutBox(col);
                /* controls to draw depends on the type of variable */
                switch (dvar->type) {
@@ -902,7 +912,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
                                break;
                }
                
-               /* value of variable */
+               /* 3) value of variable */
                if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
                        char valBuf[32];
                        
index 32008640930101d200de8ce794782c4ea8d38762..a6e6f0713d71615247816807bb8aa63fa6d65da8 100644 (file)
@@ -1467,11 +1467,11 @@ static void rna_def_drivervar(BlenderRNA *brna)
        PropertyRNA *prop;
        
        static EnumPropertyItem prop_type_items[] = {
-               {DVAR_TYPE_SINGLE_PROP, "SINGLE_PROP", 0, "Single Property", "Use the value from some RNA property (Default)"},
-               {DVAR_TYPE_TRANSFORM_CHAN, "TRANSFORMS", 0, "Transform Channel",
+               {DVAR_TYPE_SINGLE_PROP, "SINGLE_PROP", ICON_RNA, "Single Property", "Use the value from some RNA property (Default)"},
+               {DVAR_TYPE_TRANSFORM_CHAN, "TRANSFORMS", ICON_MANIPUL, "Transform Channel",
                                           "Final transformation value of object or bone"},
-               {DVAR_TYPE_ROT_DIFF, "ROTATION_DIFF", 0, "Rotational Difference", "Use the angle between two bones"},
-               {DVAR_TYPE_LOC_DIFF, "LOC_DIFF", 0, "Distance", "Distance between two bones or objects"},
+               {DVAR_TYPE_ROT_DIFF, "ROTATION_DIFF", ICON_PARTICLE_TIP, "Rotational Difference", "Use the angle between two bones"},  /* XXX: Icon... */
+               {DVAR_TYPE_LOC_DIFF, "LOC_DIFF", ICON_FULLSCREEN_ENTER, "Distance", "Distance between two bones or objects"},          /* XXX: Icon... */
                {0, NULL, 0, NULL, NULL}
        };