[Bf-blender-cvs] [855b5390417] soc-2020-info-editor: WIP: handle clog in separate TextViewContext

Mateusz Grzeliński noreply at git.blender.org
Tue Aug 11 16:26:37 CEST 2020


Commit: 855b53904179b2753537a36879b886644df4f6d5
Author: Mateusz Grzeliński
Date:   Tue Aug 11 16:24:20 2020 +0200
Branches: soc-2020-info-editor
https://developer.blender.org/rB855b53904179b2753537a36879b886644df4f6d5

WIP: handle clog in separate TextViewContext

- add separate set of operators to deal with clog - they  are currently logical mirror of reports but will be expanded
- remove pointless flag RPT_FLAG_NONE
- remove active_reports from SpaceInfo as logs are no longer converted to reports

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

M	intern/clog/CLG_log.h
M	intern/clog/clog.c
M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_ui/space_info.py
M	source/blender/blenloader/intern/readfile.c
M	source/blender/editors/space_info/CMakeLists.txt
A	source/blender/editors/space_info/info_clog.c
M	source/blender/editors/space_info/info_draw.c
A	source/blender/editors/space_info/info_draw_clog.c
A	source/blender/editors/space_info/info_draw_report.c
M	source/blender/editors/space_info/info_intern.h
M	source/blender/editors/space_info/info_report.c
M	source/blender/editors/space_info/space_info.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesdna/DNA_windowmanager_types.h
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/intern/clog/CLG_log.h b/intern/clog/CLG_log.h
index b5777d1e04d..bd5b26ab9ee 100644
--- a/intern/clog/CLG_log.h
+++ b/intern/clog/CLG_log.h
@@ -152,8 +152,15 @@ typedef struct CLG_LogRecord {
   const char *file_line;
   const char *function;
   char *message;
+  /** CLG_LogRecordFlag */
+  int flag;
 } CLG_LogRecord;
 
+typedef enum CLG_LogRecordFlag {
+  CLG_SELECT = (1 << 0),
+  /*  CLG_SYNTAX_PYTHON = (1 << 1) */
+} CLG_LogRecordFlag;
+
 /** clog version of ListBase */
 typedef struct CLG_LogRecordList {
   struct CLG_LogRecord *first, *last;
@@ -209,7 +216,7 @@ enum CLG_Severity CLG_severity_level_get(void);
 void CLG_severity_level_set(enum CLG_Severity log_level);
 unsigned short CLG_level_get(void);
 void CLG_level_set(unsigned short log_level);
-struct CLG_LogRecordList *CLG_log_record_get(void);
+struct CLG_LogRecordList *CLG_log_records_get(void);
 
 void CLG_logref_init(CLG_LogRef *clg_ref);
 
diff --git a/intern/clog/clog.c b/intern/clog/clog.c
index c6ac7a17c06..54bc7cd4e59 100644
--- a/intern/clog/clog.c
+++ b/intern/clog/clog.c
@@ -829,7 +829,7 @@ static void CLG_ctx_level_set(CLogContext *ctx, unsigned short level)
   }
 }
 
-static CLG_LogRecordList *CLG_ctx_log_record_get(CLogContext *ctx)
+static CLG_LogRecordList *CLG_ctx_log_records_get(CLogContext *ctx)
 {
   return &ctx->log_records;
 }
@@ -1041,9 +1041,9 @@ unsigned short CLG_level_get()
   return CLG_ctx_level_get(g_ctx);
 }
 
-CLG_LogRecordList *CLG_log_record_get()
+CLG_LogRecordList *CLG_log_records_get()
 {
-  return CLG_ctx_log_record_get(g_ctx);
+  return CLG_ctx_log_records_get(g_ctx);
 }
 
 /** \} */
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index a882f39e295..4092737524f 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -1848,17 +1848,17 @@ def km_info(params):
     )
 
     items.extend([
-        ("info.select_pick", {"type": 'LEFTMOUSE', "value": 'CLICK'}, None),
-        ("info.select_pick", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True},
+        ("info.report_select_pick", {"type": 'LEFTMOUSE', "value": 'CLICK'}, None),
+        ("info.report_select_pick", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True},
          {"properties": [("extend", True), ("deselect_all", False)]}),
-        ("info.select_pick", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True},
+        ("info.report_select_pick", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True},
          {"properties": [("extend_range", True)]}),
-        ("info.select_pick", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True, "shift": True},
+        ("info.report_select_pick", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True, "shift": True},
          {"properties": [("deselect_all", False), ("extend_range", True)]}),
-        ("info.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
+        ("info.report_select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
          {"properties": [("wait_for_input", False)]}),
         *_template_items_select_actions(params, "info.select_all"),
-        ("info.select_box", {"type": 'B', "value": 'PRESS'}, None),
+        ("info.report_select_box", {"type": 'B', "value": 'PRESS'}, None),
         ("info.report_replay", {"type": 'R', "value": 'PRESS'}, None),
         ("info.report_delete", {"type": 'X', "value": 'PRESS'}, None),
         ("info.report_delete", {"type": 'DEL', "value": 'PRESS'}, None),
diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py
index 1739b0349ce..4de8adcab20 100644
--- a/release/scripts/startup/bl_ui/space_info.py
+++ b/release/scripts/startup/bl_ui/space_info.py
@@ -123,11 +123,17 @@ class INFO_MT_area(Menu):
 class INFO_MT_context_menu(Menu):
     bl_label = "Info Context Menu"
 
-    def draw(self, _context):
+    def draw(self, context):
         layout = self.layout
 
-        layout.operator("info.report_copy", text="Copy")
-        layout.operator("info.report_delete", text="Delete")
+        sinfo = context.space_data
+
+        if sinfo.view == 'REPORTS':
+            layout.operator("info.report_copy", text="Copy")
+            layout.operator("info.report_delete", text="Delete")
+        else:
+            layout.operator("info.clog_copy", text="Copy Message")
+            layout.operator("info.clog_delete", text="Delete (mockup)")
 
 
 class INFO_PT_log_formatting(Panel):
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 8f787afecfa..a2494bf5f4b 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -7076,10 +7076,6 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area)
       sbuts->mainbo = sbuts->mainb;
       sbuts->mainbuser = sbuts->mainb;
     }
-    else if (sl->spacetype == SPACE_INFO) {
-      SpaceInfo *sinfo = (SpaceInfo *)sl;
-      sinfo->active_reports = NULL;
-    }
     else if (sl->spacetype == SPACE_CONSOLE) {
       SpaceConsole *sconsole = (SpaceConsole *)sl;
       ConsoleLine *cl, *cl_next;
diff --git a/source/blender/editors/space_info/CMakeLists.txt b/source/blender/editors/space_info/CMakeLists.txt
index ad410e0aade..ec0f0be7731 100644
--- a/source/blender/editors/space_info/CMakeLists.txt
+++ b/source/blender/editors/space_info/CMakeLists.txt
@@ -31,6 +31,7 @@ set(INC
   ../../windowmanager
   ../../../../intern/glew-mx
   ../../../../intern/guardedalloc
+  ../../../../intern/clog
 )
 
 set(INC_SYS
@@ -39,8 +40,11 @@ set(INC_SYS
 
 set(SRC
   info_draw.c
+  info_draw_report.c
+  info_draw_clog.c
   info_ops.c
   info_report.c
+  info_clog.c
   info_stats.c
   space_info.c
   textview.c
diff --git a/source/blender/editors/space_info/info_clog.c b/source/blender/editors/space_info/info_clog.c
new file mode 100644
index 00000000000..5e331caeacf
--- /dev/null
+++ b/source/blender/editors/space_info/info_clog.c
@@ -0,0 +1,416 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup spinfo
+ */
+
+#include <BKE_report.h>
+#include <assert.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_dynstr.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_context.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_screen.h"
+#include "ED_select_utils.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "../../../../intern/clog/CLG_log.h"
+#include "info_intern.h"
+
+bool is_log_record_visible(const CLG_LogRecord *record, const SpaceInfo *sinfo)
+{
+  return true;
+}
+
+static void log_records_select_all(CLG_LogRecordList *records, const SpaceInfo *sinfo, int action)
+{
+  if (action == SEL_TOGGLE) {
+    action = SEL_SELECT;
+    for (CLG_LogRecord *record = records->last; record; record = record->prev) {
+      if (is_log_record_visible(record, sinfo) && (record->flag & CLG_SELECT)) {
+        action = SEL_DESELECT;
+        break;
+      }
+    }
+  }
+
+  for (CLG_LogRecord *record = records->last; record; record = record->prev) {
+    if (is_log_record_visible(record, sinfo)) {
+      switch (action) {
+        case SEL_SELECT:
+          record->flag |= CLG_SELECT;
+          break;
+        case SEL_DESELECT:
+          record->flag &= ~CLG_SELECT;
+          break;
+        case SEL_INVERT:
+          record->flag ^= CLG_SELECT;
+          break;
+        default:
+          BLI_assert(0);
+      }
+    }
+  }
+}
+
+static int select_clog_pick_exec(bContext *C, wmOperator *op)
+{
+  const int clog_index = RNA_int_get(op->ptr, "clog_index");
+  const bool extend = RNA_boolean_get(op->ptr, "extend");
+  const bool use_range = RNA_boolean_get(op->ptr, "extend_range");
+  const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
+
+  SpaceInfo *sinfo = CTX_wm_space_info(C);
+
+  CLG_LogRecordList *records = CLG_log_records_get();
+  CLG_LogRecord *record = BLI_findlink((const struct ListBase *)records, clog_index);
+
+  if (clog_index == INDEX_INVALID) {  // click in empty area
+    log_records_select_all(records, sinfo, SEL_DESELECT);
+    info_area_tag_redraw(C);
+    return OPERATOR_FINISHED;
+  }
+
+  if (!record) {
+    return OPERATOR_CANCELLED;
+  }
+
+  const CLG_LogRecord *active_item = BLI_findlink((const struct ListBase *)records,
+                                                  sinfo->active_index);
+  const bool is_active_item_selected = active_item ? active_item->flag & CLG_SELECT : false;
+
+  if (deselect_all) {
+    log_records_select_all(records, sinfo, SEL_DESELECT);
+  }
+
+  if (active_item == NULL) {
+    record->flag |= CLG_SELECT;
+    sinfo->active_index = clog_index;
+    info_area_tag_redraw(C);
+    return OPERATOR_FINISHED;
+  }
+
+  if (use_range) {
+    if (is_active_item_selected) {
+      if (clog_index < sinfo->active_index) {
+        for (CLG_LogRecord *i = record; i && i->prev != active_item; i = i->next) {
+          i->flag |= CLG_SELECT;
+        }
+      }
+      else {
+        for (CLG_LogRecord *record_iter = record; record_iter && record_iter->next != active_item;
+             record_iter = record_iter->prev) {
+          record_iter->flag |= CLG_SELECT;
+        }
+      }
+      info_area_tag_redraw(C);
+      return OPERATOR_FINISHED;
+    }
+    else {
+      log_records_select_all(records, sinfo, SEL_DESELECT);
+      rec

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list