[Bf-blender-cvs] [aa60b9338ab] master: Cleanup: use 'const' style argument

Campbell Barton noreply at git.blender.org
Sun Mar 15 11:43:29 CET 2020


Commit: aa60b9338ab679853d36322829458ccb7b4f06d0
Author: Campbell Barton
Date:   Sun Mar 15 17:32:25 2020 +1100
Branches: master
https://developer.blender.org/rBaa60b9338ab679853d36322829458ccb7b4f06d0

Cleanup: use 'const' style argument

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

M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_context_menu.c
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/interface/interface_region_menu_pie.c
M	source/blender/editors/interface/interface_region_menu_popup.c
M	source/blender/editors/interface/interface_region_popover.c
M	source/blender/editors/interface/interface_region_search.c
M	source/blender/editors/interface/interface_region_tooltip.c
M	source/blender/editors/interface/interface_style.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/interface/view2d.c
M	source/blender/editors/interface/view2d_ops.c
M	source/blender/editors/screen/area.c
M	source/blender/editors/space_clip/clip_dopesheet_draw.c
M	source/blender/editors/space_file/file_draw.c
M	source/blender/editors/space_file/filesel.c
M	source/blender/windowmanager/intern/wm_files.c
M	source/blender/windowmanager/intern/wm_operators.c
M	source/blender/windowmanager/intern/wm_splash_screen.c

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

diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 6a88ef2468e..3e416cd8057 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1807,7 +1807,7 @@ uiLayout *UI_block_layout(uiBlock *block,
                           int size,
                           int em,
                           int padding,
-                          struct uiStyle *style);
+                          const struct uiStyle *style);
 void UI_block_layout_set_current(uiBlock *block, uiLayout *layout);
 void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y);
 
@@ -2433,8 +2433,8 @@ int UI_fontstyle_height_max(const struct uiFontStyle *fs);
 
 void UI_draw_icon_tri(float x, float y, char dir, const float[4]);
 
-struct uiStyle *UI_style_get(void);     /* use for fonts etc */
-struct uiStyle *UI_style_get_dpi(void); /* DPI scaled settings for drawing */
+const struct uiStyle *UI_style_get(void);     /* use for fonts etc */
+const struct uiStyle *UI_style_get_dpi(void); /* DPI scaled settings for drawing */
 
 /* linker workaround ack! */
 void UI_template_fix_linking(void);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index b5fce7ea99f..3d8c0da78ea 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -366,7 +366,7 @@ void UI_block_translate(uiBlock *block, int x, int y)
 
 static void ui_block_bounds_calc_text(uiBlock *block, float offset)
 {
-  uiStyle *style = UI_style_get();
+  const uiStyle *style = UI_style_get();
   uiBut *bt, *init_col_bt, *col_bt;
   int i = 0, j, x1addval = offset;
 
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c
index c9a46e00520..f6da9663daf 100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.c
@@ -169,7 +169,7 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *region, void *arg)
   wmKeyMapItem *kmi;
   PointerRNA ptr;
   uiLayout *layout;
-  uiStyle *style = UI_style_get_dpi();
+  const uiStyle *style = UI_style_get_dpi();
   IDProperty *prop;
   const char *idname = shortcut_get_operator_property(C, but, &prop);
 
@@ -225,7 +225,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *region, void *arg)
   wmKeyMapItem *kmi;
   PointerRNA ptr;
   uiLayout *layout;
-  uiStyle *style = UI_style_get_dpi();
+  const uiStyle *style = UI_style_get_dpi();
   int kmi_id;
   IDProperty *prop;
   const char *idname = shortcut_get_operator_property(C, but, &prop);
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 3d7378181ad..f4dd114c312 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -2848,10 +2848,9 @@ static bool ui_textedit_delete_selection(uiBut *but, uiHandleButtonData *data)
  */
 static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, const float x)
 {
-  uiStyle *style = UI_style_get();  // XXX pass on as arg
-  uiFontStyle *fstyle = &style->widget;
+  /* XXX pass on as arg. */
+  uiFontStyle fstyle = UI_style_get()->widget;
   const float aspect = but->block->aspect;
-  const short fstyle_points_prev = fstyle->points;
 
   float startx = but->rect.xmin;
   float starty_dummy = 0.0f;
@@ -2861,13 +2860,13 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
 
   ui_block_to_window_fl(data->region, but->block, &startx, &starty_dummy);
 
-  ui_fontscale(&fstyle->points, aspect);
+  ui_fontscale(&fstyle.points, aspect);
 
-  UI_fontstyle_set(fstyle);
+  UI_fontstyle_set(&fstyle);
 
-  if (fstyle->kerning == 1) {
+  if (fstyle.kerning == 1) {
     /* for BLF_width */
-    BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
+    BLF_enable(fstyle.uifont_id, BLF_KERNING_DEFAULT);
   }
 
   ui_but_text_password_hide(password_str, but, false);
@@ -2889,7 +2888,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
     while (i > 0) {
       if (BLI_str_cursor_step_prev_utf8(str, but->ofs, &i)) {
         /* 0.25 == scale factor for less sensitivity */
-        if (BLF_width(fstyle->uifont_id, str + i, (str_last - str) - i) > (startx - x) * 0.25f) {
+        if (BLF_width(fstyle.uifont_id, str + i, (str_last - str) - i) > (startx - x) * 0.25f) {
           break;
         }
       }
@@ -2913,7 +2912,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
     but->pos = pos_prev = ((str_last - str) - but->ofs);
 
     while (true) {
-      cdist = startx + BLF_width(fstyle->uifont_id, str + but->ofs, (str_last - str) - but->ofs);
+      cdist = startx + BLF_width(fstyle.uifont_id, str + but->ofs, (str_last - str) - but->ofs);
 
       /* check if position is found */
       if (cdist < x) {
@@ -2945,13 +2944,11 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
     }
   }
 
-  if (fstyle->kerning == 1) {
-    BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
+  if (fstyle.kerning == 1) {
+    BLF_disable(fstyle.uifont_id, BLF_KERNING_DEFAULT);
   }
 
   ui_but_text_password_hide(password_str, but, true);
-
-  fstyle->points = fstyle_points_prev;
 }
 
 static void ui_textedit_set_cursor_select(uiBut *but, uiHandleButtonData *data, const float x)
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index a2e239884a3..e2b4e8f2958 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -839,7 +839,7 @@ const struct uiWidgetColors *ui_tooltip_get_theme(void);
 
 void ui_draw_widget_menu_back_color(const rcti *rect, bool use_shadow, const float color[4]);
 void ui_draw_widget_menu_back(const rcti *rect, bool use_shadow);
-void ui_draw_tooltip_background(struct uiStyle *UNUSED(style), uiBlock *block, rcti *rect);
+void ui_draw_tooltip_background(const struct uiStyle *UNUSED(style), uiBlock *block, rcti *rect);
 
 extern void ui_draw_but(
     const struct bContext *C, ARegion *region, struct uiStyle *style, uiBut *but, rcti *rect);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 1aa2670942f..64ff9d02cdc 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -91,7 +91,7 @@ typedef struct uiLayoutRoot {
   uiMenuHandleFunc handlefunc;
   void *argv;
 
-  uiStyle *style;
+  const uiStyle *style;
   uiBlock *block;
   uiLayout *layout;
 } uiLayoutRoot;
@@ -499,7 +499,7 @@ static void ui_item_array(uiLayout *layout,
                           bool compact,
                           bool show_text)
 {
-  uiStyle *style = layout->root->style;
+  const uiStyle *style = layout->root->style;
   uiBut *but;
   PropertyType type;
   PropertySubType subtype;
@@ -3707,7 +3707,7 @@ static void ui_litem_layout_root(uiLayout *litem)
 /* box layout */
 static void ui_litem_estimate_box(uiLayout *litem)
 {
-  uiStyle *style = litem->root->style;
+  const uiStyle *style = litem->root->style;
 
   ui_litem_estimate_column(litem, true);
 
@@ -3722,7 +3722,7 @@ static void ui_litem_estimate_box(uiLayout *litem)
 static void ui_litem_layout_box(uiLayout *litem)
 {
   uiLayoutItemBx *box = (uiLayoutItemBx *)litem;
-  uiStyle *style = litem->root->style;
+  const uiStyle *style = litem->root->style;
   uiBut *but;
   int w, h;
 
@@ -3767,7 +3767,7 @@ static void ui_litem_layout_box(uiLayout *litem)
 /* multi-column layout, automatically flowing to the next */
 static void ui_litem_estimate_column_flow(uiLayout *litem)
 {
-  uiStyle *style = litem->root->style;
+  const uiStyle *style = litem->root->style;
   uiLayoutItemFlow *flow = (uiLayoutItemFlow *)litem;
   uiItem *item;
   int col, x, y, emh, emy, miny, itemw, itemh, maxw = 0;
@@ -3832,7 +3832,7 @@ static void ui_litem_estimate_column_flow(uiLayout *litem)
 
 static void ui_litem_layout_column_flow(uiLayout *litem)
 {
-  uiStyle *style = litem->root->style;
+  const uiStyle *style = litem->root->style;
   uiLayoutItemFlow *flow = (uiLayoutItemFlow *)litem;
   uiItem *item;
   int col, x, y, w, emh, emy, miny, itemw, itemh;
@@ -4071,7 +4071,7 @@ static void ui_litem_grid_flow_compute(ListBase *items,
 
 static void ui_litem_estimate_grid_flow(uiLayout *litem)
 {
-  uiStyle *style = litem->root->style;
+  const uiStyle *style = litem->root->style;
   uiLayoutItemGridFlow *gflow = (uiLayoutItemGridFlow *)litem;
 
   const int space_x = style->columnspace;
@@ -4199,7 +4199,7 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem)
 static void ui_litem_layout_grid_flow(uiLayout *litem)
 {
   int i;
-  uiStyle *style = litem->root->style;
+  const uiStyle *style = litem->root->style;
   uiLayoutItemGridFlow *gflow = (uiLayoutItemGridFlow *)litem;
   uiItem *item;
 
@@ -5092,8 +5092,15 @@ static void ui_layout_add_padding_button(uiLayoutRoot *root)
   }
 }
 
-uiLayout *UI_block_layout(
-    uiBlock *block, int dir, int type, int x, int y, int size, int em, int padding, uiStyle *style)
+uiLayout *UI_block_layout(uiBlock *block,
+                          int dir,
+                          int type,
+                          int x,
+                          int y,
+                          int size,
+                          int em,
+                          int padding,
+                          const uiStyle *style)
 {
   uiLayout *layout;
   uiLayoutRoot *root;
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 70d64ff26ab..1f5855aed9e 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -434,7 +434,7 @@ void UI_panel_end(
 
 static void ui_offset_panel_block(uiBlock *block)
 {
-  uiStyle *style = UI_style_get_dpi();
+  const uiStyle *style = UI_style_get_dpi();
 
   /* compute 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list