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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-12 06:06:15 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-12 06:06:15 +0400
commit3116062a828e24ed2e91c219ab338a38030f2f42 (patch)
treefe77a0722deaee3afd521b4a596bbe5c1c827b2e /source/blender/editors/interface/interface_handlers.c
parent8b9bb47a3faf753cb0ca2ec0e9c6a741c7af31c2 (diff)
2.5: Couple of small fun features
* Text window font size now supports full range 8-32, instead of just 12 and 15. I added BLF_fixed_width to get the character width of a fixed size font. * Buttons do undo push on change again. * Animated/Keyframe/Driver colors are now themable, with blend value to blend with original color. Set this to 0.5 now to give colors less constrast. * Fix tooltip popping up with RMB menu open, and missing redraw. * Autokeyframe now works for buttons. * Driver expressions can be edited in place in a button now. (still some refresh issues). * Also made python driver default for the Add Driver function in the RMB button. This way you don't have to open a Graph editor if you just want to type an expression. Also, the default expression then is the current value. * Tooltips now show some extra info, not sure what is good to have, but currently I added: * Shortcut key for operator buttons. * Python struct & property name for RNA buttons. * Expression for driven values. * Value for text/search/pointer buttons.
Diffstat (limited to 'source/blender/editors/interface/interface_handlers.c')
-rw-r--r--source/blender/editors/interface/interface_handlers.c82
1 files changed, 66 insertions, 16 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index e0ce6a7a83f..10e495cde94 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -32,6 +32,7 @@
#include "DNA_color_types.h"
#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_texture_types.h"
#include "DNA_userdef_types.h"
@@ -49,6 +50,7 @@
#include "BKE_utildefines.h"
#include "ED_screen.h"
+#include "ED_util.h"
#include "UI_interface.h"
@@ -166,6 +168,10 @@ typedef struct uiAfterFunc {
PropertyRNA *rnaprop;
bContextStore *context;
+
+ char undostr[512];
+
+ int autokey;
} uiAfterFunc;
static int ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y);
@@ -174,6 +180,7 @@ static int ui_handler_region_menu(bContext *C, wmEvent *event, void *userdata);
static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata);
static void ui_handler_remove_popup(bContext *C, void *userdata);
static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type);
+static void button_timers_tooltip_remove(bContext *C, uiBut *but);
/* ******************** menu navigation helpers ************** */
@@ -271,6 +278,32 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
}
}
+static void ui_apply_autokey_undo(bContext *C, uiBut *but)
+{
+ Scene *scene= CTX_data_scene(C);
+ uiAfterFunc *after;
+ char *str= NULL;
+
+ if ELEM5(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX);
+ else {
+ /* define which string to use for undo */
+ if ELEM(but->type, LINK, INLINK) str= "Add button link";
+ else if ELEM(but->type, MENU, ICONTEXTROW) str= but->drawstr;
+ else if(but->drawstr[0]) str= but->drawstr;
+ else str= but->tip;
+ }
+
+ /* delayed, after all other funcs run, popups are closed, etc */
+ if(str) {
+ after= MEM_callocN(sizeof(uiAfterFunc), "uiAfterFunc");
+ BLI_strncpy(after->undostr, str, sizeof(after->undostr));
+ BLI_addtail(&UIAfterFuncs, after);
+ }
+
+ /* try autokey */
+ ui_but_anim_autokey(but, scene, scene->r.cfra);
+}
+
static void ui_apply_but_funcs_after(bContext *C)
{
uiAfterFunc *afterf, after;
@@ -311,6 +344,9 @@ static void ui_apply_but_funcs_after(bContext *C)
after.handle_func(C, after.handle_func_arg, after.retval);
if(after.butm_func)
after.butm_func(C, after.butm_func_arg, after.a2);
+
+ if(after.undostr[0])
+ ED_undo_push(C, after.undostr);
}
}
@@ -1324,7 +1360,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
but->editstr= data->str;
but->pos= strlen(data->str);
but->selsta= 0;
- but->selend= strlen(but->drawstr) - strlen(but->str);
+ but->selend= strlen(data->str);
/* optional searchbox */
if(but->type==SEARCH_MENU) {
@@ -1539,7 +1575,8 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
}
if(changed) {
- if(data->interactive) ui_apply_button(C, block, but, data, 1);
+ /* never update while typing for now */
+ if(0/*data->interactive*/) ui_apply_button(C, block, but, data, 1);
else ui_check_but(but);
if(data->searchbox)
@@ -3090,6 +3127,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
}
/* handle menu */
else if(event->type == RIGHTMOUSE && event->val == KM_PRESS) {
+ button_timers_tooltip_remove(C, but);
ui_but_anim_menu(C, but);
return WM_UI_HANDLER_BREAK;
}
@@ -3315,6 +3353,27 @@ static int button_modal_state(uiHandleButtonState state)
BUTTON_STATE_TEXT_SELECTING, BUTTON_STATE_MENU_OPEN);
}
+static void button_timers_tooltip_remove(bContext *C, uiBut *but)
+{
+ uiHandleButtonData *data;
+
+ data= but->active;
+
+ if(data->tooltiptimer) {
+ WM_event_remove_window_timer(data->window, data->tooltiptimer);
+ data->tooltiptimer= NULL;
+ }
+ if(data->tooltip) {
+ ui_tooltip_free(C, data->tooltip);
+ data->tooltip= NULL;
+ }
+
+ if(data->autoopentimer) {
+ WM_event_remove_window_timer(data->window, data->autoopentimer);
+ data->autoopentimer= NULL;
+ }
+}
+
static void button_tooltip_timer_reset(uiBut *but)
{
uiHandleButtonData *data;
@@ -3362,20 +3421,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
}
else {
but->flag |= UI_SELECT;
-
- if(data->tooltiptimer) {
- WM_event_remove_window_timer(data->window, data->tooltiptimer);
- data->tooltiptimer= NULL;
- }
- if(data->tooltip) {
- ui_tooltip_free(C, data->tooltip);
- data->tooltip= NULL;
- }
-
- if(data->autoopentimer) {
- WM_event_remove_window_timer(data->window, data->autoopentimer);
- data->autoopentimer= NULL;
- }
+ button_timers_tooltip_remove(C, but);
}
/* text editing */
@@ -3502,6 +3548,10 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
}
}
+ /* autokey & undo push */
+ if(!data->cancel)
+ ui_apply_autokey_undo(C, but);
+
/* disable tooltips until mousemove */
ui_blocks_set_tooltips(data->region, 0);