[Bf-blender-cvs] [0cb264a2826] master: Cleanup: pass 'rctf' rectangle to 2D box drawing functions

Campbell Barton noreply at git.blender.org
Mon Jan 25 08:35:09 CET 2021


Commit: 0cb264a282626d1f363d1898695f44285e1e0027
Author: Campbell Barton
Date:   Mon Jan 25 18:31:11 2021 +1100
Branches: master
https://developer.blender.org/rB0cb264a282626d1f363d1898695f44285e1e0027

Cleanup: pass 'rctf' rectangle to 2D box drawing functions

Passing 4x arguments for the rectangle,
mixed in with round-box radius & color wasn't very readable.

Instead, pass a `rctf` as the first argument to UI box drawing functions.

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

M	source/blender/editors/animation/anim_channels_defines.c
M	source/blender/editors/animation/time_scrub_ui.c
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/interface/interface_icons_event.c
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/interface/interface_style.c
M	source/blender/editors/screen/area.c
M	source/blender/editors/space_file/file_draw.c
M	source/blender/editors/space_info/textview.c
M	source/blender/editors/space_nla/nla_draw.c
M	source/blender/editors/space_node/drawnode.c
M	source/blender/editors/space_node/node_draw.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_sequencer/sequencer_draw.c
M	source/blender/editors/space_text/text_draw.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c

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

diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 8f6d0045c9c..64fa93773b9 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -133,7 +133,16 @@ static void acf_generic_root_backdrop(bAnimContext *ac,
   UI_draw_roundbox_corner_set((expanded) ? UI_CNR_TOP_LEFT :
                                            (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT));
   UI_draw_roundbox_3fv_alpha(
-      true, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f);
+      &(const rctf){
+          .xmin = offset,
+          .xmax = v2d->cur.xmax + EXTRA_SCROLL_PAD,
+          .ymin = yminc,
+          .ymax = ymaxc,
+      },
+      true,
+      8,
+      color,
+      1.0f);
 }
 
 /* get backdrop color for data expanders under top-level Scene/Object */
@@ -464,7 +473,16 @@ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float ymi
    */
   UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT);
   UI_draw_roundbox_3fv_alpha(
-      true, 0, yminc - 2, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f);
+      &(const rctf){
+          .xmin = 0,
+          .xmax = v2d->cur.xmax + EXTRA_SCROLL_PAD,
+          .ymin = yminc - 2,
+          .ymax = ymaxc,
+      },
+      true,
+      8,
+      color,
+      1.0f);
 }
 
 /* name for summary entries */
@@ -875,7 +893,16 @@ static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc
   /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
   UI_draw_roundbox_corner_set(expanded ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT));
   UI_draw_roundbox_3fv_alpha(
-      true, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8, color, 1.0f);
+      &(const rctf){
+          .xmin = offset,
+          .xmax = v2d->cur.xmax + EXTRA_SCROLL_PAD,
+          .ymin = yminc,
+          .ymax = ymaxc,
+      },
+      true,
+      8,
+      color,
+      1.0f);
 }
 
 /* name for group entries */
@@ -1149,7 +1176,16 @@ static void acf_nla_controls_backdrop(bAnimContext *ac,
   /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
   UI_draw_roundbox_corner_set(expanded ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT));
   UI_draw_roundbox_3fv_alpha(
-      true, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 5, color, 1.0f);
+      &(const rctf){
+          .xmin = offset,
+          .xmax = v2d->cur.xmax + EXTRA_SCROLL_PAD,
+          .ymin = yminc,
+          .ymax = ymaxc,
+      },
+      true,
+      5,
+      color,
+      1.0f);
 }
 
 /* name for nla controls expander entries */
@@ -3936,13 +3972,16 @@ static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float y
   /* draw slightly shifted up vertically to look like it has more separation from other channels,
    * but we then need to slightly shorten it so that it doesn't look like it overlaps
    */
-  UI_draw_roundbox_4fv(true,
-                       offset,
-                       yminc + NLACHANNEL_SKIP,
-                       (float)v2d->cur.xmax,
-                       ymaxc + NLACHANNEL_SKIP - 1,
-                       8,
-                       color);
+  UI_draw_roundbox_4fv(
+      &(const rctf){
+          .xmin = offset,
+          .xmax = (float)v2d->cur.xmax,
+          .ymin = yminc + NLACHANNEL_SKIP,
+          .ymax = ymaxc + NLACHANNEL_SKIP - 1,
+      },
+      true,
+      8,
+      color);
 }
 
 /* name for nla action entries */
diff --git a/source/blender/editors/animation/time_scrub_ui.c b/source/blender/editors/animation/time_scrub_ui.c
index 98b4d93fbf1..f5240d67cca 100644
--- a/source/blender/editors/animation/time_scrub_ui.c
+++ b/source/blender/editors/animation/time_scrub_ui.c
@@ -124,23 +124,29 @@ static void draw_current_frame(const Scene *scene,
 
   UI_draw_roundbox_corner_set(UI_CNR_ALL);
 
-  UI_draw_roundbox_3fv_alpha(true,
-                             frame_x - box_width / 2 + U.pixelsize / 2,
-                             scrub_region_rect->ymin + box_padding,
-                             frame_x + box_width / 2 + U.pixelsize / 2,
-                             scrub_region_rect->ymax - box_padding,
-                             4 * UI_DPI_FAC,
-                             bg_color,
-                             1.0f);
+  UI_draw_roundbox_3fv_alpha(
+      &(const rctf){
+          .xmin = frame_x - box_width / 2 + U.pixelsize / 2,
+          .xmax = frame_x + box_width / 2 + U.pixelsize / 2,
+          .ymin = scrub_region_rect->ymin + box_padding,
+          .ymax = scrub_region_rect->ymax - box_padding,
+      },
+      true,
+      4 * UI_DPI_FAC,
+      bg_color,
+      1.0f);
 
   UI_GetThemeColorShade4fv(TH_CFRAME, 5, bg_color);
-  UI_draw_roundbox_aa(false,
-                      frame_x - box_width / 2 + U.pixelsize / 2,
-                      scrub_region_rect->ymin + box_padding,
-                      frame_x + box_width / 2 + U.pixelsize / 2,
-                      scrub_region_rect->ymax - box_padding,
-                      4 * UI_DPI_FAC,
-                      bg_color);
+  UI_draw_roundbox_aa(
+      &(const rctf){
+          .xmin = frame_x - box_width / 2 + U.pixelsize / 2,
+          .xmax = frame_x + box_width / 2 + U.pixelsize / 2,
+          .ymin = scrub_region_rect->ymin + box_padding,
+          .ymax = scrub_region_rect->ymax - box_padding,
+      },
+      true,
+      4 * UI_DPI_FAC,
+      bg_color);
 
   uchar text_color[4];
   UI_GetThemeColor4ubv(TH_HEADER_TEXT_HI, text_color);
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 015237ba954..f3c94fb7a28 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -56,6 +56,7 @@ struct bNode;
 struct bNodeSocket;
 struct bNodeTree;
 struct bScreen;
+struct rctf;
 struct rcti;
 struct uiButSearch;
 struct uiFontStyle;
@@ -414,39 +415,22 @@ void UI_draw_anti_tria(
 void UI_draw_anti_fan(float tri_array[][2], unsigned int length, const float color[4]);
 
 void UI_draw_roundbox_corner_set(int type);
-void UI_draw_roundbox_aa(
-    bool filled, float minx, float miny, float maxx, float maxy, float rad, const float color[4]);
-void UI_draw_roundbox_4fv(
-    bool filled, float minx, float miny, float maxx, float maxy, float rad, const float col[4]);
-void UI_draw_roundbox_3ub_alpha(bool filled,
-                                float minx,
-                                float miny,
-                                float maxx,
-                                float maxy,
+void UI_draw_roundbox_aa(const struct rctf *rect, bool filled, float rad, const float color[4]);
+void UI_draw_roundbox_4fv(const struct rctf *rect, bool filled, float rad, const float col[4]);
+void UI_draw_roundbox_3ub_alpha(const struct rctf *rect,
+                                bool filled,
                                 float rad,
                                 const unsigned char col[3],
                                 unsigned char alpha);
-void UI_draw_roundbox_3fv_alpha(bool filled,
-                                float minx,
-                                float miny,
-                                float maxx,
-                                float maxy,
-                                float rad,
-                                const float col[3],
-                                float alpha);
-void UI_draw_roundbox_shade_x(bool filled,
-                              float minx,
-                              float miny,
-                              float maxx,
-                              float maxy,
+void UI_draw_roundbox_3fv_alpha(
+    const struct rctf *rect, bool filled, float rad, const float col[3], float alpha);
+void UI_draw_roundbox_shade_x(const struct rctf *rect,
+                              bool filled,
                               float rad,
                               float shadetop,
                               float shadedown,
                               const float col[4]);
-void UI_draw_roundbox_4fv_ex(float minx,
-                             float miny,
-                             float maxx,
-                             float maxy,
+void UI_draw_roundbox_4fv_ex(const struct rctf *rect,
                              const float inner1[4],
                              const float inner2[4],
                              float shade_dir,
@@ -458,14 +442,11 @@ void UI_draw_roundbox_4fv_ex(float minx,
 int UI_draw_roundbox_corner_get(void);
 #endif
 
-void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
+void UI_draw_box_shadow(const struct rctf *rect, unsigned char alpha);
 void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const float color[4]);
 
 void UI_draw_safe_areas(uint pos,
-                        float x1,
-                        float x2,
-                        float y1,
-                        float y2,
+                        const struct rctf *rect,
                         const float title_aspect[2],
                         const float action_aspect[2]);
 
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 9880dfcb536..0bae57f14d3 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -81,10 +81,7 @@ int UI_draw_roundbox_corner_get(void)
 }
 #endif
 
-void UI_draw_roundbox_4fv_ex(float minx,
-                             float miny,
-                             float maxx,
-                             float maxy,
+void UI_draw_roundbox_4fv_ex(const rctf *rect,
                              const float inner1[4],
                              const float inner2[4],
                              float shade_dir,
@@ -95,14 +92,11 @@ void UI_draw_roundbox_4fv_ex(float minx,
   /* WATCH: This is assuming the ModelViewProjectionMatrix is area pixel space.
    * If it has been scaled, then it's no longer valid. */
   uiWidgetBaseParameter

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list