Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2013-03-24 17:43:40 +0400
committerTon Roosendaal <ton@blender.org>2013-03-24 17:43:40 +0400
commit1165236f69f0ca792df05919a48ae4058746d9bd (patch)
tree80bbebc880ca7bea68b0239672c3debde0ce0628
parentc4ae6f2c3653faed47644713382ae78a49ef074e (diff)
Usablity:
In text editor, the CTRL+F find now opens property region (or keeps it) and activates the search button for input. That's already nice! But next step should be to do a search on exit of the button (or while typing). That's stuff I need Campbell to help with though. Notes: - Probably Py api for property buttons could get an "operator=" arg? - The warning menu "not found" should go away - I also suggest to make "wrap" search default for new editors
-rw-r--r--source/blender/editors/include/UI_interface.h2
-rw-r--r--source/blender/editors/interface/interface_handlers.c31
-rw-r--r--source/blender/editors/space_text/space_text.c15
-rw-r--r--source/blender/editors/space_text/text_header.c32
-rw-r--r--source/blender/editors/space_text/text_intern.h4
-rw-r--r--source/blender/editors/space_text/text_ops.c2
-rw-r--r--source/blender/makesdna/DNA_space_types.h2
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c2
8 files changed, 86 insertions, 4 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 3b4415703d5..a446b1d98a3 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -643,6 +643,8 @@ void uiBlockSetDrawExtraFunc(uiBlock *block,
void (*func)(const struct bContext *C, void *, void *, void *, struct rcti *rect),
void *arg1, void *arg2);
+void UI_textbutton_activate_event(const struct bContext *C, struct ARegion *ar, void *basepoin, const char *identifier);
+
void uiButSetFocusOnEnter(struct wmWindow *win, uiBut *but);
/* Autocomplete
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index b34f4c9653f..3652e569711 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -7456,4 +7456,35 @@ void UI_remove_popup_handlers(ListBase *handlers, uiPopupBlockHandle *popup)
WM_event_remove_ui_handler(handlers, ui_handler_popup, ui_handler_remove_popup, popup, FALSE);
}
+void UI_textbutton_activate_event(const bContext *C, ARegion *ar, void *basepoin, const char *identifier)
+{
+ uiBlock *block;
+ uiBut *but;
+
+ for (block = ar->uiblocks.first; block; block = block->next) {
+ for (but = block->buttons.first; but; but = but->next) {
+ if (but->type == TEX) {
+ if (but->rnaprop && but->rnapoin.data == basepoin)
+ if (strcmp(RNA_property_identifier(but->rnaprop), identifier)==0)
+ break;
+
+ }
+ }
+ if (but)
+ break;
+ }
+
+ if (but) {
+ wmWindow *win = CTX_wm_window(C);
+ wmEvent event;
+
+ event = *(win->eventstate); /* XXX huh huh? make api call */
+ event.type = EVT_BUT_OPEN;
+ event.val = KM_PRESS;
+ event.customdata = but;
+ event.customdatafree = FALSE;
+ wm_event_add(win, &event);
+
+ }
+}
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index 58e45bc766f..600cbdb326b 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -220,6 +220,8 @@ static void text_operatortypes(void)
WM_operatortype_append(TEXT_OT_replace);
WM_operatortype_append(TEXT_OT_replace_set_selected);
+ WM_operatortype_append(TEXT_OT_start_find);
+
WM_operatortype_append(TEXT_OT_to_3d_object);
WM_operatortype_append(TEXT_OT_resolve_conflict);
@@ -233,9 +235,9 @@ static void text_keymap(struct wmKeyConfig *keyconf)
wmKeyMapItem *kmi;
keymap = WM_keymap_find(keyconf, "Text Generic", SPACE_TEXT, 0);
- WM_keymap_add_item(keymap, "TEXT_OT_properties", FKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "TEXT_OT_start_find", FKEY, KM_PRESS, KM_CTRL, 0);
#ifdef __APPLE__
- WM_keymap_add_item(keymap, "TEXT_OT_properties", FKEY, KM_PRESS, KM_OSKEY, 0);
+ WM_keymap_add_item(keymap, "TEXT_OT_start_find", FKEY, KM_PRESS, KM_OSKEY, 0);
#endif
keymap = WM_keymap_find(keyconf, "Text", SPACE_TEXT, 0);
@@ -515,7 +517,16 @@ static void text_properties_area_init(wmWindowManager *wm, ARegion *ar)
static void text_properties_area_draw(const bContext *C, ARegion *ar)
{
+ SpaceText *st = CTX_wm_space_text(C);
+
ED_region_panels(C, ar, 1, NULL, -1);
+
+ /* this flag trick is make sure buttons have been added already */
+ if (st->flags & ST_FIND_ACTIVATE) {
+
+ UI_textbutton_activate_event(C, ar, st, "find_text");
+ st->flags &= ~ST_FIND_ACTIVATE;
+ }
}
/********************* registration ********************/
diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c
index 605a08e587a..aaeea40c1a5 100644
--- a/source/blender/editors/space_text/text_header.c
+++ b/source/blender/editors/space_text/text_header.c
@@ -113,6 +113,38 @@ void TEXT_OT_properties(wmOperatorType *ot)
ot->poll = text_properties_poll;
}
+static int text_text_search_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = text_has_properties_region(sa);
+ SpaceText *st = CTX_wm_space_text(C);
+
+ if (ar) {
+ if (ar->flag & RGN_FLAG_HIDDEN)
+ ED_region_toggle_hidden(C, ar);
+
+ /* cannot send a button activate yet for case when region wasn't visible yet */
+ /* flag gets checked and cleared in main draw callback */
+ st->flags |= ST_FIND_ACTIVATE;
+
+ ED_region_tag_redraw(ar);
+ }
+ return OPERATOR_FINISHED;
+}
+
+
+void TEXT_OT_start_find(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Find";
+ ot->description = "Start searching text";
+ ot->idname = "TEXT_OT_start_find";
+
+ /* api callbacks */
+ ot->exec = text_text_search_exec;
+ ot->poll = text_properties_poll;
+}
+
/******************** XXX popup menus *******************/
#if 0
diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h
index 799bc49b624..371ccfd9bd9 100644
--- a/source/blender/editors/space_text/text_intern.h
+++ b/source/blender/editors/space_text/text_intern.h
@@ -134,11 +134,15 @@ void TEXT_OT_line_number(struct wmOperatorType *ot);
void TEXT_OT_properties(struct wmOperatorType *ot);
+/* find = find indicated text */
void TEXT_OT_find(struct wmOperatorType *ot);
void TEXT_OT_find_set_selected(struct wmOperatorType *ot);
void TEXT_OT_replace(struct wmOperatorType *ot);
void TEXT_OT_replace_set_selected(struct wmOperatorType *ot);
+/* text_find = open properties, activate search button */
+void TEXT_OT_start_find(struct wmOperatorType *ot);
+
void TEXT_OT_to_3d_object(struct wmOperatorType *ot);
void TEXT_OT_resolve_conflict(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index cdbb3e7c600..b4dc4f55368 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -2966,7 +2966,7 @@ static int text_find_exec(bContext *C, wmOperator *op)
void TEXT_OT_find(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Find";
+ ot->name = "Find Next";
ot->idname = "TEXT_OT_find";
ot->description = "Find specified text";
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index a810f4219e0..e5e38d66de5 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -840,6 +840,8 @@ typedef enum eSpaceText_Flags {
ST_FIND_ALL = (1 << 6),
ST_SHOW_MARGIN = (1 << 7),
ST_MATCH_CASE = (1 << 8),
+
+ ST_FIND_ACTIVATE = (1 << 9),
} eSpaceText_Flags;
/* stext->findstr/replacestr */
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index b2647626f3a..6c129ec0a92 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -339,7 +339,7 @@ void wm_event_do_notifiers(bContext *C)
static int wm_event_always_pass(wmEvent *event)
{
/* some events we always pass on, to ensure proper communication */
- return ISTIMER(event->type) || (event->type == WINDEACTIVATE);
+ return ISTIMER(event->type) || (event->type == WINDEACTIVATE) || (event->type == EVT_BUT_OPEN);
}
/* ********************* ui handler ******************* */