Draw Manager: Add center-color for linked/multiuser objects
authorCampbell Barton <ideasman42@gmail.com>
Tue, 11 Apr 2017 04:05:39 +0000 (14:05 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 11 Apr 2017 04:05:39 +0000 (14:05 +1000)
Draws a blue center circle for library objects.
As with regular drawing, this uses a hard-coded color.

source/blender/draw/intern/draw_common.c
source/blender/draw/intern/draw_common.h
source/blender/draw/modes/object_mode.c

index 8d9012afa506993f35fe586e87aef8aade833464..02722fa82e16b2657bc385f732c2a19a172854ed 100644 (file)
 
 #include "draw_common.h"
 
 
 #include "draw_common.h"
 
+
+#if 0
+#define UI_COLOR_RGB_FROM_U8(r, g, b, v4) \
+       ARRAY_SET_ITEMS(v4, (float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, 1.0)
+#endif
+#define UI_COLOR_RGBA_FROM_U8(r, g, b, a, v4) \
+       ARRAY_SET_ITEMS(v4, (float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, (float)a / 255.0f)
+
 /* Colors & Constant */
 GlobalsUboStorage ts;
 struct GPUUniformBuffer *globals_ubo = NULL;
 /* Colors & Constant */
 GlobalsUboStorage ts;
 struct GPUUniformBuffer *globals_ubo = NULL;
@@ -47,6 +55,8 @@ void DRW_globals_update(void)
        UI_GetThemeColor4fv(TH_GROUP_ACTIVE, ts.colorGroupActive);
        UI_GetThemeColorShade4fv(TH_GROUP_ACTIVE, -25, ts.colorGroupSelect);
        UI_GetThemeColor4fv(TH_GROUP, ts.colorGroup);
        UI_GetThemeColor4fv(TH_GROUP_ACTIVE, ts.colorGroupActive);
        UI_GetThemeColorShade4fv(TH_GROUP_ACTIVE, -25, ts.colorGroupSelect);
        UI_GetThemeColor4fv(TH_GROUP, ts.colorGroup);
+       UI_COLOR_RGBA_FROM_U8(0x88, 0xFF, 0xFF, 155, ts.colorLibrarySelect);
+       UI_COLOR_RGBA_FROM_U8(0x55, 0xCC, 0xCC, 155, ts.colorLibrary);
        UI_GetThemeColor4fv(TH_LAMP, ts.colorLamp);
        UI_GetThemeColor4fv(TH_SPEAKER, ts.colorSpeaker);
        UI_GetThemeColor4fv(TH_CAMERA, ts.colorCamera);
        UI_GetThemeColor4fv(TH_LAMP, ts.colorLamp);
        UI_GetThemeColor4fv(TH_SPEAKER, ts.colorSpeaker);
        UI_GetThemeColor4fv(TH_CAMERA, ts.colorCamera);
index ad8f312825ad88ecae5ca17659347ebc9226b698..b234adc7b99d8905952525131ad935a04ad4cdd3 100644 (file)
@@ -45,6 +45,8 @@ typedef struct GlobalsUboStorage {
        float colorGroupActive[4];
        float colorGroupSelect[4];
        float colorGroup[4];
        float colorGroupActive[4];
        float colorGroupSelect[4];
        float colorGroup[4];
+       float colorLibrarySelect[4];
+       float colorLibrary[4];
        float colorLamp[4];
        float colorSpeaker[4];
        float colorCamera[4];
        float colorLamp[4];
        float colorSpeaker[4];
        float colorCamera[4];
index 1d89455e3ee3b84a2a1d42d269910e14ebd77ff2..adf0de2f0535c076c0dfd8a40cf9dcc1b143d295 100644 (file)
@@ -155,6 +155,8 @@ typedef struct g_data{
        DRWShadingGroup *center_active;
        DRWShadingGroup *center_selected;
        DRWShadingGroup *center_deselected;
        DRWShadingGroup *center_active;
        DRWShadingGroup *center_selected;
        DRWShadingGroup *center_deselected;
+       DRWShadingGroup *center_selected_lib;
+       DRWShadingGroup *center_deselected_lib;
 
        /* Camera */
        DRWShadingGroup *camera;
 
        /* Camera */
        DRWShadingGroup *camera;
@@ -715,6 +717,16 @@ static void OBJECT_cache_init(void *vedata)
                grp = DRW_shgroup_point_batch_create(sh, psl->ob_center);
                DRW_shgroup_uniform_vec4(grp, "color", ts.colorDeselect, 1);
                stl->g_data->center_deselected = grp;
                grp = DRW_shgroup_point_batch_create(sh, psl->ob_center);
                DRW_shgroup_uniform_vec4(grp, "color", ts.colorDeselect, 1);
                stl->g_data->center_deselected = grp;
+
+               /* Select (library) */
+               grp = DRW_shgroup_point_batch_create(sh, psl->ob_center);
+               DRW_shgroup_uniform_vec4(grp, "color", ts.colorLibrarySelect, 1);
+               stl->g_data->center_selected_lib = grp;
+
+               /* Deselect (library) */
+               grp = DRW_shgroup_point_batch_create(sh, psl->ob_center);
+               DRW_shgroup_uniform_vec4(grp, "color", ts.colorLibrary, 1);
+               stl->g_data->center_deselected_lib = grp;
        }
 }
 
        }
 }
 
@@ -1047,12 +1059,32 @@ static void DRW_shgroup_relationship_lines(OBJECT_StorageList *stl, Object *ob)
 
 static void DRW_shgroup_object_center(OBJECT_StorageList *stl, Object *ob)
 {
 
 static void DRW_shgroup_object_center(OBJECT_StorageList *stl, Object *ob)
 {
+       const bool is_library = ob->id.us > 1 || ID_IS_LINKED_DATABLOCK(ob);
+       DRWShadingGroup *shgroup;
+
        if ((ob->base_flag & BASE_SELECTED) != 0) {
        if ((ob->base_flag & BASE_SELECTED) != 0) {
-               DRW_shgroup_dynamic_call_add(stl->g_data->center_selected, ob->obmat[3]);
+               if (is_library) {
+                       shgroup = stl->g_data->center_selected_lib;
+               }
+               else {
+                       shgroup = stl->g_data->center_selected;
+               }
        }
        }
-       else if (0) {
-               DRW_shgroup_dynamic_call_add(stl->g_data->center_deselected, ob->obmat[3]);
+       else {
+#if 0
+               shgroup = stl->g_data->center_deselected;
+               if (is_library) {
+                       shgroup = stl->g_data->center_deselected_lib;
+               }
+               else {
+                       shgroup = stl->g_data->center_deselected;
+               }
+#else
+               return;
+#endif
        }
        }
+
+       DRW_shgroup_dynamic_call_add(shgroup, ob->obmat[3]);
 }
 
 static void OBJECT_cache_populate(void *vedata, Object *ob)
 }
 
 static void OBJECT_cache_populate(void *vedata, Object *ob)