diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-07-03 05:57:38 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-07-03 05:57:38 +0400 |
commit | 5e92ddece3a7367ca7687e762226d639389e5517 (patch) | |
tree | ba8437a82874057138ff5e9f07b446fa6d2ff044 /source/blender/editors/interface | |
parent | 28d371d1178642e17f5dfc300f1500a132ce7149 (diff) | |
parent | fb5f9273eba4b30e1aa0573388367592b18bdbba (diff) |
NLA SoC: Merge from 2.5
21301 to 21329
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 49 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 238 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 103 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d.c | 307 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 15 |
7 files changed, 280 insertions, 435 deletions
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 1b16155c7e6..b2ba6fb38a8 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -420,6 +420,7 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect); void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect); void ui_draw_link_bezier(rcti *rect); +void widget_scroll_draw(struct uiWidgetColors *wcol, rcti *rect, rcti *slider, int state); extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect); /* theme color init */ diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index f9816235b88..2e30c5f1cb7 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -615,14 +615,13 @@ void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, ch /* for getting the enum */ PropertyRNA *prop; const EnumPropertyItem *item; - int totitem; int value; WM_operator_properties_create(&ptr, opname); /* enum lookup */ if((prop= RNA_struct_find_property(&ptr, propname))) { - RNA_property_enum_items(&ptr, prop, &item, &totitem); + RNA_property_enum_items(&ptr, prop, &item, NULL); if(RNA_enum_value_from_id(item, value_str, &value)==0) { printf("uiItemEnumO_string: %s.%s, enum %s not found.\n", RNA_struct_identifier(ptr.type), propname, value_str); return; @@ -695,14 +694,17 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA PropertySubType subtype; int len, w, h; - w= ui_text_icon_width(layout, name, icon); - h= UI_UNIT_Y; - /* arbitrary extended width by type */ type= RNA_property_type(prop); subtype= RNA_property_subtype(prop); len= RNA_property_array_length(prop); + if(type == PROP_STRING && strcmp(name, "") == 0) + name= "non-empty"; + + w= ui_text_icon_width(layout, name, icon); + h= UI_UNIT_Y; + /* increase height for arrays */ if(index == RNA_NO_INDEX && len > 0) { if(strcmp(name, "") == 0 && icon == 0) @@ -827,15 +829,48 @@ void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, prop= RNA_struct_find_property(ptr, propname); - if(!prop) { + if(!prop || RNA_property_type(prop) != PROP_ENUM) { ui_item_disabled(layout, propname); - printf("uiItemEnumR: property not found: %s\n", propname); + printf("uiItemEnumR: enum property not found: %s\n", propname); return; } uiItemFullR(layout, name, icon, ptr, prop, RNA_ENUM_VALUE, value, 0, 0, 0); } +void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value) +{ + PropertyRNA *prop; + const EnumPropertyItem *item; + int ivalue, a; + + if(!ptr->data || !propname) + return; + + prop= RNA_struct_find_property(ptr, propname); + + if(!prop || RNA_property_type(prop) != PROP_ENUM) { + ui_item_disabled(layout, propname); + printf("uiItemEnumR: enum property not found: %s\n", propname); + return; + } + + RNA_property_enum_items(ptr, prop, &item, NULL); + + if(!RNA_enum_value_from_id(item, value, &ivalue)) { + ui_item_disabled(layout, propname); + printf("uiItemEnumR: enum property value not found: %s\n", value); + return; + } + + for(a=0; item[a].identifier; a++) { + if(item[a].value == ivalue) { + uiItemFullR(layout, (char*)item[a].name, item[a].icon, ptr, prop, RNA_ENUM_VALUE, ivalue, 0, 0, 0); + break; + } + } +} + void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname) { PropertyRNA *prop; diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index a20884a61a3..319e69a40e4 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -106,7 +106,7 @@ static int panel_aligned(ScrArea *sa, ARegion *ar) } else if(sa->spacetype==SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS) return BUT_VERTICAL; - else if(ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS)) + else if(ELEM3(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) return BUT_VERTICAL; return 0; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 8f1d57b28ed..d9bc2d4d426 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -320,134 +320,6 @@ void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname #include "ED_object.h" -static void modifiers_del(bContext *C, void *ob_v, void *md_v) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= ob_v; - ReportList reports; - - BKE_reports_init(&reports, RPT_STORE); - - if(ED_object_modifier_delete(&reports, ob_v, md_v)) { - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); - DAG_object_flush_update(scene, ob, OB_RECALC_DATA); - - ED_undo_push(C, "Delete modifier"); - } - else - uiPupMenuReports(C, &reports); - - BKE_reports_clear(&reports); -} - -static void modifiers_activate(bContext *C, void *ob_v, void *md_v) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= ob_v; - - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); - DAG_object_flush_update(scene, ob, OB_RECALC_DATA); -} - -static void modifiers_moveUp(bContext *C, void *ob_v, void *md_v) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= ob_v; - ReportList reports; - - BKE_reports_init(&reports, RPT_STORE); - - if(ED_object_modifier_move_up(&reports, ob_v, md_v)) { - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); - DAG_object_flush_update(scene, ob, OB_RECALC_DATA); - - ED_undo_push(C, "Move modifier"); - } - else - uiPupMenuReports(C, &reports); - - BKE_reports_clear(&reports); -} - -static void modifiers_moveDown(bContext *C, void *ob_v, void *md_v) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= ob_v; - ReportList reports; - - BKE_reports_init(&reports, RPT_STORE); - - if(ED_object_modifier_move_down(&reports, ob_v, md_v)) { - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); - DAG_object_flush_update(scene, ob, OB_RECALC_DATA); - - ED_undo_push(C, "Move modifier"); - } - else - uiPupMenuReports(C, &reports); - - BKE_reports_clear(&reports); -} - -static void modifiers_convertParticles(bContext *C, void *obv, void *mdv) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= obv; - ReportList reports; - - BKE_reports_init(&reports, RPT_STORE); - - if(ED_object_modifier_convert(&reports, scene, obv, mdv)) { - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); - DAG_object_flush_update(scene, ob, OB_RECALC_DATA); - - ED_undo_push(C, "Convert particles to mesh object(s)."); - } - else - uiPupMenuReports(C, &reports); - - BKE_reports_clear(&reports); -} - -static void modifiers_applyModifier(bContext *C, void *obv, void *mdv) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= obv; - ReportList reports; - - BKE_reports_init(&reports, RPT_STORE); - - if(ED_object_modifier_apply(&reports, scene, obv, mdv)) { - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); - DAG_object_flush_update(scene, ob, OB_RECALC_DATA); - - ED_undo_push(C, "Apply modifier"); - } - else - uiPupMenuReports(C, &reports); - - BKE_reports_clear(&reports); -} - -static void modifiers_copyModifier(bContext *C, void *ob_v, void *md_v) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= ob_v; - ReportList reports; - - BKE_reports_init(&reports, RPT_STORE); - - if(ED_object_modifier_copy(&reports, ob_v, md_v)) { - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); - DAG_object_flush_update(scene, ob, OB_RECALC_DATA); - ED_undo_push(C, "Copy modifier"); - } - else - uiPupMenuReports(C, &reports); - - BKE_reports_clear(&reports); -} - static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v) { Scene *scene= CTX_data_scene(C); @@ -490,15 +362,7 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v) static int modifier_can_delete(ModifierData *md) { - // deletion over the deflection panel // fluid particle modifier can't be deleted here - - if(md->type==eModifierType_Fluidsim) - return 0; - if(md->type==eModifierType_Collision) - return 0; - if(md->type==eModifierType_Surface) - return 0; if(md->type == eModifierType_ParticleSystem) if(((ParticleSystemModifierData *)md)->psys->part->type == PART_FLUID) return 0; @@ -512,12 +376,12 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i PointerRNA ptr; uiBut *but; uiBlock *block; - uiLayout *column, *row, *subrow, *result= NULL; - int isVirtual = md->mode&eModifierMode_Virtual; + uiLayout *column, *row, *result= NULL; + int isVirtual = md->mode & eModifierMode_Virtual; // XXX short color = md->error?TH_REDALERT:TH_BUT_NEUTRAL; - short width = 295, buttonWidth = width-120-10; char str[128]; + /* create RNA pointer */ RNA_pointer_create(&ob->id, &RNA_Modifier, md, &ptr); column= uiLayoutColumn(layout, 1); @@ -528,57 +392,57 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i /* roundbox 4 free variables: corner-rounding, nop, roundbox type, shade */ row= uiLayoutRow(uiLayoutBox(column), 0); - block= uiLayoutGetBlock(row); + uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND); - subrow= uiLayoutRow(row, 0); - uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_LEFT); + block= uiLayoutGetBlock(row); //uiDefBut(block, ROUNDBOX, 0, "", x-10, y-4, width, 25, NULL, 7.0, 0.0, - // (!isVirtual && (md->mode&eModifierMode_Expanded))?3:15, 20, ""); + // (!isVirtual && (md->mode & eModifierMode_Expanded))?3:15, 20, ""); /* XXX uiBlockSetCol(block, TH_AUTO); */ /* open/close icon */ - if (!isVirtual) { + if(!isVirtual) { uiBlockSetEmboss(block, UI_EMBOSSN); uiDefIconButBitI(block, ICONTOG, eModifierMode_Expanded, 0, ICON_TRIA_RIGHT, 0, 0, UI_UNIT_X, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Modifier"); } /* modifier-type icon */ - uiDefIconBut(block, BUT, 0, RNA_struct_ui_icon(ptr.type), 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Current Modifier Type"); + uiItemL(row, "", RNA_struct_ui_icon(ptr.type)); uiBlockSetEmboss(block, UI_EMBOSS); - if (isVirtual) { + if(isVirtual) { + /* virtual modifier */ sprintf(str, "%s parent deform", md->name); uiDefBut(block, LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Modifier name"); but = uiDefBut(block, BUT, 0, "Make Real", 0, 0, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Convert virtual modifier to a real modifier"); uiButSetFunc(but, modifiers_convertToReal, ob, md); - } else { + } + else { + /* real modifier */ uiBlockBeginAlign(block); - uiDefBut(block, TEX, 0, "", 0, 0, buttonWidth-40, UI_UNIT_Y, md->name, 0.0, sizeof(md->name)-1, 0.0, 0.0, "Modifier name"); + uiItemR(row, "", 0, &ptr, "name", 0, 0, 0); /* Softbody not allowed in this situation, enforce! */ - if (((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && (md->type!=eModifierType_Surface)) { - uiDefIconButBitI(block, TOG, eModifierMode_Render, 0, ICON_SCENE, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during rendering"); - but= uiDefIconButBitI(block, TOG, eModifierMode_Realtime, 0, ICON_VIEW3D, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during interactive display"); - uiButSetFunc(but, modifiers_activate, ob, md); - if (mti->flags&eModifierTypeFlag_SupportsEditmode) { - but= uiDefIconButBitI(block, TOG, eModifierMode_Editmode, 0, ICON_EDITMODE_HLT, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during Editmode (only if enabled for display)"); - uiButSetFunc(but, modifiers_activate, ob, md); - } + if(((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && (md->type!=eModifierType_Surface)) { + uiItemR(row, "", ICON_SCENE, &ptr, "render", 0, 0, 0); + uiItemR(row, "", ICON_VIEW3D, &ptr, "realtime", 0, 0, 0); + + if(mti->flags & eModifierTypeFlag_SupportsEditmode) + uiItemR(row, "", ICON_VIEW3D, &ptr, "editmode", 0, 0, 0); } uiBlockEndAlign(block); /* XXX uiBlockSetEmboss(block, UI_EMBOSSR); */ - if (ob->type==OB_MESH && modifier_couldBeCage(md) && index<=lastCageIndex) { + if(ob->type==OB_MESH && modifier_couldBeCage(md) && index<=lastCageIndex) { int icon; //, color; - if (index==cageIndex) { + if(index==cageIndex) { // XXX color = TH_BUT_SETTING; icon = VICON_EDITMODE_HLT; - } else if (index<cageIndex) { + } else if(index<cageIndex) { // XXX color = TH_BUT_NEUTRAL; icon = VICON_EDITMODE_DEHLT; } else { @@ -592,67 +456,55 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i } } - subrow= uiLayoutRow(row, 0); - uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT); - + /* up/down/delete */ if(!isVirtual) { /* XXX uiBlockSetCol(block, TH_BUT_ACTION); */ - - but = uiDefIconBut(block, BUT, 0, VICON_MOVE_UP, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier up in stack"); - uiButSetFunc(but, modifiers_moveUp, ob, md); - - but = uiDefIconBut(block, BUT, 0, VICON_MOVE_DOWN, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier down in stack"); - uiButSetFunc(but, modifiers_moveDown, ob, md); + uiItemO(row, "", VICON_MOVE_UP, "OBJECT_OT_modifier_move_up"); + uiItemO(row, "", VICON_MOVE_DOWN, "OBJECT_OT_modifier_move_down"); uiBlockSetEmboss(block, UI_EMBOSSN); - - if(modifier_can_delete(md)) { - but = uiDefIconBut(block, BUT, 0, VICON_X, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Delete modifier"); - uiButSetFunc(but, modifiers_del, ob, md); - } + + if(modifier_can_delete(md)) + uiItemO(row, "", VICON_X, "OBJECT_OT_modifier_remove"); + /* XXX uiBlockSetCol(block, TH_AUTO); */ } uiBlockSetEmboss(block, UI_EMBOSS); - if(!isVirtual && (md->mode&eModifierMode_Expanded)) { + if(!isVirtual && (md->mode & eModifierMode_Expanded)) { + /* apply/convert/copy */ uiLayout *box; box= uiLayoutBox(column); row= uiLayoutRow(box, 1); - if (!isVirtual && (md->type!=eModifierType_Collision) && (md->type!=eModifierType_Surface)) { - uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE); /* only here obdata, the rest of modifiers is ob level */ + if(!isVirtual && (md->type!=eModifierType_Collision) && (md->type!=eModifierType_Surface)) { + /* only here obdata, the rest of modifiers is ob level */ + uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE); - if (md->type==eModifierType_ParticleSystem) { + if(md->type==eModifierType_ParticleSystem) { ParticleSystem *psys= ((ParticleSystemModifierData *)md)->psys; - if(!(G.f & G_PARTICLEEDIT)) { - if(ELEM3(psys->part->draw_as, PART_DRAW_PATH, PART_DRAW_GR, PART_DRAW_OB) && psys->pathcache) { - but = uiDefBut(block, BUT, 0, "Convert", 0,0,60,19, 0, 0, 0, 0, 0, "Convert the current particles to a mesh object"); - uiButSetFunc(but, modifiers_convertParticles, ob, md); - } - } - } - else{ - but = uiDefBut(block, BUT, 0, "Apply", 0,0,60,19, 0, 0, 0, 0, 0, "Apply the current modifier and remove from the stack"); - uiButSetFunc(but, modifiers_applyModifier, ob, md); + if(!(G.f & G_PARTICLEEDIT)) + if(ELEM3(psys->part->draw_as, PART_DRAW_PATH, PART_DRAW_GR, PART_DRAW_OB) && psys->pathcache) + uiItemO(row, "Convert", 0, "OBJECT_OT_modifier_convert"); } + else + uiItemO(row, "Apply", 0, "OBJECT_OT_modifier_apply"); uiBlockClearButLock(block); uiBlockSetButLock(block, ob && ob->id.lib, ERROR_LIBDATA_MESSAGE); - if (md->type!=eModifierType_Fluidsim && md->type!=eModifierType_Softbody && md->type!=eModifierType_ParticleSystem && (md->type!=eModifierType_Cloth)) { - but = uiDefBut(block, BUT, 0, "Copy", 0,0,60,19, 0, 0, 0, 0, 0, "Duplicate the current modifier at the same position in the stack"); - uiButSetFunc(but, modifiers_copyModifier, ob, md); - } + if(!ELEM4(md->type, eModifierType_Fluidsim, eModifierType_Softbody, eModifierType_ParticleSystem, eModifierType_Cloth)) + uiItemO(row, "Copy", 0, "OBJECT_OT_modifier_copy"); } result= uiLayoutColumn(box, 0); block= uiLayoutFreeBlock(box); } - if (md->error) { + if(md->error) { row = uiLayoutRow(uiLayoutBox(column), 0); /* XXX uiBlockSetCol(block, color); */ @@ -694,7 +546,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, PointerRNA *ptr) for(i=0; vmd; i++, vmd=vmd->next) { if(md == vmd) return draw_modifier(layout, ob, md, i, cageIndex, lastCageIndex); - else if(vmd->mode&eModifierMode_Virtual) + else if(vmd->mode & eModifierMode_Virtual) i--; } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index ed2d00cb00d..751a09ede49 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -293,13 +293,15 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl float maxyi= maxy - 1.0f; float facxi= 1.0f/(maxxi-minxi); /* for uv */ float facyi= 1.0f/(maxyi-minyi); - int a, tot= 0; + int a, tot= 0, minsize; - if(2.0f*rad > rect->ymax-rect->ymin) - rad= 0.5f*(rect->ymax-rect->ymin); + minsize= MIN2(rect->xmax-rect->xmin, rect->ymax-rect->ymin); + + if(2.0f*rad > minsize) + rad= 0.5f*minsize; - if(2.0f*(radi+1.0f) > rect->ymax-rect->ymin) - radi= 0.5f*(rect->ymax-rect->ymin) - 1.0f; + if(2.0f*(radi+1.0f) > minsize) + radi= 0.5f*minsize - 1.0f; /* mult */ for(a=0; a<9; a++) { @@ -525,7 +527,7 @@ static void shadecolors4(char *coltop, char *coldown, char *color, short shadeto coldown[0]= CLAMPIS(color[0]+shadedown, 0, 255); coldown[1]= CLAMPIS(color[1]+shadedown, 0, 255); coldown[2]= CLAMPIS(color[2]+shadedown, 0, 255); - coldown[3]= color[3]; + coldown[3]= color[3]; } static void round_box_shade_col4(char *col1, char *col2, float fac) @@ -1104,16 +1106,16 @@ static struct uiWidgetColors wcol_toggle= { }; static struct uiWidgetColors wcol_scroll= { - {25, 25, 25, 255}, + {50, 50, 50, 180}, + {80, 80, 80, 180}, + {100, 100, 100, 180}, {180, 180, 180, 255}, - {153, 153, 153, 255}, - {90, 90, 90, 255}, {0, 0, 0, 255}, {255, 255, 255, 255}, 1, - 0, -20 + 10, -20 }; /* free wcol struct to play with */ @@ -1204,6 +1206,10 @@ static void widget_state_label(uiWidgetType *wt, int state) } +static void widget_state_nothing(uiWidgetType *wt, int state) +{ + wt->wcol= *(wt->wcol_theme); +} /* special case, button that calls pulldown */ static void widget_state_pulldown(uiWidgetType *wt, int state) @@ -1632,44 +1638,64 @@ void ui_draw_link_bezier(rcti *rect) } } -static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) +/* function in use for buttons and for view2d sliders */ +void widget_scroll_draw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int state) { uiWidgetBase wtb; - rcti rect1; - double value; - char inner[3]; - float fac, size, rad; + float rad; int horizontal; + widget_init(&wtb); + /* determine horizontal/vertical */ horizontal= (rect->xmax - rect->xmin > rect->ymax - rect->ymin); - + if(horizontal) rad= 0.5f*(rect->ymax - rect->ymin); else rad= 0.5f*(rect->xmax - rect->xmin); - - widget_init(&wtb); + wtb.shadedir= (horizontal)? 1: 0; - + /* draw back part, colors swapped and shading inverted */ - VECCOPY(inner, wcol->inner); - VECCOPY(wcol->inner, wcol->item); if(horizontal) SWAP(short, wcol->shadetop, wcol->shadedown); - if(state & UI_SELECT) - SWAP(short, wcol->shadetop, wcol->shadedown); - round_box_edges(&wtb, roundboxalign, rect, rad); /* XXX vertical gradient is wrong */ + round_box_edges(&wtb, 15, rect, rad); widgetbase_draw(&wtb, wcol); - - VECCOPY(wcol->inner, inner); - if(horizontal) - SWAP(short, wcol->shadetop, wcol->shadedown); - if(state & UI_SELECT) - SWAP(short, wcol->shadetop, wcol->shadedown); - /* front part */ + /* slider */ + if(slider->xmax-slider->xmin<2 || slider->ymax-slider->ymin<2); + else { + + SWAP(short, wcol->shadetop, wcol->shadedown); + + QUATCOPY(wcol->inner, wcol->item); + + if(wcol->shadetop>wcol->shadedown) + wcol->shadetop+= 20; /* XXX violates themes... */ + else wcol->shadedown+= 20; + + if(state & UI_SELECT) + SWAP(short, wcol->shadetop, wcol->shadedown); + + /* draw */ + wtb.emboss= 0; /* only emboss once */ + + round_box_edges(&wtb, 15, slider, rad); + widgetbase_draw(&wtb, wcol); + + } +} + +static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) +{ + rcti rect1; + double value; + float fac, size; + int horizontal; + + /* calculate slider part */ value= ui_get_but_val(but); size= (but->softmax + but->a1 - but->softmin); @@ -1678,6 +1704,9 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat /* position */ rect1= *rect; + /* determine horizontal/vertical */ + horizontal= (rect->xmax - rect->xmin > rect->ymax - rect->ymin); + if(horizontal) { fac= (rect->xmax - rect->xmin)/(size); rect1.xmin= rect1.xmin + ceil(fac*(value - but->softmin)); @@ -1689,17 +1718,8 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat rect1.ymin= rect1.ymax - ceil(fac*(but->a1 - but->softmin)); } - /* draw */ - wtb.emboss= 0; /* only emboss once */ - - if(!horizontal) - SWAP(short, wcol->shadetop, wcol->shadedown); + widget_scroll_draw(wcol, rect, &rect1, state); - round_box_edges(&wtb, roundboxalign, &rect1, rad); /* XXX vertical gradient is wrong */ - widgetbase_draw(&wtb, wcol); - - if(!horizontal) - SWAP(short, wcol->shadetop, wcol->shadedown); } static void widget_link(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) @@ -2101,6 +2121,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type) case UI_WTYPE_SCROLL: wt.wcol_theme= &btheme->tui.wcol_scroll; + wt.state= widget_state_nothing; wt.custom= widget_scroll; break; } diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index c32c8c817fb..e54f22b5ae6 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -34,6 +34,7 @@ #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "DNA_userdef_types.h" #include "DNA_view2d_types.h" #include "BLI_blenlib.h" @@ -918,7 +919,14 @@ void UI_view2d_view_orthoSpecial(const bContext *C, View2D *v2d, short xaxis) /* Restore view matrices after drawing */ void UI_view2d_view_restore(const bContext *C) { - ED_region_pixelspace(CTX_wm_region(C)); + ARegion *ar= CTX_wm_region(C); + int width= ar->winrct.xmax-ar->winrct.xmin+1; + int height= ar->winrct.ymax-ar->winrct.ymin+1; + + wmOrtho2(0.0f, (float)width, 0.0f, (float)height); + wmLoadIdentity(); + + // ED_region_pixelspace(CTX_wm_region(C)); } /* *********************************************************************** */ @@ -1215,7 +1223,10 @@ void UI_view2d_grid_free(View2DGrid *grid) * WARNING: the start of this struct must not change, as view2d_ops.c uses this too. * For now, we don't need to have a separate (internal) header for structs like this... */ -struct View2DScrollers { +struct View2DScrollers { + rcti hor, vert; /* exact size of slider backdrop */ + int horfull, vertfull; /* set if sliders are full, we don't draw them */ + /* focus bubbles */ int vert_min, vert_max; /* vertical scrollbar */ int hor_min, hor_max; /* horizontal scrollbar */ @@ -1231,14 +1242,33 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short { View2DScrollers *scrollers; rcti vert, hor; - float fac, totsize, scrollsize; + float fac1, fac2, totsize, scrollsize; int scroll= view2d_scroll_mapped(v2d->scroll); + /* scrollers is allocated here... */ + scrollers= MEM_callocN(sizeof(View2DScrollers), "View2DScrollers"); + vert= v2d->vert; hor= v2d->hor; - /* scrollers is allocated here... */ - scrollers= MEM_callocN(sizeof(View2DScrollers), "View2DScrollers"); + /* slider rects smaller than region */ + hor.xmin+=4; + hor.xmax-=4; + if (scroll & V2D_SCROLL_BOTTOM) + hor.ymin+=4; + else + hor.ymax-=4; + + if (scroll & V2D_SCROLL_LEFT) + vert.xmin+=4; + else + vert.xmax-=4; + vert.ymin+=4; + vert.ymax-=4; + + /* store in scrollers, used for drawing */ + scrollers->vert= vert; + scrollers->hor= hor; /* scroller 'buttons': * - These should always remain within the visible region of the scrollbar @@ -1251,14 +1281,23 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short totsize= v2d->tot.xmax - v2d->tot.xmin; scrollsize= (float)(hor.xmax - hor.xmin); - fac= (v2d->cur.xmin - v2d->tot.xmin) / totsize; - scrollers->hor_min= (int)(hor.xmin + (fac * scrollsize)); + fac1= (v2d->cur.xmin - v2d->tot.xmin) / totsize; + if(fac1<=0.0f) + scrollers->hor_min= hor.xmin; + else + scrollers->hor_min= (int)(hor.xmin + (fac1 * scrollsize)); - fac= (v2d->cur.xmax - v2d->tot.xmin) / totsize; - scrollers->hor_max= (int)(hor.xmin + (fac * scrollsize)); + fac2= (v2d->cur.xmax - v2d->tot.xmin) / totsize; + if(fac2>=1.0f) + scrollers->hor_max= hor.xmax; + else + scrollers->hor_max= (int)(hor.xmin + (fac2 * scrollsize)); if (scrollers->hor_min > scrollers->hor_max) scrollers->hor_min= scrollers->hor_max; + + if(fac1 <= 0.0f && fac2 >= 1.0f) + scrollers->horfull= 1; } /* vertical scrollers */ @@ -1267,14 +1306,23 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short totsize= v2d->tot.ymax - v2d->tot.ymin; scrollsize= (float)(vert.ymax - vert.ymin); - fac= (v2d->cur.ymin- v2d->tot.ymin) / totsize; - scrollers->vert_min= (int)(vert.ymin + (fac * scrollsize)); + fac1= (v2d->cur.ymin- v2d->tot.ymin) / totsize; + if(fac1<=0.0f) + scrollers->vert_min= vert.ymin; + else + scrollers->vert_min= (int)(vert.ymin + (fac1 * scrollsize)); - fac= (v2d->cur.ymax - v2d->tot.ymin) / totsize; - scrollers->vert_max= (int)(vert.ymin + (fac * scrollsize)); + fac2= (v2d->cur.ymax - v2d->tot.ymin) / totsize; + if(fac2>=1.0f) + scrollers->vert_max= vert.ymax; + else + scrollers->vert_max= (int)(vert.ymin + (fac2 * scrollsize)); if (scrollers->vert_min > scrollers->vert_max) scrollers->vert_min= scrollers->vert_max; + + if(fac1 <= 0.0f && fac2 >= 1.0f) + scrollers->vertfull= 1; } /* grid markings on scrollbars */ @@ -1304,7 +1352,7 @@ static void scroll_printstr(View2DScrollers *scrollers, Scene *scene, float x, f * rotation values (hence 'degrees') are divided by 10 to * be able to show the curves at the same time */ - if ELEM(unit, V2D_UNIT_DEGREES, V2D_UNIT_TIME) { + if (ELEM(unit, V2D_UNIT_DEGREES, V2D_UNIT_TIME)) { power += 1; val *= 10; } @@ -1410,81 +1458,27 @@ static void scroll_printstr(View2DScrollers *scrollers, Scene *scene, float x, f void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *vs) { Scene *scene= CTX_data_scene(C); - const short darker= -50, dark= -10, light= 20, lighter= 50; - rcti vert, hor, corner; + rcti vert, hor; int scroll= view2d_scroll_mapped(v2d->scroll); /* make copies of rects for less typing */ - vert= v2d->vert; - hor= v2d->hor; + vert= vs->vert; + hor= vs->hor; /* horizontal scrollbar */ if (scroll & V2D_SCROLL_HORIZONTAL) { - /* scroller backdrop */ - UI_ThemeColorShade(TH_SHADE1, light); - glRecti(hor.xmin, hor.ymin, hor.xmax, hor.ymax); - - /* scroller 'button' - * - if view is zoomable in x, draw handles too - * - handles are drawn darker - * - no slider when view is > total for non-zoomable views - * (otherwise, zoomable ones tend to flicker) - */ - if ( (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) || - ((v2d->tot.xmax - v2d->tot.xmin) > (v2d->cur.xmax - v2d->cur.xmin)) ) - { - if (v2d->keepzoom & V2D_LOCKZOOM_X) { - /* draw base bar as rounded shape */ - UI_ThemeColorShade(TH_SHADE1, dark); - uiSetRoundBox(15); - - /* check that box is large enough for round drawing */ - if ((vs->hor_max - vs->hor_min) < (V2D_SCROLLCAP_RAD * 2)) { - /* Rounded box still gets drawn at the minimum size limit - * This doesn't represent extreme scaling well, but looks nicer... - */ - float mid= 0.5f * (vs->hor_max + vs->hor_min); - - gl_round_box_shade(GL_POLYGON, - mid-V2D_SCROLLCAP_RAD, (float)hor.ymin+2, - mid+V2D_SCROLLCAP_RAD, (float)hor.ymax-2, - V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE); - } - else { - /* draw rounded box as per normal */ - gl_round_box_shade(GL_POLYGON, - (float)vs->hor_min, (float)hor.ymin+2, - (float)vs->hor_max, (float)hor.ymax-2, - V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE); - } - } - else { - /* base bar drawn as shaded rect */ - UI_ThemeColorShade(TH_SHADE1, dark); - uiSetRoundBox(0); - gl_round_box_shade(GL_POLYGON, - (float)vs->hor_min, (float)hor.ymin+2, - (float)vs->hor_max, (float)hor.ymax-2, - V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE); - - /* 'minimum' handle */ - uiSetRoundBox(9); - UI_ThemeColorShade(TH_SHADE1, darker); - - gl_round_box_shade(GL_POLYGON, - (float)vs->hor_min-V2D_SCROLLER_HANDLE_SIZE, (float)hor.ymin+2, - (float)vs->hor_min+V2D_SCROLLER_HANDLE_SIZE, (float)hor.ymax-2, - V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE); - - /* maximum handle */ - uiSetRoundBox(6); - UI_ThemeColorShade(TH_SHADE1, darker); - - gl_round_box_shade(GL_POLYGON, - (float)vs->hor_max-V2D_SCROLLER_HANDLE_SIZE, (float)hor.ymin+2, - (float)vs->hor_max+V2D_SCROLLER_HANDLE_SIZE, (float)hor.ymax-2, - V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE); - } + + if(vs->horfull==0) { + bTheme *btheme= U.themes.first; + uiWidgetColors wcol= btheme->tui.wcol_scroll; + rcti slider; + + slider.xmin= vs->hor_min; + slider.xmax= vs->hor_max; + slider.ymin= hor.ymin; + slider.ymax= hor.ymax; + + widget_scroll_draw(&wcol, &hor, &slider, (v2d->scroll_ui & V2D_SCROLL_H_ACTIVE)?UI_SELECT:0); } /* scale indicators */ @@ -1519,19 +1513,26 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v /* draw numbers in the appropriate range */ if (dfac > 0.0f) { - for (; fac < hor.xmax; fac+=dfac, val+=grid->dx) { + float h= 2.0f+(float)(hor.ymin); + + for (; fac < hor.xmax-10; fac+=dfac, val+=grid->dx) { + + /* make prints look nicer for scrollers */ + if(fac < hor.xmin+10) + continue; + switch (vs->xunits) { case V2D_UNIT_FRAMES: /* frames (as whole numbers)*/ - scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), val, grid->powerx, V2D_UNIT_FRAMES, 'h'); + scroll_printstr(vs, scene, fac, h, val, grid->powerx, V2D_UNIT_FRAMES, 'h'); break; case V2D_UNIT_FRAMESCALE: /* frames (not always as whole numbers) */ - scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), val, grid->powerx, V2D_UNIT_FRAMESCALE, 'h'); + scroll_printstr(vs, scene, fac, h, val, grid->powerx, V2D_UNIT_FRAMESCALE, 'h'); break; case V2D_UNIT_SECONDS: /* seconds */ fac2= val/(float)FPS; - scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), fac2, grid->powerx, V2D_UNIT_SECONDS, 'h'); + scroll_printstr(vs, scene, fac, h, fac2, grid->powerx, V2D_UNIT_SECONDS, 'h'); break; case V2D_UNIT_SECONDSSEQ: /* seconds with special calculations (only used for sequencer only) */ @@ -1542,96 +1543,37 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v time= (float)floor(fac2); fac2= fac2-time; - scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), time+(float)FPS*fac2/100.0f, grid->powerx, V2D_UNIT_SECONDSSEQ, 'h'); + scroll_printstr(vs, scene, fac, h, time+(float)FPS*fac2/100.0f, grid->powerx, V2D_UNIT_SECONDSSEQ, 'h'); } break; case V2D_UNIT_DEGREES: /* Graph Editor for rotation Drivers */ /* HACK: although we're drawing horizontal, we make this draw as 'vertical', just to get degree signs */ - scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), val, grid->powerx, V2D_UNIT_DEGREES, 'v'); + scroll_printstr(vs, scene, fac, h, val, grid->powerx, V2D_UNIT_DEGREES, 'v'); break; } } } } - - /* decoration outer bevel line */ - UI_ThemeColorShade(TH_SHADE1, lighter); - if (scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)) - sdrawline(hor.xmin, hor.ymax, hor.xmax, hor.ymax); - else if (scroll & V2D_SCROLL_TOP) - sdrawline(hor.xmin, hor.ymin, hor.xmax, hor.ymin); } /* vertical scrollbar */ if (scroll & V2D_SCROLL_VERTICAL) { - /* scroller backdrop */ - UI_ThemeColorShade(TH_SHADE1, light); - glRecti(vert.xmin, vert.ymin, vert.xmax, vert.ymax); - - /* scroller 'button' - * - if view is zoomable in y, draw handles too - * - handles are drawn darker - * - no slider when view is > total for non-zoomable views - * (otherwise, zoomable ones tend to flicker) - */ - if ( (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) || - ((v2d->tot.ymax - v2d->tot.ymin) > (v2d->cur.ymax - v2d->cur.ymin)) ) - { - if (v2d->keepzoom & V2D_LOCKZOOM_Y) { - /* draw base bar as rounded shape */ - UI_ThemeColorShade(TH_SHADE1, dark); - uiSetRoundBox(15); - - /* check that box is large enough for round drawing */ - if ((vs->vert_max - vs->vert_min) < (V2D_SCROLLCAP_RAD * 2)) { - /* Rounded box still gets drawn at the minimum size limit - * This doesn't represent extreme scaling well, but looks nicer... - */ - float mid= 0.5f * (vs->vert_max + vs->vert_min); - - gl_round_box_vertical_shade(GL_POLYGON, - (float)vert.xmin+2, mid-V2D_SCROLLCAP_RAD, - (float)vert.xmax-2, mid+V2D_SCROLLCAP_RAD, - V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE); - } - else { - /* draw rounded box as per normal */ - gl_round_box_vertical_shade(GL_POLYGON, - (float)vert.xmin+2, (float)vs->vert_min, - (float)vert.xmax-2, (float)vs->vert_max, - V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE); - } - } - else { - /* base bar drawn as shaded rect */ - UI_ThemeColorShade(TH_SHADE1, dark); - uiSetRoundBox(0); - gl_round_box_vertical_shade(GL_POLYGON, - (float)vert.xmin+2, (float)vs->vert_min, - (float)vert.xmax-2, (float)vs->vert_max, - V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE); - - /* 'minimum' handle */ - UI_ThemeColorShade(TH_SHADE1, darker); - uiSetRoundBox(12); - - gl_round_box_vertical_shade(GL_POLYGON, - (float)vert.xmin+2, (float)vs->vert_min-V2D_SCROLLER_HANDLE_SIZE, - (float)vert.xmax-2, (float)vs->vert_min+V2D_SCROLLER_HANDLE_SIZE, - V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE); - - /* maximum handle */ - UI_ThemeColorShade(TH_SHADE1, darker); - uiSetRoundBox(3); - - gl_round_box_vertical_shade(GL_POLYGON, - (float)vert.xmin+2, (float)vs->vert_max-V2D_SCROLLER_HANDLE_SIZE, - (float)vert.xmax-2, (float)vs->vert_max+V2D_SCROLLER_HANDLE_SIZE, - V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE); - } + + if(vs->vertfull==0) { + bTheme *btheme= U.themes.first; + uiWidgetColors wcol= btheme->tui.wcol_scroll; + rcti slider; + + slider.xmin= vert.xmin; + slider.xmax= vert.xmax; + slider.ymin= vs->vert_min; + slider.ymax= vs->vert_max; + + widget_scroll_draw(&wcol, &vert, &slider, (v2d->scroll_ui & V2D_SCROLL_V_ACTIVE)?UI_SELECT:0); } + /* scale indiators */ // XXX will need to update the font drawing when the new stuff comes in if ((scroll & V2D_SCROLL_SCALE_VERTICAL) && (vs->grid)) { @@ -1661,42 +1603,23 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v /* draw vertical steps */ if (dfac > 0.0f) { - for (; fac < vert.ymax; fac+= dfac, val += grid->dy) { - scroll_printstr(vs, scene, (float)(vert.xmax)-14.0f, fac, val, grid->powery, vs->yunits, 'v'); + + BLF_default_rotation(90.0f); + + for (; fac < vert.ymax-10; fac+= dfac, val += grid->dy) { + + /* make prints look nicer for scrollers */ + if(fac < vert.ymin+10) + continue; + + scroll_printstr(vs, scene, (float)(vert.xmax)-2.0f, fac, val, grid->powery, vs->yunits, 'v'); } + + BLF_default_rotation(0.0f); } } - - /* decoration outer bevel line */ - UI_ThemeColorShade(TH_SHADE1, lighter); - if (scroll & V2D_SCROLL_RIGHT) - sdrawline(vert.xmin, vert.ymin, vert.xmin, vert.ymax); - else if (scroll & V2D_SCROLL_LEFT) - sdrawline(vert.xmax, vert.ymin, vert.xmax, vert.ymax); } - /* draw a 'sunken square' to cover up any overlapping corners resulting from intersection of overflowing scroller data */ - if ((scroll & V2D_SCROLL_VERTICAL) && (scroll & V2D_SCROLL_HORIZONTAL)) { - /* set bounds (these should be right) */ - corner.xmin= vert.xmin; - corner.xmax= vert.xmax; - corner.ymin= hor.ymin; - corner.ymax= hor.ymax; - - /* firstly, draw using background color to cover up any overlapping junk */ - UI_ThemeColor(TH_SHADE1); - glRecti(corner.xmin, corner.ymin, corner.xmax, corner.ymax); - - /* now, draw suggestive highlighting... */ - /* first, dark lines on top to suggest scrollers overlap box */ - UI_ThemeColorShade(TH_SHADE1, darker); - sdrawline(corner.xmin, corner.ymin, corner.xmin, corner.ymax); - sdrawline(corner.xmin, corner.ymax, corner.xmax, corner.ymax); - /* now, light lines on bottom to show box is sunken in */ - UI_ThemeColorShade(TH_SHADE1, lighter); - sdrawline(corner.xmax, corner.ymin, corner.xmax, corner.ymax); - sdrawline(corner.xmin, corner.ymin, corner.xmax, corner.ymin); - } } /* free temporary memory used for drawing scrollers */ diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index bd1c734b870..ae89e215a03 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1095,15 +1095,23 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event, vsm->zone= mouse_in_scroller_handle(y, v2d->vert.ymin, v2d->vert.ymax, scrollers->vert_min, scrollers->vert_max); } } + UI_view2d_scrollers_free(scrollers); + ED_region_tag_redraw(ar); } /* cleanup temp customdata */ static void scroller_activate_exit(bContext *C, wmOperator *op) { if (op->customdata) { + v2dScrollerMove *vsm= op->customdata; + + vsm->v2d->scroll_ui &= ~(V2D_SCROLL_H_ACTIVE|V2D_SCROLL_V_ACTIVE); + MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata= NULL; + + ED_region_tag_redraw(CTX_wm_region(C)); } } @@ -1240,6 +1248,11 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, wmEvent *event) } } + if(vsm->scroller=='h') + v2d->scroll_ui |= V2D_SCROLL_H_ACTIVE; + else + v2d->scroll_ui |= V2D_SCROLL_V_ACTIVE; + /* still ok, so can add */ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); return OPERATOR_RUNNING_MODAL; |