[Bf-blender-cvs] [c33a005297e] master: Texts in Outliner dont activate

Philipp Oeser noreply at git.blender.org
Wed Sep 29 15:12:40 CEST 2021


Commit: c33a005297ea21d0afafea96579d13607b309d7d
Author: Philipp Oeser
Date:   Mon Sep 6 16:48:39 2021 +0200
Branches: master
https://developer.blender.org/rBc33a005297ea21d0afafea96579d13607b309d7d

Texts in Outliner dont activate

Texts in Outliner dont activate on selecting (Text Editor did not change
to selected text) which is a bit inconsistent to other ID types.

ref T90862

Maniphest Tasks: T90862

Differential Revision: https://developer.blender.org/D12412

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

M	source/blender/editors/include/ED_text.h
M	source/blender/editors/interface/interface_ops.c
M	source/blender/editors/space_outliner/outliner_select.c
M	source/blender/editors/space_text/text_draw.c

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

diff --git a/source/blender/editors/include/ED_text.h b/source/blender/editors/include/ED_text.h
index 2284c82b3d5..6e012ec1a91 100644
--- a/source/blender/editors/include/ED_text.h
+++ b/source/blender/editors/include/ED_text.h
@@ -34,6 +34,8 @@ struct UndoStep;
 struct UndoType;
 struct bContext;
 
+bool ED_text_activate_in_screen(struct bContext *C, struct Text *text);
+
 void ED_text_scroll_to_cursor(struct SpaceText *st, struct ARegion *region, bool center);
 
 bool ED_text_region_location_from_cursor(struct SpaceText *st,
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index dd10d942fc9..7b59a6f7263 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -1381,16 +1381,7 @@ static int editsource_text_edit(bContext *C,
 
   /* naughty!, find text area to set, not good behavior
    * but since this is a developer tool lets allow it - campbell */
-  ScrArea *area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0);
-  if (area) {
-    SpaceText *st = area->spacedata.first;
-    ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
-    st->text = text;
-    if (region) {
-      ED_text_scroll_to_cursor(st, region, true);
-    }
-  }
-  else {
+  if (!ED_text_activate_in_screen(C, text)) {
     BKE_reportf(op->reports, RPT_INFO, "See '%s' in the text editor", text->id.name + 2);
   }
 
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 581892ebb3a..5e409db0059 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -34,6 +34,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_sequence_types.h"
 #include "DNA_shader_fx_types.h"
+#include "DNA_text_types.h"
 
 #include "BLI_listbase.h"
 #include "BLI_utildefines.h"
@@ -63,6 +64,7 @@
 #include "ED_screen.h"
 #include "ED_select_utils.h"
 #include "ED_sequencer.h"
+#include "ED_text.h"
 #include "ED_undo.h"
 
 #include "SEQ_select.h"
@@ -737,6 +739,12 @@ static void tree_element_layer_collection_activate(bContext *C, TreeElement *te)
   WM_main_add_notifier(NC_SCENE | ND_LAYER | NS_LAYER_COLLECTION | NA_ACTIVATED, NULL);
 }
 
+static void tree_element_text_activate(bContext *C, TreeElement *te)
+{
+  Text *text = (Text *)te->store_elem->id;
+  ED_text_activate_in_screen(C, text);
+}
+
 /* ---------------------------------------------- */
 
 /* generic call for ID data check or make/check active in UI */
@@ -764,6 +772,9 @@ void tree_element_activate(bContext *C,
     case ID_CA:
       tree_element_camera_activate(C, tvc->scene, te);
       break;
+    case ID_TXT:
+      tree_element_text_activate(C, te);
+      break;
   }
 }
 
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 99fcb2092c3..b541b65d676 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -48,6 +48,9 @@
 #include "text_format.h"
 #include "text_intern.h"
 
+#include "WM_api.h"
+#include "WM_types.h"
+
 /******************** text font drawing ******************/
 
 typedef struct TextDrawContext {
@@ -1734,6 +1737,23 @@ void text_update_character_width(SpaceText *st)
   text_font_end(&tdc);
 }
 
+bool ED_text_activate_in_screen(bContext *C, Text *text)
+{
+  ScrArea *area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0);
+  if (area) {
+    SpaceText *st = area->spacedata.first;
+    ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
+    st->text = text;
+    if (region) {
+      ED_text_scroll_to_cursor(st, region, true);
+    }
+    WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text);
+    return true;
+  }
+
+  return false;
+}
+
 /* Moves the view to the cursor location,
  * also used to make sure the view isn't outside the file */
 void ED_text_scroll_to_cursor(SpaceText *st, ARegion *region, const bool center)



More information about the Bf-blender-cvs mailing list