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:
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/interface/interface_handlers.c55
1 files changed, 46 insertions, 9 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index f8e9476a310..cdc692373c8 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -235,12 +235,15 @@ typedef struct uiAfterFunc {
-static bool ui_is_but_interactive(uiBut *but, const bool ctrl);
+static bool ui_is_but_interactive(uiBut *but, const bool labeledit);
static bool ui_but_contains_pt(uiBut *but, int mx, int my);
static bool ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y);
static uiBut *ui_but_find_mouse_over_ex(ARegion *ar, int x, int y, bool ctrl);
static uiBut *ui_but_find_mouse_over(ARegion *ar, const wmEvent *event);
+static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type);
static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState state);
+static void button_activate_exit(bContext *C, uiBut *but, uiHandleButtonData *data,
+ const bool mousemove, const bool onfree);
static int ui_handler_region_menu(bContext *C, const wmEvent *event, 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);
@@ -3523,6 +3526,34 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
return retval;
}
+static int ui_do_but_LISTROW(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
+{
+ ARegion *ar = CTX_wm_region(C);
+
+ if (data->state == BUTTON_STATE_HIGHLIGHT) {
+ /* hack to pass on ctrl+click and double click to overlapping text
+ * editing field for editing list item names */
+ if ((ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS && event->ctrl) ||
+ (event->type == LEFTMOUSE && event->val == KM_DBL_CLICK)) {
+ uiBut *labelbut = ui_but_find_mouse_over_ex(ar, event->x, event->y, true);
+
+ if (labelbut && labelbut->type == TEX) {
+ /* exit listrow */
+ data->cancel = true;
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ button_activate_exit(C, but, data, false, false);
+
+ /* enter text editing */
+ button_activate_init(C, ar, labelbut, BUTTON_ACTIVATE_TEXT_EDITING);
+ return WM_UI_HANDLER_BREAK;
+ }
+ }
+ }
+
+ return ui_do_but_EXIT(C, but, data, event);
+}
+
+
static int ui_do_but_LISTBOX(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
{
uiList *ui_list = but->custom_data;
@@ -5678,10 +5709,12 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
case LISTBOX:
retval = ui_do_but_LISTBOX(C, block, but, data, event);
break;
+ case LISTROW:
+ retval = ui_do_but_LISTROW(C, but, data, event);
+ break;
case ROUNDBOX:
case LABEL:
case ROW:
- case LISTROW:
case BUT_IMAGE:
case PROGRESSBAR:
case NODESOCKET:
@@ -5749,7 +5782,8 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
/* reset to default (generic function, only use if not handled by switch above) */
/* XXX hardcoded keymap check.... */
- if (data->state == BUTTON_STATE_HIGHLIGHT) {
+ data = but->active;
+ if (data && data->state == BUTTON_STATE_HIGHLIGHT) {
if ((retval == WM_UI_HANDLER_CONTINUE) &&
(event->type == BACKSPACEKEY && event->val == KM_PRESS))
{
@@ -5890,7 +5924,7 @@ static bool ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y)
* Can we mouse over the button or is it hidden/disabled/layout.
* Note: ctrl is kind of a hack currently, so that non-embossed TEX button behaves as a label when ctrl is not pressed.
*/
-static bool ui_is_but_interactive(uiBut *but, const bool ctrl)
+static bool ui_is_but_interactive(uiBut *but, const bool labeledit)
{
/* note, LABEL is included for highlights, this allows drags */
if ((but->type == LABEL) && but->dragpoin == NULL)
@@ -5901,7 +5935,9 @@ static bool ui_is_but_interactive(uiBut *but, const bool ctrl)
return false;
if (but->flag & UI_SCROLLED)
return false;
- if ((but->type == TEX) && (but->dt & UI_EMBOSSN) && !ctrl)
+ if ((but->type == TEX) && (but->dt & UI_EMBOSSN) && !labeledit)
+ return false;
+ if ((but->type == LISTROW) && labeledit)
return false;
return true;
@@ -5915,7 +5951,7 @@ bool ui_is_but_search_unlink_visible(uiBut *but)
}
/* x and y are only used in case event is NULL... */
-static uiBut *ui_but_find_mouse_over_ex(ARegion *ar, const int x, const int y, const bool ctrl)
+static uiBut *ui_but_find_mouse_over_ex(ARegion *ar, const int x, const int y, const bool labeledit)
{
uiBlock *block;
uiBut *but, *butover = NULL;
@@ -5932,7 +5968,7 @@ static uiBut *ui_but_find_mouse_over_ex(ARegion *ar, const int x, const int y, c
ui_window_to_block(ar, block, &mx, &my);
for (but = block->buttons.first; but; but = but->next) {
- if (ui_is_but_interactive(but, ctrl)) {
+ if (ui_is_but_interactive(but, labeledit)) {
if (ui_but_contains_pt(but, mx, my)) {
butover = but;
}
@@ -6655,9 +6691,10 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
case MOUSEMOVE:
if (ELEM(but->type, LINK, INLINK)) {
+ ARegion *ar = data->region;
but->flag |= UI_SELECT;
ui_do_button(C, block, but, event);
- ED_region_tag_redraw(data->region);
+ ED_region_tag_redraw(ar);
}
else {
/* deselect the button when moving the mouse away */
@@ -6734,7 +6771,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
/* may have been re-allocated above (eyedropper for eg) */
data = but->active;
- if (data->state == BUTTON_STATE_EXIT) {
+ if (data && data->state == BUTTON_STATE_EXIT) {
uiBut *post_but = data->postbut;
uiButtonActivateType post_type = data->posttype;