diff options
Diffstat (limited to 'source/blender/editors/interface')
8 files changed, 76 insertions, 65 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index ae5af185442..759301cc8f3 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -262,14 +262,12 @@ static int ui_is_a_warp_but(uiBut *but) static int ui_is_utf8_but(uiBut *but) { if (but->rnaprop) { - int subtype= RNA_property_subtype(but->rnaprop); - - if(ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) { - return TRUE; - } + const int subtype= RNA_property_subtype(but->rnaprop); + return !(ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)); + } + else { + return !(but->flag & UI_BUT_NO_UTF8); } - - return !(but->flag & UI_BUT_NO_UTF8); } /* ********************** button apply/revert ************************/ @@ -300,7 +298,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but) after->func_arg3= but->func_arg3; after->funcN= but->funcN; - after->func_argN= but->func_argN; + after->func_argN= MEM_dupallocN(but->func_argN); after->rename_func= but->rename_func; after->rename_arg1= but->rename_arg1; @@ -404,6 +402,8 @@ static void ui_apply_but_funcs_after(bContext *C) after.func(C, after.func_arg1, after.func_arg2); if(after.funcN) 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); @@ -1679,7 +1679,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data) { if(but) { - if(!ui_is_utf8_but(but)) { + if(ui_is_utf8_but(but)) { int strip= BLI_utf8_invalid_strip(but->editstr, strlen(but->editstr)); /* not a file?, strip non utf-8 chars */ if(strip) { diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 9507a1a07f4..037cc22f879 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -798,36 +798,39 @@ void UI_icons_init(int first_dyn_id) init_brush_icons(); } -/* Render size for preview images at level miplevel */ -static int preview_render_size(int miplevel) +/* Render size for preview images and icons + */ +static int preview_render_size(enum eIconSizes size) { - switch (miplevel) { - case 0: return 32; - case 1: return PREVIEW_DEFAULT_HEIGHT; + switch (size) { + case ICON_SIZE_ICON: return 32; + case ICON_SIZE_PREVIEW: return PREVIEW_DEFAULT_HEIGHT; } return 0; } -static void icon_create_mipmap(struct PreviewImage* prv_img, int miplevel) +/* Create rect for the icon + */ +static void icon_create_rect(struct PreviewImage* prv_img, enum eIconSizes size) { - unsigned int size = preview_render_size(miplevel); + unsigned int render_size = preview_render_size(size); if (!prv_img) { if (G.f & G_DEBUG) printf("Error: requested preview image does not exist"); } - if (!prv_img->rect[miplevel]) { - prv_img->w[miplevel] = size; - prv_img->h[miplevel] = size; - prv_img->changed[miplevel] = 1; - prv_img->changed_timestamp[miplevel] = 0; - prv_img->rect[miplevel] = MEM_callocN(size*size*sizeof(unsigned int), "prv_rect"); + if (!prv_img->rect[size]) { + prv_img->w[size] = render_size; + prv_img->h[size] = render_size; + prv_img->changed[size] = 1; + prv_img->changed_timestamp[size] = 0; + prv_img->rect[size] = MEM_callocN(render_size*render_size*sizeof(unsigned int), "prv_rect"); } } /* only called when icon has changed */ /* only call with valid pointer from UI_icon_draw */ -static void icon_set_image(bContext *C, ID *id, PreviewImage* prv_img, int miplevel) +static void icon_set_image(bContext *C, ID *id, PreviewImage* prv_img, enum eIconSizes size) { if (!prv_img) { if (G.f & G_DEBUG) @@ -835,11 +838,10 @@ static void icon_set_image(bContext *C, ID *id, PreviewImage* prv_img, int miple return; } - /* create the preview rect */ - icon_create_mipmap(prv_img, miplevel); + icon_create_rect(prv_img, size); - ED_preview_icon_job(C, prv_img, id, prv_img->rect[miplevel], - prv_img->w[miplevel], prv_img->h[miplevel]); + ED_preview_icon_job(C, prv_img, id, prv_img->rect[size], + prv_img->w[size], prv_img->h[size]); } static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), int rw, int rh, unsigned int *rect, float alpha, float *rgb, short is_preview) @@ -928,17 +930,17 @@ static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy glDisable(GL_TEXTURE_2D); } -/* Drawing size for preview images at level miplevel */ -static int preview_size(int miplevel) +/* Drawing size for preview images */ +static int get_draw_size(enum eIconSizes size) { - switch (miplevel) { - case 0: return ICON_DEFAULT_HEIGHT; - case 1: return PREVIEW_DEFAULT_HEIGHT; + switch (size) { + case ICON_SIZE_ICON: return ICON_DEFAULT_HEIGHT; + case ICON_SIZE_PREVIEW: return PREVIEW_DEFAULT_HEIGHT; } return 0; } -static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, float *rgb, int miplevel, int draw_size, int UNUSED(nocreate), int is_preview) +static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, float *rgb, enum eIconSizes size, int draw_size, int UNUSED(nocreate), int is_preview) { Icon *icon = NULL; DrawInfo *di = NULL; @@ -988,11 +990,11 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al if(pi) { /* no create icon on this level in code */ - if(!pi->rect[miplevel]) return; /* something has gone wrong! */ + if(!pi->rect[size]) return; /* something has gone wrong! */ /* preview images use premul alpha ... */ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - icon_draw_rect(x, y, w, h, aspect, pi->w[miplevel], pi->h[miplevel], pi->rect[miplevel], 1.0f, NULL, is_preview); + icon_draw_rect(x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], 1.0f, NULL, is_preview); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } } @@ -1024,7 +1026,7 @@ static void ui_id_brush_render(bContext *C, ID *id) if(!pi) return; - for(i = 0; i < PREVIEW_MIPMAPS; i++) { + for(i = 0; i < NUM_ICON_SIZES; i++) { /* check if rect needs to be created; changed only set by dynamic icons */ if((pi->changed[i] || !pi->rect[i])) { @@ -1113,21 +1115,21 @@ int ui_id_icon_get(bContext *C, ID *id, int big) return iconid; } -static void icon_draw_mipmap(float x, float y, int icon_id, float aspect, float alpha, int miplevel, int nocreate) +static void icon_draw_at_size(float x, float y, int icon_id, float aspect, float alpha, enum eIconSizes size, int nocreate) { - int draw_size = preview_size(miplevel); - icon_draw_size(x, y, icon_id, aspect, alpha, NULL, miplevel, draw_size, nocreate, FALSE); + int draw_size = get_draw_size(size); + icon_draw_size(x, y, icon_id, aspect, alpha, NULL, size, draw_size, nocreate, FALSE); } void UI_icon_draw_aspect(float x, float y, int icon_id, float aspect, float alpha) { - icon_draw_mipmap(x, y, icon_id, aspect, alpha, PREVIEW_MIPMAP_ZERO, 0); + icon_draw_at_size(x, y, icon_id, aspect, alpha, ICON_SIZE_ICON, 0); } void UI_icon_draw_aspect_color(float x, float y, int icon_id, float aspect, float *rgb) { - int draw_size = preview_size(PREVIEW_MIPMAP_ZERO); - icon_draw_size(x, y, icon_id, aspect, 1.0f, rgb, PREVIEW_MIPMAP_ZERO, draw_size, FALSE, FALSE); + int draw_size = get_draw_size(ICON_SIZE_ICON); + icon_draw_size(x, y, icon_id, aspect, 1.0f, rgb, ICON_SIZE_ICON, draw_size, FALSE, FALSE); } void UI_icon_draw(float x, float y, int icon_id) @@ -1137,21 +1139,21 @@ void UI_icon_draw(float x, float y, int icon_id) void UI_icon_draw_size(float x, float y, int size, int icon_id, float alpha) { - icon_draw_size(x, y, icon_id, 1.0f, alpha, NULL, PREVIEW_MIPMAP_ZERO, size, TRUE, FALSE); + icon_draw_size(x, y, icon_id, 1.0f, alpha, NULL, ICON_SIZE_ICON, size, TRUE, FALSE); } void UI_icon_draw_preview(float x, float y, int icon_id) { - icon_draw_mipmap(x, y, icon_id, 1.0f, 1.0f, PREVIEW_MIPMAP_LARGE, 0); + icon_draw_at_size(x, y, icon_id, 1.0f, 1.0f, ICON_SIZE_PREVIEW, 0); } void UI_icon_draw_preview_aspect(float x, float y, int icon_id, float aspect) { - icon_draw_mipmap(x, y, icon_id, aspect, 1.0f, PREVIEW_MIPMAP_LARGE, 0); + icon_draw_at_size(x, y, icon_id, aspect, 1.0f, ICON_SIZE_PREVIEW, 0); } void UI_icon_draw_preview_aspect_size(float x, float y, int icon_id, float aspect, int size) { - icon_draw_size(x, y, icon_id, aspect, 1.0f, NULL, PREVIEW_MIPMAP_LARGE, size, FALSE, TRUE); + icon_draw_size(x, y, icon_id, aspect, 1.0f, NULL, ICON_SIZE_PREVIEW, size, FALSE, TRUE); } diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 12506d28593..e9fad382beb 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -97,7 +97,7 @@ static int eyedropper_cancel(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } -static void eyedropper_sample(bContext *C, Eyedropper *eye, short mx, short my) +static void eyedropper_sample(bContext *C, Eyedropper *eye, int mx, int my) { if(RNA_property_type(eye->prop) == PROP_FLOAT) { const int color_manage = CTX_data_scene(C)->r.color_mgt_flag & R_COLOR_MANAGEMENT; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index a4c2dbb9943..624f06db3c1 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1625,7 +1625,7 @@ void ui_block_func_ICONTEXTROW(bContext *UNUSED(C), uiLayout *layout, void *arg_ } #if 0 -static void ui_warp_pointer(short x, short y) +static void ui_warp_pointer(int x, int y) { /* XXX 2.50 which function to use for this? */ /* OSX has very poor mousewarp support, it sends events; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 7648d5067b4..60a6008de43 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -461,7 +461,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str uiButSetNFunc(but, NULL, MEM_dupallocN(template), NULL); } else { - but= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Unlink datablock. Shift + Click to set users to zero, data gets not saved"); + but= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Unlink datablock. Shift + Click to set users to zero, data will then not be saved"); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_DELETE)); if(RNA_property_flag(template->prop) & PROP_NEVER_NULL) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index ecadb52ad5d..58ed1e31b81 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -888,7 +888,7 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) /* textbut exception, clip right when... */ if(but->editstr && but->pos >= 0) { float width; - char buf[256]; + char buf[UI_MAX_DRAW_STR]; /* copy draw string */ BLI_strncpy(buf, but->drawstr, sizeof(buf)); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 32301dd6423..84cf5af5414 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -2028,7 +2028,7 @@ typedef struct View2DString { unsigned char ub[4]; int pack; } col; - short mval[2]; + int mval[2]; rcti rect; } View2DString; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 62b191c2c6e..4cb67994704 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -86,6 +86,7 @@ typedef struct v2dViewPanData { /* options for version 1 */ int startx, starty; /* mouse x/y values in window when operator was initiated */ int lastx, lasty; /* previous x/y values of mouse in window */ + int invoke_event; /* event starting pan, for modal exit */ short in_scroller; /* for MMB in scrollers (old feature in past, but now not that useful) */ } v2dViewPanData; @@ -202,7 +203,8 @@ static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event) /* set initial settings */ vpd->startx= vpd->lastx= event->x; vpd->starty= vpd->lasty= event->y; - + vpd->invoke_event= event->type; + if (event->type == MOUSEPAN) { RNA_int_set(op->ptr, "deltax", event->prevx - event->x); RNA_int_set(op->ptr, "deltay", event->prevy - event->y); @@ -261,17 +263,19 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event) WM_operator_name_call(C, "VIEW2D_OT_zoom", WM_OP_INVOKE_DEFAULT, NULL); return OPERATOR_FINISHED; } - case MIDDLEMOUSE: - case ESCKEY: - if (event->val==KM_RELEASE) { - /* calculate overall delta mouse-movement for redo */ - RNA_int_set(op->ptr, "deltax", (vpd->startx - vpd->lastx)); - RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty)); - - view_pan_exit(op); - WM_cursor_restore(CTX_wm_window(C)); - - return OPERATOR_FINISHED; + + default: + if (event->type == vpd->invoke_event || event->type==ESCKEY) { + if (event->val==KM_RELEASE) { + /* calculate overall delta mouse-movement for redo */ + RNA_int_set(op->ptr, "deltax", (vpd->startx - vpd->lastx)); + RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty)); + + view_pan_exit(op); + WM_cursor_restore(CTX_wm_window(C)); + + return OPERATOR_FINISHED; + } } break; } @@ -519,6 +523,7 @@ typedef struct v2dViewZoomData { double timer_lastdraw; int lastx, lasty; /* previous x/y values of mouse in window */ + int invoke_event; /* event type that invoked, for modal exits */ float dx, dy; /* running tally of previous delta values (for obtaining final zoom) */ float mx_2d, my_2d; /* initial mouse location in v2d coords */ } v2dViewZoomData; @@ -923,6 +928,9 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_float_set(op->ptr, "deltax", 0); RNA_float_set(op->ptr, "deltay", 0); + /* for modal exit test */ + vzd->invoke_event= event->type; + if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { ARegion *ar= CTX_wm_region(C); @@ -1021,8 +1029,9 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) /* apply zooming */ view_zoomdrag_apply(C, op); } - else if (ELEM3(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE)) { /* XXX needs modal keymap */ - if (event->val==KM_RELEASE) { + else if (event->type == vzd->invoke_event || event->type==ESCKEY) { + if (event->val == KM_RELEASE) { + /* for redo, store the overall deltas - need to respect zoom-locks here... */ if ((v2d->keepzoom & V2D_LOCKZOOM_X)==0) RNA_float_set(op->ptr, "deltax", vzd->dx); |