[Bf-blender-cvs] [aacdf55a50d] master: Cleanup: ARegion.sizex/y should not be used to access region size

Julian Eisel noreply at git.blender.org
Fri Jan 10 14:30:05 CET 2020


Commit: aacdf55a50d8b9a0a95dd191a66deb7b58edca0b
Author: Julian Eisel
Date:   Fri Jan 10 14:23:47 2020 +0100
Branches: master
https://developer.blender.org/rBaacdf55a50d8b9a0a95dd191a66deb7b58edca0b

Cleanup: ARegion.sizex/y should not be used to access region size

This should only be used to change and recalculate region sizes in a DPI
independent way. To get the size with DPI applied, ARegion.winx/y should
be used instead.
Added note on this in comment.

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

M	source/blender/editors/animation/time_scrub_ui.c
M	source/blender/editors/space_clip/space_clip.c
M	source/blender/editors/space_graph/graph_edit.c
M	source/blender/editors/space_graph/space_graph.c
M	source/blender/editors/space_sequencer/sequencer_draw.c
M	source/blender/makesdna/DNA_screen_types.h

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

diff --git a/source/blender/editors/animation/time_scrub_ui.c b/source/blender/editors/animation/time_scrub_ui.c
index 70a9b7ba1fa..ae489fb5233 100644
--- a/source/blender/editors/animation/time_scrub_ui.c
+++ b/source/blender/editors/animation/time_scrub_ui.c
@@ -179,9 +179,9 @@ void ED_time_scrub_channel_search_draw(const bContext *C, ARegion *ar, bDopeShee
 
   rcti rect;
   rect.xmin = 0;
-  rect.xmax = ceilf(ar->sizex * UI_DPI_FAC);
-  rect.ymin = ar->sizey * UI_DPI_FAC - UI_TIME_SCRUB_MARGIN_Y;
-  rect.ymax = ceilf(ar->sizey * UI_DPI_FAC);
+  rect.xmax = ar->winx;
+  rect.ymin = ar->winy - UI_TIME_SCRUB_MARGIN_Y;
+  rect.ymax = ar->winy;
 
   uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
   immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 16305a9b17b..04c939ec41b 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -1083,11 +1083,7 @@ static void graph_region_draw(const bContext *C, ARegion *ar)
   /* scale indicators */
   {
     rcti rect;
-    BLI_rcti_init(&rect,
-                  0,
-                  15 * UI_DPI_FAC,
-                  15 * UI_DPI_FAC,
-                  UI_DPI_FAC * ar->sizey - UI_TIME_SCRUB_MARGIN_Y);
+    BLI_rcti_init(&rect, 0, 15 * UI_DPI_FAC, 15 * UI_DPI_FAC, ar->winy - UI_TIME_SCRUB_MARGIN_Y);
     UI_view2d_draw_scale_y__values(ar, v2d, &rect, TH_TEXT);
   }
 }
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 03df93e4c8a..98fe8c71454 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -298,7 +298,7 @@ static int graphkeys_viewall(bContext *C,
   if (!BLI_listbase_is_empty(ED_context_get_markers(C))) {
     pad_bottom = UI_MARKER_MARGIN_Y;
   }
-  BLI_rctf_pad_y(&cur_new, ac.ar->sizey * UI_DPI_FAC, pad_bottom, pad_top);
+  BLI_rctf_pad_y(&cur_new, ac.ar->winy, pad_bottom, pad_top);
 
   UI_view2d_smooth_view(C, ac.ar, &cur_new, smooth_viewtx);
   return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 7bc907bb3db..d01e4112fd0 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -326,11 +326,7 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
   /* scale numbers */
   {
     rcti rect;
-    BLI_rcti_init(&rect,
-                  0,
-                  15 * UI_DPI_FAC,
-                  15 * UI_DPI_FAC,
-                  UI_DPI_FAC * ar->sizey - UI_TIME_SCRUB_MARGIN_Y);
+    BLI_rcti_init(&rect, 0, 15 * UI_DPI_FAC, 15 * UI_DPI_FAC, ar->winy - UI_TIME_SCRUB_MARGIN_Y);
     UI_view2d_draw_scale_y__values(ar, v2d, &rect, TH_SCROLL_TEXT);
   }
 }
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 70cb28fa937..333a51e2eac 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -2119,11 +2119,7 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
   /* channel numbers */
   {
     rcti rect;
-    BLI_rcti_init(&rect,
-                  0,
-                  15 * UI_DPI_FAC,
-                  15 * UI_DPI_FAC,
-                  UI_DPI_FAC * ar->sizey - UI_TIME_SCRUB_MARGIN_Y);
+    BLI_rcti_init(&rect, 0, 15 * UI_DPI_FAC, 15 * UI_DPI_FAC, ar->winy - UI_TIME_SCRUB_MARGIN_Y);
     UI_view2d_draw_scale_y__block(ar, v2d, &rect, TH_SCROLL_TEXT);
   }
 }
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index d3c5a707b44..60fb7b62dff 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -409,7 +409,9 @@ typedef struct ARegion {
   short flag;
 
   /** Current split size in unscaled pixels (if zero it uses regiontype).
-   * To convert to pixels use: `UI_DPI_FAC * ar->sizex + 0.5f`. */
+   * To convert to pixels use: `UI_DPI_FAC * ar->sizex + 0.5f`.
+   * However to get the current region size, you should usually use winx/winy from above, not this!
+   */
   short sizex, sizey;
 
   /** Private, cached notifier events. */



More information about the Bf-blender-cvs mailing list