Small enhancement to grab-resize of uiLists, suggested by plasmasolutions: do not effectively apply auto-size until we stop grabbing, avoid size of uiLists to switch between rows and maxrows while dragging.

This commit is contained in:
Bastien Montagne
2013-08-27 18:56:04 +00:00
parent 8bdb1f6155
commit 025bac4570
3 changed files with 13 additions and 2 deletions

View File

@@ -3424,10 +3424,12 @@ static int ui_do_but_LISTBOX(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
data->escapecancel = true;
*size = (int)data->origvalue;
button_activate_state(C, but, BUTTON_STATE_EXIT);
ui_list->flag &= ~UILST_RESIZING;
ED_region_tag_redraw(data->region);
}
else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
ui_list->flag &= ~UILST_RESIZING;
ED_region_tag_redraw(data->region);
}
else if (event->type == MOUSEMOVE) {
@@ -6552,6 +6554,7 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar)
/* Again, have to override values set by ui_numedit_begin, because our listbox button also has a rnapoin... */
*size = data->origvalue = (double)dyn_data->visual_height;
ui_list->flag |= UILST_RESIZING;
retval = WM_UI_HANDLER_BREAK;
}

View File

@@ -2517,10 +2517,17 @@ static void prepare_list(uiList *ui_list, int len, int activei, int rows, int ma
maxrows = 5;
if (columns == 0)
columns = 9;
if (ui_list->list_grip >= rows)
if (ui_list->list_grip >= rows) {
maxrows = rows = ui_list->list_grip;
else
}
else {
ui_list->list_grip = 0; /* Reset to auto-size mode. */
/* Prevent auto-size mode to take effect while grab-resizing! */
if (ui_list->flag & UILST_RESIZING) {
maxrows = rows;
}
}
if (columns > 1) {
dyn_data->height = (int)ceil((double)len / (double)columns);

View File

@@ -256,6 +256,7 @@ enum {
/* uiList flag */
enum {
UILST_SCROLL_TO_ACTIVE_ITEM = 1 << 0, /* Scroll list to make active item visible. */
UILST_RESIZING = 1 << 1, /* We are currently resizing, deactivate autosize! */
};
/* regiontype, first two are the default set */