[Bf-blender-cvs] [5642e1e73d6] soc-2020-info-editor: Fix clog keymap

Mateusz Grzeliński noreply at git.blender.org
Wed Aug 12 11:48:46 CEST 2020


Commit: 5642e1e73d6251693950e26d1c8b3ca788e41616
Author: Mateusz Grzeliński
Date:   Wed Aug 12 11:48:38 2020 +0200
Branches: soc-2020-info-editor
https://developer.blender.org/rB5642e1e73d6251693950e26d1c8b3ca788e41616

Fix clog keymap

Follow up to 855b5390417 (previous commit)

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

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	source/blender/editors/space_info/info_clog.c
M	source/blender/editors/space_info/info_draw_clog.c
M	source/blender/editors/space_info/info_intern.h
M	source/blender/editors/space_info/info_report.c
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 4092737524f..8fc9ba43c48 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -1857,12 +1857,28 @@ def km_info(params):
          {"properties": [("deselect_all", False), ("extend_range", True)]}),
         ("info.report_select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
          {"properties": [("wait_for_input", False)]}),
-        *_template_items_select_actions(params, "info.select_all"),
+        *_template_items_select_actions(params, "info.report_select_all"),
         ("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),
         ("info.report_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
+
+        ("info.clog_select_pick", {"type": 'LEFTMOUSE', "value": 'CLICK'}, None),
+        ("info.clog_select_pick", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True},
+         {"properties": [("extend", True), ("deselect_all", False)]}),
+        ("info.clog_select_pick", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True},
+         {"properties": [("extend_range", True)]}),
+        ("info.clog_select_pick", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True, "shift": True},
+         {"properties": [("deselect_all", False), ("extend_range", True)]}),
+        ("info.clog_select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
+         {"properties": [("wait_for_input", False)]}),
+        *_template_items_select_actions(params, "info.clog_select_all"),
+        ("info.clog_select_box", {"type": 'B', "value": 'PRESS'}, None),
+        ("info.clog_delete", {"type": 'X', "value": 'PRESS'}, None),
+        ("info.clog_delete", {"type": 'DEL', "value": 'PRESS'}, None),
+        ("info.clog_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
+
         *_template_items_context_menu("INFO_MT_context_menu", params.context_menu_event),
     ])
 
diff --git a/source/blender/editors/space_info/info_clog.c b/source/blender/editors/space_info/info_clog.c
index 5e331caeacf..5c7c9694e9e 100644
--- a/source/blender/editors/space_info/info_clog.c
+++ b/source/blender/editors/space_info/info_clog.c
@@ -18,7 +18,6 @@
  * \ingroup spinfo
  */
 
-#include <BKE_report.h>
 #include <assert.h>
 #include <limits.h>
 #include <stdlib.h>
@@ -41,11 +40,18 @@
 #include "RNA_access.h"
 #include "RNA_define.h"
 
-#include "../../../../intern/clog/CLG_log.h"
+#include "CLG_log.h"
 #include "info_intern.h"
 
+bool ED_operator_info_clog_active(bContext *C)
+{
+  const SpaceInfo *sinfo = CTX_wm_space_info(C);
+  return ED_operator_info_active(C) && sinfo->view == INFO_VIEW_CLOG;
+}
+
 bool is_log_record_visible(const CLG_LogRecord *record, const SpaceInfo *sinfo)
 {
+  UNUSED_VARS(record, sinfo);
   return true;
 }
 
@@ -181,7 +187,7 @@ void INFO_OT_clog_select_pick(wmOperatorType *ot)
   ot->idname = "INFO_OT_clog_select_pick";
 
   /* api callbacks */
-  ot->poll = ED_operator_info_active;
+  ot->poll = ED_operator_info_clog_active;
   ot->invoke = select_clog_pick_invoke;
   ot->exec = select_clog_pick_exec;
 
@@ -232,7 +238,7 @@ void INFO_OT_clog_select_all(wmOperatorType *ot)
   ot->idname = "INFO_OT_clog_select_all";
 
   /* api callbacks */
-  ot->poll = ED_operator_info_active;
+  ot->poll = ED_operator_info_clog_active;
   ot->exec = clog_select_all_exec;
 
   /* properties */
@@ -245,7 +251,7 @@ static int box_select_exec(bContext *C, wmOperator *op)
   SpaceInfo *sinfo = CTX_wm_space_info(C);
   ARegion *region = CTX_wm_region(C);
   CLG_LogRecordList *records = CLG_log_records_get();
-  CLG_LogRecord *report_min, *report_max;
+  CLG_LogRecord *record_min, *record_max;
   rcti rect;
 
   WM_operator_properties_border_to_rcti(op, &rect);
@@ -262,39 +268,39 @@ static int box_select_exec(bContext *C, wmOperator *op)
   }
 
   BLI_assert(sinfo->view == INFO_VIEW_CLOG);
-  report_min = info_text_pick(sinfo, region, NULL, rect.ymax);
-  report_max = info_text_pick(sinfo, region, NULL, rect.ymin);
+  record_min = info_text_pick(sinfo, region, NULL, rect.ymax);
+  record_max = info_text_pick(sinfo, region, NULL, rect.ymin);
 
-  if (report_min == NULL && report_max == NULL) {
+  if (record_min == NULL && record_max == NULL) {
     log_records_select_all(records, sinfo, SEL_DESELECT);
   }
   else {
     /* get the first record if none found */
-    if (report_min == NULL) {
+    if (record_min == NULL) {
       // printf("find_min\n");
       LISTBASE_FOREACH (CLG_LogRecord *, record, records) {
         if (is_log_record_visible(record, sinfo)) {
-          report_min = record;
+          record_min = record;
           break;
         }
       }
     }
 
-    if (report_max == NULL) {
+    if (record_max == NULL) {
       // printf("find_max\n");
       for (CLG_LogRecord *record = records->last; record; record = record->prev) {
         if (is_log_record_visible(record, sinfo)) {
-          report_max = record;
+          record_max = record;
           break;
         }
       }
     }
 
-    if (report_min == NULL || report_max == NULL) {
+    if (record_min == NULL || record_max == NULL) {
       return OPERATOR_CANCELLED;
     }
 
-    for (CLG_LogRecord *record = report_min; (record != report_max->next); record = record->next) {
+    for (CLG_LogRecord *record = record_min; (record != record_max->next); record = record->next) {
       if (!is_log_record_visible(record, sinfo)) {
         continue;
       }
@@ -320,7 +326,7 @@ void INFO_OT_clog_select_box(wmOperatorType *ot)
   ot->modal = WM_gesture_box_modal;
   ot->cancel = WM_gesture_box_cancel;
 
-  ot->poll = ED_operator_info_active;
+  ot->poll = ED_operator_info_clog_active;
 
   /* flags */
   /* ot->flag = OPTYPE_REGISTER; */
@@ -334,13 +340,11 @@ static int clog_delete_exec(bContext *C, wmOperator *UNUSED(op))
 {
   SpaceInfo *sinfo = CTX_wm_space_info(C);
   CLG_LogRecordList *records = CLG_log_records_get();
-  int clog_mask = info_report_mask(sinfo);
 
-  CLG_LogRecord *record, *report_next;
+  CLG_LogRecord *record, *record_next;
 
   for (record = records->first; record;) {
-
-    report_next = record->next;
+    record_next = record->next;
 
     if (is_log_record_visible(record, sinfo) && (record->flag & CLG_SELECT)) {
       printf("NOT IMPLEMENTED YET");
@@ -349,7 +353,7 @@ static int clog_delete_exec(bContext *C, wmOperator *UNUSED(op))
       //      MEM_freeN(record);
     }
 
-    record = report_next;
+    record = record_next;
   }
   info_area_tag_redraw(C);
 
@@ -359,12 +363,12 @@ static int clog_delete_exec(bContext *C, wmOperator *UNUSED(op))
 void INFO_OT_clog_delete(wmOperatorType *ot)
 {
   /* identifiers */
-  ot->name = "Delete Reports";
-  ot->description = "Delete selected records";
+  ot->name = "Delete Log Records";
+  ot->description = "Delete selected log records";
   ot->idname = "INFO_OT_clog_delete";
 
   /* api callbacks */
-  ot->poll = ED_operator_info_active;
+  ot->poll = ED_operator_info_clog_active;
   ot->exec = clog_delete_exec;
 
   /* flags */
@@ -401,12 +405,12 @@ static int clog_copy_exec(bContext *C, wmOperator *UNUSED(op))
 void INFO_OT_clog_copy(wmOperatorType *ot)
 {
   /* identifiers */
-  ot->name = "Copy Reports to Clipboard";
-  ot->description = "Copy selected records to Clipboard";
+  ot->name = "Copy Log Message to Clipboard";
+  ot->description = "Copy selected log records to Clipboard";
   ot->idname = "INFO_OT_clog_copy";
 
   /* api callbacks */
-  ot->poll = ED_operator_info_active;
+  ot->poll = ED_operator_info_clog_active;
   ot->exec = clog_copy_exec;
 
   /* flags */
diff --git a/source/blender/editors/space_info/info_draw_clog.c b/source/blender/editors/space_info/info_draw_clog.c
index c5f6a854bd2..4fa6d62091a 100644
--- a/source/blender/editors/space_info/info_draw_clog.c
+++ b/source/blender/editors/space_info/info_draw_clog.c
@@ -49,7 +49,11 @@ enum eTextViewContext_LineFlag clog_line_draw_data(struct TextViewContext *tvc,
                                                    uchar r_icon_fg[4],
                                                    uchar r_icon_bg[4])
 {
+  const SpaceInfo *sinfo = tvc->arg1;
+  const CLG_LogRecordList *records = tvc->arg2;
   const CLG_LogRecord *record = tvc->iter;
+  const CLG_LogRecord *active_record = BLI_findlink((const struct ListBase *)records,
+                                                    sinfo->active_index);
   int data_flag = 0;
 
   /* Same text color no matter what type of record. */
@@ -57,13 +61,19 @@ enum eTextViewContext_LineFlag clog_line_draw_data(struct TextViewContext *tvc,
   data_flag = TVC_LINE_FG_SIMPLE;
 
   /* Zebra striping for background, only for deselected records. */
-  if (tvc->iter_tmp % 2) {
-    UI_GetThemeColor4ubv(TH_BACK, bg);
+  if (record->flag & CLG_SELECT) {
+    int bg_id = (record == active_record) ? TH_INFO_ACTIVE : TH_INFO_SELECTED;
+    UI_GetThemeColor4ubv(bg_id, bg);
   }
   else {
-    float col_alternating[4];
-    UI_GetThemeColor4fv(TH_ROW_ALTERNATE, col_alternating);
-    UI_GetThemeColorBlend4ubv(TH_BACK, TH_ROW_ALTERNATE, col_alternating[3], bg);
+    if (tvc->iter_tmp % 2) {
+      UI_GetThemeColor4ubv(TH_BACK, bg);
+    }
+    else {
+      float col_alternating[4];
+      UI_GetThemeColor4fv(TH_ROW_ALTERNATE, col_alternating);
+      UI_GetThemeColorBlend4ubv(TH_BACK, TH_ROW_ALTERNATE, col_alternating[3], bg);
+    }
   }
 
   /* Icon color and background depend of record type. */
@@ -107,12 +117,10 @@ enum eTextViewContext_LineFlag clog_line_draw_data(struct TextViewContext *tvc,
     *r_icon = ICON_NONE;
   }
 
-  /* how to implement selection with logs?
-    if (record->flag & RPT_SELECT) {
-      icon_fg_id = TH_INFO_SELECTED;
-      icon_bg_id = TH_INFO_SELECTED_TEXT;
-    }
-  */
+  if (record->flag & CLG_SELECT) {
+    icon_fg_id = TH_INFO_SELECTED;
+    icon_bg_id = TH_INFO_SELECTED_TEXT;
+  }
 
   if (*r_icon != ICON_NONE) {


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list