[Bf-blender-cvs] [ceab47f3479] master: Cleanup: text-view comments, variable names, const args

Campbell Barton noreply at git.blender.org
Tue Dec 3 13:43:48 CET 2019


Commit: ceab47f34790b5598453720fe276e5e6d521c4be
Author: Campbell Barton
Date:   Tue Dec 3 23:24:12 2019 +1100
Branches: master
https://developer.blender.org/rBceab47f34790b5598453720fe276e5e6d521c4be

Cleanup: text-view comments, variable names, const args

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

M	source/blender/editors/space_console/console_draw.c
M	source/blender/editors/space_console/console_intern.h
M	source/blender/editors/space_info/info_draw.c
M	source/blender/editors/space_info/info_intern.h
M	source/blender/editors/space_info/textview.c
M	source/blender/editors/space_info/textview.h
M	source/blender/makesdna/DNA_space_types.h

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

diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c
index 5476bde8af5..bf6683ffc33 100644
--- a/source/blender/editors/space_console/console_draw.c
+++ b/source/blender/editors/space_console/console_draw.c
@@ -154,12 +154,12 @@ static int console_textview_line_color(struct TextViewContext *tvc,
     uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
     xy[1] += tvc->lheight / 6;
 
-    console_cursor_wrap_offset(sc->prompt, tvc->console_width, &offl, &offc, NULL);
-    console_cursor_wrap_offset(cl->line, tvc->console_width, &offl, &offc, cl->line + cl->cursor);
+    console_cursor_wrap_offset(sc->prompt, tvc->columns, &offl, &offc, NULL);
+    console_cursor_wrap_offset(cl->line, tvc->columns, &offl, &offc, cl->line + cl->cursor);
     pen[0] = tvc->cwidth * offc;
     pen[1] = -2 - tvc->lheight * offl;
 
-    console_cursor_wrap_offset(cl->line + cl->cursor, tvc->console_width, &offl, &offc, NULL);
+    console_cursor_wrap_offset(cl->line + cl->cursor, tvc->columns, &offl, &offc, NULL);
     pen[1] += tvc->lheight * offl;
 
     /* cursor */
@@ -196,16 +196,16 @@ static void console_textview_draw_rect_calc(const ARegion *ar, rcti *draw_rect)
 }
 
 static int console_textview_main__internal(struct SpaceConsole *sc,
-                                           ARegion *ar,
-                                           int draw,
+                                           const ARegion *ar,
+                                           const bool do_draw,
                                            const int mval[2],
-                                           void **mouse_pick,
-                                           int *pos_pick)
+                                           void **r_mval_pick_item,
+                                           int *r_mval_pick_offset)
 {
   ConsoleLine cl_dummy = {NULL};
   int ret = 0;
 
-  View2D *v2d = &ar->v2d;
+  const View2D *v2d = &ar->v2d;
 
   TextViewContext tvc = {0};
 
@@ -230,32 +230,32 @@ static int console_textview_main__internal(struct SpaceConsole *sc,
   console_textview_draw_rect_calc(ar, &tvc.draw_rect);
 
   console_scrollback_prompt_begin(sc, &cl_dummy);
-  ret = textview_draw(&tvc, draw, mval, mouse_pick, pos_pick);
+  ret = textview_draw(&tvc, do_draw, mval, r_mval_pick_item, r_mval_pick_offset);
   console_scrollback_prompt_end(sc, &cl_dummy);
 
   return ret;
 }
 
-void console_textview_main(struct SpaceConsole *sc, ARegion *ar)
+void console_textview_main(struct SpaceConsole *sc, const ARegion *ar)
 {
   const int mval[2] = {INT_MAX, INT_MAX};
-  console_textview_main__internal(sc, ar, 1, mval, NULL, NULL);
+  console_textview_main__internal(sc, ar, true, mval, NULL, NULL);
 }
 
-int console_textview_height(struct SpaceConsole *sc, ARegion *ar)
+int console_textview_height(struct SpaceConsole *sc, const ARegion *ar)
 {
   const int mval[2] = {INT_MAX, INT_MAX};
-  return console_textview_main__internal(sc, ar, 0, mval, NULL, NULL);
+  return console_textview_main__internal(sc, ar, false, mval, NULL, NULL);
 }
 
-int console_char_pick(struct SpaceConsole *sc, ARegion *ar, const int mval[2])
+int console_char_pick(struct SpaceConsole *sc, const ARegion *ar, const int mval[2])
 {
-  int pos_pick = 0;
-  void *mouse_pick = NULL;
+  int r_mval_pick_offset = 0;
+  void *mval_pick_item = NULL;
 
   rcti draw_rect;
   console_textview_draw_rect_calc(ar, &draw_rect);
 
-  console_textview_main__internal(sc, ar, 0, mval, &mouse_pick, &pos_pick);
-  return pos_pick;
+  console_textview_main__internal(sc, ar, false, mval, &mval_pick_item, &r_mval_pick_offset);
+  return r_mval_pick_offset;
 }
diff --git a/source/blender/editors/space_console/console_intern.h b/source/blender/editors/space_console/console_intern.h
index 2a5675b9c3b..def7fbc193b 100644
--- a/source/blender/editors/space_console/console_intern.h
+++ b/source/blender/editors/space_console/console_intern.h
@@ -28,10 +28,10 @@ struct bContext;
 struct wmOperatorType;
 
 /* console_draw.c */
-void console_textview_main(struct SpaceConsole *sc, struct ARegion *ar);
+void console_textview_main(struct SpaceConsole *sc, const struct ARegion *ar);
 /* needed to calculate the scrollbar */
-int console_textview_height(struct SpaceConsole *sc, struct ARegion *ar);
-int console_char_pick(struct SpaceConsole *sc, struct ARegion *ar, const int mval[2]);
+int console_textview_height(struct SpaceConsole *sc, const struct ARegion *ar);
+int console_char_pick(struct SpaceConsole *sc, const struct ARegion *ar, const int mval[2]);
 
 void console_scrollback_prompt_begin(struct SpaceConsole *sc, ConsoleLine *cl_dummy);
 void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine *cl_dummy);
diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c
index f2f8b2da4db..64570459532 100644
--- a/source/blender/editors/space_info/info_draw.c
+++ b/source/blender/editors/space_info/info_draw.c
@@ -228,7 +228,7 @@ static int report_textview_line_color(struct TextViewContext *tvc,
 
 #undef USE_INFO_NEWLINE
 
-static void info_textview_draw_rect_calc(ARegion *ar, rcti *draw_rect)
+static void info_textview_draw_rect_calc(const ARegion *ar, rcti *draw_rect)
 {
   const int margin = 4 * UI_DPI_FAC;
   draw_rect->xmin = margin;
@@ -239,16 +239,16 @@ static void info_textview_draw_rect_calc(ARegion *ar, rcti *draw_rect)
 }
 
 static int info_textview_main__internal(struct SpaceInfo *sinfo,
-                                        ARegion *ar,
+                                        const ARegion *ar,
                                         ReportList *reports,
-                                        int draw,
-                                        int mval[2],
-                                        void **mouse_pick,
-                                        int *pos_pick)
+                                        const bool do_draw,
+                                        const int mval[2],
+                                        void **r_mval_pick_item,
+                                        int *r_mval_pick_offset)
 {
   int ret = 0;
 
-  View2D *v2d = &ar->v2d;
+  const View2D *v2d = &ar->v2d;
 
   TextViewContext tvc = {0};
   tvc.begin = report_textview_begin;
@@ -271,31 +271,28 @@ static int info_textview_main__internal(struct SpaceInfo *sinfo,
 
   info_textview_draw_rect_calc(ar, &tvc.draw_rect);
 
-  ret = textview_draw(&tvc, draw, mval, mouse_pick, pos_pick);
+  ret = textview_draw(&tvc, do_draw, mval, r_mval_pick_item, r_mval_pick_offset);
 
   return ret;
 }
 
-void *info_text_pick(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports, int mouse_y)
+void *info_text_pick(struct SpaceInfo *sinfo, const ARegion *ar, ReportList *reports, int mval_y)
 {
-  void *mouse_pick = NULL;
-  int mval[2];
+  void *mval_pick_item = NULL;
+  const int mval[2] = {0, mval_y};
 
-  mval[0] = 0;
-  mval[1] = mouse_y;
-
-  info_textview_main__internal(sinfo, ar, reports, 0, mval, &mouse_pick, NULL);
-  return (void *)mouse_pick;
+  info_textview_main__internal(sinfo, ar, reports, false, mval, &mval_pick_item, NULL);
+  return (void *)mval_pick_item;
 }
 
-int info_textview_height(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports)
+int info_textview_height(struct SpaceInfo *sinfo, const ARegion *ar, ReportList *reports)
 {
   int mval[2] = {INT_MAX, INT_MAX};
-  return info_textview_main__internal(sinfo, ar, reports, 0, mval, NULL, NULL);
+  return info_textview_main__internal(sinfo, ar, reports, false, mval, NULL, NULL);
 }
 
-void info_textview_main(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports)
+void info_textview_main(struct SpaceInfo *sinfo, const ARegion *ar, ReportList *reports)
 {
   int mval[2] = {INT_MAX, INT_MAX};
-  info_textview_main__internal(sinfo, ar, reports, 1, mval, NULL, NULL);
+  info_textview_main__internal(sinfo, ar, reports, true, mval, NULL, NULL);
 }
diff --git a/source/blender/editors/space_info/info_intern.h b/source/blender/editors/space_info/info_intern.h
index 7d4d6e5ab90..177b43edf74 100644
--- a/source/blender/editors/space_info/info_intern.h
+++ b/source/blender/editors/space_info/info_intern.h
@@ -46,11 +46,15 @@ void INFO_OT_reports_display_update(struct wmOperatorType *ot);
 
 /* info_draw.c */
 void *info_text_pick(struct SpaceInfo *sinfo,
-                     struct ARegion *ar,
+                     const struct ARegion *ar,
                      ReportList *reports,
                      int mouse_y);
-int info_textview_height(struct SpaceInfo *sinfo, struct ARegion *ar, struct ReportList *reports);
-void info_textview_main(struct SpaceInfo *sinfo, struct ARegion *ar, struct ReportList *reports);
+int info_textview_height(struct SpaceInfo *sinfo,
+                         const struct ARegion *ar,
+                         struct ReportList *reports);
+void info_textview_main(struct SpaceInfo *sinfo,
+                        const struct ARegion *ar,
+                        struct ReportList *reports);
 
 /* info_report.c */
 int info_report_mask(struct SpaceInfo *sinfo);
diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c
index a112929cf25..3cdd4020a70 100644
--- a/source/blender/editors/space_info/textview.c
+++ b/source/blender/editors/space_info/textview.c
@@ -39,40 +39,40 @@
 
 static void console_font_begin(const int font_id, const int lheight)
 {
-  /* 0.875 is based on: 16 pixels lines get 14 pixel text */
+  /* 0.875 is based on: 16 pixels lines get 14 pixel text. */
   BLF_size(font_id, 0.875 * lheight, 72);
 }
 
-typedef struct ConsoleDrawContext {
+typedef struct TextViewDrawState {
   int font_id;
   int cwidth;
   int lheight;
-  /** text vertical offset */
+  /** Text vertical offset per line. */
   int lofs;
-  /** number of characters that fit into the width of the console (fixed width) */
-  int console_width;
+  /** Number of characters that fit into the width of the console (fixed width). */
+  int columns;
   const rcti *draw_rect;
   int scroll_ymin, scroll_ymax;
   int *xy;   // [2]
   int *sel;  // [2]
-  /* bottom of view == 0, top of file == combine chars, end of l

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list