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
This commit is contained in:
parent
ef29bf9023
commit
c33a005297
Notes:
blender-bot
2023-02-14 06:49:57 +01:00
Referenced by issue #90862, Outliner: Wrong icon for non-py file-types
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue