[Bf-blender-cvs] [53e1e6a98fc] temp-lineart-contained: Cleanup: Make panel type flag names more clear

Hans Goudey noreply at git.blender.org
Sat Dec 19 06:18:54 CET 2020


Commit: 53e1e6a98fc59c19960add1abcbfd42e83ba041f
Author: Hans Goudey
Date:   Fri Nov 13 13:56:55 2020 -0500
Branches: temp-lineart-contained
https://developer.blender.org/rB53e1e6a98fc59c19960add1abcbfd42e83ba041f

Cleanup: Make panel type flag names more clear

The overlap with the `Panel` flags that start with "PNL" was quite
confusing because wasn't clear which enum a flag was from. The
new names are a bit longer, but the clarity is worth it.

===================================================================

M	source/blender/blenkernel/BKE_screen.h
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/interface/interface_region_hud.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/screen/area.c
M	source/blender/editors/space_buttons/buttons_context.c
M	source/blender/editors/space_buttons/space_buttons.c
M	source/blender/editors/space_clip/clip_buttons.c
M	source/blender/editors/space_file/file_panels.c
M	source/blender/editors/space_image/image_buttons.c
M	source/blender/editors/space_nla/nla_buttons.c
M	source/blender/editors/space_node/node_buttons.c
M	source/blender/editors/space_sequencer/sequencer_buttons.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c
M	source/blender/makesrna/intern/rna_ui.c
M	source/blender/modifiers/intern/MOD_ui_common.c
M	source/blender/shader_fx/intern/FX_ui_common.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 81669fd6878..8e370ed27c5 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -280,15 +280,15 @@ typedef struct PanelType {
 
 /* #PanelType.flag */
 enum {
-  PNL_DEFAULT_CLOSED = (1 << 0),
-  PNL_NO_HEADER = (1 << 1),
+  PANEL_TYPE_DEFAULT_CLOSED = (1 << 0),
+  PANEL_TYPE_NO_HEADER = (1 << 1),
   /** Makes buttons in the header shrink/stretch to fill full layout width. */
-  PNL_LAYOUT_HEADER_EXPAND = (1 << 2),
-  PNL_LAYOUT_VERT_BAR = (1 << 3),
+  PANEL_TYPE_HEADER_EXPAND = (1 << 2),
+  PANEL_TYPE_LAYOUT_VERT_BAR = (1 << 3),
   /** This panel type represents data external to the UI. */
-  PNL_INSTANCED = (1 << 4),
+  PANEL_TYPE_INSTANCED = (1 << 4),
   /** Draw panel like a box widget. */
-  PNL_DRAW_BOX = (1 << 6),
+  PANEL_TYPE_DRAW_BOX = (1 << 6),
 };
 
 /* uilist types */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 4c3fd57131c..02e083076f0 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1997,7 +1997,7 @@ void UI_block_draw(const bContext *C, uiBlock *block)
   else if (block->panel) {
     bool show_background = region->alignment != RGN_ALIGN_FLOAT;
     if (show_background) {
-      if (block->panel->type && (block->panel->type->flag & PNL_NO_HEADER)) {
+      if (block->panel->type && (block->panel->type->flag & PANEL_TYPE_NO_HEADER)) {
         if (region->regiontype == RGN_TYPE_TOOLS) {
           /* We never want a background around active tools. */
           show_background = false;
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 76dc41a7312..ecc22656366 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -336,7 +336,7 @@ void UI_list_panel_unique_str(Panel *panel, char *r_name)
  * and is freed by #UI_panels_free_instanced.
  *
  * \note The only panels that should need to be deleted at runtime are panels with the
- * #PNL_INSTANCED flag set.
+ * #PANEL_TYPE_INSTANCED flag set.
  */
 static void panel_delete(const bContext *C, ARegion *region, ListBase *panels, Panel *panel)
 {
@@ -363,7 +363,7 @@ void UI_panels_free_instanced(const bContext *C, ARegion *region)
 {
   /* Delete panels with the instanced flag. */
   LISTBASE_FOREACH_MUTABLE (Panel *, panel, &region->panels) {
-    if ((panel->type != NULL) && (panel->type->flag & PNL_INSTANCED)) {
+    if ((panel->type != NULL) && (panel->type->flag & PANEL_TYPE_INSTANCED)) {
       /* Make sure the panel's handler is removed before deleting it. */
       if (C != NULL && panel->activedata != NULL) {
         panel_activate_state(C, panel, PANEL_STATE_EXIT);
@@ -407,7 +407,7 @@ bool UI_panel_list_matches_data(ARegion *region,
 
   int i = 0;
   LISTBASE_FOREACH (Panel *, panel, &region->panels) {
-    if (panel->type != NULL && panel->type->flag & PNL_INSTANCED) {
+    if (panel->type != NULL && panel->type->flag & PANEL_TYPE_INSTANCED) {
       /* The panels were reordered by drag and drop. */
       if (panel->flag & PNL_INSTANCED_LIST_ORDER_CHANGED) {
         return false;
@@ -458,7 +458,7 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr
   int list_panels_len = 0;
   LISTBASE_FOREACH (const Panel *, panel, &region->panels) {
     if (panel->type) {
-      if (panel->type->flag & PNL_INSTANCED) {
+      if (panel->type->flag & PANEL_TYPE_INSTANCED) {
         if (panel_type_context_poll(region, panel->type, context)) {
           list_panels_len++;
         }
@@ -471,7 +471,7 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr
   PanelSort *sort_index = panel_sort;
   LISTBASE_FOREACH (Panel *, panel, &region->panels) {
     if (panel->type) {
-      if (panel->type->flag & PNL_INSTANCED) {
+      if (panel->type->flag & PANEL_TYPE_INSTANCED) {
         if (panel_type_context_poll(region, panel->type, context)) {
           sort_index->panel = panel;
           sort_index++;
@@ -524,7 +524,7 @@ static bool panel_set_expand_from_list_data_recursive(Panel *panel, short flag,
 static void panel_set_expansion_from_list_data(const bContext *C, Panel *panel)
 {
   BLI_assert(panel->type != NULL);
-  BLI_assert(panel->type->flag & PNL_INSTANCED);
+  BLI_assert(panel->type->flag & PANEL_TYPE_INSTANCED);
   if (panel->type->get_list_data_expand_flag == NULL) {
     /* Instanced panel doesn't support loading expansion. */
     return;
@@ -547,7 +547,7 @@ static void region_panels_set_expansion_from_list_data(const bContext *C, ARegio
   LISTBASE_FOREACH (Panel *, panel, &region->panels) {
     if (panel->runtime_flag & PANEL_ACTIVE) {
       PanelType *panel_type = panel->type;
-      if (panel_type != NULL && panel->type->flag & PNL_INSTANCED) {
+      if (panel_type != NULL && panel->type->flag & PANEL_TYPE_INSTANCED) {
         panel_set_expansion_from_list_data(C, panel);
       }
     }
@@ -585,7 +585,7 @@ static void set_panels_list_data_expand_flag(const bContext *C, const ARegion *r
     }
 
     /* Check for #PANEL_ACTIVE so we only set the expand flag for active panels. */
-    if (panel_type->flag & PNL_INSTANCED && panel->runtime_flag & PANEL_ACTIVE) {
+    if (panel_type->flag & PANEL_TYPE_INSTANCED && panel->runtime_flag & PANEL_ACTIVE) {
       short expand_flag;
       short flag_index = 0;
       get_panel_expand_flag(panel, &expand_flag, &flag_index);
@@ -636,7 +636,7 @@ static void panels_collapse_all(ARegion *region, const Panel *from_panel)
     PanelType *pt = panel->type;
 
     /* Close panels with headers in the same context. */
-    if (pt && from_pt && !(pt->flag & PNL_NO_HEADER)) {
+    if (pt && from_pt && !(pt->flag & PANEL_TYPE_NO_HEADER)) {
       if (!pt->context[0] || !from_pt->context[0] || STREQ(pt->context, from_pt->context)) {
         if ((panel->flag & PNL_PIN) || !category || !pt->category[0] ||
             STREQ(pt->category, category)) {
@@ -690,7 +690,7 @@ Panel *UI_panel_begin(
     panel->type = pt;
     BLI_strncpy(panel->panelname, idname, sizeof(panel->panelname));
 
-    if (pt->flag & PNL_DEFAULT_CLOSED) {
+    if (pt->flag & PANEL_TYPE_DEFAULT_CLOSED) {
       panel->flag |= PNL_CLOSED;
       panel->runtime_flag |= PANEL_WAS_CLOSED;
     }
@@ -920,7 +920,7 @@ static void panel_set_expansion_from_seach_filter_recursive(const bContext *C,
 {
   /* This has to run on inactive panels that may not have a type,
    * but we can prevent running on header-less panels in some cases. */
-  if (panel->type == NULL || !(panel->type->flag & PNL_NO_HEADER)) {
+  if (panel->type == NULL || !(panel->type->flag & PANEL_TYPE_NO_HEADER)) {
     SET_FLAG_FROM_TEST(panel->runtime_flag, use_search_closed, PANEL_USE_CLOSED_FROM_SEARCH);
   }
 
@@ -1002,7 +1002,7 @@ static void region_panels_remove_invisible_layouts(ARegion *region)
 bool UI_panel_is_closed(const Panel *panel)
 {
   /* Header-less panels can never be closed, otherwise they could disappear. */
-  if (panel->type && panel->type->flag & PNL_NO_HEADER) {
+  if (panel->type && panel->type->flag & PANEL_TYPE_NO_HEADER) {
     return false;
   }
 
@@ -1110,7 +1110,7 @@ void ui_draw_aligned_panel(const uiStyle *style,
                            * can't be dragged. This may be changed in future. */
                           show_background);
   const int panel_col = is_subpanel ? TH_PANEL_SUB_BACK : TH_PANEL_BACK;
-  const bool draw_box_style = (panel->type && panel->type->flag & PNL_DRAW_BOX);
+  const bool draw_box_style = (panel->type && panel->type->flag & PANEL_TYPE_DRAW_BOX);
 
   /* Use the theme for box widgets for box-style panels. */
   uiWidgetColors *box_wcol = NULL;
@@ -1122,7 +1122,7 @@ void ui_draw_aligned_panel(const uiStyle *style,
   const uint pos = GPU_vertformat_attr_add(
       immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
 
-  if (panel->type && (panel->type->flag & PNL_NO_HEADER)) {
+  if (panel->type && (panel->type->flag & PANEL_TYPE_NO_HEADER)) {
     if (show_background) {
       immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
       immUniformThemeColor(panel_col);
@@ -1578,7 +1578,7 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active)
 
 static int get_panel_size_y(const Panel *panel)
 {
-  if (panel->type && (panel->type->flag & PNL_NO_HEADER)) {
+  if (panel->type && (panel->type->flag & PANEL_TYPE_NO_HEADER)) {
     return panel->sizey;
   }
 
@@ -1589,7 +1589,7 @@ static int get_panel_real_size_y(const Panel *panel)
 {
   const int sizey = UI_panel_is_closed(panel) ? 0 : panel->sizey;
 
-  if (panel->type && (panel->type->flag & PNL_NO_HEADER)) {
+  if (panel->type && (panel->type->flag & PANEL_TYPE_NO_HEADER)) {
     return sizey;
   }
 
@@ -1633,13 +1633,13 @@ static int find_highest_panel(const void *a, const void *b)
 
   /* Stick uppermost header-less panels to the top of the region -
    * prevent them from being sorted (multiple header-less panels have to be sorted though). */
-  if (panel_a->type->flag & PNL_NO_HEADER && panel_b->type->flag & PNL_NO_HEADER) {
+  if (panel_a->type->flag & PANEL_TYPE_NO_HEADER && panel_b->type->flag & PANEL_TYPE_NO_HEADER) {
     /* Skip and check for `ofsy` and #Panel.sortorder below. */
   }
-  if (panel_a->type->flag & PNL_NO_HEADER) {
+  if (panel_a->type->flag & PANEL_TYPE_NO_HEADER) {
     return -1;
   }
-  if (panel_b->type->flag & PNL_NO_HEADER) {
+  if (panel_b->type->flag & PANEL_TYPE_NO_HEADER) {
     return 1;
   }
 
@@ -1738,7 +1738,7 @@ static bool uiAlignPanelStep(ARegion *region, const float factor, const bool dra
   const int region_offset_x = panel_region_offset_x_get(region);
   for (int i = 0; i < active_panels_len; i++) {
     PanelSort *ps = &panel_sort[i];
-    const bool use_box = ps->panel->type->flag & PNL_DRAW_BOX;
+    const bool use_box = ps->panel->type->flag & PANEL_TYPE_DRAW_BOX;
     ps->panel->runtime.region_ofsx = region_offset_x;
     ps->new_offset_x = region_offset_x + ((use_box) ? UI_PANEL_BOX_STYLE_MARGIN : 0);
   }
@@ -1748,7 +1748,7 @@ static bool uiA

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list