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:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-01-16 03:13:12 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-01-16 03:13:12 +0400
commite0df491d1e465588cc018c6f6d00f72739b71516 (patch)
treefe4cbcdaa4633545bbc817c28eb780b551e5ac05 /source/blender/editors/interface
parent76a211d80947a453f594e4cf0a1e0acc6786eddf (diff)
parent23806a2b7d50082d70a0e4ecab22aafb8433708a (diff)
Merged changes in the trunk up to revision 43404.
Conflicts resolved: source/blender/python/SConscript
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface.c10
-rw-r--r--source/blender/editors/interface/interface_draw.c10
-rw-r--r--source/blender/editors/interface/interface_handlers.c4
-rw-r--r--source/blender/editors/interface/interface_intern.h2
-rw-r--r--source/blender/editors/interface/interface_layout.c24
-rw-r--r--source/blender/editors/interface/interface_regions.c12
-rw-r--r--source/blender/editors/interface/interface_style.c6
-rw-r--r--source/blender/editors/interface/interface_templates.c36
-rw-r--r--source/blender/editors/interface/interface_widgets.c66
-rw-r--r--source/blender/editors/interface/view2d.c16
-rw-r--r--source/blender/editors/interface/view2d_ops.c37
11 files changed, 146 insertions, 77 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 4948073f9c6..7ff69277843 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -831,7 +831,9 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
if(but->optype) {
IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
- if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, buf, sizeof(buf))) {
+ if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE,
+ buf, sizeof(buf)))
+ {
UI_MENU_KEY_STR_CAT
}
}
@@ -846,7 +848,9 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
IDP_AssignString(prop_menu_name, mt->idname, sizeof(mt->idname));
- if(WM_key_event_operator_string(C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, FALSE, buf, sizeof(buf))) {
+ if(WM_key_event_operator_string(C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, FALSE,
+ buf, sizeof(buf)))
+ {
UI_MENU_KEY_STR_CAT
}
}
@@ -2920,7 +2924,7 @@ static void autocomplete_id(bContext *C, char *str, void *arg_v)
/* search if str matches the beginning of an ID struct */
if(str[0]) {
- AutoComplete *autocpl= autocomplete_begin(str, 22);
+ AutoComplete *autocpl= autocomplete_begin(str, MAX_ID_NAME-2);
ID *id;
for(id= listb->first; id; id= id->next)
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 1f1228a9bc5..56f7fd04080 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1511,8 +1511,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
else if(scopes->track_preview) {
/* additional margin around image */
/* NOTE: should be kept in sync with value from BKE_movieclip_update_scopes */
- const int margin= 2;
- float zoomx, zoomy, track_pos[2], off_x, off_y;
+ const int margin= 3;
+ float zoomx, zoomy, track_pos[2], off_x, off_y, x0, y0;
int a;
ImBuf *drawibuf;
@@ -1529,11 +1529,11 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
off_x= ((int)track_pos[0]-track_pos[0]+0.5)*zoomx;
off_y= ((int)track_pos[1]-track_pos[1]+0.5)*zoomy;
+ x0= (int)(off_x+rect.xmin-zoomx*(margin-0.5f))+1;
+ y0= (int)(off_y+rect.ymin-zoomy*(margin-0.5f))+1;
drawibuf= scale_trackpreview_ibuf(scopes->track_preview, zoomx, zoomy);
- glaDrawPixelsSafe(off_x+rect.xmin-zoomx*(margin-0.5f), off_y+rect.ymin-zoomy*(margin-0.5f),
- rect.xmax-rect.xmin+2+(int)(zoomx*(margin-0.5f)-off_x),
- rect.ymax-rect.ymin+2+(int)(zoomy*(margin-0.5f)-off_y),
+ glaDrawPixelsSafe(x0, y0, rect.xmax-x0+1, rect.ymax-y0+1,
drawibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, drawibuf->rect);
IMB_freeImBuf(drawibuf);
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 525b15ac7e3..3a19bb2a90c 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4388,7 +4388,9 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
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, buf, sizeof(buf))) {
+ if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE,
+ buf, sizeof(buf)))
+ {
char *butstr_orig;
// XXX but->str changed... should not, remove the hotkey from it
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index e4cc605e3f5..e31d7e39d89 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -444,7 +444,7 @@ extern void ui_draw_aligned_panel(struct uiStyle *style, uiBlock *block, rcti *r
/* interface_draw.c */
extern void ui_dropshadow(rctf *rct, float radius, float aspect, int select);
-void ui_draw_gradient(rcti *rect, float *hsv, int type, float alpha);
+void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha);
void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 84f0c61cd0c..a01efa25d19 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -1208,7 +1208,7 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s
if(itemptr.type && RNA_struct_is_ID(itemptr.type)) {
ID *id= itemptr.data;
- char name_ui[32];
+ char name_ui[MAX_ID_NAME];
#if 0 /* this name is used for a string comparison and can't be modified, TODO */
name_uiprefix_id(name_ui, id);
@@ -2742,6 +2742,11 @@ const char *uiLayoutIntrospect(uiLayout *layout)
return str;
}
+static void ui_layout_operator_buts__reset_cb(bContext *UNUSED(C), void *op_pt, void *UNUSED(arg_dummy2))
+{
+ WM_operator_properties_reset((wmOperator *)op_pt);
+}
+
/* this function does not initialize the layout, functions can be called on the layout before and after */
void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align, const short flag)
{
@@ -2803,7 +2808,22 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,in
uiItemL(layout, IFACE_("No Properties"), ICON_NONE);
}
}
-
+
+ /* its possible that reset can do nothing if all have PROP_SKIP_SAVE enabled
+ * but this is not so important if this button is drawn in those cases
+ * (which isn't all that likely anyway) - campbell */
+ if (op->properties->len) {
+ uiBlock *block;
+ uiBut *but;
+ uiLayout *col; /* needed to avoid alignment errors with previous buttons */
+
+ col= uiLayoutColumn(layout, 0);
+ block= uiLayoutGetBlock(col);
+ but = uiDefIconTextBut(block , BUT, 0, ICON_FILE_REFRESH, "Reset", 0, 0, 18, 20, NULL, 0.0, 0.0, 0.0, 0.0,
+ "Reset operator defaults");
+ uiButSetFunc(but, ui_layout_operator_buts__reset_cb, op, NULL);
+ }
+
/* set various special settings for buttons */
{
uiBut *but;
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index c535f2c1ad0..0c5aed83c1b 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -409,7 +409,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
/* operator keymap (not menus, they already have it) */
prop= (but->opptr)? but->opptr->data: NULL;
- if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, buf, sizeof(buf))) {
+ if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE,
+ buf, sizeof(buf)))
+ {
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Shortcut: %s"), buf);
data->color[data->totline]= 0x888888;
data->totline++;
@@ -2109,7 +2111,7 @@ uiBlock *ui_block_func_COL(bContext *C, uiPopupBlockHandle *handle, void *arg_bu
uiBut *but= arg_but;
uiBlock *block;
- block= uiBeginBlock(C, handle->region, "colorpicker", UI_EMBOSS);
+ block= uiBeginBlock(C, handle->region, __func__, UI_EMBOSS);
if (but->rnaprop) {
if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) {
@@ -2299,8 +2301,8 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut
uiStyle *style= UI_GetStyle();
uiPopupBlockHandle *handle;
uiPopupMenu *pup;
- pup= MEM_callocN(sizeof(uiPopupMenu), "menu dummy");
- pup->block= uiBeginBlock(C, NULL, "ui_button_menu_create", UI_EMBOSSP);
+ pup= MEM_callocN(sizeof(uiPopupMenu), __func__);
+ pup->block= uiBeginBlock(C, NULL, __func__, UI_EMBOSSP);
pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
pup->slideout= (but && (but->block->flag & UI_BLOCK_LOOP));
pup->but= but;
@@ -2361,7 +2363,7 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
uiPopupMenu *pup= MEM_callocN(sizeof(uiPopupMenu), "popup menu");
uiBut *but;
- pup->block= uiBeginBlock(C, NULL, "uiPupMenuBegin", UI_EMBOSSP);
+ pup->block= uiBeginBlock(C, NULL, __func__, UI_EMBOSSP);
pup->block->flag |= UI_BLOCK_POPUP_MEMORY;
pup->block->puphash= ui_popup_menu_hash(title);
pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 0e9dbaf3022..16b543737d0 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -180,7 +180,7 @@ void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str,
if (fs->kerning == 1)
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
- BLF_draw(fs->uifont_id, str, 65535); /* XXX, use real length */
+ BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
BLF_disable(fs->uifont_id, BLF_CLIPPING);
if (fs->shadow)
BLF_disable(fs->uifont_id, BLF_SHADOW);
@@ -243,7 +243,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
if (fs->kerning == 1)
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
- BLF_draw(fs->uifont_id, str, 65535); /* XXX, use real length */
+ BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
BLF_disable(fs->uifont_id, BLF_ROTATION);
BLF_disable(fs->uifont_id, BLF_CLIPPING);
if (fs->shadow)
@@ -291,7 +291,7 @@ void UI_DrawString(float x, float y, const char *str)
uiStyleFontSet(&style->widget);
BLF_position(style->widget.uifont_id, x, y, 0.0f);
- BLF_draw(style->widget.uifont_id, str, 65535); /* XXX, use real length */
+ BLF_draw(style->widget.uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
if (style->widget.kerning == 1)
BLF_disable(style->widget.uifont_id, BLF_KERNING_DEFAULT);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 8df43b92760..3a72c98e8f0 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -140,7 +140,7 @@ static void id_search_cb(const bContext *C, void *arg_template, const char *str,
continue;
if(BLI_strcasestr(id->name+2, str)) {
- char name_ui[32];
+ char name_ui[MAX_ID_NAME];
name_uiprefix_id(name_ui, id);
iconid= ui_id_icon_get((bContext*)C, id, 1);
@@ -181,7 +181,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
/* fake button, it holds space for search items */
uiDefBut(block, LABEL, 0, "", 10, 15, w, h, NULL, 0, 0, 0, 0, NULL);
- but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 0, w, 19, template.prv_rows, template.prv_cols, "");
+ but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, w, 19, template.prv_rows, template.prv_cols, "");
uiButSetSearchFunc(but, id_search_cb, &template, id_search_call_cb, idptr.data);
}
/* list view */
@@ -189,7 +189,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
/* fake button, it holds space for search items */
uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
- but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 0, 150, 19, 0, 0, "");
+ but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, 19, 0, 0, "");
uiButSetSearchFunc(but, id_search_cb, &template, id_search_call_cb, idptr.data);
}
@@ -414,11 +414,11 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
}
if(id->us > 1) {
- char str[32];
+ char numstr[32];
- BLI_snprintf(str, sizeof(str), "%d", id->us);
+ BLI_snprintf(numstr, sizeof(numstr), "%d", id->us);
- but= uiDefBut(block, BUT, 0, str, 0,0,UI_UNIT_X + ((id->us < 10) ? 0:10), UI_UNIT_Y, NULL, 0, 0, 0, 0,
+ but= uiDefBut(block, BUT, 0, numstr, 0,0,UI_UNIT_X + ((id->us < 10) ? 0:10), UI_UNIT_Y, NULL, 0, 0, 0, 0,
TIP_("Display number of users of this data (click to make a single-user copy)"));
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE));
@@ -1622,7 +1622,7 @@ static uiBlock *curvemap_clipping_func(bContext *C, struct ARegion *ar, void *cu
uiBut *bt;
float width= 8*UI_UNIT_X;
- block= uiBeginBlock(C, ar, "curvemap_clipping_func", UI_EMBOSS);
+ block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
/* use this for a fake extra empy space around the buttons */
uiDefBut(block, LABEL, 0, "", -4, 16, width+8, 6*UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
@@ -1681,7 +1681,7 @@ static uiBlock *curvemap_tools_func(bContext *C, struct ARegion *ar, void *cumap
uiBlock *block;
short yco= 0, menuwidth=10*UI_UNIT_X;
- block= uiBeginBlock(C, ar, "curvemap_tools_func", UI_EMBOSS);
+ block= uiBeginBlock(C, ar, __func__, UI_EMBOSS);
uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v);
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, "");
@@ -1703,7 +1703,7 @@ static uiBlock *curvemap_brush_tools_func(bContext *C, struct ARegion *ar, void
uiBlock *block;
short yco= 0, menuwidth=10*UI_UNIT_X;
- block= uiBeginBlock(C, ar, "curvemap_tools_func", UI_EMBOSS);
+ block= uiBeginBlock(C, ar, __func__, UI_EMBOSS);
uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v);
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, "");
@@ -2282,7 +2282,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
uiBlock *block;
uiBut *but;
Panel *pa;
- char *name, str[32];
+ const char *name;
+ char numstr[32];
int rnaicon=0, icon=0, i= 0, activei= 0, len= 0, items, found, min, max;
/* validate arguments */
@@ -2373,7 +2374,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
uiItemL(row, (name)? name: "", icon);
if(name)
- MEM_freeN(name);
+ MEM_freeN((void *)name);
}
i++;
@@ -2386,8 +2387,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
uiItemL(row, "", ICON_NONE);
/* next/prev button */
- BLI_snprintf(str, sizeof(str), "%d :", i);
- but= uiDefIconTextButR_prop(block, NUM, 0, 0, str, 0,0,UI_UNIT_X*5,UI_UNIT_Y, activeptr, activeprop, 0, 0, 0, 0, 0, "");
+ BLI_snprintf(numstr, sizeof(numstr), "%d :", i);
+ but= uiDefIconTextButR_prop(block, NUM, 0, 0, numstr, 0,0,UI_UNIT_X*5,UI_UNIT_Y, activeptr, activeprop, 0, 0, 0, 0, 0, "");
if(i == 0)
uiButSetFlag(but, UI_BUT_DISABLED);
}
@@ -2471,12 +2472,15 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char
int len= strlen(ot->name);
/* display name for menu, can hold hotkey */
- BLI_strncpy(name, ot->name, 256);
+ BLI_strncpy(name, ot->name, sizeof(name));
/* check for hotkey */
- if(len < 256-6) {
- if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE, &name[len+1], 256-len-1))
+ if(len < sizeof(name)-6) {
+ if (WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE,
+ &name[len+1], sizeof(name)-len-1))
+ {
name[len]= '|';
+ }
}
if(0==uiSearchItemAdd(items, name, ot, 0))
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index d8a34262e81..f5c62f65512 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -130,9 +130,12 @@ typedef struct uiWidgetType {
static float cornervec[WIDGET_CURVE_RESOLU][2]= {{0.0, 0.0}, {0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169},
{0.707, 0.293}, {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}, {1.0, 1.0}};
-static float jit[8][2]= {{0.468813 , -0.481430}, {-0.155755 , -0.352820},
-{0.219306 , -0.238501}, {-0.393286 , -0.110949}, {-0.024699 , 0.013908},
-{0.343805 , 0.147431}, {-0.272855 , 0.269918}, {0.095909 , 0.388710}};
+#define WIDGET_AA_JITTER 8
+static float jit[WIDGET_AA_JITTER][2]= {
+ { 0.468813 , -0.481430}, {-0.155755 , -0.352820},
+ { 0.219306 , -0.238501}, {-0.393286 , -0.110949},
+ {-0.024699 , 0.013908}, { 0.343805 , 0.147431},
+ {-0.272855 , 0.269918}, { 0.095909 , 0.388710}};
static float num_tria_vert[3][2]= {
{-0.352077, 0.532607}, {-0.352077, -0.549313}, {0.330000, -0.008353}};
@@ -165,14 +168,14 @@ static unsigned int check_tria_face[4][3]= {
GLubyte checker_stipple_sml[32*32/8] =
{
- 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, \
- 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, \
- 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, \
- 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, \
- 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, \
- 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, \
- 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, \
- 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, \
+ 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,
+ 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,
+ 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,
+ 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,
+ 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,
+ 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,
+ 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,
+ 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,
};
/* ************************************************* */
@@ -192,7 +195,7 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y
glVertexPointer(2, GL_FLOAT, 0, tri_arr);
/* for each AA step */
- for(j=0; j<8; j++) {
+ for (j = 0; j < WIDGET_AA_JITTER; j++) {
glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f);
glDrawArrays(GL_TRIANGLES, 0, 3);
glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f);
@@ -212,7 +215,7 @@ void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float m
color[3] *= 0.125f;
glColor4fv(color);
- for(j=0; j<8; j++) {
+ for (j = 0; j < WIDGET_AA_JITTER; j++) {
glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f);
uiDrawBox(mode, minx, miny, maxx, maxy, rad);
glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f);
@@ -749,6 +752,11 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
float quad_strip[WIDGET_SIZE_MAX*2+2][2]; /* + 2 because the last pair is wrapped */
float quad_strip_emboss[WIDGET_SIZE_MAX*2][2]; /* only for emboss */
+ const unsigned char tcol[4] = {wcol->outline[0],
+ wcol->outline[1],
+ wcol->outline[2],
+ UCHAR_MAX / WIDGET_AA_JITTER};
+
widget_verts_to_quad_strip(wtb, wtb->totvert, quad_strip);
if(wtb->emboss) {
@@ -757,11 +765,11 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
glEnableClientState(GL_VERTEX_ARRAY);
- for(j=0; j<8; j++) {
+ for (j = 0; j < WIDGET_AA_JITTER; j++) {
glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f);
/* outline */
- glColor4ub(wcol->outline[0], wcol->outline[1], wcol->outline[2], 32);
+ glColor4ubv(tcol);
glVertexPointer(2, GL_FLOAT, 0, quad_strip);
glDrawArrays(GL_QUAD_STRIP, 0, wtb->totvert*2 + 2);
@@ -782,16 +790,20 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
/* decoration */
if(wtb->tria1.tot || wtb->tria2.tot) {
+ const unsigned char tcol[4] = {wcol->item[0],
+ wcol->item[1],
+ wcol->item[2],
+ (unsigned char)((float)wcol->item[3] / WIDGET_AA_JITTER)};
/* for each AA step */
- for(j=0; j<8; j++) {
+ for (j = 0; j < WIDGET_AA_JITTER; j++) {
glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f);
if(wtb->tria1.tot) {
- glColor4ub(wcol->item[0], wcol->item[1], wcol->item[2], 32);
+ glColor4ubv(tcol);
widget_trias_draw(&wtb->tria1);
}
if(wtb->tria2.tot) {
- glColor4ub(wcol->item[0], wcol->item[1], wcol->item[2], 32);
+ glColor4ubv(tcol);
widget_trias_draw(&wtb->tria2);
}
@@ -1875,7 +1887,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
/* ************ custom buttons, old stuff ************** */
/* draws in resolution of 20x4 colors */
-void ui_draw_gradient(rcti *rect, float *hsv, int type, float alpha)
+void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha)
{
int a;
float h= hsv[0], s= hsv[1], v= hsv[2];
@@ -2489,10 +2501,8 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
if (color_profile)
linearrgb_to_srgb_v3_v3(col, col);
- wcol->inner[0]= FTOCHAR(col[0]);
- wcol->inner[1]= FTOCHAR(col[1]);
- wcol->inner[2]= FTOCHAR(col[2]);
- wcol->inner[3]= FTOCHAR(col[3]);
+ F4TOCHAR4(col, wcol->inner);
+
wcol->shaded = 0;
wcol->alpha_check = (wcol->inner[3] < 255);
@@ -3264,7 +3274,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state)
{
rcti trect = *rect;
-
+ float font_dims[2] = {0.0f, 0.0f};
uiWidgetType *wt= widget_type(UI_WTYPE_MENU_ITEM);
wt->state(wt, state);
@@ -3276,10 +3286,12 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int
glColor3ubv((unsigned char*)wt->wcol.text);
else
glColor3ubv((unsigned char*)wt->wcol.text_sel);
-
+
+ BLF_width_and_height(fstyle->uifont_id, name, &font_dims[0], &font_dims[1]);
+
trect.xmin += 0;
- trect.xmax = trect.xmin + BLF_width(fstyle->uifont_id, name) + 10;
+ trect.xmax = trect.xmin + font_dims[0] + 10;
trect.ymin += 10;
- trect.ymax = trect.ymin + BLF_height(fstyle->uifont_id, name);
+ trect.ymax = trect.ymin + font_dims[1];
uiStyleFontDraw(fstyle, &trect, name);
}
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 57d46de9cb7..b8201d762df 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1507,7 +1507,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
static void scroll_printstr(Scene *scene, float x, float y, float val, int power, short unit, char dir)
{
int len;
- char str[32];
+ char timecode_str[32];
/* adjust the scale unit to work ok */
if (dir == 'v') {
@@ -1522,10 +1522,10 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power
}
/* get string to print */
- ANIM_timecode_string_from_frame(str, scene, power, (unit == V2D_UNIT_SECONDS), val);
+ ANIM_timecode_string_from_frame(timecode_str, scene, power, (unit == V2D_UNIT_SECONDS), val);
/* get length of string, and adjust printing location to fit it into the horizontal scrollbar */
- len= strlen(str);
+ len= strlen(timecode_str);
if (dir == 'h') {
/* seconds/timecode display has slightly longer strings... */
if (unit == V2D_UNIT_SECONDS)
@@ -1536,12 +1536,12 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power
/* Add degree sympbol to end of string for vertical scrollbar? */
if ((dir == 'v') && (unit == V2D_UNIT_DEGREES)) {
- str[len]= 186;
- str[len+1]= 0;
+ timecode_str[len]= 186;
+ timecode_str[len+1]= 0;
}
/* draw it */
- BLF_draw_default_ascii(x, y, 0.0f, str, sizeof(str)-1);
+ BLF_draw_default_ascii(x, y, 0.0f, timecode_str, sizeof(timecode_str));
}
/* Draw scrollbars in the given 2d-region */
@@ -2093,11 +2093,11 @@ void UI_view2d_text_cache_draw(ARegion *ar)
}
if(v2s->rect.xmin >= v2s->rect.xmax)
- BLF_draw_default((float)v2s->mval[0]+xofs, (float)v2s->mval[1]+yofs, 0.0, str, 65535);
+ BLF_draw_default((float)v2s->mval[0]+xofs, (float)v2s->mval[1]+yofs, 0.0, str, BLF_DRAW_STR_DUMMY_MAX);
else {
BLF_clipping_default(v2s->rect.xmin-4, v2s->rect.ymin-4, v2s->rect.xmax+4, v2s->rect.ymax+4);
BLF_enable_default(BLF_CLIPPING);
- BLF_draw_default(v2s->rect.xmin+xofs, v2s->rect.ymin+yofs, 0.0f, str, 65535);
+ BLF_draw_default(v2s->rect.xmin+xofs, v2s->rect.ymin+yofs, 0.0f, str, BLF_DRAW_STR_DUMMY_MAX);
BLF_disable_default(BLF_CLIPPING);
}
}
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index a993e651b5f..2959d525cfb 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -1207,6 +1207,7 @@ typedef struct v2dScrollerMove {
float delta; /* amount moved by mouse on axis of interest */
float scrollbarwidth; /* width of the scrollbar itself, used for page up/down clicks */
+ int scrollbar_orig; /* initial location of scrollbar x/y, mouse relative */
int lastx, lasty; /* previous mouse coordinates (in screen coordinates) for determining movement */
} v2dScrollerMove;
@@ -1302,15 +1303,16 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
vsm->v2d= v2d;
vsm->ar= ar;
vsm->scroller= in_scroller;
-
+
/* store mouse-coordinates, and convert mouse/screen coordinates to region coordinates */
vsm->lastx = event->x;
vsm->lasty = event->y;
-
/* 'zone' depends on where mouse is relative to bubble
* - zooming must be allowed on this axis, otherwise, default to pan
*/
scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
+
+
if (in_scroller == 'h') {
/* horizontal scroller - calculate adjustment factor first */
mask_size= (float)(v2d->hor.xmax - v2d->hor.xmin);
@@ -1325,6 +1327,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
}
vsm->scrollbarwidth = scrollers->hor_max - scrollers->hor_min;
+ vsm->scrollbar_orig = ((scrollers->hor_max + scrollers->hor_min) / 2) + ar->winrct.xmin;
}
else {
/* vertical scroller - calculate adjustment factor first */
@@ -1340,6 +1343,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
}
vsm->scrollbarwidth = scrollers->vert_max - scrollers->vert_min;
+ vsm->scrollbar_orig = ((scrollers->vert_max + scrollers->vert_min) / 2) + + ar->winrct.ymin;
}
UI_view2d_scrollers_free(scrollers);
@@ -1464,6 +1468,7 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event)
break;
case LEFTMOUSE:
+ case MIDDLEMOUSE:
if (event->val==KM_RELEASE) {
/* single-click was in empty space outside bubble, so scroll by 1 'page' */
if (ELEM(vsm->zone, SCROLLHANDLE_MIN_OUTSIDE, SCROLLHANDLE_MAX_OUTSIDE)) {
@@ -1484,6 +1489,7 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event)
}
}
break;
+
}
return OPERATOR_RUNNING_MODAL;
@@ -1508,6 +1514,21 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, wmEvent *event)
scroller_activate_init(C, op, event, in_scroller);
vsm= (v2dScrollerMove *)op->customdata;
+ /* support for quick jump to location - gtk and qt do this on linux */
+ if (event->type == MIDDLEMOUSE) {
+ switch (vsm->scroller) {
+ case 'h': /* horizontal scroller - so only horizontal movement ('cur' moves opposite to mouse) */
+ vsm->delta= (float)(event->x - vsm->scrollbar_orig);
+ break;
+ case 'v': /* vertical scroller - so only vertical movement ('cur' moves opposite to mouse) */
+ vsm->delta= (float)(event->y - vsm->scrollbar_orig);
+ break;
+ }
+ scroller_activate_apply(C, op);
+
+ vsm->zone= SCROLLHANDLE_BAR;
+ }
+
/* check if zoom zones are inappropriate (i.e. zoom widgets not shown), so cannot continue
* NOTE: see view2d.c for latest conditions, and keep this in sync with that
*/
@@ -1669,6 +1690,10 @@ void UI_view2d_keymap(wmKeyConfig *keyconf)
{
wmKeyMap *keymap= WM_keymap_find(keyconf, "View2D", 0, 0);
+ /* scrollers */
+ WM_keymap_add_item(keymap, "VIEW2D_OT_scroller_activate", LEFTMOUSE, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "VIEW2D_OT_scroller_activate", MIDDLEMOUSE, KM_PRESS, 0, 0);
+
/* pan/scroll */
WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MIDDLEMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0);
@@ -1713,12 +1738,13 @@ void UI_view2d_keymap(wmKeyConfig *keyconf)
/* borderzoom - drag */
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_border", BKEY, KM_PRESS, KM_SHIFT, 0);
-
- /* scrollers */
- WM_keymap_add_item(keymap, "VIEW2D_OT_scroller_activate", LEFTMOUSE, KM_PRESS, 0, 0);
/* Alternative keymap for buttons listview */
keymap= WM_keymap_find(keyconf, "View2D Buttons List", 0, 0);
+
+ WM_keymap_add_item(keymap, "VIEW2D_OT_scroller_activate", LEFTMOUSE, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "VIEW2D_OT_scroller_activate", MIDDLEMOUSE, KM_PRESS, 0, 0);
+
WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MIDDLEMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MOUSEPAN, 0, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", WHEELDOWNMOUSE, KM_PRESS, 0, 0);
@@ -1732,6 +1758,5 @@ void UI_view2d_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_out", PADMINUS, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_in", PADPLUSKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_reset", HOMEKEY, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "VIEW2D_OT_scroller_activate", LEFTMOUSE, KM_PRESS, 0, 0);
}