commit before doing some hefty shapekey change, will break compilation
This commit is contained in:
@@ -92,6 +92,7 @@ typedef enum uiHandleButtonState {
|
||||
} uiHandleButtonState;
|
||||
|
||||
typedef struct uiHandleButtonData {
|
||||
wmWindowManager *wm;
|
||||
wmWindow *window;
|
||||
ARegion *region;
|
||||
|
||||
@@ -1943,8 +1944,11 @@ static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
|
||||
{
|
||||
if(data->state == BUTTON_STATE_HIGHLIGHT) {
|
||||
if(ELEM4(event->type, LEFTMOUSE, PADENTER, RETKEY, EVT_BUT_OPEN) && event->val==KM_PRESS) {
|
||||
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
if(but->dt == UI_EMBOSSN && !event->ctrl);
|
||||
else {
|
||||
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(data->state == BUTTON_STATE_TEXT_EDITING) {
|
||||
@@ -2056,9 +2060,21 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
|
||||
/* Mouse location isn't screen clamped to the screen so use a linear mapping
|
||||
* 2px == 1-int, or 1px == 1-ClickStep */
|
||||
if(ui_is_but_float(but)) {
|
||||
tempf = data->startvalue + ((mx - data->dragstartx) * fac * 0.01*but->a1);
|
||||
fac *= 0.01*but->a1;
|
||||
tempf = data->startvalue + ((mx - data->dragstartx) * fac);
|
||||
tempf= ui_numedit_apply_snapf(tempf, softmin, softmax, softrange, snap);
|
||||
|
||||
#if 1 /* fake moving the click start, nicer for dragging back after passing the limit */
|
||||
if(tempf < softmin) {
|
||||
data->dragstartx -= (softmin-tempf) / fac;
|
||||
tempf= softmin;
|
||||
} else if (tempf > softmax) {
|
||||
data->dragstartx += (tempf-softmax) / fac;
|
||||
tempf= softmax;
|
||||
}
|
||||
#else
|
||||
CLAMP(tempf, softmin, softmax);
|
||||
#endif
|
||||
|
||||
if(tempf != data->value) {
|
||||
data->dragchange= 1;
|
||||
@@ -2067,9 +2083,22 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
|
||||
}
|
||||
}
|
||||
else {
|
||||
temp= data->startvalue + (mx - data->dragstartx)/2; /* simple 2px == 1 */
|
||||
fac = 0.5; /* simple 2px == 1 */
|
||||
|
||||
temp= data->startvalue + ((mx - data->dragstartx) * fac);
|
||||
temp= ui_numedit_apply_snap(temp, softmin, softmax, snap);
|
||||
|
||||
#if 1 /* fake moving the click start, nicer for dragging back after passing the limit */
|
||||
if(temp < softmin) {
|
||||
data->dragstartx -= (softmin-temp) / fac;
|
||||
temp= softmin;
|
||||
} else if (temp > softmax) {
|
||||
data->dragstartx += (temp-softmax) / fac;
|
||||
temp= softmax;
|
||||
}
|
||||
#else
|
||||
CLAMP(temp, softmin, softmax);
|
||||
#endif
|
||||
|
||||
if(temp != data->value) {
|
||||
data->dragchange= 1;
|
||||
@@ -2077,6 +2106,8 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
|
||||
changed= 1;
|
||||
}
|
||||
}
|
||||
|
||||
data->draglastx= mx;
|
||||
}
|
||||
else {
|
||||
/* Use a non-linear mapping of the mouse drag especially for large floats (normal behavior) */
|
||||
@@ -3625,15 +3656,35 @@ static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y)
|
||||
if(but->flag & UI_HIDDEN)
|
||||
continue;
|
||||
if(ui_but_contains_pt(but, mx, my))
|
||||
/* give precedence to already activated buttons */
|
||||
if(!butover || (!butover->active && but->active))
|
||||
butover= but;
|
||||
butover= but;
|
||||
}
|
||||
}
|
||||
|
||||
return butover;
|
||||
}
|
||||
|
||||
static uiBut *ui_list_find_mouse_over(ARegion *ar, int x, int y)
|
||||
{
|
||||
uiBlock *block;
|
||||
uiBut *but;
|
||||
int mx, my;
|
||||
|
||||
if(!ui_mouse_inside_region(ar, x, y))
|
||||
return NULL;
|
||||
|
||||
for(block=ar->uiblocks.first; block; block=block->next) {
|
||||
mx= x;
|
||||
my= y;
|
||||
ui_window_to_block(ar, block, &mx, &my);
|
||||
|
||||
for(but=block->buttons.last; but; but= but->prev)
|
||||
if(but->type == LISTBOX && ui_but_contains_pt(but, mx, my))
|
||||
return but;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ****************** button state handling **************************/
|
||||
|
||||
static int button_modal_state(uiHandleButtonState state)
|
||||
@@ -3650,7 +3701,7 @@ static void button_timers_tooltip_remove(bContext *C, uiBut *but)
|
||||
data= but->active;
|
||||
|
||||
if(data->tooltiptimer) {
|
||||
WM_event_remove_window_timer(data->window, data->tooltiptimer);
|
||||
WM_event_remove_timer(data->wm, data->window, data->tooltiptimer);
|
||||
data->tooltiptimer= NULL;
|
||||
}
|
||||
if(data->tooltip) {
|
||||
@@ -3659,7 +3710,7 @@ static void button_timers_tooltip_remove(bContext *C, uiBut *but)
|
||||
}
|
||||
|
||||
if(data->autoopentimer) {
|
||||
WM_event_remove_window_timer(data->window, data->autoopentimer);
|
||||
WM_event_remove_timer(data->wm, data->window, data->autoopentimer);
|
||||
data->autoopentimer= NULL;
|
||||
}
|
||||
}
|
||||
@@ -3671,13 +3722,13 @@ static void button_tooltip_timer_reset(uiBut *but)
|
||||
data= but->active;
|
||||
|
||||
if(data->tooltiptimer) {
|
||||
WM_event_remove_window_timer(data->window, data->tooltiptimer);
|
||||
WM_event_remove_timer(data->wm, data->window, data->tooltiptimer);
|
||||
data->tooltiptimer= NULL;
|
||||
}
|
||||
|
||||
if(U.flag & USER_TOOLTIPS)
|
||||
if(!but->block->tooltipdisabled)
|
||||
data->tooltiptimer= WM_event_add_window_timer(data->window, TIMER, BUTTON_TOOLTIP_DELAY);
|
||||
data->tooltiptimer= WM_event_add_timer(data->wm, data->window, TIMER, BUTTON_TOOLTIP_DELAY);
|
||||
}
|
||||
|
||||
static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState state)
|
||||
@@ -3705,7 +3756,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
|
||||
else time= -1;
|
||||
|
||||
if(time >= 0)
|
||||
data->autoopentimer= WM_event_add_window_timer(data->window, TIMER, 0.02*(double)time);
|
||||
data->autoopentimer= WM_event_add_timer(data->wm, data->window, TIMER, 0.02*(double)time);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3723,12 +3774,12 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
|
||||
/* number editing */
|
||||
if(state == BUTTON_STATE_NUM_EDITING) {
|
||||
if(ui_is_a_warp_but(but))
|
||||
WM_cursor_grab(CTX_wm_window(C), TRUE);
|
||||
WM_cursor_grab(CTX_wm_window(C), TRUE, TRUE, NULL);
|
||||
ui_numedit_begin(but, data);
|
||||
} else if(data->state == BUTTON_STATE_NUM_EDITING) {
|
||||
ui_numedit_end(but, data);
|
||||
if(ui_is_a_warp_but(but))
|
||||
WM_cursor_ungrab(CTX_wm_window(C), FALSE);
|
||||
WM_cursor_ungrab(CTX_wm_window(C));
|
||||
}
|
||||
/* menu open */
|
||||
if(state == BUTTON_STATE_MENU_OPEN)
|
||||
@@ -3738,10 +3789,10 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
|
||||
|
||||
/* add a short delay before exiting, to ensure there is some feedback */
|
||||
if(state == BUTTON_STATE_WAIT_FLASH) {
|
||||
data->flashtimer= WM_event_add_window_timer(data->window, TIMER, BUTTON_FLASH_DELAY);
|
||||
data->flashtimer= WM_event_add_timer(data->wm, data->window, TIMER, BUTTON_FLASH_DELAY);
|
||||
}
|
||||
else if(data->flashtimer) {
|
||||
WM_event_remove_window_timer(data->window, data->flashtimer);
|
||||
WM_event_remove_timer(data->wm, data->window, data->flashtimer);
|
||||
data->flashtimer= NULL;
|
||||
}
|
||||
|
||||
@@ -3772,6 +3823,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
|
||||
|
||||
/* setup struct */
|
||||
data= MEM_callocN(sizeof(uiHandleButtonData), "uiHandleButtonData");
|
||||
data->wm= CTX_wm_manager(C);
|
||||
data->window= CTX_wm_window(C);
|
||||
data->region= ar;
|
||||
if( ELEM(but->type, BUT_CURVE, SEARCH_MENU) ); // XXX curve is temp
|
||||
@@ -3999,6 +4051,10 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
|
||||
data->cancel= 1;
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
}
|
||||
else if(ui_but_find_mouse_over(ar, event->x, event->y) != but) {
|
||||
data->cancel= 1;
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
}
|
||||
else if(event->x!=event->prevx || event->y!=event->prevy) {
|
||||
/* re-enable tooltip on mouse move */
|
||||
ui_blocks_set_tooltips(ar, 1);
|
||||
@@ -4009,7 +4065,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
|
||||
case TIMER: {
|
||||
/* handle tooltip timer */
|
||||
if(event->customdata == data->tooltiptimer) {
|
||||
WM_event_remove_window_timer(data->window, data->tooltiptimer);
|
||||
WM_event_remove_timer(data->wm, data->window, data->tooltiptimer);
|
||||
data->tooltiptimer= NULL;
|
||||
|
||||
if(!data->tooltip)
|
||||
@@ -4017,7 +4073,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
|
||||
}
|
||||
/* handle menu auto open timer */
|
||||
else if(event->customdata == data->autoopentimer) {
|
||||
WM_event_remove_window_timer(data->window, data->autoopentimer);
|
||||
WM_event_remove_timer(data->wm, data->window, data->autoopentimer);
|
||||
data->autoopentimer= NULL;
|
||||
|
||||
if(ui_mouse_inside_button(ar, but, event->x, event->y))
|
||||
@@ -4031,7 +4087,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
|
||||
case MIDDLEMOUSE:
|
||||
/* XXX hardcoded keymap check... but anyway, while view changes, tooltips should be removed */
|
||||
if(data->tooltiptimer) {
|
||||
WM_event_remove_window_timer(data->window, data->tooltiptimer);
|
||||
WM_event_remove_timer(data->wm, data->window, data->tooltiptimer);
|
||||
data->tooltiptimer= NULL;
|
||||
}
|
||||
/* pass on purposedly */
|
||||
@@ -4122,6 +4178,71 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int ui_handle_list_event(bContext *C, wmEvent *event, ARegion *ar)
|
||||
{
|
||||
uiBut *but= ui_list_find_mouse_over(ar, event->x, event->y);
|
||||
int retval= WM_UI_HANDLER_CONTINUE;
|
||||
int value, min, max;
|
||||
|
||||
if(but && (event->val == KM_PRESS)) {
|
||||
Panel *pa= but->block->panel;
|
||||
|
||||
if(ELEM(event->type, UPARROWKEY, DOWNARROWKEY) ||
|
||||
((ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE) && event->alt))) {
|
||||
/* activate up/down the list */
|
||||
value= RNA_property_int_get(&but->rnapoin, but->rnaprop);
|
||||
|
||||
if(ELEM(event->type, UPARROWKEY, WHEELUPMOUSE))
|
||||
value--;
|
||||
else
|
||||
value++;
|
||||
|
||||
if(value < pa->list_scroll)
|
||||
pa->list_scroll= value;
|
||||
else if(value >= pa->list_scroll+pa->list_size)
|
||||
pa->list_scroll= value - pa->list_size + 1;
|
||||
|
||||
RNA_property_int_range(&but->rnapoin, but->rnaprop, &min, &max);
|
||||
value= CLAMPIS(value, min, max);
|
||||
|
||||
RNA_property_int_set(&but->rnapoin, but->rnaprop, value);
|
||||
RNA_property_update(C, &but->rnapoin, but->rnaprop);
|
||||
ED_region_tag_redraw(ar);
|
||||
|
||||
retval= WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
else if(ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE) && event->shift) {
|
||||
/* silly replacement for proper grip */
|
||||
if(pa->list_grip_size == 0)
|
||||
pa->list_grip_size= pa->list_size;
|
||||
|
||||
if(event->type == WHEELUPMOUSE)
|
||||
pa->list_grip_size--;
|
||||
else
|
||||
pa->list_grip_size++;
|
||||
|
||||
pa->list_grip_size= MAX2(pa->list_grip_size, 1);
|
||||
|
||||
ED_region_tag_redraw(ar);
|
||||
|
||||
retval= WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
else if(ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE)) {
|
||||
/* list template will clamp */
|
||||
if(event->type == WHEELUPMOUSE)
|
||||
pa->list_scroll--;
|
||||
else
|
||||
pa->list_scroll++;
|
||||
|
||||
ED_region_tag_redraw(ar);
|
||||
|
||||
retval= WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void ui_handle_button_return_submenu(bContext *C, wmEvent *event, uiBut *but)
|
||||
{
|
||||
uiHandleButtonData *data;
|
||||
@@ -4586,6 +4707,9 @@ static int ui_handler_region(bContext *C, wmEvent *event, void *userdata)
|
||||
if(!but || !button_modal_state(but->active->state))
|
||||
retval= ui_handler_panel_region(C, event);
|
||||
|
||||
if(retval == WM_UI_HANDLER_CONTINUE)
|
||||
retval= ui_handle_list_event(C, event, ar);
|
||||
|
||||
if(retval == WM_UI_HANDLER_CONTINUE) {
|
||||
if(but)
|
||||
retval= ui_handle_button_event(C, event, but);
|
||||
|
||||
Reference in New Issue
Block a user