diff options
Diffstat (limited to 'source/blender/editors/interface/interface_handlers.c')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 470 |
1 files changed, 235 insertions, 235 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 6332d006dbb..d597fde767f 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4,7 +4,7 @@ * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -17,7 +17,7 @@ * * The Original Code is Copyright (C) 2008 Blender Foundation. * All rights reserved. - * + * * Contributor(s): Blender Foundation * * ***** END GPL LICENSE BLOCK ***** @@ -296,7 +296,7 @@ typedef struct uiHandleButtonData { /* tooltip */ unsigned int tooltip_force : 1; - + /* auto open */ bool used_mouse; wmTimer *autoopentimer; @@ -338,7 +338,7 @@ typedef struct uiHandleButtonData { /* menu open (watch UI_screen_free_active_but) */ uiPopupBlockHandle *menu; int menuretval; - + /* search box (watch UI_screen_free_active_but) */ ARegion *searchbox; #ifdef USE_KEYNAV_LIMIT @@ -365,14 +365,14 @@ typedef struct uiAfterFunc { uiButHandleFunc func; void *func_arg1; void *func_arg2; - + uiButHandleNFunc funcN; void *func_argN; uiButHandleRenameFunc rename_func; void *rename_arg1; void *rename_orig; - + uiBlockHandleFunc handle_func; void *handle_func_arg; int retval; @@ -459,18 +459,18 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val) } else { lastdy += dy; - + if (ABS(lastdy) > (int)UI_UNIT_Y) { if (U.uiflag2 & USER_TRACKPAD_NATURAL) dy = -dy; - + *val = KM_PRESS; - + if (dy > 0) *type = WHEELUPMOUSE; else *type = WHEELDOWNMOUSE; - + lastdy = 0; } } @@ -537,7 +537,7 @@ static uiBut *ui_but_next(uiBut *but) static uiBut *ui_but_first(uiBlock *block) { uiBut *but; - + but = block->buttons.first; while (but) { if (ui_but_is_editable(but)) return but; @@ -549,7 +549,7 @@ static uiBut *ui_but_first(uiBlock *block) static uiBut *ui_but_last(uiBlock *block) { uiBut *but; - + but = block->buttons.last; while (but) { if (ui_but_is_editable(but)) return but; @@ -606,7 +606,7 @@ static void ui_mouse_scale_warp( float *r_mx, float *r_my, const bool shift) { const float fac = ui_mouse_scale_warp_factor(shift); - + /* slow down the mouse, this is fairly picky */ *r_mx = (data->dragstartx * (1.0f - fac) + mx * fac); *r_my = (data->dragstarty * (1.0f - fac) + my * fac); @@ -717,7 +717,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but) after->butm_func_arg = block->butm_func_arg; after->a2 = but->a2; } - + if (block->handle) after->popup_op = block->handle->popup_op; @@ -832,17 +832,17 @@ static void ui_apply_but_funcs_after(bContext *C) after.funcN(C, after.func_argN, after.func_arg2); if (after.func_argN) MEM_freeN(after.func_argN); - + if (after.handle_func) 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.rename_func) after.rename_func(C, after.rename_arg1, after.rename_orig); if (after.rename_orig) MEM_freeN(after.rename_orig); - + if (after.undostr[0]) ED_undo_push(C, after.undostr); } @@ -880,32 +880,32 @@ static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data) { double value; int w, lvalue, push; - + value = ui_but_value_get(but); lvalue = (int)value; - + if (but->bit) { w = UI_BITBUT_TEST(lvalue, but->bitnr); if (w) lvalue = UI_BITBUT_CLR(lvalue, but->bitnr); else lvalue = UI_BITBUT_SET(lvalue, but->bitnr); - + ui_but_value_set(but, (double)lvalue); if (but->type == UI_BTYPE_ICON_TOGGLE || but->type == UI_BTYPE_ICON_TOGGLE_N) { ui_but_update_edited(but); } } else { - + if (value == 0.0) push = 1; else push = 0; - + if (ELEM(but->type, UI_BTYPE_TOGGLE_N, UI_BTYPE_ICON_TOGGLE_N, UI_BTYPE_CHECKBOX_N)) push = !push; ui_but_value_set(but, (double)push); if (but->type == UI_BTYPE_ICON_TOGGLE || but->type == UI_BTYPE_ICON_TOGGLE_N) { ui_but_update_edited(but); } } - + ui_apply_but_func(C, but); data->retval = but->retval; @@ -1705,11 +1705,11 @@ static bool ui_but_contains_point_px_icon(uiBut *but, ARegion *ar, const wmEvent { rcti rect; int x = event->x, y = event->y; - + ui_window_to_block(ar, but->block, &x, &y); - + BLI_rcti_rctf_copy(&rect, &but->rect); - + if (but->imb || but->type == UI_BTYPE_COLOR) { /* use button size itself */ } @@ -1721,7 +1721,7 @@ static bool ui_but_contains_point_px_icon(uiBut *but, ARegion *ar, const wmEvent rect.xmin += delta / 2; rect.xmax -= delta / 2; } - + return BLI_rcti_isect_pt(&rect, x, y); } @@ -1812,7 +1812,7 @@ static bool ui_but_drag_init( } return true; } - + return false; } @@ -2028,13 +2028,13 @@ static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleB { wmDrag *wmd; ListBase *drags = event->customdata; /* drop event type has listbase customdata by default */ - + for (wmd = drags->first; wmd; wmd = wmd->next) { if (wmd->type == WM_DRAG_ID) { /* align these types with UI_but_active_drop_name */ if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) { ID *id = (ID *)wmd->poin; - + button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); ui_textedit_string_set(but, data, id->name + 2); @@ -2048,7 +2048,7 @@ static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleB } } } - + } /* ******************* copy and paste ******************** */ @@ -2086,7 +2086,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, /* numeric value */ if (ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER)) { - + if (but->poin == NULL && but->rnapoin.data == NULL) { /* pass */ } @@ -2189,7 +2189,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, /* RGB triple */ else if (but->type == UI_BTYPE_COLOR) { float rgba[4]; - + if (but->poin == NULL && but->rnapoin.data == NULL) { /* pass */ } @@ -2200,7 +2200,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, rgba[3] = RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3); else rgba[3] = 1.0f; - + ui_but_v3_get(but, rgba); /* convert to linear color to do compatible copy between gamma and non-gamma */ if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) @@ -2208,7 +2208,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, BLI_snprintf(buf_copy, sizeof(buf_copy), "[%f, %f, %f, %f]", rgba[0], rgba[1], rgba[2], rgba[3]); WM_clipboard_text_set(buf_copy, 0); - + } else { if (sscanf(buf_paste, "[%f, %f, %f, %f]", &rgba[0], &rgba[1], &rgba[2], &rgba[3]) == 4) { @@ -2350,7 +2350,7 @@ static int ui_text_position_from_hidden(uiBut *but, int pos) for (i = 0, strpos = butstr; i < pos; i++) strpos = BLI_str_find_next_char_utf8(strpos, NULL); - + return (strpos - butstr); } @@ -2448,7 +2448,7 @@ static bool ui_textedit_delete_selection(uiBut *but, uiHandleButtonData *data) memmove(str + but->selsta, str + but->selend, (len - but->selend) + 1); changed = true; } - + but->pos = but->selend = but->selsta; return changed; } @@ -2479,7 +2479,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con if (fstyle->kerning == 1) /* for BLF_width */ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); - + ui_but_text_password_hide(password_str, but, false); if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) { @@ -2489,13 +2489,13 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con } /* but this extra .05 makes clicks inbetween characters feel nicer */ startx += ((UI_TEXT_MARGIN_X + 0.05f) * U.widget_unit) / aspect; - + /* mouse dragged outside the widget to the left */ if (x < startx) { int i = but->ofs; str_last = &str[but->ofs]; - + while (i > 0) { if (BLI_str_cursor_step_prev_utf8(str, but->ofs, &i)) { /* 0.25 == scale factor for less sensitivity */ @@ -2517,7 +2517,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con /* keep track of previous distance from the cursor to the char */ float cdist, cdist_prev = 0.0f; short pos_prev; - + str_last = &str[strlen(str)]; but->pos = pos_prev = ((str_last - str) - but->ofs); @@ -2550,10 +2550,10 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con but->pos += but->ofs; if (but->pos < 0) but->pos = 0; } - + if (fstyle->kerning == 1) BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT); - + ui_but_text_password_hide(password_str, but, true); fstyle->points = fstyle_points_prev; @@ -2789,7 +2789,7 @@ static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const in char *pbuf; bool changed = false; int buf_len; - + /* paste */ if (mode == UI_TEXTEDIT_PASTE) { /* extract the first line from the clipboard */ @@ -2816,7 +2816,7 @@ static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const in BLI_strncpy(buf, data->str + but->selsta, sellen + 1); WM_clipboard_text_set(buf, 0); MEM_freeN(buf); - + /* for cut only, delete the selection afterwards */ if (mode == UI_TEXTEDIT_CUT) { if ((but->selend - but->selsta) > 0) { @@ -2972,7 +2972,7 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data) printf("%s: invalid utf8 - stripped chars %d\n", __func__, strip); } } - + if (data->searchbox) { if (data->cancel == false) { if ((ui_searchbox_apply(but, data->searchbox) == false) && @@ -2991,11 +2991,11 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data) MEM_SAFE_FREE(but->search_arg); } } - + but->editstr = NULL; but->pos = -1; } - + WM_cursor_modal_restore(win); #ifdef WITH_INPUT_IME @@ -3092,7 +3092,7 @@ static void ui_do_but_textedit( ui_searchbox_event(C, data->searchbox, but, event); #endif } - + break; case RIGHTMOUSE: case ESCKEY: @@ -3112,7 +3112,7 @@ static void ui_do_but_textedit( case LEFTMOUSE: { bool had_selection = but->selsta != but->selend; - + /* exit on LMB only on RELEASE for searchbox, to mimic other popups, and allow multiple menu levels */ if (data->searchbox) inbox = ui_searchbox_inside(data->searchbox, event->x, event->y); @@ -3142,7 +3142,7 @@ static void ui_do_but_textedit( retval = WM_UI_HANDLER_BREAK; } } - + /* only select a word in button if there was no selection before */ if (event->val == KM_DBL_CLICK && had_selection == false) { ui_textedit_move(but, data, STRCUR_DIR_PREV, false, STRCUR_JUMP_DELIM); @@ -3239,7 +3239,7 @@ static void ui_do_but_textedit( event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE); retval = WM_UI_HANDLER_BREAK; break; - + case AKEY: /* Ctrl + A: Select all */ @@ -3317,7 +3317,7 @@ static void ui_do_but_textedit( } retval = WM_UI_HANDLER_BREAK; - + } /* textbutton with this flag: do live update (e.g. for search buttons) */ if (but->flag & UI_BUT_TEXTEDIT_UPDATE) { @@ -3353,7 +3353,7 @@ static void ui_do_but_textedit( ui_but_update_edited(but); } but->changed = true; - + if (data->searchbox) ui_searchbox_update(C, data->searchbox, but, true); /* true = reset */ } @@ -3550,7 +3550,7 @@ int ui_but_menu_direction(uiBut *but) if (data && data->menu) return data->menu->direction; - + return 0; } @@ -3642,7 +3642,7 @@ static int ui_do_but_HOTKEYEVT( return WM_UI_HANDLER_BREAK; } } - + /* always set */ but->modifier_key = 0; if (event->shift) but->modifier_key |= KM_SHIFT; @@ -3652,15 +3652,15 @@ static int ui_do_but_HOTKEYEVT( ui_but_update(but); ED_region_tag_redraw(data->region); - + if (event->val == KM_PRESS) { if (ISHOTKEY(event->type)) { - + if (WM_key_event_string(event->type, false)[0]) ui_but_value_set(but, event->type); else data->cancel = true; - + button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } @@ -3671,10 +3671,10 @@ static int ui_do_but_HOTKEYEVT( button_activate_state(C, but, BUTTON_STATE_EXIT); } } - + } } - + return WM_UI_HANDLER_CONTINUE; } @@ -3899,13 +3899,13 @@ static int ui_do_but_EXIT( bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { - + if (data->state == BUTTON_STATE_HIGHLIGHT) { /* first handle click on icondrag type button */ if (event->type == LEFTMOUSE && but->dragpoin) { if (ui_but_contains_point_px_icon(but, data->region, event)) { - + /* tell the button to wait and keep checking further events to * see if it should start dragging */ button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG); @@ -3934,25 +3934,25 @@ static int ui_do_but_EXIT( } } else if (data->state == BUTTON_STATE_WAIT_DRAG) { - + /* this function also ends state */ if (ui_but_drag_init(C, but, data, event)) { return WM_UI_HANDLER_BREAK; } - - /* If the mouse has been pressed and released, getting to - * this point without triggering a drag, then clear the + + /* If the mouse has been pressed and released, getting to + * this point without triggering a drag, then clear the * drag state for this button and continue to pass on the event */ if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_CONTINUE; } - - /* while waiting for a drag to be triggered, always block + + /* while waiting for a drag to be triggered, always block * other events from getting handled */ return WM_UI_HANDLER_BREAK; } - + return WM_UI_HANDLER_CONTINUE; } @@ -3966,7 +3966,7 @@ static float ui_numedit_apply_snapf( } else { float fac = 1.0f; - + if (ui_but_is_unit(but)) { UnitSettings *unit = but->block->unit; int unit_type = RNA_SUBTYPE_UNIT_VALUE(UI_but_unit_type_get(but)); @@ -4014,7 +4014,7 @@ static float ui_numedit_apply_snapf( else { BLI_assert(0); } - + if (fac != 1.0f) tempf *= fac; } @@ -4159,7 +4159,7 @@ static bool ui_numedit_but_NUM( } data->dragf += (((float)(mx - data->draglastx)) / deler) * non_linear_scale; - + CLAMP(data->dragf, 0.0f, 1.0f); data->draglastx = mx; tempf = (softmin + data->dragf * softrange); @@ -4172,7 +4172,7 @@ static bool ui_numedit_but_NUM( CLAMP(temp, softmin, softmax); lvalue = (int)data->value; - + if (temp != lvalue) { data->dragchange = true; data->value = (double)temp; @@ -4262,11 +4262,11 @@ static int ui_do_but_NUM( if (data->state == BUTTON_STATE_HIGHLIGHT) { int type = event->type, val = event->val; - + if (type == MOUSEPAN) { ui_pan_to_scroll(event, &type, &val); } - + /* XXX hardcoded keymap check.... */ if (type == MOUSEPAN && event->alt) retval = WM_UI_HANDLER_BREAK; /* allow accumulating values, otherwise scrolling gets preference */ @@ -4302,7 +4302,7 @@ static int ui_do_but_NUM( copy_v2_v2_int(data->multi_data.drag_start, &event->x); #endif } - + } else if (data->state == BUTTON_STATE_NUM_EDITING) { if (event->type == ESCKEY || event->type == RIGHTMOUSE) { @@ -4363,7 +4363,7 @@ static int ui_do_but_NUM( ui_do_but_textedit_select(C, block, but, data, event); retval = WM_UI_HANDLER_BREAK; } - + if (click) { /* we can click on the side arrows to increment/decrement, * or click inside to edit the value directly */ @@ -4426,7 +4426,7 @@ static int ui_do_but_NUM( retval = WM_UI_HANDLER_BREAK; } - + data->draglastx = mx; data->draglasty = my; @@ -4675,13 +4675,13 @@ static int ui_do_but_SLI( /* nudge slider to the left or right */ float f, tempf, softmin, softmax, softrange; int temp; - + button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); - + softmin = but->softmin; softmax = but->softmax; softrange = softmax - softmin; - + tempf = data->value; temp = (int)data->value; @@ -4694,13 +4694,13 @@ static int ui_do_but_SLI( { f = (float)(mx - but->rect.xmin) / (BLI_rctf_size_x(&but->rect)); } - + f = softmin + f * softrange; - + if (!ui_but_is_float(but)) { if (f < temp) temp--; else temp++; - + if (temp >= softmin && temp <= softmax) data->value = temp; else @@ -4709,13 +4709,13 @@ static int ui_do_but_SLI( else { if (f < tempf) tempf -= 0.01f; else tempf += 0.01f; - + if (tempf >= softmin && tempf <= softmax) data->value = tempf; else data->cancel = true; } - + button_activate_state(C, but, BUTTON_STATE_EXIT); retval = WM_UI_HANDLER_BREAK; } @@ -4728,7 +4728,7 @@ static int ui_do_but_SLI( data->draglastx = mx; data->draglasty = my; - + return retval; } @@ -4739,7 +4739,7 @@ static int ui_do_but_SCROLL( int mx, my /*, click = 0 */; int retval = WM_UI_HANDLER_CONTINUE; bool horizontal = (BLI_rctf_size_x(&but->rect) > BLI_rctf_size_y(&but->rect)); - + mx = event->x; my = event->y; ui_window_to_block(data->region, block, &mx, &my); @@ -4785,7 +4785,7 @@ static int ui_do_but_SCROLL( retval = WM_UI_HANDLER_BREAK; } - + return retval; } @@ -4868,9 +4868,9 @@ static int ui_do_but_BLOCK( bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { - + if (data->state == BUTTON_STATE_HIGHLIGHT) { - + /* first handle click on icondrag type button */ if (event->type == LEFTMOUSE && but->dragpoin && event->val == KM_PRESS) { if (ui_but_contains_point_px_icon(but, data->region, event)) { @@ -4927,19 +4927,19 @@ static int ui_do_but_BLOCK( } } else if (data->state == BUTTON_STATE_WAIT_DRAG) { - + /* this function also ends state */ if (ui_but_drag_init(C, but, data, event)) { return WM_UI_HANDLER_BREAK; } - + /* outside icon quit, not needed if drag activated */ if (0 == ui_but_contains_point_px_icon(but, data->region, event)) { button_activate_state(C, but, BUTTON_STATE_EXIT); data->cancel = true; return WM_UI_HANDLER_BREAK; } - + if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { button_activate_state(C, but, BUTTON_STATE_MENU_OPEN); return WM_UI_HANDLER_BREAK; @@ -4958,7 +4958,7 @@ static bool ui_numedit_but_UNITVEC( float dx, dy, rad, radsq, mrad, *fp; int mdx, mdy; bool changed = true; - + /* button is presumed square */ /* if mouse moves outside of sphere, it does negative normal */ @@ -4968,21 +4968,21 @@ static bool ui_numedit_but_UNITVEC( fp = data->origvec; rad = BLI_rctf_size_x(&but->rect); radsq = rad * rad; - + if (fp[2] > 0.0f) { mdx = (rad * fp[0]); mdy = (rad * fp[1]); } else if (fp[2] > -1.0f) { mrad = rad / sqrtf(fp[0] * fp[0] + fp[1] * fp[1]); - + mdx = 2.0f * mrad * fp[0] - (rad * fp[0]); mdy = 2.0f * mrad * fp[1] - (rad * fp[1]); } else { mdx = mdy = 0; } - + dx = (float)(mx + mdx - data->dragstartx); dy = (float)(my + mdy - data->dragstarty); @@ -4994,12 +4994,12 @@ static bool ui_numedit_but_UNITVEC( fp[2] = sqrtf(radsq - dx * dx - dy * dy); } else { /* outer circle */ - + mrad = rad / sqrtf(mrad); // veclen - + dx *= (2.0f * mrad - 1.0f); dy *= (2.0f * mrad - 1.0f); - + mrad = dx * dx + dy * dy; if (mrad < radsq) { fp[0] = dx; @@ -5199,7 +5199,7 @@ static int ui_do_but_UNITVEC( /* also do drag the first time */ if (ui_numedit_but_UNITVEC(but, data, mx, my, snap)) ui_numedit_apply(C, block, but, data); - + return WM_UI_HANDLER_BREAK; } } @@ -5217,7 +5217,7 @@ static int ui_do_but_UNITVEC( return WM_UI_HANDLER_BREAK; } - + return WM_UI_HANDLER_CONTINUE; } @@ -5288,30 +5288,30 @@ static bool ui_numedit_but_HSVCUBE( ui_block_cm_to_display_space_v3(but->block, rgb); ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsv); - + /* only apply the delta motion, not absolute */ if (shift) { rcti rect_i; float xpos, ypos, hsvo[3]; - + BLI_rcti_rctf_copy(&rect_i, &but->rect); - + /* calculate original hsv again */ copy_v3_v3(rgb, data->origvec); if (use_display_colorspace) ui_block_cm_to_display_space_v3(but->block, rgb); - + copy_v3_v3(hsvo, hsv); ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsvo); - + /* and original position */ ui_hsvcube_pos_from_vals(but, &rect_i, hsvo, &xpos, &ypos); - + mx_fl = xpos - (data->dragstartx - mx_fl); my_fl = ypos - (data->dragstarty - my_fl); } - + /* relative position within box */ x = ((float)mx_fl - but->rect.xmin) / BLI_rctf_size_x(&but->rect); y = ((float)my_fl - but->rect.ymin) / BLI_rctf_size_y(&but->rect); @@ -5428,10 +5428,10 @@ static void ui_ndofedit_but_HSVCUBE( case UI_GRAD_V_ALT: case UI_GRAD_L_ALT: /* vertical 'value' strip */ - + /* exception only for value strip - use the range set in but->min/max */ hsv[2] += ndof->rvec[0] * sensitivity; - + CLAMP(hsv[2], but->softmin, but->softmax); break; default: @@ -5481,19 +5481,19 @@ static int ui_do_but_HSVCUBE( /* also do drag the first time */ if (ui_numedit_but_HSVCUBE(but, data, mx, my, snap, event->shift != 0)) ui_numedit_apply(C, block, but, data); - + return WM_UI_HANDLER_BREAK; } #ifdef WITH_INPUT_NDOF else if (event->type == NDOF_MOTION) { const wmNDOFMotionData *ndof = event->customdata; const enum eSnapType snap = ui_event_to_snap(event); - + ui_ndofedit_but_HSVCUBE(but, data, ndof, snap, event->shift != 0); - + button_activate_state(C, but, BUTTON_STATE_EXIT); ui_apply_but(C, but->block, but, data, true); - + return WM_UI_HANDLER_BREAK; } #endif /* WITH_INPUT_NDOF */ @@ -5501,9 +5501,9 @@ static int ui_do_but_HSVCUBE( else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) { if (ELEM(but->a1, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) { int len; - + /* reset only value */ - + len = RNA_property_array_length(&but->rnapoin, but->rnaprop); if (ELEM(len, 3, 4)) { float rgb[3], def_hsv[3]; @@ -5519,10 +5519,10 @@ static int ui_do_but_HSVCUBE( def_hsv[0] = hsv[0]; def_hsv[1] = hsv[1]; - + ui_color_picker_to_rgb_HSVCUBE_v(but, def_hsv, rgb); ui_but_v3_set(but, rgb); - + RNA_property_update(C, &but->rnapoin, but->rnaprop); return WM_UI_HANDLER_BREAK; } @@ -5548,7 +5548,7 @@ static int ui_do_but_HSVCUBE( else if (event->type == LEFTMOUSE && event->val != KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_EXIT); } - + return WM_UI_HANDLER_BREAK; } @@ -5569,7 +5569,7 @@ static bool ui_numedit_but_HSVCIRCLE( bool use_display_colorspace = ui_but_is_colorpicker_display_space(but); ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift); - + #ifdef USE_CONT_MOUSE_CORRECT if (ui_but_is_cursor_warp(but)) { /* OK but can go outside bounds */ @@ -5609,7 +5609,7 @@ static bool ui_numedit_but_HSVCIRCLE( /* only apply the delta motion, not absolute */ if (shift) { float xpos, ypos, hsvo[3], rgbo[3]; - + /* calculate original hsv again */ copy_v3_v3(hsvo, hsv); copy_v3_v3(rgbo, data->origvec); @@ -5623,9 +5623,9 @@ static bool ui_numedit_but_HSVCIRCLE( mx_fl = xpos - (data->dragstartx - mx_fl); my_fl = ypos - (data->dragstarty - my_fl); - + } - + ui_hsvcircle_vals_from_pos(hsv, hsv + 1, &rect, mx_fl, my_fl); if ((but->flag & UI_BUT_COLOR_CUBIC) && (U.color_picker_type == USER_CP_CIRCLE_HSV)) @@ -5645,10 +5645,10 @@ static bool ui_numedit_but_HSVCIRCLE( ui_block_cm_to_scene_linear_v3(but->block, rgb); ui_but_v3_set(but, rgb); - + data->draglastx = mx; data->draglasty = my; - + return changed; } @@ -5664,28 +5664,28 @@ static void ui_ndofedit_but_HSVCIRCLE( float rgb[3]; float phi, r /*, sqr */ /* UNUSED */, v[2]; float sensitivity = (shift ? 0.06f : 0.3f) * ndof->dt; - + ui_but_v3_get(but, rgb); if (use_display_colorspace) ui_block_cm_to_display_space_v3(but->block, rgb); ui_rgb_to_color_picker_compat_v(rgb, hsv); - + /* Convert current color on hue/sat disc to circular coordinates phi, r */ phi = fmodf(hsv[0] + 0.25f, 1.0f) * -2.0f * (float)M_PI; r = hsv[1]; /* sqr = r > 0.0f ? sqrtf(r) : 1; */ /* UNUSED */ - + /* Convert to 2d vectors */ v[0] = r * cosf(phi); v[1] = r * sinf(phi); - + /* Use ndof device y and x rotation to move the vector in 2d space */ v[0] += ndof->rvec[2] * sensitivity; v[1] += ndof->rvec[0] * sensitivity; /* convert back to polar coords on circle */ phi = atan2f(v[0], v[1]) / (2.0f * (float)M_PI) + 0.5f; - + /* use ndof Y rotation to additionally rotate hue */ phi += ndof->rvec[1] * sensitivity * 0.5f; r = len_v2(v); @@ -5713,14 +5713,14 @@ static void ui_ndofedit_but_HSVCIRCLE( hsv_clamp_v(hsv, FLT_MAX); ui_color_picker_to_rgb_v(hsv, data->vec); - + if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (data->vec[0] || data->vec[1] || data->vec[2])) { normalize_v3_length(data->vec, but->a2); } if (use_display_colorspace) ui_block_cm_to_scene_linear_v3(but->block, data->vec); - + ui_but_v3_set(but, data->vec); } #endif /* WITH_INPUT_NDOF */ @@ -5735,7 +5735,7 @@ static int ui_do_but_HSVCIRCLE( mx = event->x; my = event->y; ui_window_to_block(data->region, block, &mx, &my); - + if (data->state == BUTTON_STATE_HIGHLIGHT) { if (event->type == LEFTMOUSE && event->val == KM_PRESS) { const enum eSnapType snap = ui_event_to_snap(event); @@ -5744,52 +5744,52 @@ static int ui_do_but_HSVCIRCLE( data->draglastx = mx; data->draglasty = my; button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); - + /* also do drag the first time */ if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, snap, event->shift != 0)) ui_numedit_apply(C, block, but, data); - + return WM_UI_HANDLER_BREAK; } #ifdef WITH_INPUT_NDOF else if (event->type == NDOF_MOTION) { const enum eSnapType snap = ui_event_to_snap(event); const wmNDOFMotionData *ndof = event->customdata; - + ui_ndofedit_but_HSVCIRCLE(but, data, ndof, snap, event->shift != 0); button_activate_state(C, but, BUTTON_STATE_EXIT); ui_apply_but(C, but->block, but, data, true); - + return WM_UI_HANDLER_BREAK; } #endif /* WITH_INPUT_NDOF */ /* XXX hardcoded keymap check.... */ else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) { int len; - + /* reset only saturation */ - + len = RNA_property_array_length(&but->rnapoin, but->rnaprop); if (len >= 3) { float rgb[3], def_hsv[3]; float *def; def = MEM_callocN(sizeof(float) * len, "reset_defaults - float"); - + RNA_property_float_get_default_array(&but->rnapoin, but->rnaprop, def); ui_color_picker_to_rgb_v(def, def_hsv); - + ui_but_v3_get(but, rgb); ui_rgb_to_color_picker_compat_v(rgb, hsv); - + def_hsv[0] = hsv[0]; def_hsv[2] = hsv[2]; hsv_to_rgb_v(def_hsv, rgb); ui_but_v3_set(but, rgb); - + RNA_property_update(C, &but->rnapoin, but->rnaprop); - + MEM_freeN(def); } return WM_UI_HANDLER_BREAK; @@ -5828,7 +5828,7 @@ static int ui_do_but_HSVCIRCLE( } return WM_UI_HANDLER_BREAK; } - + return WM_UI_HANDLER_CONTINUE; } @@ -5847,10 +5847,10 @@ static bool ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int m dx = ((float)(mx - data->draglastx)) / BLI_rctf_size_x(&but->rect); data->dragcbd->pos += dx; CLAMP(data->dragcbd->pos, 0.0f, 1.0f); - + BKE_colorband_update_sort(data->coba); data->dragcbd = data->coba->data + data->coba->cur; /* because qsort */ - + data->draglastx = mx; changed = true; @@ -5897,7 +5897,7 @@ static int ui_do_but_COLORBAND( mindist = xco; } } - + data->dragcbd = coba->data + coba->cur; data->dragfstart = data->dragcbd->pos; button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); @@ -5951,10 +5951,10 @@ static bool ui_numedit_but_CURVE( dragx = data->draglastx; dragy = data->draglasty; ui_window_to_block(data->region, block, &dragx, &dragy); - + zoomx = BLI_rctf_size_x(&but->rect) / BLI_rctf_size_x(&cumap->curr); zoomy = BLI_rctf_size_y(&but->rect) / BLI_rctf_size_y(&cumap->curr); - + if (snap) { float d[2]; @@ -5993,7 +5993,7 @@ static bool ui_numedit_but_CURVE( } curvemapping_changed(cumap, false); - + if (moved_point) { data->draglastx = evtx; data->draglasty = evty; @@ -6017,7 +6017,7 @@ static bool ui_numedit_but_CURVE( else { fx = (mx - dragx) / zoomx; fy = (my - dragy) / zoomy; - + /* clamp for clip */ if (cumap->flag & CUMA_DO_CLIP) { if (cumap->curr.xmin - fx < cumap->clipr.xmin) @@ -6034,7 +6034,7 @@ static bool ui_numedit_but_CURVE( cumap->curr.ymin -= fy; cumap->curr.xmax -= fx; cumap->curr.ymax -= fy; - + data->draglastx = evtx; data->draglasty = evty; @@ -6056,7 +6056,7 @@ static int ui_do_but_CURVE( mx = event->x; my = event->y; ui_window_to_block(data->region, block, &mx, &my); - + if (data->state == BUTTON_STATE_HIGHLIGHT) { if (event->type == LEFTMOUSE && event->val == KM_PRESS) { CurveMapping *cumap = (CurveMapping *)but->poin; @@ -6069,7 +6069,7 @@ static int ui_do_but_CURVE( if (event->ctrl) { float f_xy[2]; BLI_rctf_transform_pt_v(&cumap->curr, &but->rect, f_xy, m_xy); - + curvemap_insert(cuma, f_xy[0], f_xy[1]); curvemapping_changed(cumap, false); changed = true; @@ -6091,7 +6091,7 @@ static int ui_do_but_CURVE( int i; float f_xy[2], f_xy_prev[2]; - /* if the click didn't select anything, check if it's clicked on the + /* if the click didn't select anything, check if it's clicked on the * curve itself, and if so, add a point */ cmp = cuma->table; @@ -6112,10 +6112,10 @@ static int ui_do_but_CURVE( curvemapping_changed(cumap, false); changed = true; - + /* reset cmp back to the curve points again, rather than drawing segments */ cmp = cuma->curve; - + /* find newly added point and make it 'sel' */ for (a = 0; a < cuma->totpoint; a++) { if (cmp[a].x == f_xy[0]) { @@ -6146,7 +6146,7 @@ static int ui_do_but_CURVE( } data->dragsel = sel; - + data->dragstartx = event->x; data->dragstarty = event->y; data->draglastx = event->x; @@ -6159,7 +6159,7 @@ static int ui_do_but_CURVE( else if (data->state == BUTTON_STATE_NUM_EDITING) { if (event->type == MOUSEMOVE) { if (event->x != data->draglastx || event->y != data->draglasty) { - + if (ui_numedit_but_CURVE(block, but, data, event->x, event->y, event->ctrl != 0, event->shift != 0)) ui_numedit_apply(C, block, but, data); } @@ -6220,11 +6220,11 @@ static int ui_do_but_HISTOGRAM( uiHandleButtonData *data, const wmEvent *event) { int mx, my; - + mx = event->x; my = event->y; ui_window_to_block(data->region, block, &mx, &my); - + if (data->state == BUTTON_STATE_HIGHLIGHT) { if (event->type == LEFTMOUSE && event->val == KM_PRESS) { data->dragstartx = mx; @@ -6232,18 +6232,18 @@ static int ui_do_but_HISTOGRAM( data->draglastx = mx; data->draglasty = my; button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); - + /* also do drag the first time */ if (ui_numedit_but_HISTOGRAM(but, data, mx, my)) ui_numedit_apply(C, block, but, data); - + return WM_UI_HANDLER_BREAK; } /* XXX hardcoded keymap check.... */ else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) { Histogram *hist = (Histogram *)but->poin; hist->ymax = 1.f; - + button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } @@ -6267,7 +6267,7 @@ static int ui_do_but_HISTOGRAM( } return WM_UI_HANDLER_BREAK; } - + return WM_UI_HANDLER_CONTINUE; } @@ -6438,7 +6438,7 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event)) char shortcut_str[128]; IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; - + /* complex code to change name of button */ if (WM_key_event_operator_string( C, but->optype->idname, but->opcontext, prop, true, @@ -6469,18 +6469,18 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg) BLI_assert(kmi != NULL); RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr); - + block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); UI_block_func_handle_set(block, but_shortcut_name_func, but); UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT); UI_block_direction_set(block, UI_DIR_CENTER_Y); - + layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style); - + uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE); - + UI_block_bounds_set_popup(block, 6, -50, 26); - + return block; } @@ -6500,7 +6500,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg) uiStyle *style = UI_style_get_dpi(); IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; int kmi_id; - + /* XXX this guess_opname can potentially return a different keymap than being found on adding later... */ km = WM_keymap_guess_opname(C, but->optype->idname); kmi = WM_keymap_add_item(km, but->optype->idname, AKEY, KM_PRESS, 0, 0); @@ -6526,7 +6526,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg) layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style); uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE); - + UI_block_bounds_set_popup(block, 6, -50, 26); #ifdef USE_KEYMAP_ADD_HACK @@ -6575,7 +6575,7 @@ static void remove_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) BLI_assert(kmi != NULL); WM_keymap_remove_item(km, kmi); - + but_shortcut_name_func(C, but, 0); } @@ -6667,7 +6667,7 @@ static bool ui_but_menu(bContext *C, uiBut *but) if (but->type == UI_BTYPE_IMAGE) { return false; } - + /* highly unlikely getting the label ever fails */ UI_but_string_info_get(C, but, &label, NULL); @@ -6698,7 +6698,7 @@ static bool ui_but_menu(bContext *C, uiBut *but) /* determine if we can key a single component of an array */ is_array = RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0; is_array_component = (is_array && but->rnaindex != -1); - + /* Keyframes */ if (but->flag & UI_BUT_ANIMATED_KEY) { /* replace/delete keyfraemes */ @@ -6718,11 +6718,11 @@ static bool ui_but_menu(bContext *C, uiBut *but) uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Keyframe"), ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 1); } - + /* keyframe settings */ uiItemS(layout); - - + + } else if (but->flag & UI_BUT_DRIVEN) { /* pass */ @@ -6739,7 +6739,7 @@ static bool ui_but_menu(bContext *C, uiBut *but) ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1); } } - + if ((but->flag & UI_BUT_ANIMATED) && (but->rnapoin.type != &RNA_NlaStrip)) { if (is_array_component) { uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"), @@ -6774,7 +6774,7 @@ static bool ui_but_menu(bContext *C, uiBut *but) uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"), ICON_NONE, "ANIM_OT_paste_driver_button"); } - + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Drivers Editor"), ICON_DRIVER, "SCREEN_OT_drivers_editor_show"); } @@ -6785,13 +6785,13 @@ static bool ui_but_menu(bContext *C, uiBut *but) uiItemS(layout); if (is_array_component) { - uiItemMenuEnumO(layout, C, "ANIM_OT_driver_button_add", "mapping_type", - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Drivers"), + uiItemMenuEnumO(layout, C, "ANIM_OT_driver_button_add", "mapping_type", + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Drivers"), ICON_DRIVER); } else { - uiItemMenuEnumO(layout, C, "ANIM_OT_driver_button_add", "mapping_type", - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Driver"), + uiItemMenuEnumO(layout, C, "ANIM_OT_driver_button_add", "mapping_type", + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Driver"), ICON_DRIVER); } @@ -6799,11 +6799,11 @@ static bool ui_but_menu(bContext *C, uiBut *but) uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"), ICON_NONE, "ANIM_OT_paste_driver_button"); } - + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Drivers Editor"), ICON_NONE, "SCREEN_OT_drivers_editor_show"); } - + /* Keying Sets */ /* TODO: check on modifyability of Keying Set when doing this */ if (is_anim) { @@ -6879,7 +6879,7 @@ static bool ui_but_menu(bContext *C, uiBut *but) /* Copy Property Value * Paste Property Value */ - + if (is_array_component) { uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset All to Default Values"), ICON_LOOP_BACK, "UI_OT_reset_default_button", "all", 1); @@ -6894,7 +6894,7 @@ static bool ui_but_menu(bContext *C, uiBut *but) uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Unset"), ICON_NONE, "UI_OT_unset_property_button"); } - + if (is_array_component) { uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy All To Selected"), ICON_NONE, "UI_OT_copy_to_selected_button", "all", true); @@ -7382,7 +7382,7 @@ bool UI_but_active_drop_name(bContext *C) if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) return 1; } - + return 0; } @@ -7424,11 +7424,11 @@ static bool ui_region_contains_point_px(ARegion *ar, int x, int y) if (!BLI_rcti_isect_pt(&winrct, x, y)) { for (uiBlock *block = ar->uiblocks.first; block; block = block->next) block->auto_open = false; - + return false; } - /* also, check that with view2d, that the mouse is not over the scrollbars + /* also, check that with view2d, that the mouse is not over the scrollbars * NOTE: care is needed here, since the mask rect may include the scrollbars * even when they are not visible, so we need to make a copy of the mask to * use to check @@ -7436,7 +7436,7 @@ static bool ui_region_contains_point_px(ARegion *ar, int x, int y) if (ar->v2d.mask.xmin != ar->v2d.mask.xmax) { View2D *v2d = &ar->v2d; int mx, my; - + /* convert window coordinates to region coordinates */ mx = x; my = y; @@ -7447,7 +7447,7 @@ static bool ui_region_contains_point_px(ARegion *ar, int x, int y) return false; } } - + return true; } @@ -7471,7 +7471,7 @@ static bool ui_but_contains_point_px(ARegion *ar, uiBut *but, int x, int y) else if (!ui_but_contains_pt(but, mx, my)) { return false; } - + return true; } @@ -7696,7 +7696,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s but->flag |= UI_SELECT; UI_but_tooltip_timer_remove(C, but); } - + /* text editing */ if (state == BUTTON_STATE_TEXT_EDITING && data->state != BUTTON_STATE_TEXT_SELECTING) ui_textedit_begin(C, but, data); @@ -7704,7 +7704,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s ui_textedit_end(C, but, data); else if (data->state == BUTTON_STATE_TEXT_SELECTING && state != BUTTON_STATE_TEXT_EDITING) ui_textedit_end(C, but, data); - + /* number editing */ if (state == BUTTON_STATE_NUM_EDITING) { if (ui_but_is_cursor_warp(but)) @@ -7781,7 +7781,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s } } } - + /* wait for mousemove to enable drag */ if (state == BUTTON_STATE_WAIT_DRAG) { but->flag &= ~UI_SELECT; @@ -7825,7 +7825,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA data->interactive = true; } } - + data->state = BUTTON_STATE_INIT; /* activate button */ @@ -7843,14 +7843,14 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA data->used_mouse = true; } button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT); - + /* activate right away */ if (but->flag & UI_BUT_IMMEDIATE) { if (but->type == UI_BTYPE_HOTKEY_EVENT) button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT); /* .. more to be added here */ } - + if (type == BUTTON_ACTIVATE_OPEN) { button_activate_state(C, but, BUTTON_STATE_MENU_OPEN); @@ -7859,7 +7859,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA ARegion *subar = data->menu->region; uiBlock *subblock = subar->uiblocks.first; uiBut *subbut; - + if (subblock) { subbut = ui_but_first(subblock); @@ -8167,7 +8167,7 @@ void UI_context_update_anim_flag(const bContext *C) ui_but_anim_flag(but, (scene) ? scene->r.cfra : 0.0f); ui_but_override_flag(but); ED_region_tag_redraw(ar); - + if (but->active) { activebut = but; } @@ -8200,7 +8200,7 @@ static uiBut *ui_but_find_open_event(ARegion *ar, const wmEvent *event) { uiBlock *block; uiBut *but; - + for (block = ar->uiblocks.first; block; block = block->next) { for (but = block->buttons.first; but; but = but->next) if (but == event->customdata) @@ -8240,15 +8240,15 @@ void ui_but_activate_event(bContext *C, ARegion *ar, uiBut *but) { wmWindow *win = CTX_wm_window(C); wmEvent event; - + button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER); - + wm_event_init_from_window(win, &event); event.type = EVT_BUT_OPEN; event.val = KM_PRESS; event.customdata = but; event.customdatafree = false; - + ui_do_button(C, but->block, but, &event); } @@ -8346,7 +8346,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) ar = data->region; retval = WM_UI_HANDLER_CONTINUE; - + if (data->state == BUTTON_STATE_HIGHLIGHT) { switch (event->type) { case WINDEACTIVATE: @@ -8524,7 +8524,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) } bt = ui_but_find_mouse_over(ar, event); - + if (bt && bt->active != data) { if (but->type != UI_BTYPE_COLOR) { /* exception */ data->cancel = true; @@ -8753,7 +8753,7 @@ static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, u menu->menuretval = 0; } - + /* now change button state or exit, which will close the submenu */ if ((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_CANCEL)) { if (menu->menuretval != UI_RETURN_OK) @@ -8864,7 +8864,7 @@ static bool ui_mouse_motion_towards_check( p2[0] = rect_px.xmax + margin; p2[1] = rect_px.ymin - margin; - + p3[0] = rect_px.xmax + margin; p3[1] = rect_px.ymax + margin; @@ -8922,7 +8922,7 @@ static bool ui_mouse_motion_keynav_test(struct uiKeyNavLock *keynav, const wmEve static char ui_menu_scroll_test(uiBlock *block, int my) { if (block->flag & (UI_BLOCK_CLIPTOP | UI_BLOCK_CLIPBOTTOM)) { - if (block->flag & UI_BLOCK_CLIPTOP) + if (block->flag & UI_BLOCK_CLIPTOP) if (my > block->rect.ymax - UI_MENU_SCROLL_MOUSE) return 't'; if (block->flag & UI_BLOCK_CLIPBOTTOM) @@ -8991,12 +8991,12 @@ static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my, uiBut *to_bt) /* set flags again */ ui_popup_block_scrolltest(block); - + ED_region_tag_redraw(ar); - + return 1; } - + return 0; } @@ -9161,14 +9161,14 @@ static int ui_handle_menu_event( if (block->flag & UI_BLOCK_MOVEMOUSE_QUIT) { ui_mouse_motion_towards_init(menu, &event->x); } - + /* add menu scroll timer, if needed */ if (ui_menu_scroll_test(block, my)) if (menu->scrolltimer == NULL) menu->scrolltimer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, MENU_SCROLL_INTERVAL); } - + /* first block own event func */ if (block->block_event_func && block->block_event_func(C, block, event)) { /* pass */ @@ -9208,7 +9208,7 @@ static int ui_handle_menu_event( retval = WM_UI_HANDLER_BREAK; break; - + case UPARROWKEY: case DOWNARROWKEY: case WHEELUPMOUSE: @@ -9221,11 +9221,11 @@ static int ui_handle_menu_event( else if (inside || (block->flag & UI_BLOCK_LOOP)) { int type = event->type; int val = event->val; - + /* convert pan to scrollwheel */ if (type == MOUSEPAN) ui_pan_to_scroll(event, &type, &val); - + if (val == KM_PRESS) { const bool is_next = (ELEM(type, DOWNARROWKEY, WHEELDOWNMOUSE) == @@ -9296,10 +9296,10 @@ static int ui_handle_menu_event( count = 0; for (but = block->buttons.first; but; but = but->next) { bool doit = false; - + if (!ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE)) count++; - + /* exception for rna layer buts */ if (but->rnapoin.data && but->rnaprop && ELEM(RNA_property_subtype(but->rnaprop), PROP_LAYER, PROP_LAYER_MEMBER)) @@ -9399,7 +9399,7 @@ static int ui_handle_menu_event( } } } - + /* here we check return conditions for menus */ if (block->flag & UI_BLOCK_LOOP) { /* if we click outside the block, verify if we clicked on the @@ -9479,7 +9479,7 @@ static int ui_handle_menu_event( uiSafetyRct *saferct; ui_mouse_motion_towards_check(block, menu, &event->x, is_parent_inside == false); - + /* check for all parent rects, enables arrowkeys to be used */ for (saferct = block->saferct.first; saferct; saferct = saferct->next) { /* for mouse move we only check our own rect, for other @@ -10075,7 +10075,7 @@ static int ui_region_handler(bContext *C, const wmEvent *event, void *UNUSED(use /* re-enable tooltips */ if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy)) ui_blocks_set_tooltips(ar, true); - + /* delayed apply callbacks */ ui_apply_but_funcs_after(C); @@ -10091,7 +10091,7 @@ static void ui_region_handler_remove(bContext *C, void *UNUSED(userdata)) if (ar == NULL) return; UI_blocklist_free(C, &ar->uiblocks); - + sc = CTX_wm_screen(C); if (sc == NULL) return; @@ -10227,7 +10227,7 @@ static int ui_popup_handler(bContext *C, const wmEvent *event, void *userdata) win->last_pie_event = block->pie_data.event; reset_pie = true; } - + ui_popup_block_free(C, menu); UI_popup_handlers_remove(&win->modalhandlers, menu); CTX_wm_menu_set(C, NULL); @@ -10337,7 +10337,7 @@ bool UI_textbutton_activate_rna( { uiBlock *block; uiBut *but = NULL; - + for (block = ar->uiblocks.first; block; block = block->next) { for (but = block->buttons.first; but; but = but->next) { if (but->type == UI_BTYPE_TEXT) { @@ -10351,7 +10351,7 @@ bool UI_textbutton_activate_rna( if (but) break; } - + if (but) { UI_but_active_only(C, ar, block, but); return true; @@ -10366,7 +10366,7 @@ bool UI_textbutton_activate_but(const bContext *C, uiBut *actbut) ARegion *ar = CTX_wm_region(C); uiBlock *block; uiBut *but = NULL; - + for (block = ar->uiblocks.first; block; block = block->next) { for (but = block->buttons.first; but; but = but->next) if (but == actbut && but->type == UI_BTYPE_TEXT) @@ -10375,7 +10375,7 @@ bool UI_textbutton_activate_but(const bContext *C, uiBut *actbut) if (but) break; } - + if (but) { UI_but_active_only(C, ar, block, but); return true; |