[Bf-blender-cvs] [73e2076d014] soc-2020-info-editor: InfoEditor: add autoscroll

Mateusz Grzeliński noreply at git.blender.org
Mon Aug 17 21:24:33 CEST 2020


Commit: 73e2076d014dca15ac361d98cc472043e1fd77a7
Author: Mateusz Grzeliński
Date:   Mon Aug 17 14:00:01 2020 +0200
Branches: soc-2020-info-editor
https://developer.blender.org/rB73e2076d014dca15ac361d98cc472043e1fd77a7

InfoEditor: add autoscroll

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

M	release/scripts/startup/bl_ui/space_info.py
M	source/blender/blenloader/intern/versioning_defaults.c
M	source/blender/editors/space_info/space_info.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py
index b24ef9b65c9..af433952864 100644
--- a/release/scripts/startup/bl_ui/space_info.py
+++ b/release/scripts/startup/bl_ui/space_info.py
@@ -38,6 +38,7 @@ class INFO_HT_header(Header):
         layout.separator_spacer()
 
         layout.separator_spacer()
+        row.prop(sinfo, "use_autoscroll")
 
         row = layout.row()
         if sinfo.view == 'CLOGS':
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index f7732735e60..95c66a50155 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -182,6 +182,8 @@ static void blo_update_defaults_screen(bScreen *screen,
       sinfo->report_mask_exclude = RPT_DEBUG_ALL;
       sinfo->log_severity_mask = INFO_CLOG_SEVERITY_MASK_DEFAULT;
       sinfo->log_format = INFO_CLOG_FORMAT_DEFAULT;
+      sinfo->view_options = INFO_VIEW_OPTIONS_DEFAULT;
+      sinfo->last_view_height = 0;
     }
     else if (area->spacetype == SPACE_TEXT) {
       /* Show syntax and line numbers in Script workspace text editor. */
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index 834bf23b75b..1b976ac3675 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -65,6 +65,10 @@ static SpaceLink *info_create(const ScrArea *UNUSED(area), const Scene *UNUSED(s
   sinfo->spacetype = SPACE_INFO;
 
   sinfo->report_mask_exclude = RPT_DEBUG_ALL;
+  sinfo->log_severity_mask = INFO_CLOG_SEVERITY_MASK_DEFAULT;
+  sinfo->log_format = INFO_CLOG_FORMAT_DEFAULT;
+  sinfo->view_options = INFO_VIEW_OPTIONS_DEFAULT;
+  sinfo->last_view_height = 0;
 
   /* header */
   region = MEM_callocN(sizeof(ARegion), "header for info");
@@ -119,7 +123,7 @@ static SpaceLink *info_duplicate(SpaceLink *sl)
 {
   SpaceInfo *sinfo = (SpaceInfo *)sl;
   SpaceInfo *sinfo_new = MEM_dupallocN(sl);
-  if (sinfo->search_filter != NULL){
+  if (sinfo->search_filter != NULL) {
     sinfo_new->search_filter = MEM_dupallocN(sinfo->search_filter);
   }
 
@@ -151,11 +155,15 @@ static void info_textview_update_rect(const bContext *C, ARegion *region)
   SpaceInfo *sinfo = CTX_wm_space_info(C);
   View2D *v2d = &region->v2d;
 
-  UI_view2d_totRect_set(
-      v2d,
-      region->winx - 1,
-      info_textview_height(
-          sinfo, region, sinfo->view == INFO_VIEW_REPORTS ? CTX_wm_reports(C) : NULL));
+  const int height = info_textview_height(
+      sinfo, region, sinfo->view == INFO_VIEW_REPORTS ? CTX_wm_reports(C) : NULL);
+  UI_view2d_totRect_set(v2d, region->winx - 1, height);
+  /* default behavior of View2d is actually to autoscroll, so reverse condition */
+  if (!(sinfo->view_options & INFO_VIEW_USE_AUTOSCROLL)) {
+    v2d->cur.ymin += height - sinfo->last_view_height;
+    v2d->cur.ymax += height - sinfo->last_view_height;
+  }
+  sinfo->last_view_height = height;
 }
 
 static void info_main_region_draw(const bContext *C, ARegion *region)
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index f1878ef3d09..7440c5747d9 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -129,7 +129,8 @@ typedef struct SpaceInfo {
   int report_mask_exclude;
   int active_index;
   char view;
-  char _pad1[7];
+  char view_options;
+  char _pad1[6];
 
   int log_format;
   /** for boolean properties use_log_*_filter */
@@ -141,6 +142,7 @@ typedef struct SpaceInfo {
   int log_severity_mask;
   int filter_log_level;
 
+  /* SpaceInfoFilter list. */
   ListBase filter_log_file_line;
   ListBase filter_log_type;
   ListBase filter_log_function;
@@ -156,10 +158,17 @@ typedef enum eSpaceInfo_UseLogFilter {
 
 /* SpaceInfo.view */
 typedef enum eSpaceInfo_View {
-  INFO_VIEW_REPORTS,
+  INFO_VIEW_REPORTS = 0,
   INFO_VIEW_CLOG,
 } eSpaceInfo_View;
 
+/* SpaceInfo.view_options */
+typedef enum eSpaceInfo_ViewOptions {
+  INFO_VIEW_USE_AUTOSCROLL = (1 << 0),
+} eSpaceInfo_ViewOptions;
+
+#define INFO_VIEW_OPTIONS_DEFAULT INFO_VIEW_USE_AUTOSCROLL
+
 /* SpaceInfo.log_severity_mask, keep in sync with CLG_Severity */
 typedef enum eSpaceInfo_LogSeverityMask {
   INFO_CLOG_SEVERITY_DEBUG = (1 << 0),
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 794ea5da68b..27456ba9732 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -6209,6 +6209,10 @@ static void rna_def_space_info(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "View reports or logs", "");
   RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
   RNA_def_property_update(prop, NC_SPACE | ND_SPACE_INFO, NULL);
+
+  prop = RNA_def_property(srna, "use_autoscroll", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "view_options", INFO_VIEW_USE_AUTOSCROLL);
+  RNA_def_property_ui_text(prop, "Use Autoscroll", "");
 }
 
 static void rna_def_space_userpref(BlenderRNA *brna)



More information about the Bf-blender-cvs mailing list