Changeset View
Standalone View
source/blender/editors/space_outliner/outliner_draw.c
| Show First 20 Lines • Show All 800 Lines • ▼ Show 20 Lines | else { | ||||
| /* always make layer active */ | /* always make layer active */ | ||||
| BKE_gpencil_layer_setactive(gpd, gpl); | BKE_gpencil_layer_setactive(gpd, gpl); | ||||
| // XXX: name needs translation stuff | // XXX: name needs translation stuff | ||||
| BLI_uniquename( | BLI_uniquename( | ||||
| &gpd->layers, gpl, "GP Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info)); | &gpd->layers, gpl, "GP Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info)); | ||||
| WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, gpd); | WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, gpd); | ||||
| break; | break; | ||||
| } | } | ||||
| case TSE_R_LAYER: { | case TSE_R_LAYER: { | ||||
| Scene *scene = (Scene *)tselem->id; | Scene *scene = (Scene *)tselem->id; | ||||
| ViewLayer *view_layer = te->directdata; | ViewLayer *view_layer = te->directdata; | ||||
| /* Restore old name. */ | /* Restore old name. */ | ||||
| char newname[sizeof(view_layer->name)]; | char newname[sizeof(view_layer->name)]; | ||||
| ▲ Show 20 Lines • Show All 1,328 Lines • ▼ Show 20 Lines | switch (tselem->type) { | ||||
| if (collection && !(collection->flag & COLLECTION_IS_MASTER)) { | if (collection && !(collection->flag & COLLECTION_IS_MASTER)) { | ||||
| data.drag_id = tselem->id; | data.drag_id = tselem->id; | ||||
| data.drag_parent = (data.drag_id && te->parent) ? TREESTORE(te->parent)->id : NULL; | data.drag_parent = (data.drag_id && te->parent) ? TREESTORE(te->parent)->id : NULL; | ||||
| } | } | ||||
| data.icon = ICON_GROUP; | data.icon = ICON_GROUP; | ||||
| break; | break; | ||||
| } | } | ||||
| /* Removed the icons from outliner. | /* Removed the icons from outliner. | ||||
antoniov: You can remove these comments now (very old ones) | |||||
| * Need a better structure with Layers, Palettes and Colors. */ | * Need a better structure with Layers, Palettes and Colors. */ | ||||
| case TSE_GP_LAYER: { | case TSE_GP_LAYER: { | ||||
| /* indicate whether layer is active */ | /* indicate whether layer is active */ | ||||
| bGPDlayer *gpl = te->directdata; | bGPDlayer *gpl = te->directdata; | ||||
| if (gpl->flag & GP_LAYER_ACTIVE) { | if (gpl->flag & GP_LAYER_ACTIVE) { | ||||
| data.icon = ICON_GREASEPENCIL; | data.icon = ICON_GREASEPENCIL; | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 468 Lines • ▼ Show 20 Lines | if (level < 1 || (tselem->type == 0 && te->idcode == ID_OB)) { | ||||
| /* active blocks get white circle */ | /* active blocks get white circle */ | ||||
| if (tselem->type == 0) { | if (tselem->type == 0) { | ||||
| if (te->idcode == ID_OB) { | if (te->idcode == ID_OB) { | ||||
| active = (OBACT(view_layer) == (Object *)tselem->id) ? OL_DRAWSEL_NORMAL : | active = (OBACT(view_layer) == (Object *)tselem->id) ? OL_DRAWSEL_NORMAL : | ||||
| OL_DRAWSEL_NONE; | OL_DRAWSEL_NONE; | ||||
| } | } | ||||
| else if (is_object_data_in_editmode(tselem->id, obact)) { | else if (is_object_data_in_editmode(tselem->id, obact)) { | ||||
| active = OL_DRAWSEL_ACTIVE; | active = OL_DRAWSEL_ACTIVE; | ||||
| } | } | ||||
Not Done Inline ActionsDon't assume you can cast from GP flags to eOLDrawState. - active = (gpl->flag & GP_LAYER_ACTIVE); + active = (gpl->flag & GP_LAYER_ACTIVE) ? OL_DRAWSEL_ACTIVE : OL_DRAWSEL_NONE; dfelinto: Don't assume you can cast from GP flags to eOLDrawState.
```
- active = (gpl->flag &… | |||||
| else { | else { | ||||
| active = tree_element_active(C, scene, view_layer, soops, te, OL_SETSEL_NONE, false); | active = tree_element_active(C, scene, view_layer, soops, te, OL_SETSEL_NONE, false); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| active = tree_element_type_active( | active = tree_element_type_active( | ||||
| C, scene, view_layer, soops, te, tselem, OL_SETSEL_NONE, false); | C, scene, view_layer, soops, te, tselem, OL_SETSEL_NONE, false); | ||||
| } | } | ||||
| Show All 32 Lines | static void outliner_draw_iconrow(bContext *C, | ||||
| if (level == 0) { | if (level == 0) { | ||||
| for (int i = 0; i < INDEX_ID_MAX; i++) { | for (int i = 0; i < INDEX_ID_MAX; i++) { | ||||
| const int num_subtypes = (i == INDEX_ID_OB) ? OB_TYPE_MAX : 1; | const int num_subtypes = (i == INDEX_ID_OB) ? OB_TYPE_MAX : 1; | ||||
| /* See tree_element_id_type_to_index for the index logic. */ | /* See tree_element_id_type_to_index for the index logic. */ | ||||
| int index_base = i; | int index_base = i; | ||||
| if (i > INDEX_ID_OB) { | if (i > INDEX_ID_OB) { | ||||
| index_base += OB_TYPE_MAX; | index_base += OB_TYPE_MAX; | ||||
| } | } | ||||
| for (int j = 0; j < num_subtypes; j++) { | for (int j = 0; j < num_subtypes; j++) { | ||||
Not Done Inline ActionsPay attention to the building warnings: outlinder_draw.c:2688:24: warning: declaration of ‘active’ shadows a previous local [-Wshadow]
eOLDrawState active = merged->active[index];
outliner_draw.c:2616:16: note shadowed declaration is here
eOLDrawState active = OL_DRAWSEL_NONE;dfelinto: Pay attention to the building warnings:
```
outlinder_draw.c:2688:24: warning: declaration of… | |||||
| const int index = index_base + j; | const int index = index_base + j; | ||||
| if (merged->num_elements[index] != 0) { | if (merged->num_elements[index] != 0) { | ||||
Not Done Inline ActionsComments should always start with a capital letter and end with a full stop: - /* don't highlight collapsed multiple (icon with number) */ - /* Don't highlight collapsed multiple (icon with number). */ But more than that, comments should try to explain the why, the how is the code itself in this case. A better comment would be: That said we don't want this rule to everything. It is only useful to things that are active among the other elements that are nested with it. Not for things that are active among a higher context. In different words, for objects and collections it is really important to know which collection has the active object/collection. dfelinto: Comments should always start with a capital letter and end with a full stop:
```
- /* don't… | |||||
| outliner_draw_iconrow_doit(block, | outliner_draw_iconrow_doit(block, | ||||
| merged->tree_element[index], | merged->tree_element[index], | ||||
| fstyle, | fstyle, | ||||
| xmax, | xmax, | ||||
| offsx, | offsx, | ||||
| ys, | ys, | ||||
| alpha_fac, | alpha_fac, | ||||
| merged->active[index], | merged->active[index], | ||||
| ▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | if (tselem->type == 0) { | ||||
| active = OL_DRAWSEL_ACTIVE; | active = OL_DRAWSEL_ACTIVE; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| active = tree_element_type_active( | active = tree_element_type_active( | ||||
| C, scene, view_layer, soops, te, tselem, OL_SETSEL_NONE, false); | C, scene, view_layer, soops, te, tselem, OL_SETSEL_NONE, false); | ||||
| /* active collection*/ | /* active collection*/ | ||||
| icon_bgcolor[3] = 0.2f; | icon_bgcolor[3] = 0.2f; | ||||
Not Done Inline ActionsSee note above about comments (and yes, I know the original comment was violating that). dfelinto: See note above about comments (and yes, I know the original comment was violating that). | |||||
| } | } | ||||
Not Done Inline ActionsThat is more personal than anything, but I would probably bring this down to one line: - bGPDlayer *gpl = te->directdata;
- if (gpl->flag & GP_LAYER_ACTIVE) {
+ if (((bGPDlayer *)te->directdata)->flag & GP_LAYER_ACTIVE) {dfelinto: That is more personal than anything, but I would probably bring this down to one line:
```… | |||||
| /* Checkbox to enable collections. */ | /* Checkbox to enable collections. */ | ||||
| if ((tselem->type == TSE_LAYER_COLLECTION) && | if ((tselem->type == TSE_LAYER_COLLECTION) && | ||||
| (soops->show_restrict_flags & SO_RESTRICT_ENABLE)) { | (soops->show_restrict_flags & SO_RESTRICT_ENABLE)) { | ||||
| tselem_draw_layer_collection_enable_icon( | tselem_draw_layer_collection_enable_icon( | ||||
| scene, block, xmax, (float)startx + offsx + UI_UNIT_X, (float)*starty, te, 0.8f); | scene, block, xmax, (float)startx + offsx + UI_UNIT_X, (float)*starty, te, 0.8f); | ||||
| offsx += UI_UNIT_X; | offsx += UI_UNIT_X; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 631 Lines • Show Last 20 Lines | |||||
You can remove these comments now (very old ones)