diff options
author | Rohan Rathi <rohanrathi08@gmail.com> | 2018-07-02 21:01:19 +0300 |
---|---|---|
committer | Rohan Rathi <rohanrathi08@gmail.com> | 2018-07-02 21:01:19 +0300 |
commit | 31e43d021fdc55c6ec6741d382f4bbb05d1d62e9 (patch) | |
tree | 8ad72888c5516dcc0eb982d629a732c406177c83 /source/blender/editors | |
parent | 368a64fe041ee0950584f5b51e2f64036edb31d0 (diff) | |
parent | 31c9bd35bc9bb913b7a786da9c80751dbc60e006 (diff) |
Merge branch 'blender2.8' into soc-2018-bevel
Diffstat (limited to 'source/blender/editors')
328 files changed, 5923 insertions, 7496 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index e4213a8d907..f0bde9dcdfb 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -70,6 +70,7 @@ #include "BKE_context.h" #include "GPU_immediate.h" +#include "GPU_state.h" #include "DEG_depsgraph.h" @@ -3832,8 +3833,8 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float selected = 0; /* set blending again, as may not be set in previous step */ - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); /* step 1) draw backdrop ........................................... */ if (acf->draw_backdrop) @@ -3852,7 +3853,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float } /* turn off blending, since not needed anymore... */ - glDisable(GL_BLEND); + GPU_blend(false); /* step 4) draw special toggles ................................. * - in Graph Editor, checkboxes for visibility in curves area @@ -3930,7 +3931,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float /* FIXME: replace hardcoded color here, and check on extents! */ immUniformColor3f(1.0f, 0.0f, 0.0f); - glLineWidth(2.0f); + GPU_line_width(2.0f); immBegin(GWN_PRIM_LINES, 2); immVertex2f(pos, (float)offset, yminc); diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index ebe977420c6..f629c20b04a 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -659,7 +659,7 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f /* ****************** Operator Utilities ********************************** */ /* poll callback for being in an Animation Editor channels list region */ -static int animedit_poll_channels_active(bContext *C) +static bool animedit_poll_channels_active(bContext *C) { ScrArea *sa = CTX_wm_area(C); @@ -675,7 +675,7 @@ static int animedit_poll_channels_active(bContext *C) } /* poll callback for Animation Editor channels list region + not in NLA-tweakmode for NLA */ -static int animedit_poll_channels_nla_tweakmode_off(bContext *C) +static bool animedit_poll_channels_nla_tweakmode_off(bContext *C) { ScrArea *sa = CTX_wm_area(C); Scene *scene = CTX_data_scene(C); @@ -1415,7 +1415,7 @@ static void ANIM_OT_channels_move(wmOperatorType *ot) /* ******************** Group Channel Operator ************************ */ -static int animchannels_grouping_poll(bContext *C) +static bool animchannels_grouping_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); SpaceLink *sl; @@ -2190,7 +2190,7 @@ static void ANIM_OT_channels_clean_empty(wmOperatorType *ot) /* ******************* Reenable Disabled Operator ******************* */ -static int animchannels_enable_poll(bContext *C) +static bool animchannels_enable_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); @@ -2264,7 +2264,7 @@ static void ANIM_OT_channels_fcurves_enable(wmOperatorType *ot) /* ****************** Find / Set Filter Operator ******************** */ /* XXX: make this generic? */ -static int animchannels_find_poll(bContext *C) +static bool animchannels_find_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); @@ -2300,18 +2300,9 @@ static int animchannels_find_exec(bContext *C, wmOperator *op) if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - /* update filter text, and ensure that filter is enabled if there's something there - * NOTE: we turn the filter off if there's nothing (this is a quick shortcut for dismissing) - */ + /* update filter text */ RNA_string_get(op->ptr, "query", ac.ads->searchstr); - if (ac.ads->searchstr[0]) { - ac.ads->filterflag |= ADS_FILTER_BY_FCU_NAME; - } - else { - ac.ads->filterflag &= ~ADS_FILTER_BY_FCU_NAME; - } - /* redraw */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); @@ -2693,7 +2684,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, AnimData *adt = ob->adt; /* set selection status */ - if (base->flag & BASE_SELECTABLED) { + if (base->flag & BASE_SELECTABLE) { if (selectmode == SELECT_INVERT) { /* swap select */ ED_object_base_select(base, BA_INVERT); diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index c2cfb877745..953898a0586 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -64,6 +64,7 @@ #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "GPU_state.h" /* *************************************************** */ /* CURRENT FRAME DRAWING */ @@ -138,7 +139,7 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag) const float time = scene->r.cfra + scene->r.subframe; const float x = (float)(time * scene->r.framelen); - glLineWidth((flag & DRAWCFRA_WIDE) ? 3.0 : 2.0); + GPU_line_width((flag & DRAWCFRA_WIDE) ? 3.0 : 2.0); Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -166,8 +167,8 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width) /* only draw this if preview range is set */ if (PRVRANGEON) { - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -187,7 +188,7 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width) immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } } @@ -199,8 +200,8 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width) void ANIM_draw_framerange(Scene *scene, View2D *v2d) { /* draw darkened area outside of active timeline frame range */ - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -216,7 +217,7 @@ void ANIM_draw_framerange(Scene *scene, View2D *v2d) immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); } - glDisable(GL_BLEND); + GPU_blend(false); /* thin lines where the actual frames are */ immUniformThemeColorShade(TH_BACK, -60); diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 8892fed025a..c59d24bbdf8 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -245,6 +245,18 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction) /* update scene-pointer (no need to check for pinning yet, as not implemented) */ saction->ads.source = (ID *)ac->scene; + /* sync scene's "selected keys only" flag with our "only selected" flag + * XXX: This is a workaround for T55525. We shouldn't really be syncing the flags like this, + * but it's a simpler fix for now than also figuring out how the next/prev keyframe tools + * should work in the 3D View if we allowed full access to the timeline's dopesheet filters + * (i.e. we'd have to figure out where to host those settings, to be on a scene level like + * this flag currently is, along with several other unknowns) + */ + if (ac->scene->flag & SCE_KEYS_NO_SELONLY) + saction->ads.filterflag &= ~ADS_FILTER_ONLYSEL; + else + saction->ads.filterflag |= ADS_FILTER_ONLYSEL; + ac->datatype = ANIMCONT_TIMELINE; ac->data = &saction->ads; @@ -1209,7 +1221,7 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, eAnim_Chan /* only include if this curve is active */ if (!(filter_mode & ANIMFILTER_ACTIVE) || (fcu->flag & FCURVE_ACTIVE)) { /* name based filtering... */ - if ( ((ads) && (ads->filterflag & ADS_FILTER_BY_FCU_NAME)) && (owner_id) ) { + if ( ((ads) && (ads->searchstr[0] != '\0')) && (owner_id) ) { if (skip_fcurve_with_name(ads, fcu, channel_type, owner, owner_id)) continue; } @@ -1441,7 +1453,7 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDop /* only include if this track is active */ if (!(filter_mode & ANIMFILTER_ACTIVE) || (nlt->flag & NLATRACK_ACTIVE)) { /* name based filtering... */ - if (((ads) && (ads->filterflag & ADS_FILTER_BY_FCU_NAME)) && (owner_id)) { + if (((ads) && (ads->searchstr[0] != '\0')) && (owner_id)) { bool track_ok = false, strip_ok = false; /* check if the name of the track, or the strips it has are ok... */ @@ -1621,7 +1633,7 @@ static size_t animdata_filter_gpencil_layers_data(ListBase *anim_data, bDopeShee /* active... */ if (!(filter_mode & ANIMFILTER_ACTIVE) || (gpl->flag & GP_LAYER_ACTIVE)) { /* skip layer if the name doesn't match the filter string */ - if ((ads) && (ads->filterflag & ADS_FILTER_BY_FCU_NAME)) { + if ((ads) && (ads->searchstr[0] != '\0')) { if (name_matches_dopesheet_filter(ads, gpl->info) == false) continue; } @@ -1713,7 +1725,7 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, ListBase *anim_data, voi */ if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) { /* layer visibility - we check both object and base, since these may not be in sync yet */ - if ((base->flag & BASE_VISIBLED) == 0) continue; + if ((base->flag & BASE_VISIBLE) == 0) continue; /* outliner restrict-flag */ if (ob->restrictflag & OB_RESTRICT_VIEW) continue; @@ -1729,7 +1741,7 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, ListBase *anim_data, voi * objects by the grouped status is on * - used to ease the process of doing multiple-character choreographies */ - if (ads->filterflag & ADS_FILTER_ONLYOBGROUP) { + if (ads->filter_grp != NULL) { if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0) continue; } @@ -2852,7 +2864,7 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_m */ if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) { /* layer visibility - we check both object and base, since these may not be in sync yet */ - if ((base->flag & BASE_VISIBLED) == 0) + if ((base->flag & BASE_VISIBLE) == 0) return false; /* outliner restrict-flag */ @@ -2896,7 +2908,7 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_m * objects by the grouped status is on * - used to ease the process of doing multiple-character choreographies */ - if (ads->filterflag & ADS_FILTER_ONLYOBGROUP) { + if (ads->filter_grp != NULL) { if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0) return false; } diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index e957e84857a..05350ffd18e 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -61,6 +61,7 @@ #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "UI_interface.h" #include "UI_interface_icons.h" @@ -389,8 +390,8 @@ static void draw_marker( #endif int icon_id; - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); /* vertical line - dotted */ #ifdef DURIAN_CAMERA_SWITCH @@ -405,7 +406,7 @@ static void draw_marker( immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); if (marker->flag & SELECT) { @@ -444,7 +445,7 @@ static void draw_marker( UI_icon_draw(xpos - 0.45f * UI_DPI_ICON_SIZE, yoffs + UI_DPI_ICON_SIZE, icon_id); - glDisable(GL_BLEND); + GPU_blend(false); /* and the marker name too, shifted slightly to the top-right */ #ifdef DURIAN_CAMERA_SWITCH @@ -491,12 +492,12 @@ void ED_markers_draw(const bContext *C, int flag) const unsigned char shade[4] = {0, 0, 0, 16}; immUniformColor4ubv(shade); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); immRectf(pos, v2d->cur.xmin, 0, v2d->cur.xmax, UI_MARKER_MARGIN_Y); - glDisable(GL_BLEND); + GPU_blend(false); immUnbindProgram(); } @@ -540,7 +541,7 @@ void ED_markers_draw(const bContext *C, int flag) /* ------------------------ */ /* special poll() which checks if there are selected markers first */ -static int ed_markers_poll_selected_markers(bContext *C) +static bool ed_markers_poll_selected_markers(bContext *C) { ListBase *markers = ED_context_get_markers(C); @@ -552,7 +553,7 @@ static int ed_markers_poll_selected_markers(bContext *C) return ED_markers_get_first_selected(markers) != NULL; } -static int ed_markers_poll_selected_no_locked_markers(bContext *C) +static bool ed_markers_poll_selected_no_locked_markers(bContext *C) { ListBase *markers = ED_context_get_markers(C); ToolSettings *ts = CTX_data_tool_settings(C); @@ -570,7 +571,7 @@ static int ed_markers_poll_selected_no_locked_markers(bContext *C) /* special poll() which checks if there are any markers at all first */ -static int ed_markers_poll_markers_exist(bContext *C) +static bool ed_markers_poll_markers_exist(bContext *C) { ListBase *markers = ED_context_get_markers(C); ToolSettings *ts = CTX_data_tool_settings(C); @@ -769,7 +770,7 @@ static void ed_marker_move_update_header(bContext *C, wmOperator *op) BLI_snprintf(str, sizeof(str), IFACE_("Marker offset %s"), str_offs); } - ED_area_headerprint(CTX_wm_area(C), str); + ED_area_status_text(CTX_wm_area(C), str); } /* copy selection to temp buffer */ @@ -829,7 +830,7 @@ static void ed_marker_move_exit(bContext *C, wmOperator *op) op->customdata = NULL; /* clear custom header prints */ - ED_area_headerprint(CTX_wm_area(C), NULL); + ED_area_status_text(CTX_wm_area(C), NULL); } static int ed_marker_move_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -1670,8 +1671,10 @@ void ED_keymap_marker(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "MARKER_OT_select_border", BKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "MARKER_OT_select_all", AKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "MARKER_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MARKER_OT_delete", DELKEY, KM_PRESS, 0, 0); + WM_keymap_verify_item(keymap, "MARKER_OT_rename", MKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "MARKER_OT_move", GKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 4402ca78976..5f6b299c617 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -64,7 +64,7 @@ /* ********************** frame change operator ***************************/ /* Check if the operator can be run from the current context */ -static int change_frame_poll(bContext *C) +static bool change_frame_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); @@ -279,7 +279,7 @@ static void ANIM_OT_change_frame(wmOperatorType *ot) /* ****************** Start/End Frame Operators *******************************/ -static int anim_set_end_frames_poll(bContext *C) +static bool anim_set_end_frames_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index f303be0dd76..99725c7da99 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -819,7 +819,7 @@ static const EnumPropertyItem *driver_mapping_type_itemsf(bContext *C, PointerRN /* Add Driver (With Menu) Button Operator ------------------------ */ -static int add_driver_button_poll(bContext *C) +static bool add_driver_button_poll(bContext *C) { PointerRNA ptr = {{NULL}}; PropertyRNA *prop = NULL; diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index d1377703949..fcccf07190b 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -54,6 +54,7 @@ #include "GPU_draw.h" #include "GPU_immediate.h" +#include "GPU_state.h" #include "UI_resources.h" #include "UI_view2d.h" @@ -561,7 +562,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa const float icon_sz = U.widget_unit * 0.5f * yscale_fac; const float half_icon_sz = 0.5f * icon_sz; - glEnable(GL_BLEND); + GPU_blend(true); /* locked channels are less strongly shown, as feedback for locked channels in DopeSheet */ /* TODO: allow this opacity factor to be themed? */ @@ -654,7 +655,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa } } - glDisable(GL_BLEND); + GPU_blend(false); } /* *************************** Channel Drawing Funcs *************************** */ @@ -1056,4 +1057,3 @@ void mask_to_keylist(bDopeSheet *UNUSED(ads), MaskLayer *masklay, DLRBT_Tree *ke } } } - diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 6b24008c4d8..1bbfa6cc979 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -1471,4 +1471,3 @@ short bezt_selmap_flush(KeyframeEditData *ked, BezTriple *bezt) return 0; } - diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index fe5714aba2e..e234a3a131a 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1331,7 +1331,7 @@ enum { * This is based on the standard ED_operator_areaactive callback, * except that it does special checks for a few spacetypes too... */ -static int modify_key_op_poll(bContext *C) +static bool modify_key_op_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); Scene *scene = CTX_data_scene(C); diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 5bf23a53819..b5a998f60da 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -74,14 +74,14 @@ */ /* poll callback for adding default KeyingSet */ -static int keyingset_poll_default_add(bContext *C) +static bool keyingset_poll_default_add(bContext *C) { /* as long as there's an active Scene, it's fine */ return (CTX_data_scene(C) != NULL); } /* poll callback for editing active KeyingSet */ -static int keyingset_poll_active_edit(bContext *C) +static bool keyingset_poll_active_edit(bContext *C) { Scene *scene = CTX_data_scene(C); @@ -93,7 +93,7 @@ static int keyingset_poll_active_edit(bContext *C) } /* poll callback for editing active KeyingSet Path */ -static int keyingset_poll_activePath_edit(bContext *C) +static bool keyingset_poll_activePath_edit(bContext *C) { Scene *scene = CTX_data_scene(C); KeyingSet *ks; diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 1fe729b7c4b..a37a2bada08 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -251,4 +251,3 @@ int bone_looper(struct Object *ob, struct Bone *bone, void *data, #endif /* __ARMATURE_INTERN_H__ */ - diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index a73e64af0ee..350dee07a2c 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -468,4 +468,3 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot) /* settings */ ot->prop = RNA_def_enum(ot->srna, "type", axis_items, 0, "Axis", "Axis tag names with"); } - diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index cee99c3b8f8..067b9fd76a8 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -204,7 +204,11 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ARMATURE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_align", AKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "ARMATURE_OT_calculate_roll", NKEY, KM_PRESS, KM_CTRL, 0); +#else + WM_keymap_add_item(keymap, "ARMATURE_OT_calculate_roll", NKEY, KM_PRESS, KM_SHIFT, 0); +#endif WM_keymap_add_item(keymap, "ARMATURE_OT_roll_clear", RKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_switch_direction", FKEY, KM_PRESS, KM_ALT, 0); @@ -247,8 +251,12 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_armature_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_armature_delete", DELKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "ARMATURE_OT_dissolve", XKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "ARMATURE_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); + + WM_keymap_add_item(keymap, "ARMATURE_OT_dissolve", XKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "ARMATURE_OT_dissolve", DELKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "ARMATURE_OT_extrude_move", EKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_extrude_forked", EKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_click_extrude", ACTIONMOUSE, KM_CLICK, KM_CTRL, 0); @@ -395,4 +403,3 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_specials", WKEY, KM_PRESS, 0, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_propagate", PKEY, KM_PRESS, KM_ALT, 0); } - diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index cc149d3e42f..e0155a8c435 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -909,4 +909,3 @@ void ARMATURE_OT_parent_clear(wmOperatorType *ot) ot->prop = RNA_def_enum(ot->srna, "type", prop_editarm_clear_parent_types, 0, "ClearType", "What way to clear parenting"); } - diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index e295e1fd35a..ae2e7339c66 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -349,7 +349,7 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv return OPERATOR_FINISHED; } -static int armature_select_linked_poll(bContext *C) +static bool armature_select_linked_poll(bContext *C) { return (ED_operator_view3d_active(C) && ED_operator_editarmature(C)); } diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c index 87a66514417..63068e61ba3 100644 --- a/source/blender/editors/armature/armature_skinning.c +++ b/source/blender/editors/armature/armature_skinning.c @@ -45,11 +45,12 @@ #include "BKE_armature.h" #include "BKE_context.h" #include "BKE_deform.h" +#include "BKE_mesh_iterators.h" #include "BKE_mesh_runtime.h" +#include "BKE_modifier.h" #include "BKE_object_deform.h" #include "BKE_report.h" #include "BKE_subsurf.h" -#include "BKE_modifier.h" #include "DEG_depsgraph.h" @@ -259,7 +260,7 @@ static void add_verts_to_dgroups( * into account and vertex weights can be mirrored. * * The mesh vertex positions used are either the final deformed coords - * from the derivedmesh in weightpaint mode, the final subsurf coords + * from the evaluated mesh in weightpaint mode, the final subsurf coords * when parenting, or simply the original mesh coords. */ @@ -373,15 +374,11 @@ static void add_verts_to_dgroups( verts = MEM_callocN(mesh->totvert * sizeof(*verts), "closestboneverts"); if (wpmode) { - /* if in weight paint mode, use final verts from derivedmesh */ - DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH); + /* if in weight paint mode, use final verts from evaluated mesh */ + Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH); - if (dm->foreachMappedVert) { - mesh_get_mapped_verts_coords(dm, verts, mesh->totvert); - vertsfilled = 1; - } - - dm->release(dm); + BKE_mesh_foreach_mapped_vert_coords_get(me_eval, verts, mesh->totvert); + vertsfilled = 1; } else if (modifiers_findByType(ob, eModifierType_Subsurf)) { /* is subsurf on? Lets use the verts on the limit surface then. diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 1f01def5133..001c8ce215f 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -29,6 +29,7 @@ #include "DNA_object_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_scene_types.h" #include "BLI_math.h" @@ -39,10 +40,10 @@ #include "BLT_translation.h" -#include "BKE_DerivedMesh.h" -#include "BKE_modifier.h" +#include "BKE_bvhutils.h" #include "BKE_mesh.h" #include "BKE_mesh_runtime.h" +#include "BKE_modifier.h" #include "ED_mesh.h" #include "ED_armature.h" diff --git a/source/blender/editors/armature/meshlaplacian.h b/source/blender/editors/armature/meshlaplacian.h index 9c4ceacbee6..6758f9d16ac 100644 --- a/source/blender/editors/armature/meshlaplacian.h +++ b/source/blender/editors/armature/meshlaplacian.h @@ -71,4 +71,3 @@ void rigid_deform_end(int cancel); /* ED_mesh_deform_bind_callback(...) defined in ED_armature.h */ #endif - diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index ffe64cc24b0..661492ba056 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -294,7 +294,7 @@ void POSE_OT_paths_calculate(wmOperatorType *ot) /* --------- */ -static int pose_update_paths_poll(bContext *C) +static bool pose_update_paths_poll(bContext *C) { if (ED_operator_posemode_exclusive(C)) { Object *ob = CTX_data_active_object(C); @@ -773,7 +773,7 @@ void POSE_OT_rotation_mode_set(wmOperatorType *ot) /* ********************************************** */ -static int armature_layers_poll(bContext *C) +static bool armature_layers_poll(bContext *C) { /* Armature layers operators can be used in posemode OR editmode for armatures */ return ED_operator_posemode(C) || ED_operator_editarmature(C); @@ -806,7 +806,7 @@ static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op) bArmature *arm = armature_layers_get_data(&ob); PointerRNA ptr; int maxLayers = (RNA_boolean_get(op->ptr, "all")) ? 32 : 16; - int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + bool layers[32] = {false}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ int i; /* sanity checking */ @@ -858,7 +858,7 @@ static int armature_layers_invoke(bContext *C, wmOperator *op, const wmEvent *ev Object *ob = CTX_data_active_object(C); bArmature *arm = armature_layers_get_data(&ob); PointerRNA ptr; - int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + bool layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ /* sanity checking */ if (arm == NULL) @@ -879,7 +879,7 @@ static int armature_layers_exec(bContext *C, wmOperator *op) Object *ob = CTX_data_active_object(C); bArmature *arm = armature_layers_get_data(&ob); PointerRNA ptr; - int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + bool layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ if (arm == NULL) { return OPERATOR_CANCELLED; @@ -923,7 +923,7 @@ void ARMATURE_OT_armature_layers(wmOperatorType *ot) /* Present a popup to get the layers that should be used */ static int pose_bone_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + bool layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ /* get layers that are active already */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) @@ -949,7 +949,7 @@ static int pose_bone_layers_exec(bContext *C, wmOperator *op) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); PointerRNA ptr; - int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + bool layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ if (ob == NULL || ob->data == NULL) { return OPERATOR_CANCELLED; @@ -998,7 +998,7 @@ void POSE_OT_bone_layers(wmOperatorType *ot) /* Present a popup to get the layers that should be used */ static int armature_bone_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + bool layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ /* get layers that are active already */ CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) @@ -1026,7 +1026,7 @@ static int armature_bone_layers_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_edit_object(C); PointerRNA ptr; - int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + bool layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ /* get the values set in the operator properties */ RNA_boolean_get_array(op->ptr, "layers", layers); @@ -1262,7 +1262,7 @@ static int toggle_bone_selection_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static int pose_select_linked_poll(bContext *C) +static bool pose_select_linked_poll(bContext *C) { return (ED_operator_view3d_active(C) && ED_operator_posemode(C)); } diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index b9c4584ff15..2227bf33908 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -174,7 +174,7 @@ static Object *get_poselib_object(bContext *C) } /* Poll callback for operators that require existing PoseLib data (with poses) to work */ -static int has_poselib_pose_data_poll(bContext *C) +static bool has_poselib_pose_data_poll(bContext *C) { Object *ob = get_poselib_object(C); return (ob && ob->poselib); @@ -183,7 +183,7 @@ static int has_poselib_pose_data_poll(bContext *C) /* Poll callback for operators that require existing PoseLib data (with poses) * as they need to do some editing work on those poses (i.e. not on lib-linked actions) */ -static int has_poselib_pose_data_for_editing_poll(bContext *C) +static bool has_poselib_pose_data_for_editing_poll(bContext *C) { Object *ob = get_poselib_object(C); return (ob && ob->poselib && !ID_IS_LINKED(ob->poselib)); @@ -379,7 +379,7 @@ void POSELIB_OT_action_sanitize(wmOperatorType *ot) /* ------------------------------------------ */ /* Poll callback for adding poses to a PoseLib */ -static int poselib_add_poll(bContext *C) +static bool poselib_add_poll(bContext *C) { /* There are 2 cases we need to be careful with: * 1) When this operator is invoked from a hotkey, there may be no PoseLib yet @@ -1115,10 +1115,8 @@ static void poselib_preview_apply(bContext *C, wmOperator *op) /* do header print - if interactively previewing */ if (pld->state == PL_PREVIEW_RUNNING) { if (pld->flag & PL_PREVIEW_SHOWORIGINAL) { - BLI_strncpy(pld->headerstr, - IFACE_("PoseLib Previewing Pose: [Showing Original Pose] | Use Tab to start previewing poses again"), - sizeof(pld->headerstr)); - ED_area_headerprint(pld->sa, pld->headerstr); + ED_area_status_text(pld->sa, IFACE_("PoseLib Previewing Pose: [Showing Original Pose]")); + ED_workspace_status_text(C, IFACE_("Use Tab to start previewing poses again")); } else if (pld->searchstr[0]) { char tempstr[65]; @@ -1142,17 +1140,17 @@ static void poselib_preview_apply(bContext *C, wmOperator *op) BLI_snprintf(pld->headerstr, sizeof(pld->headerstr), IFACE_("PoseLib Previewing Pose: Filter - [%s] | " - "Current Pose - \"%s\" | " - "Use ScrollWheel or PageUp/Down to change"), + "Current Pose - \"%s\""), tempstr, markern); - ED_area_headerprint(pld->sa, pld->headerstr); + ED_area_status_text(pld->sa, pld->headerstr); + ED_workspace_status_text(C, IFACE_("Use ScrollWheel or PageUp/Down to change pose")); } else { BLI_snprintf(pld->headerstr, sizeof(pld->headerstr), - IFACE_("PoseLib Previewing Pose: \"%s\" | " - "Use ScrollWheel or PageUp/Down to change"), + IFACE_("PoseLib Previewing Pose: \"%s\""), pld->marker->name); - ED_area_headerprint(pld->sa, pld->headerstr); + ED_area_status_text(pld->sa, pld->headerstr); + ED_workspace_status_text(C, NULL); } } @@ -1602,7 +1600,8 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op) TimeMarker *marker = pld->marker; /* redraw the header so that it doesn't show any of our stuff anymore */ - ED_area_headerprint(pld->sa, NULL); + ED_area_status_text(pld->sa, NULL); + ED_workspace_status_text(C, NULL); /* this signal does one recalc on pose, then unlocks, so ESC or edit will work */ pose->flag |= POSE_DO_UNLOCK; diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index 75fd952b52a..72f0c68f660 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -390,7 +390,7 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve return OPERATOR_FINISHED; } -static int pose_select_linked_poll(bContext *C) +static bool pose_select_linked_poll(bContext *C) { return (ED_operator_view3d_active(C) && ED_operator_posemode(C)); } @@ -1049,4 +1049,3 @@ void POSE_OT_select_mirror(wmOperatorType *ot) RNA_def_boolean(ot->srna, "only_active", false, "Active Only", "Only operate on the active bone"); RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); } - diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index b82535f013b..0a07af4ab43 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -705,7 +705,7 @@ static void pose_slide_draw_status(tPoseSlideOp *pso) BLI_snprintf(status_str, sizeof(status_str), "%s: %d %% | %s", mode_str, (int)(pso->percentage * 100.0f), limits_str); } - ED_area_headerprint(pso->sa, status_str); + ED_area_status_text(pso->sa, status_str); } /* common code for invoke() methods */ @@ -857,7 +857,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) case PADENTER: { /* return to normal cursor and header status */ - ED_area_headerprint(pso->sa, NULL); + ED_area_status_text(pso->sa, NULL); WM_cursor_modal_restore(win); /* insert keyframes as required... */ @@ -872,7 +872,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) case RIGHTMOUSE: { /* return to normal cursor and header status */ - ED_area_headerprint(pso->sa, NULL); + ED_area_status_text(pso->sa, NULL); WM_cursor_modal_restore(win); /* reset transforms back to original state */ diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 5d27e13ed17..29124f9c895 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -286,7 +286,11 @@ void ED_keymap_curve(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "CURVE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "unselected", true); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "CURVE_OT_normals_make_consistent", NKEY, KM_PRESS, KM_CTRL, 0); +#else + WM_keymap_add_item(keymap, "CURVE_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT, 0); +#endif WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index aa50916f5e0..1d7a9ac46c7 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -6244,7 +6244,7 @@ bool ED_curve_active_center(Curve *cu, float center[3]) /******************** Match texture space operator ***********************/ -static int match_texture_space_poll(bContext *C) +static bool match_texture_space_poll(bContext *C) { Object *object = CTX_data_active_object(C); diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index 887f3dd13da..e679b04f25d 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -53,6 +53,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "curve_intern.h" @@ -433,15 +434,15 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - glEnable(GL_BLEND); - glEnable(GL_LINE_SMOOTH); + GPU_blend(true); + GPU_line_smooth(true); imm_cpack(0x0); immBegin(GWN_PRIM_LINE_STRIP, stroke_len); - glLineWidth(3.0f); + GPU_line_width(3.0f); if (v3d->zbuf) { - glDisable(GL_DEPTH_TEST); + GPU_depth_test(false); } for (int i = 0; i < stroke_len; i++) { @@ -452,7 +453,7 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS imm_cpack(0xffffffff); immBegin(GWN_PRIM_LINE_STRIP, stroke_len); - glLineWidth(1.0f); + GPU_line_width(1.0f); for (int i = 0; i < stroke_len; i++) { immVertex3fv(pos, coord_array[i]); @@ -461,11 +462,11 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS immEnd(); if (v3d->zbuf) { - glEnable(GL_DEPTH_TEST); + GPU_depth_test(true); } - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); + GPU_blend(false); + GPU_line_smooth(false); immUnbindProgram(); } diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt index 98b57fcbd71..640239ccc60 100644 --- a/source/blender/editors/datafiles/CMakeLists.txt +++ b/source/blender/editors/datafiles/CMakeLists.txt @@ -202,6 +202,10 @@ set(ICON_NAMES group_uvs rna rna_add + mouse_lmb + mouse_mmb + mouse_rmb + mouse_drag outliner_ob_empty outliner_ob_mesh outliner_ob_curve diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index a30cb578046..a79a5052eb8 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -64,6 +64,7 @@ #include "GPU_immediate.h" #include "GPU_draw.h" +#include "GPU_state.h" #include "ED_gpencil.h" #include "ED_screen.h" @@ -215,7 +216,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short if (totpoints == 1) { /* if drawing a single point, draw it larger */ - glPointSize((float)(thickness + 2) * points->pressure); + GPU_point_size((float)(thickness + 2) * points->pressure); immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR); immBegin(GWN_PRIM_POINTS, 1); gp_set_tpoint_varying_color(pt, ink, color); @@ -225,7 +226,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short float oldpressure = points[0].pressure; /* draw stroke curve */ - glLineWidth(max_ff(oldpressure * thickness, 1.0)); + GPU_line_width(max_ff(oldpressure * thickness, 1.0)); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints); @@ -245,7 +246,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short immEnd(); draw_points = 0; - glLineWidth(max_ff(pt->pressure * thickness, 1.0f)); + GPU_line_width(max_ff(pt->pressure * thickness, 1.0f)); immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints - i + 1); /* need to roll-back one point to ensure that there are no gaps in the stroke */ @@ -625,7 +626,7 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi /* TODO: implement this with a geometry shader to draw one continuous tapered stroke */ /* draw stroke curve */ - glLineWidth(max_ff(curpressure * thickness, 1.0f)); + GPU_line_width(max_ff(curpressure * thickness, 1.0f)); immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints + cyclic_add); const bGPDspoint *pt = points; for (int i = 0; i < totpoints; i++, pt++) { @@ -646,7 +647,7 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi draw_points = 0; curpressure = pt->pressure; - glLineWidth(max_ff(curpressure * thickness, 1.0f)); + GPU_line_width(max_ff(curpressure * thickness, 1.0f)); immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints - i + 1 + cyclic_add); /* need to roll-back one point to ensure that there are no gaps in the stroke */ @@ -941,7 +942,7 @@ static void gp_draw_strokes( if (no_xray) { glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig); glDepthMask(0); - glEnable(GL_DEPTH_TEST); + GPU_depth_test(true); /* first arg is normally rv3d->dist, but this isn't * available here and seems to work quite well without */ @@ -1005,7 +1006,7 @@ static void gp_draw_strokes( } if (no_xray) { glDepthMask(mask_orig); - glDisable(GL_DEPTH_TEST); + GPU_depth_test(false); bglPolygonOffset(0.0, 0.0); } @@ -1090,7 +1091,7 @@ static void gp_draw_strokes_edit( if (no_xray) { glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig); glDepthMask(0); - glEnable(GL_DEPTH_TEST); + GPU_depth_test(true); /* first arg is normally rv3d->dist, but this isn't * available here and seems to work quite well without */ @@ -1215,7 +1216,7 @@ static void gp_draw_strokes_edit( if (dflag & GP_DRAWDATA_ONLY3D) { if (no_xray) { glDepthMask(mask_orig); - glDisable(GL_DEPTH_TEST); + GPU_depth_test(false); bglPolygonOffset(0.0, 0.0); #if 0 @@ -1329,7 +1330,7 @@ void ED_gp_draw_interpolation(tGPDinterpolate *tgpi, const int type) } /* turn on alpha-blending */ - glEnable(GL_BLEND); + GPU_blend(true); for (tgpil = tgpi->ilayers.first; tgpil; tgpil = tgpil->next) { /* calculate parent position */ ED_gpencil_parent_location(tgpil->gpl, diff_mat); @@ -1338,7 +1339,7 @@ void ED_gp_draw_interpolation(tGPDinterpolate *tgpi, const int type) tgpil->gpl->thickness, 1.0f, color, true, true, diff_mat); } } - glDisable(GL_BLEND); + GPU_blend(false); } /* loop over gpencil data layers, drawing them */ @@ -1365,7 +1366,7 @@ static void gp_draw_data_layers( continue; /* set basic stroke thickness */ - glLineWidth(lthick); + GPU_line_width(lthick); /* Add layer drawing settings to the set of "draw flags" * NOTE: If the setting doesn't apply, it *must* be cleared, @@ -1479,15 +1480,15 @@ static void gp_draw_status_text(const bGPdata *gpd, ARegion *ar) /* grease pencil icon... */ // XXX: is this too intrusive? - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); xco -= U.widget_unit; yco -= (int)printable_size[1] / 2; UI_icon_draw(xco, yco, ICON_GREASEPENCIL); - glDisable(GL_BLEND); + GPU_blend(false); } } @@ -1497,7 +1498,7 @@ static void gp_draw_data( int offsx, int offsy, int winx, int winy, int cfra, int dflag) { /* turn on smooth lines (i.e. anti-aliasing) */ - glEnable(GL_LINE_SMOOTH); + GPU_line_smooth(true); /* XXX: turn on some way of ensuring that the polygon edges get smoothed * GL_POLYGON_SMOOTH is nasty and shouldn't be used, as it ends up @@ -1505,15 +1506,15 @@ static void gp_draw_data( */ /* turn on alpha-blending */ - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); /* draw! */ gp_draw_data_layers(brush, alpha, gpd, offsx, offsy, winx, winy, cfra, dflag); /* turn off alpha blending, then smooth lines */ - glDisable(GL_BLEND); // alpha blending - glDisable(GL_LINE_SMOOTH); // smooth lines + GPU_blend(false); // alpha blending + GPU_line_smooth(false); // smooth lines } /* if we have strokes for scenes (3d view)/clips (movie clip editor) diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index f9284d71db3..75e4c510bcf 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -78,6 +78,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" +#include "GPU_state.h" #include "gpencil_intern.h" @@ -988,8 +989,8 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customda unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); + GPU_line_smooth(true); + GPU_blend(true); /* Inner Ring: Light color for action of the brush */ /* TODO: toggle between add and remove? */ @@ -1002,8 +1003,8 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customda immUnbindProgram(); - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); + GPU_blend(false); + GPU_line_smooth(false); } } @@ -1042,7 +1043,7 @@ static void gpsculpt_brush_header_set(bContext *C, tGP_BrushEditData *gso) " | Shift-Wheel Up/Down for Strength"), (brush_name) ? brush_name : "<?>"); - ED_area_headerprint(CTX_wm_area(C), str); + ED_workspace_status_text(C, str); } /* ************************************************ */ @@ -1176,7 +1177,7 @@ static void gpsculpt_brush_exit(bContext *C, wmOperator *op) } /* disable cursor and headerprints */ - ED_area_headerprint(CTX_wm_area(C), NULL); + ED_workspace_status_text(C, NULL); WM_cursor_modal_restore(win); gpencil_toggle_brush_cursor(C, false); @@ -1186,7 +1187,7 @@ static void gpsculpt_brush_exit(bContext *C, wmOperator *op) } /* poll callback for stroke sculpting operator(s) */ -static int gpsculpt_brush_poll(bContext *C) +static bool gpsculpt_brush_poll(bContext *C) { /* NOTE: this is a bit slower, but is the most accurate... */ return CTX_DATA_COUNT(C, editable_gpencil_strokes) != 0; diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c index d2301337c0e..ccdbcba71f9 100644 --- a/source/blender/editors/gpencil/gpencil_convert.c +++ b/source/blender/editors/gpencil/gpencil_convert.c @@ -1291,7 +1291,7 @@ static void gp_convert_set_end_frame(struct Main *UNUSED(main), struct Scene *UN } } -static int gp_convert_poll(bContext *C) +static bool gp_convert_poll(bContext *C) { bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDlayer *gpl = NULL; diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 9f437f28f0f..c28fea0fc41 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -131,7 +131,7 @@ void GPENCIL_OT_data_add(wmOperatorType *ot) /* ******************* Unlink Data ************************ */ /* poll callback for adding data/layers - special */ -static int gp_data_unlink_poll(bContext *C) +static bool gp_data_unlink_poll(bContext *C) { bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL); @@ -420,7 +420,7 @@ void GPENCIL_OT_hide(wmOperatorType *ot) /* ********************** Show All Layers ***************************** */ /* poll callback for showing layers */ -static int gp_reveal_poll(bContext *C) +static bool gp_reveal_poll(bContext *C) { return ED_gpencil_data_get_active(C) != NULL; } @@ -1811,7 +1811,7 @@ void GPENCIL_OT_palettecolor_hide(wmOperatorType *ot) /* ********************** Show All Colors ***************************** */ /* poll callback for showing colors */ -static int gp_palettecolor_reveal_poll(bContext *C) +static bool gp_palettecolor_reveal_poll(bContext *C) { return ED_gpencil_data_get_active(C) != NULL; } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 45caadf3742..ec67b2da161 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -86,7 +86,7 @@ /* ************************************************ */ /* Stroke Edit Mode Management */ -static int gpencil_editmode_toggle_poll(bContext *C) +static bool gpencil_editmode_toggle_poll(bContext *C) { return ED_gpencil_data_get_active(C) != NULL; } @@ -131,7 +131,7 @@ void GPENCIL_OT_editmode_toggle(wmOperatorType *ot) /* Stroke Editing Operators */ /* poll callback for all stroke editing operators */ -static int gp_stroke_edit_poll(bContext *C) +static bool gp_stroke_edit_poll(bContext *C) { /* NOTE: this is a bit slower, but is the most accurate... */ return CTX_DATA_COUNT(C, editable_gpencil_strokes) != 0; @@ -517,7 +517,7 @@ void GPENCIL_OT_copy(wmOperatorType *ot) /* --------------------- */ /* Paste selected strokes */ -static int gp_strokes_paste_poll(bContext *C) +static bool gp_strokes_paste_poll(bContext *C) { /* 1) Must have GP datablock to paste to * - We don't need to have an active layer though, as that can easily get added @@ -784,7 +784,7 @@ void GPENCIL_OT_move_to_layer(wmOperatorType *ot) /* ********************* Add Blank Frame *************************** */ /* Basically the same as the drawing op */ -static int UNUSED_FUNCTION(gp_blank_frame_add_poll)(bContext *C) +static bool UNUSED_FUNCTION(gp_blank_frame_add_poll)(bContext *C) { if (ED_operator_regionactive(C)) { /* check if current context can support GPencil data */ @@ -864,7 +864,7 @@ void GPENCIL_OT_blank_frame_add(wmOperatorType *ot) /* ******************* Delete Active Frame ************************ */ -static int gp_actframe_delete_poll(bContext *C) +static bool gp_actframe_delete_poll(bContext *C) { bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); @@ -916,7 +916,7 @@ void GPENCIL_OT_active_frame_delete(wmOperatorType *ot) /* **************** Delete All Active Frames ****************** */ -static int gp_actframe_delete_all_poll(bContext *C) +static bool gp_actframe_delete_all_poll(bContext *C) { bGPdata *gpd = ED_gpencil_data_get_active(C); @@ -1370,7 +1370,7 @@ void GPENCIL_OT_dissolve(wmOperatorType *ot) /* NOTE: For now, we only allow these in the 3D view, as other editors do not * define a cursor or gridstep which can be used */ -static int gp_snap_poll(bContext *C) +static bool gp_snap_poll(bContext *C) { bGPdata *gpd = CTX_data_gpencil_data(C); ScrArea *sa = CTX_wm_area(C); @@ -2090,7 +2090,7 @@ typedef enum eGP_ReprojectModes { GP_REPROJECT_SURFACE, } eGP_ReprojectModes; -static int gp_strokes_reproject_poll(bContext *C) +static bool gp_strokes_reproject_poll(bContext *C) { /* 2 Requirements: * - 1) Editable GP data diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index 67b88efa285..90ff1e0bb25 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -94,12 +94,12 @@ bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, struct Scene *scene, const float /* Poll Callbacks ------------------------------------ */ /* gpencil_utils.c */ -int gp_add_poll(struct bContext *C); -int gp_active_layer_poll(struct bContext *C); -int gp_active_brush_poll(struct bContext *C); -int gp_active_palette_poll(struct bContext *C); -int gp_active_palettecolor_poll(struct bContext *C); -int gp_brush_crt_presets_poll(bContext *C); +bool gp_add_poll(struct bContext *C); +bool gp_active_layer_poll(struct bContext *C); +bool gp_active_brush_poll(struct bContext *C); +bool gp_active_palette_poll(struct bContext *C); +bool gp_active_palettecolor_poll(struct bContext *C); +bool gp_brush_crt_presets_poll(bContext *C); /* Copy/Paste Buffer --------------------------------- */ /* gpencil_edit.c */ diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c index ff3f5b20858..cc30d7ec266 100644 --- a/source/blender/editors/gpencil/gpencil_interpolate.c +++ b/source/blender/editors/gpencil/gpencil_interpolate.c @@ -85,7 +85,7 @@ /* Core/Shared Utilities */ /* Poll callback for interpolation operators */ -static int gpencil_view3d_poll(bContext *C) +static bool gpencil_view3d_poll(bContext *C) { bGPdata *gpd = CTX_data_gpencil_data(C); bGPDlayer *gpl = CTX_data_active_gpencil_layer(C); @@ -352,32 +352,33 @@ static void gpencil_mouse_update_shift(tGPDinterpolate *tgpi, wmOperator *op, co } /* Helper: Draw status message while the user is running the operator */ -static void gpencil_interpolate_status_indicators(tGPDinterpolate *p) +static void gpencil_interpolate_status_indicators(bContext *C, tGPDinterpolate *p) { Scene *scene = p->scene; char status_str[UI_MAX_DRAW_STR]; char msg_str[UI_MAX_DRAW_STR]; - BLI_strncpy(msg_str, IFACE_("GPencil Interpolation: ESC/RMB to cancel, Enter/LMB to confirm, WHEEL/MOVE to adjust factor"), UI_MAX_DRAW_STR); + BLI_strncpy(msg_str, IFACE_("GPencil Interpolation: "), UI_MAX_DRAW_STR); if (hasNumInput(&p->num)) { char str_offs[NUM_STR_REP_LEN]; outputNumInput(&p->num, str_offs, &scene->unit); - BLI_snprintf(status_str, sizeof(status_str), "%s: %s", msg_str, str_offs); + BLI_snprintf(status_str, sizeof(status_str), "%s%s", msg_str, str_offs); } else { - BLI_snprintf(status_str, sizeof(status_str), "%s: %d %%", msg_str, (int)((p->init_factor + p->shift) * 100.0f)); + BLI_snprintf(status_str, sizeof(status_str), "%s%d %%", msg_str, (int)((p->init_factor + p->shift) * 100.0f)); } - ED_area_headerprint(p->sa, status_str); + ED_area_status_text(p->sa, status_str); + ED_workspace_status_text(C, IFACE_("ESC/RMB to cancel, Enter/LMB to confirm, WHEEL/MOVE to adjust factor")); } /* Update screen and stroke */ static void gpencil_interpolate_update(bContext *C, wmOperator *op, tGPDinterpolate *tgpi) { /* update shift indicator in header */ - gpencil_interpolate_status_indicators(tgpi); + gpencil_interpolate_status_indicators(C, tgpi); /* apply... */ tgpi->shift = RNA_float_get(op->ptr, "shift"); /* update points position */ @@ -403,7 +404,8 @@ static void gpencil_interpolate_exit(bContext *C, wmOperator *op) } /* clear status message area */ - ED_area_headerprint(tgpi->sa, NULL); + ED_area_status_text(tgpi->sa, NULL); + ED_workspace_status_text(C, NULL); /* finally, free memory used by temp data */ for (tgpil = tgpi->ilayers.first; tgpil; tgpil = tgpil->next) { @@ -526,7 +528,7 @@ static int gpencil_interpolate_invoke(bContext *C, wmOperator *op, const wmEvent WM_cursor_modal_set(win, BC_EW_SCROLLCURSOR); /* update shift indicator in header */ - gpencil_interpolate_status_indicators(tgpi); + gpencil_interpolate_status_indicators(C, tgpi); WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); /* add a modal handler for this operator */ @@ -550,7 +552,8 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent case RETKEY: { /* return to normal cursor and header status */ - ED_area_headerprint(tgpi->sa, NULL); + ED_area_status_text(tgpi->sa, NULL); + ED_workspace_status_text(C, NULL); WM_cursor_modal_restore(win); /* insert keyframes as required... */ @@ -585,7 +588,8 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent case RIGHTMOUSE: { /* return to normal cursor and header status */ - ED_area_headerprint(tgpi->sa, NULL); + ED_area_status_text(tgpi->sa, NULL); + ED_workspace_status_text(C, NULL); WM_cursor_modal_restore(win); /* clean up temp data */ @@ -1032,7 +1036,7 @@ void GPENCIL_OT_interpolate_sequence(wmOperatorType *ot) /* ******************** Remove Breakdowns ************************ */ -static int gpencil_interpolate_reverse_poll(bContext *C) +static bool gpencil_interpolate_reverse_poll(bContext *C) { if (!gpencil_view3d_poll(C)) { return 0; diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c index cb6ccc8d8ef..f22d653800e 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil/gpencil_ops.c @@ -109,12 +109,13 @@ static void ed_keymap_gpencil_general(wmKeyConfig *keyconf) /* Delete Active Frame - For easier video tutorials/review sessions */ /* NOTE: This works even when not in EditMode */ WM_keymap_add_item(keymap, "GPENCIL_OT_active_frames_delete_all", XKEY, KM_PRESS, 0, DKEY); + WM_keymap_add_item(keymap, "GPENCIL_OT_active_frames_delete_all", DELKEY, KM_PRESS, 0, DKEY); } /* ==================== */ /* Poll callback for stroke editing mode */ -static int gp_stroke_editmode_poll(bContext *C) +static bool gp_stroke_editmode_poll(bContext *C) { bGPdata *gpd = CTX_data_gpencil_data(C); return (gpd && (gpd->flag & GP_DATA_STROKE_EDITMODE)); @@ -245,6 +246,7 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "GPENCIL_OT_dissolve", DELKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "GPENCIL_OT_active_frames_delete_all", XKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "GPENCIL_OT_active_frames_delete_all", DELKEY, KM_PRESS, KM_SHIFT, 0); /* menu edit specials */ WM_keymap_add_menu(keymap, "GPENCIL_MT_gpencil_edit_specials", WKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index c8f1901d075..ec8a213301f 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -73,6 +73,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" +#include "GPU_state.h" #include "RNA_access.h" #include "RNA_define.h" @@ -202,7 +203,7 @@ static void gp_session_validatebuffer(tGPsdata *p); /* Context Wrangling... */ /* check if context is suitable for drawing */ -static int gpencil_draw_poll(bContext *C) +static bool gpencil_draw_poll(bContext *C) { if (ED_operator_regionactive(C)) { /* check if current context can support GPencil data */ @@ -1878,9 +1879,9 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr) const uint shdr_pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_line_smooth(true); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); immUniformColor4ub(255, 100, 100, 20); imm_draw_circle_fill_2d(shdr_pos, x, y, p->radius, 40); @@ -1890,11 +1891,11 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr) immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); immUniformColor4f(1.0f, 0.39f, 0.39f, 0.78f); - immUniform1i("num_colors", 0); /* "simple" mode */ + immUniform1i("colors_len", 0); /* "simple" mode */ immUniform1f("dash_width", 12.0f); immUniform1f("dash_factor", 0.5f); @@ -1905,8 +1906,8 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr) immUnbindProgram(); - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); + GPU_blend(false); + GPU_line_smooth(false); } } @@ -2025,38 +2026,38 @@ static void gpencil_draw_cursor_set(tGPsdata *p) } /* update UI indicators of status, including cursor and header prints */ -static void gpencil_draw_status_indicators(tGPsdata *p) +static void gpencil_draw_status_indicators(bContext *C, tGPsdata *p) { /* header prints */ switch (p->status) { case GP_STATUS_PAINTING: /* only print this for paint-sessions, otherwise it gets annoying */ if (GPENCIL_SKETCH_SESSIONS_ON(p->scene)) - ED_area_headerprint(p->sa, IFACE_("Grease Pencil: Drawing/erasing stroke... Release to end stroke")); + ED_workspace_status_text(C, IFACE_("Grease Pencil: Drawing/erasing stroke... Release to end stroke")); break; case GP_STATUS_IDLING: /* print status info */ switch (p->paintmode) { case GP_PAINTMODE_ERASER: - ED_area_headerprint(p->sa, IFACE_("Grease Pencil Erase Session: Hold and drag LMB or RMB to erase | " + ED_workspace_status_text(C, IFACE_("Grease Pencil Erase Session: Hold and drag LMB or RMB to erase | " "ESC/Enter to end (or click outside this area)")); break; case GP_PAINTMODE_DRAW_STRAIGHT: - ED_area_headerprint(p->sa, IFACE_("Grease Pencil Line Session: Hold and drag LMB to draw | " + ED_workspace_status_text(C, IFACE_("Grease Pencil Line Session: Hold and drag LMB to draw | " "ESC/Enter to end (or click outside this area)")); break; case GP_PAINTMODE_DRAW: - ED_area_headerprint(p->sa, IFACE_("Grease Pencil Freehand Session: Hold and drag LMB to draw | " + ED_workspace_status_text(C, IFACE_("Grease Pencil Freehand Session: Hold and drag LMB to draw | " "E/ESC/Enter to end (or click outside this area)")); break; case GP_PAINTMODE_DRAW_POLY: - ED_area_headerprint(p->sa, IFACE_("Grease Pencil Poly Session: LMB click to place next stroke vertex | " + ED_workspace_status_text(C, IFACE_("Grease Pencil Poly Session: LMB click to place next stroke vertex | " "ESC/Enter to end (or click outside this area)")); break; default: /* unhandled future cases */ - ED_area_headerprint(p->sa, IFACE_("Grease Pencil Session: ESC/Enter to end (or click outside this area)")); + ED_workspace_status_text(C, IFACE_("Grease Pencil Session: ESC/Enter to end (or click outside this area)")); break; } break; @@ -2064,7 +2065,7 @@ static void gpencil_draw_status_indicators(tGPsdata *p) case GP_STATUS_ERROR: case GP_STATUS_DONE: /* clear status string */ - ED_area_headerprint(p->sa, NULL); + ED_workspace_status_text(C, NULL); break; } } @@ -2744,7 +2745,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) estate = OPERATOR_CANCELLED; else { /* update status indicators - cursor, header, etc. */ - gpencil_draw_status_indicators(p); + gpencil_draw_status_indicators(C, p); gpencil_draw_cursor_set(p); /* cursor may have changed outside our control - T44084 */ } diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index ac0b046e499..dd556e99264 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -67,7 +67,7 @@ /* ********************************************** */ /* Polling callbacks */ -static int gpencil_select_poll(bContext *C) +static bool gpencil_select_poll(bContext *C) { bGPdata *gpd = ED_gpencil_data_get_active(C); diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 4ee3bdd587e..8b65855f7c4 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -262,14 +262,14 @@ bool ED_gpencil_has_keyframe_v3d(Scene *scene, Object *ob, int cfra) /* Poll Callbacks */ /* poll callback for adding data/layers - special */ -int gp_add_poll(bContext *C) +bool gp_add_poll(bContext *C) { /* the base line we have is that we have somewhere to add Grease Pencil data */ return ED_gpencil_data_get_pointers(C, NULL) != NULL; } /* poll callback for checking if there is an active layer */ -int gp_active_layer_poll(bContext *C) +bool gp_active_layer_poll(bContext *C) { bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); @@ -278,7 +278,7 @@ int gp_active_layer_poll(bContext *C) } /* poll callback for checking if there is an active brush */ -int gp_active_brush_poll(bContext *C) +bool gp_active_brush_poll(bContext *C) { ToolSettings *ts = CTX_data_tool_settings(C); bGPDbrush *brush = BKE_gpencil_brush_getactive(ts); @@ -287,7 +287,7 @@ int gp_active_brush_poll(bContext *C) } /* poll callback for checking if there is an active palette */ -int gp_active_palette_poll(bContext *C) +bool gp_active_palette_poll(bContext *C) { bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd); @@ -296,7 +296,7 @@ int gp_active_palette_poll(bContext *C) } /* poll callback for checking if there is an active palette color */ -int gp_active_palettecolor_poll(bContext *C) +bool gp_active_palettecolor_poll(bContext *C) { bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd); diff --git a/source/blender/editors/include/BIF_gl.h b/source/blender/editors/include/BIF_gl.h index f91e7d42bca..e2e110ffc31 100644 --- a/source/blender/editors/include/BIF_gl.h +++ b/source/blender/editors/include/BIF_gl.h @@ -48,4 +48,3 @@ #define GLA_PIXEL_OFS 0.375f #endif /* #ifdef __BIF_GL_H__ */ - diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 943191c8892..59a54f03e56 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -690,6 +690,7 @@ void ANIM_list_elem_update(struct Main *bmain, struct Scene *scene, bAnimListEle void ANIM_sync_animchannels_to_data(const struct bContext *C); void ANIM_center_frame(struct bContext *C, int smooth_viewtx); + /* ************************************************* */ /* OPERATORS */ @@ -716,7 +717,10 @@ void ED_animedit_unlink_action(struct bContext *C, struct ID *id, struct AnimData *adt, struct bAction *act, struct ReportList *reports, bool force_delete); + +/* Drivers Editor - Utility to set up UI correctly */ +void ED_drivers_editor_init(struct bContext *C, struct ScrArea *sa); + /* ************************************************ */ #endif /* __ED_ANIM_API_H__ */ - diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h index 91f8b39f7b9..4844d96e6e8 100644 --- a/source/blender/editors/include/ED_clip.h +++ b/source/blender/editors/include/ED_clip.h @@ -44,13 +44,13 @@ struct Scene; /* ** clip_editor.c ** */ /* common poll functions */ -int ED_space_clip_poll(struct bContext *C); +bool ED_space_clip_poll(struct bContext *C); -int ED_space_clip_view_clip_poll(struct bContext *C); +bool ED_space_clip_view_clip_poll(struct bContext *C); -int ED_space_clip_tracking_poll(struct bContext *C); -int ED_space_clip_maskedit_poll(struct bContext *C); -int ED_space_clip_maskedit_mask_poll(struct bContext *C); +bool ED_space_clip_tracking_poll(struct bContext *C); +bool ED_space_clip_maskedit_poll(struct bContext *C); +bool ED_space_clip_maskedit_mask_poll(struct bContext *C); void ED_space_clip_get_size(struct SpaceClip *sc, int *width, int *height); void ED_space_clip_get_size_fl(struct SpaceClip *sc, float size[2]); diff --git a/source/blender/editors/include/ED_datafiles.h b/source/blender/editors/include/ED_datafiles.h index 1559fc8f302..7d509d1243a 100644 --- a/source/blender/editors/include/ED_datafiles.h +++ b/source/blender/editors/include/ED_datafiles.h @@ -242,4 +242,3 @@ extern char datatoc_mc24_jpg[]; #endif /* __ED_DATAFILES_H__ */ - diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h index f2b7d2cb4a1..64739d968b8 100644 --- a/source/blender/editors/include/ED_fileselect.h +++ b/source/blender/editors/include/ED_fileselect.h @@ -156,4 +156,3 @@ char *ED_fsmenu_entry_get_name(struct FSMenuEntry *fsentry); void ED_fsmenu_entry_set_name(struct FSMenuEntry *fsentry, const char *name); #endif /* __ED_FILESELECT_H__ */ - diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h index 73926b8a687..f8af67b55ff 100644 --- a/source/blender/editors/include/ED_image.h +++ b/source/blender/editors/include/ED_image.h @@ -76,8 +76,8 @@ bool ED_space_image_show_uvedit(struct SpaceImage *sima, struct Object *obedit); bool ED_space_image_paint_curve(const struct bContext *C); bool ED_space_image_check_show_maskedit(struct SpaceImage *sima, struct ViewLayer *view_layer); -int ED_space_image_maskedit_poll(struct bContext *C); -int ED_space_image_maskedit_mask_poll(struct bContext *C); +bool ED_space_image_maskedit_poll(struct bContext *C); +bool ED_space_image_maskedit_mask_poll(struct bContext *C); void ED_image_draw_info(struct Scene *scene, struct ARegion *ar, bool color_manage, bool use_default_view, int channels, int x, int y, const unsigned char cp[4], const float fp[4], const float linearcol[4], int *zp, float *zpf); @@ -85,4 +85,3 @@ void ED_image_draw_info(struct Scene *scene, struct ARegion *ar, bool color_mana bool ED_space_image_show_cache(struct SpaceImage *sima); #endif /* __ED_IMAGE_H__ */ - diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 5882c44a9b3..b0807c8e5ae 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -133,7 +133,7 @@ struct KeyingSetInfo; struct ExtensionRNA; /* Polling Callback for KeyingSets */ -typedef int (*cbKeyingSet_Poll)(struct KeyingSetInfo *ksi, struct bContext *C); +typedef bool (*cbKeyingSet_Poll)(struct KeyingSetInfo *ksi, struct bContext *C); /* Context Iterator Callback for KeyingSets */ typedef void (*cbKeyingSet_Iterator)(struct KeyingSetInfo *ksi, struct bContext *C, struct KeyingSet *ks); /* Property Specifier Callback for KeyingSets (called from iterators) */ diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index a9c9e8c0fbd..a473974eb3f 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -225,14 +225,9 @@ typedef struct MirrTopoStore_t { } MirrTopoStore_t; bool ED_mesh_mirrtopo_recalc_check( - struct Mesh *me, struct DerivedMesh *dm, MirrTopoStore_t *mesh_topo_store); -bool ED_mesh_mirrtopo_recalc_check__real_mesh( - struct Mesh *me, struct Mesh *dm, MirrTopoStore_t *mesh_topo_store); + struct Mesh *me, struct Mesh *me_eval, MirrTopoStore_t *mesh_topo_store); void ED_mesh_mirrtopo_init( - struct Mesh *me, struct DerivedMesh *dm, MirrTopoStore_t *mesh_topo_store, - const bool skip_em_vert_array_init); -void ED_mesh_mirrtopo_init__real_mesh( - struct Mesh *me, struct Mesh *dm, MirrTopoStore_t *mesh_topo_store, + struct Mesh *me, struct Mesh *me_eval, MirrTopoStore_t *mesh_topo_store, const bool skip_em_vert_array_init); void ED_mesh_mirrtopo_free(MirrTopoStore_t *mesh_topo_store); @@ -284,7 +279,7 @@ void ED_mesh_edges_remove(struct Mesh *mesh, struct ReportList *reports, int cou void ED_mesh_vertices_remove(struct Mesh *mesh, struct ReportList *reports, int count); void ED_mesh_calc_tessface(struct Mesh *mesh, bool free_mpoly); -void ED_mesh_update(struct Mesh *mesh, struct bContext *C, int calc_edges, int calc_tessface); +void ED_mesh_update(struct Mesh *mesh, struct bContext *C, bool calc_edges, bool calc_tessface); void ED_mesh_uv_texture_ensure(struct Mesh *me, const char *name); int ED_mesh_uv_texture_add(struct Mesh *me, const char *name, const bool active_set); @@ -322,22 +317,17 @@ int join_mesh_shapes_exec(struct bContext *C, struct wmOperator *op); /* mirror lookup api */ int ED_mesh_mirror_spatial_table( - struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm, const float co[3], char mode); -int ED_mesh_mirror_spatial_table__real_mesh( - struct Object *ob, struct BMEditMesh *em, struct Mesh *mesh, const float co[3], char mode); -int ED_mesh_mirror_topo_table(struct Object *ob, struct DerivedMesh *dm, char mode); -int ED_mesh_mirror_topo_table__real_mesh(struct Object *ob, struct Mesh *mesh, char mode); + struct Object *ob, struct BMEditMesh *em, struct Mesh *me_eval, const float co[3], char mode); +int ED_mesh_mirror_topo_table(struct Object *ob, struct Mesh *me_eval, char mode); /* retrieves mirrored cache vert, or NULL if there isn't one. * note: calling this without ensuring the mirror cache state * is bad.*/ -int mesh_get_x_mirror_vert(struct Object *ob, struct DerivedMesh *dm, int index, const bool use_topology); -int mesh_get_x_mirror_vert__real_mesh(struct Object *ob, struct Mesh *mesh, int index, const bool use_topology); +int mesh_get_x_mirror_vert(struct Object *ob, struct Mesh *me_eval, int index, const bool use_topology); struct BMVert *editbmesh_get_x_mirror_vert(struct Object *ob, struct BMEditMesh *em, struct BMVert *eve, const float co[3], int index, const bool use_topology); -int *mesh_get_x_mirror_faces(struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm); -int *mesh_get_x_mirror_faces__real_mesh(struct Object *ob, struct BMEditMesh *em, struct Mesh *mesh); +int *mesh_get_x_mirror_faces(struct Object *ob, struct BMEditMesh *em, struct Mesh *me_eval); int ED_mesh_mirror_get_vert(struct Object *ob, int index); diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index 0b3ce144097..8d652609fbc 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -110,4 +110,3 @@ void ED_operatormacros_node(void); bool ED_space_node_color_sample(struct Main *bmain, struct SpaceNode *snode, struct ARegion *ar, int mval[2], float r_col[3]); #endif /* __ED_NODE_H__ */ - diff --git a/source/blender/editors/include/ED_outliner.h b/source/blender/editors/include/ED_outliner.h index c1b3c3e9e1c..52fdeb2045c 100644 --- a/source/blender/editors/include/ED_outliner.h +++ b/source/blender/editors/include/ED_outliner.h @@ -30,7 +30,7 @@ struct bContext; struct ListBase; -int ED_outliner_collections_editor_poll(struct bContext *C); +bool ED_outliner_collections_editor_poll(struct bContext *C); void ED_outliner_selected_objects_get(const struct bContext *C, struct ListBase *objects); diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h index 8b522c91188..b50250dfb96 100644 --- a/source/blender/editors/include/ED_particle.h +++ b/source/blender/editors/include/ED_particle.h @@ -71,4 +71,3 @@ void PE_deselect_all_visible(struct PTCacheEdit *edit); void ED_particle_undosys_type(struct UndoType *ut); #endif /* __ED_PARTICLE_H__ */ - diff --git a/source/blender/editors/include/ED_physics.h b/source/blender/editors/include/ED_physics.h index fed842c969e..32444beb0fe 100644 --- a/source/blender/editors/include/ED_physics.h +++ b/source/blender/editors/include/ED_physics.h @@ -40,9 +40,9 @@ struct Scene; struct Object; /* particle_edit.c */ -int PE_poll(struct bContext *C); -int PE_hair_poll(struct bContext *C); -int PE_poll_view3d(struct bContext *C); +bool PE_poll(struct bContext *C); +bool PE_hair_poll(struct bContext *C); +bool PE_poll_view3d(struct bContext *C); /* rigidbody_object.c */ bool ED_rigidbody_object_add(struct Main *bmain, struct Scene *scene, struct Object *ob, int type, struct ReportList *reports); @@ -57,4 +57,3 @@ void ED_operatortypes_physics(void); void ED_keymap_physics(struct wmKeyConfig *keyconf); #endif /* __ED_PHYSICS_H__ */ - diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 204c5fa5956..1a7055e2cfa 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -60,6 +60,10 @@ struct Main; struct wmMsgBus; struct wmMsgSubscribeKey; struct wmMsgSubscribeValue; +struct wmOperatorType; +struct IDProperty; +struct MenuType; +struct PropertyRNA; /* regions */ void ED_region_do_listen( @@ -141,13 +145,15 @@ void ED_area_tag_redraw_regiontype(ScrArea *sa, int type); void ED_area_tag_refresh(ScrArea *sa); void ED_area_do_refresh(struct bContext *C, ScrArea *sa); void ED_area_azones_update(ScrArea *sa, const int mouse_xy[]); -void ED_area_headerprint(ScrArea *sa, const char *str); +void ED_area_status_text(ScrArea *sa, const char *str); void ED_area_newspace(struct bContext *C, ScrArea *sa, int type, const bool skip_ar_exit); void ED_area_prevspace(struct bContext *C, ScrArea *sa); void ED_area_swapspace(struct bContext *C, ScrArea *sa1, ScrArea *sa2); int ED_area_headersize(void); int ED_area_header_alignment(const ScrArea *area); int ED_area_global_size_y(const ScrArea *area); +int ED_area_global_min_size_y(const ScrArea *area); +int ED_area_global_max_size_y(const ScrArea *area); bool ED_area_is_global(const ScrArea *area); int ED_region_global_size_y(void); void ED_area_update_region_sizes(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *area); @@ -242,6 +248,8 @@ void ED_workspace_object_mode_sync_from_object( void ED_workspace_object_mode_sync_from_scene( struct wmWindowManager *wm, WorkSpace *workspace, struct Scene *scene); +void ED_workspace_status_text(struct bContext *C, const char *str); + /* anim */ void ED_update_for_newframe(struct Main *bmain, struct Depsgraph *depsgraph); @@ -257,61 +265,90 @@ void ED_keymap_screen(struct wmKeyConfig *keyconf); void ED_operatortypes_workspace(void); /* operators; context poll callbacks */ -int ED_operator_screenactive(struct bContext *C); -int ED_operator_screen_mainwinactive(struct bContext *C); -int ED_operator_areaactive(struct bContext *C); -int ED_operator_regionactive(struct bContext *C); - -int ED_operator_scene(struct bContext *C); -int ED_operator_scene_editable(struct bContext *C); -int ED_operator_objectmode(struct bContext *C); - -int ED_operator_view3d_active(struct bContext *C); -int ED_operator_region_view3d_active(struct bContext *C); -int ED_operator_animview_active(struct bContext *C); -int ED_operator_outliner_active(struct bContext *C); -int ED_operator_outliner_active_no_editobject(struct bContext *C); -int ED_operator_file_active(struct bContext *C); -int ED_operator_action_active(struct bContext *C); -int ED_operator_buttons_active(struct bContext *C); -int ED_operator_node_active(struct bContext *C); -int ED_operator_node_editable(struct bContext *C); -int ED_operator_graphedit_active(struct bContext *C); -int ED_operator_sequencer_active(struct bContext *C); -int ED_operator_sequencer_active_editable(struct bContext *C); -int ED_operator_image_active(struct bContext *C); -int ED_operator_nla_active(struct bContext *C); -int ED_operator_info_active(struct bContext *C); -int ED_operator_console_active(struct bContext *C); - - -int ED_operator_object_active(struct bContext *C); -int ED_operator_object_active_editable(struct bContext *C); -int ED_operator_object_active_editable_mesh(struct bContext *C); -int ED_operator_object_active_editable_font(struct bContext *C); -int ED_operator_editmesh(struct bContext *C); -int ED_operator_editmesh_view3d(struct bContext *C); -int ED_operator_editmesh_region_view3d(struct bContext *C); -int ED_operator_editmesh_auto_smooth(struct bContext *C); -int ED_operator_editarmature(struct bContext *C); -int ED_operator_editcurve(struct bContext *C); -int ED_operator_editcurve_3d(struct bContext *C); -int ED_operator_editsurf(struct bContext *C); -int ED_operator_editsurfcurve(struct bContext *C); -int ED_operator_editsurfcurve_region_view3d(struct bContext *C); -int ED_operator_editfont(struct bContext *C); -int ED_operator_editlattice(struct bContext *C); -int ED_operator_editmball(struct bContext *C); -int ED_operator_uvedit(struct bContext *C); -int ED_operator_uvedit_space_image(struct bContext *C); -int ED_operator_uvmap(struct bContext *C); -int ED_operator_posemode_exclusive(struct bContext *C); -int ED_operator_posemode_context(struct bContext *C); -int ED_operator_posemode(struct bContext *C); -int ED_operator_posemode_local(struct bContext *C); -int ED_operator_mask(struct bContext *C); -int ED_operator_camera(struct bContext *C); - +bool ED_operator_screenactive(struct bContext *C); +bool ED_operator_screen_mainwinactive(struct bContext *C); +bool ED_operator_areaactive(struct bContext *C); +bool ED_operator_regionactive(struct bContext *C); + +bool ED_operator_scene(struct bContext *C); +bool ED_operator_scene_editable(struct bContext *C); +bool ED_operator_objectmode(struct bContext *C); + +bool ED_operator_view3d_active(struct bContext *C); +bool ED_operator_region_view3d_active(struct bContext *C); +bool ED_operator_animview_active(struct bContext *C); +bool ED_operator_outliner_active(struct bContext *C); +bool ED_operator_outliner_active_no_editobject(struct bContext *C); +bool ED_operator_file_active(struct bContext *C); +bool ED_operator_action_active(struct bContext *C); +bool ED_operator_buttons_active(struct bContext *C); +bool ED_operator_node_active(struct bContext *C); +bool ED_operator_node_editable(struct bContext *C); +bool ED_operator_graphedit_active(struct bContext *C); +bool ED_operator_sequencer_active(struct bContext *C); +bool ED_operator_sequencer_active_editable(struct bContext *C); +bool ED_operator_image_active(struct bContext *C); +bool ED_operator_nla_active(struct bContext *C); +bool ED_operator_info_active(struct bContext *C); +bool ED_operator_console_active(struct bContext *C); + + +bool ED_operator_object_active(struct bContext *C); +bool ED_operator_object_active_editable(struct bContext *C); +bool ED_operator_object_active_editable_mesh(struct bContext *C); +bool ED_operator_object_active_editable_font(struct bContext *C); +bool ED_operator_editmesh(struct bContext *C); +bool ED_operator_editmesh_view3d(struct bContext *C); +bool ED_operator_editmesh_region_view3d(struct bContext *C); +bool ED_operator_editmesh_auto_smooth(struct bContext *C); +bool ED_operator_editarmature(struct bContext *C); +bool ED_operator_editcurve(struct bContext *C); +bool ED_operator_editcurve_3d(struct bContext *C); +bool ED_operator_editsurf(struct bContext *C); +bool ED_operator_editsurfcurve(struct bContext *C); +bool ED_operator_editsurfcurve_region_view3d(struct bContext *C); +bool ED_operator_editfont(struct bContext *C); +bool ED_operator_editlattice(struct bContext *C); +bool ED_operator_editmball(struct bContext *C); +bool ED_operator_uvedit(struct bContext *C); +bool ED_operator_uvedit_space_image(struct bContext *C); +bool ED_operator_uvmap(struct bContext *C); +bool ED_operator_posemode_exclusive(struct bContext *C); +bool ED_operator_posemode_context(struct bContext *C); +bool ED_operator_posemode(struct bContext *C); +bool ED_operator_posemode_local(struct bContext *C); +bool ED_operator_mask(struct bContext *C); +bool ED_operator_camera(struct bContext *C); + +/* screen_user_menu.c */ + +struct bUserMenu *ED_screen_user_menu_find(struct bContext *C); +struct bUserMenu *ED_screen_user_menu_ensure(struct bContext *C); + + +struct bUserMenuItem_Op *ED_screen_user_menu_item_find_operator( + struct ListBase *lb, + const struct wmOperatorType *ot, struct IDProperty *prop, short opcontext); +struct bUserMenuItem_Menu *ED_screen_user_menu_item_find_menu( + struct ListBase *lb, + const struct MenuType *mt); +struct bUserMenuItem_Prop *ED_screen_user_menu_item_find_prop( + struct ListBase *lb, + const char *context_data_path, const char *prop_id, int prop_index); + +void ED_screen_user_menu_item_add_operator( + struct ListBase *lb, const char *ui_name, + const struct wmOperatorType *ot, const struct IDProperty *prop, short opcontext); +void ED_screen_user_menu_item_add_menu( + struct ListBase *lb, const char *ui_name, + const struct MenuType *mt); +void ED_screen_user_menu_item_add_prop( + ListBase *lb, const char *ui_name, + const char *context_data_path, const char *prop_id, int prop_index); + +void ED_screen_user_menu_item_remove( + struct ListBase *lb, struct bUserMenuItem *umi); +void ED_screen_user_menu_register(void); /* Cache display helpers */ @@ -334,4 +371,3 @@ void ED_area_type_hud_ensure(struct bContext *C, struct ScrArea *sa); #define ED_KEYMAP_HEADER 64 #endif /* __ED_SCREEN_H__ */ - diff --git a/source/blender/editors/include/ED_sequencer.h b/source/blender/editors/include/ED_sequencer.h index 94885c2abe0..18446966c4f 100644 --- a/source/blender/editors/include/ED_sequencer.h +++ b/source/blender/editors/include/ED_sequencer.h @@ -35,9 +35,9 @@ struct SpaceSeq; void ED_sequencer_select_sequence_single(struct Scene *scene, struct Sequence *seq, bool deselect_all); void ED_sequencer_deselect_all(struct Scene *scene); -int ED_space_sequencer_maskedit_mask_poll(struct bContext *C); +bool ED_space_sequencer_maskedit_mask_poll(struct bContext *C); bool ED_space_sequencer_check_show_maskedit(struct SpaceSeq *sseq, struct Scene *scene); -int ED_space_sequencer_maskedit_poll(struct bContext *C); +bool ED_space_sequencer_maskedit_poll(struct bContext *C); bool ED_space_sequencer_check_show_imbuf(struct SpaceSeq *sseq); bool ED_space_sequencer_check_show_strip(struct SpaceSeq *sseq); diff --git a/source/blender/editors/include/ED_sound.h b/source/blender/editors/include/ED_sound.h index 87ab9041305..b4b424b0318 100644 --- a/source/blender/editors/include/ED_sound.h +++ b/source/blender/editors/include/ED_sound.h @@ -34,4 +34,3 @@ void ED_operatortypes_sound(void); #endif /* __ED_SOUND_H__ */ - diff --git a/source/blender/editors/include/ED_transverts.h b/source/blender/editors/include/ED_transverts.h index 9005d55feff..363bb31c3dc 100644 --- a/source/blender/editors/include/ED_transverts.h +++ b/source/blender/editors/include/ED_transverts.h @@ -50,7 +50,7 @@ void ED_transverts_create_from_obedit(TransVertStore *tvs, struct Object *obedit void ED_transverts_update_obedit(TransVertStore *tvs, struct Object *obedit); void ED_transverts_free(TransVertStore *tvs); bool ED_transverts_check_obedit(Object *obedit); -int ED_transverts_poll(struct bContext *C); +bool ED_transverts_poll(struct bContext *C); /* currently only used for bmesh index values */ enum { diff --git a/source/blender/editors/include/ED_undo.h b/source/blender/editors/include/ED_undo.h index 37744e7eb0f..7995644f39e 100644 --- a/source/blender/editors/include/ED_undo.h +++ b/source/blender/editors/include/ED_undo.h @@ -68,4 +68,3 @@ void ED_undosys_type_free(void); struct MemFile *ED_undosys_stack_memfile_get_active(struct UndoStack *ustack); #endif /* __ED_UNDO_H__ */ - diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h index 3a35bddeb77..7e91b5b88c1 100644 --- a/source/blender/editors/include/ED_util.h +++ b/source/blender/editors/include/ED_util.h @@ -55,4 +55,3 @@ void apply_keyb_grid(int shift, int ctrl, float *val, float fac1, float fac2, fl void unpack_menu(struct bContext *C, const char *opname, const char *id_name, const char *abs_name, const char *folder, struct PackedFile *pf); #endif /* __ED_UTIL_H__ */ - diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index e6cd276e5c7..434e9cfe2ac 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -145,4 +145,3 @@ void ED_uvedit_draw_main( void ED_uvedit_buttons_register(struct ARegionType *art); #endif /* __ED_UVEDIT_H__ */ - diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 343bffa0082..efcf5978968 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -98,11 +98,28 @@ typedef struct ViewDepths { bool damaged; } ViewDepths; + +/* Rotate 3D cursor on placement. */ +enum eV3DCursorOrient { + V3D_CURSOR_ORIENT_NONE = 0, + V3D_CURSOR_ORIENT_VIEW, + V3D_CURSOR_ORIENT_GEOM, +}; + struct View3DCursor *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D *v3d); -void ED_view3d_cursor3d_calc_mat3(const struct Scene *scene, const struct View3D *v3d, float mat[3][3]); -void ED_view3d_cursor3d_calc_mat4(const struct Scene *scene, const struct View3D *v3d, float mat[4][4]); -void ED_view3d_cursor3d_position(struct bContext *C, float fp[3], const int mval[2]); -void ED_view3d_cursor3d_update(struct bContext *C, const int mval[2]); +void ED_view3d_cursor3d_calc_mat3(const struct Scene *scene, const struct View3D *v3d, float mat[3][3]); +void ED_view3d_cursor3d_calc_mat4(const struct Scene *scene, const struct View3D *v3d, float mat[4][4]); +void ED_view3d_cursor3d_position( + struct bContext *C, const int mval[2], + const bool use_depth, + float cursor_co[3]); +void ED_view3d_cursor3d_position_rotation( + struct bContext *C, const int mval[2], + const bool use_depth, enum eV3DCursorOrient orientation, + float cursor_co[3], float cursor_quat[4]); +void ED_view3d_cursor3d_update( + struct bContext *C, const int mval[2], + bool use_depth, enum eV3DCursorOrient orientation); struct Camera *ED_view3d_camera_data_get(struct View3D *v3d, struct RegionView3D *rv3d); @@ -379,7 +396,7 @@ bool edge_inside_circle(const float cent[2], float radius, const float screen_co /* get 3d region from context, also if mouse is in header or toolbar */ struct RegionView3D *ED_view3d_context_rv3d(struct bContext *C); bool ED_view3d_context_user_region(struct bContext *C, struct View3D **r_v3d, struct ARegion **r_ar); -int ED_operator_rv3d_user_region_poll(struct bContext *C); +bool ED_operator_rv3d_user_region_poll(struct bContext *C); void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d); void ED_view3d_init_mats_rv3d_gl(struct Object *ob, struct RegionView3D *rv3d); @@ -390,7 +407,7 @@ void ED_view3d_check_mats_rv3d(struct RegionView3D *rv3d); # define ED_view3d_clear_mats_rv3d(rv3d) (void)(rv3d) # define ED_view3d_check_mats_rv3d(rv3d) (void)(rv3d) #endif -int ED_view3d_view_layer_set(int lay, const int *values, int *active); +int ED_view3d_view_layer_set(int lay, const bool *values, int *active); struct RV3DMatrixStore *ED_view3d_mats_rv3d_backup(struct RegionView3D *rv3d); void ED_view3d_mats_rv3d_restore(struct RegionView3D *rv3d, struct RV3DMatrixStore *rv3dmat); diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index 03c99bb7f0d..4c67a306e75 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -267,15 +267,16 @@ DEF_ICON(GROUP_UVS) DEF_ICON(RNA) DEF_ICON(RNA_ADD) - /* available */ + /* MONOCHROME ICONS */ +DEF_ICON(MOUSE_LMB) +DEF_ICON(MOUSE_MMB) +DEF_ICON(MOUSE_RMB) +DEF_ICON(MOUSE_MOVE) +DEF_ICON(MOUSE_LMB_DRAG) +DEF_ICON(MOUSE_MMB_DRAG) +DEF_ICON(MOUSE_RMB_DRAG) + #ifndef DEF_ICON_BLANK_SKIP - DEF_ICON(BLANK092) - DEF_ICON(BLANK093) - DEF_ICON(BLANK094) - DEF_ICON(BLANK095) - DEF_ICON(BLANK096) - DEF_ICON(BLANK097) - DEF_ICON(BLANK098) DEF_ICON(BLANK099) DEF_ICON(BLANK100) DEF_ICON(BLANK101) @@ -292,10 +293,8 @@ DEF_ICON(RNA_ADD) DEF_ICON(BLANK112) DEF_ICON(BLANK113) DEF_ICON(BLANK114) -#endif -DEF_ICON(RESTRICT_VIEW_OFF) -DEF_ICON(RESTRICT_VIEW_ON) -#ifndef DEF_ICON_BLANK_SKIP + DEF_ICON(BLANK115) + DEF_ICON(BLANK116) DEF_ICON(BLANK116b) #endif @@ -356,8 +355,10 @@ DEF_ICON(OUTLINER_DATA_GREASEPENCIL) DEF_ICON(BLANK138) DEF_ICON(BLANK139) DEF_ICON(BLANK140) - DEF_ICON(BLANK141) - DEF_ICON(BLANK142) +#endif +DEF_ICON(RESTRICT_VIEW_OFF) +DEF_ICON(RESTRICT_VIEW_ON) +#ifndef DEF_ICON_BLANK_SKIP DEF_ICON(BLANK142b) #endif diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 0b4817c8049..e5218e287d4 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -402,6 +402,15 @@ typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event); */ typedef bool (*uiMenuStepFunc)(struct bContext *C, int direction, void *arg1); + +/* interface_query.c */ +bool UI_but_is_tool(const uiBut *but); +#define UI_but_is_decorator(but) \ + ((but)->func == ui_but_anim_decorate_cb) + +bool UI_block_is_empty(const uiBlock *block); + + /* interface_region_menu_popup.c */ /* Popup Menus * @@ -418,6 +427,7 @@ uiPopupMenu *UI_popup_menu_begin_ex( struct bContext *C, const char *title, const char *block_name, int icon) ATTR_NONNULL(); void UI_popup_menu_end(struct bContext *C, struct uiPopupMenu *head); +bool UI_popup_menu_end_or_cancel(struct bContext *C, struct uiPopupMenu *head); struct uiLayout *UI_popup_menu_layout(uiPopupMenu *head); void UI_popup_menu_reports(struct bContext *C, struct ReportList *reports) ATTR_NONNULL(); @@ -980,16 +990,16 @@ bool uiLayoutGetPropSep(uiLayout *layout); bool uiLayoutGetPropDecorate(uiLayout *layout); /* layout specifiers */ -uiLayout *uiLayoutRow(uiLayout *layout, int align); -uiLayout *uiLayoutColumn(uiLayout *layout, int align); -uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align); +uiLayout *uiLayoutRow(uiLayout *layout, bool align); +uiLayout *uiLayoutColumn(uiLayout *layout, bool align); +uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, bool align); uiLayout *uiLayoutGridFlow( - uiLayout *layout, int row_major, int num_columns, int even_columns, int even_rows, int align); + uiLayout *layout, bool row_major, int columns_len, bool even_columns, bool even_rows, bool align); uiLayout *uiLayoutBox(uiLayout *layout); uiLayout *uiLayoutListBox(uiLayout *layout, struct uiList *ui_list, struct PointerRNA *ptr, struct PropertyRNA *prop, struct PointerRNA *actptr, struct PropertyRNA *actprop); -uiLayout *uiLayoutAbsolute(uiLayout *layout, int align); -uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align); +uiLayout *uiLayoutAbsolute(uiLayout *layout, bool align); +uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, bool align); uiLayout *uiLayoutOverlap(uiLayout *layout); uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout); uiLayout *uiLayoutRadial(uiLayout *layout); @@ -1030,22 +1040,22 @@ uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct Pointe void uiTemplateOperatorRedoProperties(uiLayout *layout, const struct bContext *C); uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr); -void uiTemplatePreview(uiLayout *layout, struct bContext *C, struct ID *id, int show_buttons, struct ID *parent, +void uiTemplatePreview(uiLayout *layout, struct bContext *C, struct ID *id, bool show_buttons, struct ID *parent, struct MTex *slot, const char *preview_id); -void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int expand); +void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool expand); void uiTemplateIcon(uiLayout *layout, int icon_value, float icon_scale); -void uiTemplateIconView(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int show_labels, float icon_scale); +void uiTemplateIconView(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool show_labels, float icon_scale); void uiTemplateHistogram(uiLayout *layout, struct PointerRNA *ptr, const char *propname); void uiTemplateWaveform(uiLayout *layout, struct PointerRNA *ptr, const char *propname); void uiTemplateVectorscope(uiLayout *layout, struct PointerRNA *ptr, const char *propname); void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type, - int levels, int brush, int neg_slope); -void uiTemplateColorPicker(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int value_slider, int lock, int lock_luminosity, int cubic); -void uiTemplatePalette(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int color); + bool levels, bool brush, bool neg_slope); +void uiTemplateColorPicker(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool value_slider, bool lock, bool lock_luminosity, bool cubic); +void uiTemplatePalette(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool color); void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *used_ptr, const char *used_propname, int active_layer); -void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact, int multiview); -void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, int color_management); +void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, bool compact, bool multiview); +void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, bool color_management); void uiTemplateImageStereo3d(uiLayout *layout, struct PointerRNA *stereo3d_format_ptr); void uiTemplateImageViews(uiLayout *layout, struct PointerRNA *imaptr); void uiTemplateImageFormatViews(uiLayout *layout, PointerRNA *imfptr, PointerRNA *ptr); @@ -1062,6 +1072,7 @@ void uiTemplateHeader3D_mode(uiLayout *layout, struct bContext *C); void uiTemplateHeader3D(uiLayout *layout, struct bContext *C); void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C); void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C); +void uiTemplateInputStatus(uiLayout *layout, struct bContext *C); void uiTemplateKeymapItemProperties(uiLayout *layout, struct PointerRNA *ptr); void uiTemplateComponentMenu(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name); void uiTemplateNodeSocket(uiLayout *layout, struct bContext *C, float *color); @@ -1078,9 +1089,9 @@ void uiTemplateNodeView(uiLayout *layout, struct bContext *C, struct bNodeTree * void uiTemplateTextureUser(uiLayout *layout, struct bContext *C); void uiTemplateTextureShow(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop); -void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, int compact); +void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, bool compact); void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname); -void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *trackptr, int cmpact); +void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *trackptr, bool compact); void uiTemplateMovieclipInformation(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr); void uiTemplateColorspaceSettings(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname); @@ -1129,7 +1140,7 @@ void uiItemsFullEnumO_items( void uiItemL(uiLayout *layout, const char *name, int icon); /* label */ void uiItemLDrag(uiLayout *layout, struct PointerRNA *ptr, const char *name, int icon); /* label icon for dragging */ -void uiItemM(uiLayout *layout, struct bContext *C, const char *menuname, const char *name, int icon); /* menu */ +void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon); /* menu */ void uiItemV(uiLayout *layout, const char *name, int icon, int argval); /* value */ void uiItemS(uiLayout *layout); /* separator */ void uiItemSpacer(uiLayout *layout); /* Special separator. */ @@ -1163,7 +1174,7 @@ void ED_operatortypes_ui(void); void ED_keymap_ui(struct wmKeyConfig *keyconf); void UI_drop_color_copy(struct wmDrag *drag, struct wmDropBox *drop); -int UI_drop_color_poll(struct bContext *C, struct wmDrag *drag, const struct wmEvent *event); +bool UI_drop_color_poll(struct bContext *C, struct wmDrag *drag, const struct wmEvent *event); bool UI_context_copy_to_selected_list( struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, @@ -1258,8 +1269,4 @@ void UI_widgetbase_draw_cache_end(void); /* Support click-drag motion which presses the button and closes a popover (like a menu). */ #define USE_UI_POPOVER_ONCE -bool UI_but_is_tool(const uiBut *but); -#define UI_but_is_decorator(but) \ - ((but)->func == ui_but_anim_decorate_cb) - #endif /* __UI_INTERFACE_H__ */ diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt index 07ba3b90e11..ee18f956cac 100644 --- a/source/blender/editors/interface/CMakeLists.txt +++ b/source/blender/editors/interface/CMakeLists.txt @@ -44,6 +44,7 @@ set(SRC interface.c interface_align.c interface_anim.c + interface_context_menu.c interface_draw.c interface_eyedropper.c interface_eyedropper_color.c @@ -56,7 +57,7 @@ set(SRC interface_layout.c interface_ops.c interface_panel.c - interface_regions.c + interface_query.c interface_region_color_picker.c interface_region_hud.c interface_region_menu_pie.c @@ -65,6 +66,7 @@ set(SRC interface_region_popup.c interface_region_search.c interface_region_tooltip.c + interface_regions.c interface_style.c interface_templates.c interface_utils.c diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 8c37054098b..3b2a2e9d3ed 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -61,6 +61,7 @@ #include "GPU_glew.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "BLF_api.h" #include "BLT_translation.h" @@ -104,18 +105,6 @@ static void ui_but_to_pixelrect(struct rcti *rect, const struct ARegion *ar, str static void ui_but_free(const bContext *C, uiBut *but); -bool ui_block_is_menu(const uiBlock *block) -{ - return (((block->flag & UI_BLOCK_LOOP) != 0) && - /* non-menu popups use keep-open, so check this is off */ - ((block->flag & UI_BLOCK_KEEP_OPEN) == 0)); -} - -bool ui_block_is_pie_menu(const uiBlock *block) -{ - return ((block->flag & UI_BLOCK_RADIAL) != 0); -} - static bool ui_but_is_unit_radians_ex(UnitSettings *unit, const int unit_type) { return (unit->system_rotation == USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION); @@ -946,10 +935,11 @@ void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool do_str else { butstr_orig = BLI_strdup(but->str); } - BLI_snprintf(but->strdata, - sizeof(but->strdata), - "%s" UI_SEP_CHAR_S "%s", - butstr_orig, shortcut_str); + BLI_snprintf( + but->strdata, + sizeof(but->strdata), + "%s" UI_SEP_CHAR_S "%s", + butstr_orig, shortcut_str); MEM_freeN(butstr_orig); but->str = but->strdata; but->flag |= UI_BUT_HAS_SEP_CHAR; @@ -1381,7 +1371,7 @@ void UI_block_draw(const bContext *C, uiBlock *block) UI_block_end(C, block); /* we set this only once */ - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); /* scale fonts */ ui_fontscale(&style.paneltitle.points, block->aspect); @@ -2132,8 +2122,9 @@ static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double va precision = float_precision; } - bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precision, - unit->system, RNA_SUBTYPE_UNIT_VALUE(unit_type), do_split, pad); + bUnit_AsString( + str, len_max, ui_get_but_scale_unit(but, value), precision, + unit->system, RNA_SUBTYPE_UNIT_VALUE(unit_type), do_split, pad); } static float ui_get_but_step_unit(uiBut *but, float step_default) @@ -2354,8 +2345,9 @@ static bool ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char /* ugly, use the draw string to get the value, * this could cause problems if it includes some text which resolves to a unit */ - bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, - ui_get_but_scale_unit(but, 1.0), but->block->unit->system, RNA_SUBTYPE_UNIT_VALUE(unit_type)); + bUnit_ReplaceString( + str_unit_convert, sizeof(str_unit_convert), but->drawstr, + ui_get_but_scale_unit(but, 1.0), but->block->unit->system, RNA_SUBTYPE_UNIT_VALUE(unit_type)); return BPY_execute_string_as_number(C, str_unit_convert, true, r_value); } @@ -3440,12 +3432,14 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu } else { if (item->icon) { - uiDefIconTextButI(block, UI_BTYPE_BUT_MENU, B_NOP, item->icon, item->name, 0, 0, - UI_UNIT_X * 5, UI_UNIT_Y, &handle->retvalue, item->value, 0.0, 0, -1, item->description); + uiDefIconTextButI( + block, UI_BTYPE_BUT_MENU, B_NOP, item->icon, item->name, 0, 0, + UI_UNIT_X * 5, UI_UNIT_Y, &handle->retvalue, item->value, 0.0, 0, -1, item->description); } else { - uiDefButI(block, UI_BTYPE_BUT_MENU, B_NOP, item->name, 0, 0, - UI_UNIT_X * 5, UI_UNIT_X, &handle->retvalue, item->value, 0.0, 0, -1, item->description); + uiDefButI( + block, UI_BTYPE_BUT_MENU, B_NOP, item->name, 0, 0, + UI_UNIT_X * 5, UI_UNIT_X, &handle->retvalue, item->value, 0.0, 0, -1, item->description); } } } @@ -4780,4 +4774,3 @@ void UI_exit(void) ui_resources_free(); ui_but_clipboard_free(); } - diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c new file mode 100644 index 00000000000..240649c8ab0 --- /dev/null +++ b/source/blender/editors/interface/interface_context_menu.c @@ -0,0 +1,817 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/interface/interface_context_menu.c + * \ingroup edinterface + * + * Generic context popup menus. + */ + +#include <string.h> + +#include "MEM_guardedalloc.h" + +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" + +#include "BLI_path_util.h" +#include "BLI_string.h" +#include "BLI_utildefines.h" + +#include "BLT_translation.h" + +#include "BKE_addon.h" +#include "BKE_context.h" +#include "BKE_idprop.h" +#include "BKE_screen.h" + +#include "ED_screen.h" +#include "ED_keyframing.h" + +#include "UI_interface.h" + +#include "interface_intern.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + +/* This hack is needed because we don't have a good way to re-reference keymap items once added: T42944 */ +#define USE_KEYMAP_ADD_HACK + +/* -------------------------------------------------------------------- */ +/** \name Button Context Menu + * \{ */ + +static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event)) +{ + uiBut *but = (uiBut *)arg1; + + if (but->optype) { + char shortcut_str[128]; + + 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, + shortcut_str, sizeof(shortcut_str))) + { + ui_but_add_shortcut(but, shortcut_str, true); + } + else { + /* simply strip the shortcut */ + ui_but_add_shortcut(but, NULL, true); + } + } +} + +static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg) +{ + wmWindowManager *wm = CTX_wm_manager(C); + uiBlock *block; + uiBut *but = (uiBut *)arg; + wmKeyMap *km; + wmKeyMapItem *kmi; + PointerRNA ptr; + uiLayout *layout; + uiStyle *style = UI_style_get_dpi(); + IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; + + kmi = WM_key_event_operator(C, but->optype->idname, but->opcontext, prop, true, &km); + BLI_assert(kmi != NULL); + + RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr); + + block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); + UI_block_func_handle_set(block, but_shortcut_name_func, but); + UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT); + UI_block_direction_set(block, UI_DIR_CENTER_Y); + + layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style); + + uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE); + + UI_block_bounds_set_popup(block, 6, -50, 26); + + return block; +} + +#ifdef USE_KEYMAP_ADD_HACK +static int g_kmi_id_hack; +#endif + +static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg) +{ + wmWindowManager *wm = CTX_wm_manager(C); + uiBlock *block; + uiBut *but = (uiBut *)arg; + wmKeyMap *km; + wmKeyMapItem *kmi; + PointerRNA ptr; + uiLayout *layout; + uiStyle *style = UI_style_get_dpi(); + IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; + int kmi_id; + + /* XXX this guess_opname can potentially return a different keymap than being found on adding later... */ + km = WM_keymap_guess_opname(C, but->optype->idname); + kmi = WM_keymap_add_item(km, but->optype->idname, AKEY, KM_PRESS, 0, 0); + kmi_id = kmi->id; + + /* copy properties, prop can be NULL for reset */ + if (prop) + prop = IDP_CopyProperty(prop); + WM_keymap_properties_reset(kmi, prop); + + /* update and get pointers again */ + WM_keyconfig_update(wm); + + km = WM_keymap_guess_opname(C, but->optype->idname); + kmi = WM_keymap_item_find_id(km, kmi_id); + + RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr); + + block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); + UI_block_func_handle_set(block, but_shortcut_name_func, but); + UI_block_direction_set(block, UI_DIR_CENTER_Y); + + layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style); + + uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE); + + UI_block_bounds_set_popup(block, 6, -50, 26); + +#ifdef USE_KEYMAP_ADD_HACK + g_kmi_id_hack = kmi_id; +#endif + return block; +} + +static void menu_add_shortcut_cancel(struct bContext *C, void *arg1) +{ + uiBut *but = (uiBut *)arg1; + wmKeyMap *km; + wmKeyMapItem *kmi; +#ifndef USE_KEYMAP_ADD_HACK + IDProperty *prop; +#endif + int kmi_id; + +#ifdef USE_KEYMAP_ADD_HACK + km = WM_keymap_guess_opname(C, but->optype->idname); + kmi_id = g_kmi_id_hack; + UNUSED_VARS(but); +#else + prop = (but->opptr) ? but->opptr->data : NULL; + kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, true, &km); +#endif + + kmi = WM_keymap_item_find_id(km, kmi_id); + WM_keymap_remove_item(km, kmi); +} + +static void popup_change_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) +{ + uiBut *but = (uiBut *)arg1; + UI_popup_block_invoke(C, menu_change_shortcut, but); +} + +static void remove_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) +{ + uiBut *but = (uiBut *)arg1; + wmKeyMap *km; + wmKeyMapItem *kmi; + IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; + + kmi = WM_key_event_operator(C, but->optype->idname, but->opcontext, prop, true, &km); + BLI_assert(kmi != NULL); + + WM_keymap_remove_item(km, kmi); + + but_shortcut_name_func(C, but, 0); +} + +static void popup_add_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) +{ + uiBut *but = (uiBut *)arg1; + UI_popup_block_ex(C, menu_add_shortcut, NULL, menu_add_shortcut_cancel, but, NULL); +} + +static bool ui_but_is_user_menu_compatible(bContext *C, uiBut *but) +{ + return (but->optype || + (but->rnaprop && + (RNA_property_type(but->rnaprop) == PROP_BOOLEAN) && + (WM_context_member_from_ptr(C, &but->rnapoin) != NULL)) || + UI_but_menutype_get(but)); +} + +static bUserMenuItem *ui_but_user_menu_find(bContext *C, uiBut *but, bUserMenu *um) +{ + MenuType *mt = NULL; + if (but->optype) { + IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; + return (bUserMenuItem *)ED_screen_user_menu_item_find_operator( + &um->items, but->optype, prop, but->opcontext); + } + else if (but->rnaprop) { + const char *member_id = WM_context_member_from_ptr(C, &but->rnapoin); + const char *prop_id = RNA_property_identifier(but->rnaprop); + return (bUserMenuItem *)ED_screen_user_menu_item_find_prop( + &um->items, member_id, prop_id, but->rnaindex); + } + else if ((mt = UI_but_menutype_get(but))) { + return (bUserMenuItem *)ED_screen_user_menu_item_find_menu( + &um->items, mt); + } + else { + return NULL; + } +} + +static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um) +{ + BLI_assert(ui_but_is_user_menu_compatible(C, but)); + + char drawstr[sizeof(but->drawstr)]; + STRNCPY(drawstr, but->drawstr); + if (but->flag & UI_BUT_HAS_SEP_CHAR) { + char *sep = strrchr(drawstr, UI_SEP_CHAR); + if (sep) { + *sep = '\0'; + } + } + + MenuType *mt = NULL; + if (but->optype) { + ED_screen_user_menu_item_add_operator( + &um->items, drawstr, + but->optype, but->opptr ? but->opptr->data : NULL, but->opcontext); + } + else if (but->rnaprop) { + /* Note: 'member_id' may be a path. */ + const char *member_id = WM_context_member_from_ptr(C, &but->rnapoin); + const char *data_path = RNA_path_from_ID_to_struct(&but->rnapoin); + const char *member_id_data_path = member_id; + if (data_path) { + member_id_data_path = BLI_sprintfN("%s.%s", member_id, data_path); + } + const char *prop_id = RNA_property_identifier(but->rnaprop); + /* Note, ignore 'drawstr', use property idname always. */ + ED_screen_user_menu_item_add_prop( + &um->items, "", + member_id_data_path, prop_id, but->rnaindex); + if (data_path) { + MEM_freeN((void *)data_path); + } + if (member_id != member_id_data_path) { + MEM_freeN((void *)member_id_data_path); + } + } + else if ((mt = UI_but_menutype_get(but))) { + ED_screen_user_menu_item_add_menu( + &um->items, drawstr, + mt); + } +} + +static void popup_user_menu_add_or_replace_func(bContext *C, void *arg1, void *UNUSED(arg2)) +{ + uiBut *but = arg1; + bUserMenu *um = ED_screen_user_menu_ensure(C); + ui_but_user_menu_add(C, but, um); +} + +static void popup_user_menu_remove_func(bContext *UNUSED(C), void *arg1, void *arg2) +{ + bUserMenu *um = arg1; + bUserMenuItem *umi = arg2; + ED_screen_user_menu_item_remove(&um->items, umi); +} + +static void ui_but_menu_add_path_operators(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop) +{ + const PropertySubType subtype = RNA_property_subtype(prop); + wmOperatorType *ot = WM_operatortype_find("WM_OT_path_open", true); + char filepath[FILE_MAX]; + char dir[FILE_MAXDIR]; + char file[FILE_MAXFILE]; + PointerRNA props_ptr; + + BLI_assert(ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH)); + UNUSED_VARS_NDEBUG(subtype); + + RNA_property_string_get(ptr, prop, filepath); + BLI_split_dirfile(filepath, dir, file, sizeof(dir), sizeof(file)); + + if (file[0]) { + BLI_assert(subtype == PROP_FILEPATH); + uiItemFullO_ptr( + layout, ot, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open File Externally"), + ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &props_ptr); + RNA_string_set(&props_ptr, "filepath", filepath); + } + + uiItemFullO_ptr( + layout, ot, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Location Externally"), + ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &props_ptr); + RNA_string_set(&props_ptr, "filepath", dir); +} + +bool ui_popup_context_menu_for_button(bContext *C, uiBut *but) +{ + /* having this menu for some buttons makes no sense */ + if (but->type == UI_BTYPE_IMAGE) { + return false; + } + + uiPopupMenu *pup; + uiLayout *layout; + + { + uiStringInfo label = {BUT_GET_LABEL, NULL}; + + /* highly unlikely getting the label ever fails */ + UI_but_string_info_get(C, but, &label, NULL); + + pup = UI_popup_menu_begin(C, label.strinfo ? label.strinfo : "", ICON_NONE); + layout = UI_popup_menu_layout(pup); + if (label.strinfo) { + MEM_freeN(label.strinfo); + } + uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); + } + + if (but->rnapoin.data && but->rnaprop) { + PointerRNA *ptr = &but->rnapoin; + PropertyRNA *prop = but->rnaprop; + const PropertyType type = RNA_property_type(prop); + const PropertySubType subtype = RNA_property_subtype(prop); + bool is_anim = RNA_property_animateable(ptr, prop); + bool is_editable = RNA_property_editable(ptr, prop); + /*bool is_idprop = RNA_property_is_idprop(prop);*/ /* XXX does not work as expected, not strictly needed */ + bool is_set = RNA_property_is_set(ptr, prop); + + /* second slower test, saved people finding keyframe items in menus when its not possible */ + if (is_anim) + is_anim = RNA_property_path_from_ID_check(&but->rnapoin, but->rnaprop); + + /* determine if we can key a single component of an array */ + const bool is_array = RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0; + const bool is_array_component = (is_array && but->rnaindex != -1); + + const int override_status = RNA_property_static_override_status(ptr, prop, -1); + const bool is_overridable = (override_status & RNA_OVERRIDE_STATUS_OVERRIDABLE) != 0; + + /* Keyframes */ + if (but->flag & UI_BUT_ANIMATED_KEY) { + /* Set the (button_pointer, button_prop) and pointer data for Python access to the hovered ui element. */ + uiLayoutSetContextFromBut(layout, but); + + /* replace/delete keyfraemes */ + if (is_array_component) { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Keyframes"), + ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Single Keyframe"), + ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Keyframes"), + ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 1); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Single Keyframe"), + ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 0); + } + else { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Keyframe"), + ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Keyframe"), + ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 1); + } + + /* keyframe settings */ + uiItemS(layout); + + + } + else if (but->flag & UI_BUT_DRIVEN) { + /* pass */ + } + else if (is_anim) { + if (is_array_component) { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframes"), + ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Single Keyframe"), + ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0); + } + else { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframe"), + ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1); + } + } + + if ((but->flag & UI_BUT_ANIMATED) && (but->rnapoin.type != &RNA_NlaStrip)) { + if (is_array_component) { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"), + ICON_KEY_DEHLT, "ANIM_OT_keyframe_clear_button", "all", 1); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Single Keyframes"), + ICON_NONE, "ANIM_OT_keyframe_clear_button", "all", 0); + } + else { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"), + ICON_KEY_DEHLT, "ANIM_OT_keyframe_clear_button", "all", 1); + } + } + + /* Drivers */ + if (but->flag & UI_BUT_DRIVEN) { + uiItemS(layout); + + if (is_array_component) { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Drivers"), + ICON_X, "ANIM_OT_driver_button_remove", "all", 1); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Single Driver"), + ICON_NONE, "ANIM_OT_driver_button_remove", "all", 0); + } + else { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Driver"), + ICON_X, "ANIM_OT_driver_button_remove", "all", 1); + } + + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Driver"), + ICON_NONE, "ANIM_OT_copy_driver_button"); + if (ANIM_driver_can_paste()) { + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"), + ICON_NONE, "ANIM_OT_paste_driver_button"); + } + + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Edit Driver"), + ICON_DRIVER, "ANIM_OT_driver_button_edit"); + + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Drivers Editor"), + ICON_NONE, "SCREEN_OT_drivers_editor_show"); + } + else if (but->flag & (UI_BUT_ANIMATED_KEY | UI_BUT_ANIMATED)) { + /* pass */ + } + else if (is_anim) { + uiItemS(layout); + + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Driver"), + ICON_DRIVER, "ANIM_OT_driver_button_add"); + + if (ANIM_driver_can_paste()) { + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"), + ICON_NONE, "ANIM_OT_paste_driver_button"); + } + + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Drivers Editor"), + ICON_NONE, "SCREEN_OT_drivers_editor_show"); + } + + /* Keying Sets */ + /* TODO: check on modifyability of Keying Set when doing this */ + if (is_anim) { + uiItemS(layout); + + if (is_array_component) { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add All to Keying Set"), + ICON_KEYINGSET, "ANIM_OT_keyingset_button_add", "all", 1); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Single to Keying Set"), + ICON_NONE, "ANIM_OT_keyingset_button_add", "all", 0); + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Keying Set"), + ICON_NONE, "ANIM_OT_keyingset_button_remove"); + } + else { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Keying Set"), + ICON_KEYINGSET, "ANIM_OT_keyingset_button_add", "all", 1); + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Keying Set"), + ICON_NONE, "ANIM_OT_keyingset_button_remove"); + } + } + + if (is_overridable) { + wmOperatorType *ot; + PointerRNA op_ptr; + /* Override Operators */ + uiItemS(layout); + + if (but->flag & UI_BUT_OVERRIDEN) { + if (is_array_component) { +#if 0 /* Disabled for now. */ + ot = WM_operatortype_find("UI_OT_override_type_set_button", false); + uiItemFullO_ptr( + layout, ot, "Overrides Type", ICON_NONE, + NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); + RNA_boolean_set(&op_ptr, "all", true); + uiItemFullO_ptr( + layout, ot, "Single Override Type", ICON_NONE, + NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); + RNA_boolean_set(&op_ptr, "all", false); +#endif + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Overrides"), + ICON_X, "UI_OT_override_remove_button", "all", true); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Single Override"), + ICON_X, "UI_OT_override_remove_button", "all", false); + } + else { +#if 0 /* Disabled for now. */ + uiItemFullO( + layout, "UI_OT_override_type_set_button", "Override Type", ICON_NONE, + NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); + RNA_boolean_set(&op_ptr, "all", false); +#endif + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Override"), + ICON_X, "UI_OT_override_remove_button", "all", true); + } + } + else { + if (is_array_component) { + ot = WM_operatortype_find("UI_OT_override_type_set_button", false); + uiItemFullO_ptr( + layout, ot, "Define Overrides", ICON_NONE, + NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); + RNA_boolean_set(&op_ptr, "all", true); + uiItemFullO_ptr( + layout, ot, "Define Single Override", ICON_NONE, + NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); + RNA_boolean_set(&op_ptr, "all", false); + } + else { + uiItemFullO( + layout, "UI_OT_override_type_set_button", "Define Override", ICON_NONE, + NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); + RNA_boolean_set(&op_ptr, "all", false); + } + } + } + + uiItemS(layout); + + /* Property Operators */ + + /* Copy Property Value + * Paste Property Value */ + + if (is_array_component) { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset All to Default Values"), + ICON_LOOP_BACK, "UI_OT_reset_default_button", "all", 1); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset Single to Default Value"), + ICON_NONE, "UI_OT_reset_default_button", "all", 0); + } + else { + uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset to Default Value"), + ICON_LOOP_BACK, "UI_OT_reset_default_button", "all", 1); + } + if (is_editable /*&& is_idprop*/ && is_set) { + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Unset"), + ICON_NONE, "UI_OT_unset_property_button"); + } + + if (is_array_component) { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy All To Selected"), + ICON_NONE, "UI_OT_copy_to_selected_button", "all", true); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Single To Selected"), + ICON_NONE, "UI_OT_copy_to_selected_button", "all", false); + } + else { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy To Selected"), + ICON_NONE, "UI_OT_copy_to_selected_button", "all", true); + } + + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Data Path"), + ICON_NONE, "UI_OT_copy_data_path_button"); + + uiItemS(layout); + + if (type == PROP_STRING && ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH)) { + ui_but_menu_add_path_operators(layout, ptr, prop); + uiItemS(layout); + } + } + + /* Operator buttons */ + if (but->optype) { + uiBlock *block = uiLayoutGetBlock(layout); + uiBut *but2; + IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; + int w = uiLayoutGetWidth(layout); + wmKeyMap *km; + /* We want to know if this op has a shortcut, be it hotkey or not. */ + wmKeyMapItem *kmi = WM_key_event_operator(C, but->optype->idname, but->opcontext, prop, false, &km); + + /* We do have a shortcut, but only keyboard ones are editbale that way... */ + if (kmi) { + if (ISKEYBOARD(kmi->type)) { +#if 0 /* would rather use a block but, but gets weirdly positioned... */ + uiDefBlockBut( + block, menu_change_shortcut, but, "Change Shortcut", + 0, 0, uiLayoutGetWidth(layout), UI_UNIT_Y, ""); +#endif + + but2 = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_HAND, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Change Shortcut"), + 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); + UI_but_func_set(but2, popup_change_shortcut_func, but, NULL); + + but2 = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_NONE, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Shortcut"), + 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); + UI_but_func_set(but2, remove_shortcut_func, but, NULL); + } + else { + but2 = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_HAND, IFACE_("Non-Keyboard Shortcut"), + 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, + TIP_("Only keyboard shortcuts can be edited that way, " + "please use User Preferences otherwise")); + UI_but_flag_enable(but2, UI_BUT_DISABLED); + } + } + /* only show 'add' if there's a suitable key map for it to go in */ + else if (WM_keymap_guess_opname(C, but->optype->idname)) { + but2 = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_HAND, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Shortcut"), + 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); + UI_but_func_set(but2, popup_add_shortcut_func, but, NULL); + } + + /* Set the operator pointer for python access */ + uiLayoutSetContextFromBut(layout, but); + + uiItemS(layout); + } + + /* Favorites Menu */ + if (ui_but_is_user_menu_compatible(C, but)) { + uiBlock *block = uiLayoutGetBlock(layout); + const int w = uiLayoutGetWidth(layout); + uiBut *but2; + + but2 = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_MENU_PANEL, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Favorites Menu"), + 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, + "Add to a user defined context menu (stored in the user preferences)"); + UI_but_func_set(but2, popup_user_menu_add_or_replace_func, but, NULL); + + bUserMenu *um = ED_screen_user_menu_find(C); + if (um) { + bUserMenuItem *umi = ui_but_user_menu_find(C, but, um); + if (umi != NULL) { + but2 = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_CANCEL, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Favorites Menu"), + 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); + UI_but_func_set(but2, popup_user_menu_remove_func, um, umi); + } + } + uiItemS(layout); + } + + /* Show header tools for header buttons. */ + if (ui_block_is_menu(but->block) == false) { + ARegion *ar = CTX_wm_region(C); + if (ar && (ar->regiontype == RGN_TYPE_HEADER)) { + uiItemMenuF(layout, IFACE_("Header"), ICON_NONE, ED_screens_header_tools_menu_create, NULL); + uiItemS(layout); + } + } + + { /* Docs */ + char buf[512]; + + if (UI_but_online_manual_id(but, buf, sizeof(buf))) { + PointerRNA ptr_props; + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Online Manual"), + ICON_URL, "WM_OT_doc_view_manual_ui_context"); + + uiItemFullO( + layout, "WM_OT_doc_view", + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Online Python Reference"), + ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &ptr_props); + RNA_string_set(&ptr_props, "doc_id", buf); + + /* XXX inactive option, not for public! */ +#if 0 + uiItemFullO( + layout, "WM_OT_doc_edit", "Submit Description", ICON_NONE, + NULL, WM_OP_INVOKE_DEFAULT, 0, &ptr_props); + RNA_string_set(&ptr_props, "doc_id", buf); + RNA_string_set(&ptr_props, "doc_new", RNA_property_description(but->rnaprop)); +#endif + } + } + + if (but->optype) { + uiItemO(layout, NULL, + ICON_NONE, "UI_OT_copy_python_command_button"); + } + + /* perhaps we should move this into (G.debug & G_DEBUG) - campbell */ + if (U.flag & USER_DEVELOPER_UI) { + if (ui_block_is_menu(but->block) == false) { + uiItemFullO(layout, "UI_OT_editsource", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL); + } + } + + if (BKE_addon_find(&U.addons, "ui_translate")) { + uiItemFullO(layout, "UI_OT_edittranslation_init", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL); + } + + MenuType *mt = WM_menutype_find("WM_MT_button_context", true); + if (mt) { + UI_menutype_draw(C, mt, uiLayoutColumn(layout, false)); + } + + return UI_popup_menu_end_or_cancel(C, pup); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Panel Context Menu + * \{ */ + +/** + * menu to show when right clicking on the panel header + */ +void ui_popup_context_menu_for_panel(bContext *C, ARegion *ar, Panel *pa) +{ + bScreen *sc = CTX_wm_screen(C); + const bool has_panel_category = UI_panel_category_is_visible(ar); + const bool any_item_visible = has_panel_category; + PointerRNA ptr; + uiPopupMenu *pup; + uiLayout *layout; + + if (!any_item_visible) { + return; + } + + RNA_pointer_create(&sc->id, &RNA_Panel, pa, &ptr); + + pup = UI_popup_menu_begin(C, IFACE_("Panel"), ICON_NONE); + layout = UI_popup_menu_layout(pup); + + if (has_panel_category) { + char tmpstr[80]; + BLI_snprintf(tmpstr, sizeof(tmpstr), "%s" UI_SEP_CHAR_S "%s", IFACE_("Pin"), IFACE_("Shift+Left Mouse")); + uiItemR(layout, &ptr, "use_pin", 0, tmpstr, ICON_NONE); + + /* evil, force shortcut flag */ + { + uiBlock *block = uiLayoutGetBlock(layout); + uiBut *but = block->buttons.last; + but->flag |= UI_BUT_HAS_SEP_CHAR; + } + } + UI_popup_menu_end(C, pup); +} + +/** \} */ diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index f093f47519c..c336c48f62a 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -58,6 +58,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "UI_interface.h" @@ -119,7 +120,7 @@ void UI_draw_roundbox_aa(bool filled, float minx, float miny, float maxx, float .alpha_discard = 1.0f, }; - glEnable(GL_BLEND); + GPU_blend(true); if (filled) { /* plain antialiased filled box */ @@ -135,24 +136,26 @@ void UI_draw_roundbox_aa(bool filled, float minx, float miny, float maxx, float } else { /* plain antialiased unfilled box */ - glEnable(GL_LINE_SMOOTH); + GPU_line_smooth(true); Gwn_Batch *batch = ui_batch_roundbox_get(filled, false); GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); GWN_batch_draw(batch); - glDisable(GL_LINE_SMOOTH); + GPU_line_smooth(false); } - glDisable(GL_BLEND); + GPU_blend(false); } void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float maxy, float rad, const float col[4]) { #if 0 - float vec[7][2] = {{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}}; + float vec[7][2] = { + {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}, + }; int a; Gwn_VertFormat *format = immVertexFormat(); @@ -266,8 +269,10 @@ void UI_draw_roundbox_shade_x( float rad, float shadetop, float shadedown, const float col[4]) { #if 0 - float vec[7][2] = {{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}}; + float vec[7][2] = { + {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}, + }; const float div = maxy - miny; const float idiv = 1.0f / div; float coltop[3], coldown[3]; @@ -411,8 +416,10 @@ void UI_draw_roundbox_shade_y( bool filled, float minx, float miny, float maxx, float maxy, float rad, float shadeleft, float shaderight, const float col[4]) { - float vec[7][2] = {{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}}; + float vec[7][2] = { + {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}, + }; const float div = maxx - minx; const float idiv = 1.0f / div; float colLeft[3], colRight[3]; @@ -550,10 +557,10 @@ void ui_draw_but_TAB_outline(const rcti *rect, float rad, unsigned char highligh const int miny = rect->ymin + U.pixelsize, maxy = rect->ymax - U.pixelsize; int a; float vec[4][2] = { - {0.195, 0.02}, - {0.55, 0.169}, - {0.831, 0.45}, - {0.98, 0.805}, + {0.195, 0.02}, + {0.55, 0.169}, + {0.831, 0.45}, + {0.98, 0.805}, }; @@ -645,12 +652,12 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w /* scissor doesn't seem to be doing the right thing...? */ #if 0 /* prevent drawing outside widget area */ - GLint scissor[4]; - glGetIntegerv(GL_SCISSOR_BOX, scissor); - glScissor(rect->xmin, rect->ymin, w, h); + int scissor[4]; + GPU_scissor_get_i(scissor); + GPU_scissor(rect->xmin, rect->ymin, w, h); #endif - glEnable(GL_BLEND); + GPU_blend(true); if (w != ibuf->x || h != ibuf->y) { facx = (float)w / (float)ibuf->x; @@ -658,14 +665,15 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w } IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); - immDrawPixelsTex(&state, (float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, ibuf->rect, - facx, facy, NULL); + immDrawPixelsTex( + &state, (float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, ibuf->rect, + facx, facy, NULL); - glDisable(GL_BLEND); + GPU_blend(false); #if 0 // restore scissortest - glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); + GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]); #endif #endif @@ -710,9 +718,9 @@ void UI_draw_safe_areas( static void draw_scope_end(const rctf *rect, GLint *scissor) { /* restore scissortest */ - glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); + GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); /* outline */ UI_draw_roundbox_corner_set(UI_CNR_ALL); @@ -731,14 +739,14 @@ static void histogram_draw_one( if (res == 0) return; - glEnable(GL_LINE_SMOOTH); + GPU_line_smooth(true); glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ONE); immUniformColor4fv(color); if (is_line) { /* curve outline */ - glLineWidth(1.5); + GPU_line_width(1.5); immBegin(GWN_PRIM_LINE_STRIP, res); for (int i = 0; i < res; i++) { @@ -762,7 +770,7 @@ static void histogram_draw_one( /* curve outline */ immUniformColor4f(0.0f, 0.0f, 0.0f, 0.25f); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); immBegin(GWN_PRIM_LINE_STRIP, res); for (int i = 0; i < res; i++) { float x2 = x + i * (w / (float)res); @@ -771,7 +779,7 @@ static void histogram_draw_one( immEnd(); } - glDisable(GL_LINE_SMOOTH); + GPU_line_smooth(false); } #define HISTOGRAM_TOT_GRID_LINES 4 @@ -792,8 +800,8 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS float w = BLI_rctf_size_x(&rect); float h = BLI_rctf_size_y(&rect) * hist->ymax; - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); float color[4]; UI_GetThemeColor4fv(TH_PREVIEW_BACK, color); @@ -801,12 +809,13 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS UI_draw_roundbox_4fv(true, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f, color); /* need scissor test, histogram can draw outside of boundary */ - GLint scissor[4]; - glGetIntegerv(GL_SCISSOR_BOX, scissor); - glScissor((rect.xmin - 1), - (rect.ymin - 1), - (rect.xmax + 1) - (rect.xmin - 1), - (rect.ymax + 1) - (rect.ymin - 1)); + int scissor[4]; + GPU_scissor_get_i(scissor); + GPU_scissor( + (rect.xmin - 1), + (rect.ymin - 1), + (rect.xmax + 1) - (rect.xmin - 1), + (rect.ymax + 1) - (rect.ymin - 1)); Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -879,7 +888,7 @@ static void waveform_draw_one(float *waveform, int nbr, const float col[3]) void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *recti) { Scopes *scopes = (Scopes *)but->poin; - GLint scissor[4]; + int scissor[4]; float colors[3][3]; float colorsycc[3][3] = {{1, 0, 1}, {1, 1, 0}, {0, 1, 1}}; float colors_alpha[3][3], colorsycc_alpha[3][3]; /* colors pre multiplied by alpha for speed up */ @@ -916,8 +925,8 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE /* Flush text cache before changing scissors. */ BLF_batch_draw_flush(); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); float color[4]; UI_GetThemeColor4fv(TH_PREVIEW_BACK, color); @@ -925,11 +934,12 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE UI_draw_roundbox_4fv(true, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f, color); /* need scissor test, waveform can draw outside of boundary */ - glGetIntegerv(GL_SCISSOR_BOX, scissor); - glScissor((rect.xmin - 1), - (rect.ymin - 1), - (rect.xmax + 1) - (rect.xmin - 1), - (rect.ymax + 1) - (rect.ymin - 1)); + GPU_scissor_get_i(scissor); + GPU_scissor( + (rect.xmin - 1), + (rect.ymin - 1), + (rect.xmax + 1) - (rect.xmin - 1), + (rect.ymax + 1) - (rect.ymin - 1)); /* draw scale numbers first before binding any shader */ for (int i = 0; i < 6; i++) { @@ -943,8 +953,8 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE /* Flush text cache before drawing things on top. */ BLF_batch_draw_flush(); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -1010,7 +1020,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE if (scopes->ok && scopes->waveform_1 != NULL) { glBlendFunc(GL_ONE, GL_ONE); - glPointSize(1.0); + GPU_point_size(1.0); /* LUMA (1 channel) */ if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) { @@ -1098,7 +1108,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE /* outline */ draw_scope_end(&rect, scissor); - glDisable(GL_BLEND); + GPU_blend(false); } static float polar_to_x(float center, float diam, float ampli, float angle) @@ -1187,8 +1197,8 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN float alpha = scopes->vecscope_alpha * scopes->vecscope_alpha * scopes->vecscope_alpha; - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); float color[4]; UI_GetThemeColor4fv(TH_PREVIEW_BACK, color); @@ -1196,12 +1206,13 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN UI_draw_roundbox_4fv(true, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f, color); /* need scissor test, hvectorscope can draw outside of boundary */ - GLint scissor[4]; - glGetIntegerv(GL_SCISSOR_BOX, scissor); - glScissor((rect.xmin - 1), - (rect.ymin - 1), - (rect.xmax + 1) - (rect.xmin - 1), - (rect.ymax + 1) - (rect.ymin - 1)); + int scissor[4]; + GPU_scissor_get_i(scissor); + GPU_scissor( + (rect.xmin - 1), + (rect.ymin - 1), + (rect.xmax + 1) - (rect.xmin - 1), + (rect.ymax + 1) - (rect.ymin - 1)); Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -1249,7 +1260,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN float col[3] = {alpha, alpha, alpha}; glBlendFunc(GL_ONE, GL_ONE); - glPointSize(1.0); + GPU_point_size(1.0); gpuPushMatrix(); gpuTranslate2f(centerx, centery); @@ -1265,12 +1276,12 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN /* outline */ draw_scope_end(&rect, scissor); - glDisable(GL_BLEND); + GPU_blend(false); } static void ui_draw_colorband_handle_tri_hlight(unsigned int pos, float x1, float y1, float halfwidth, float height) { - glEnable(GL_LINE_SMOOTH); + GPU_line_smooth(true); immBegin(GWN_PRIM_LINE_STRIP, 3); immVertex2f(pos, x1 + halfwidth, y1); @@ -1278,7 +1289,7 @@ static void ui_draw_colorband_handle_tri_hlight(unsigned int pos, float x1, floa immVertex2f(pos, x1 - halfwidth, y1); immEnd(); - glDisable(GL_LINE_SMOOTH); + GPU_line_smooth(false); } static void ui_draw_colorband_handle_tri(unsigned int pos, float x1, float y1, float halfwidth, float height, bool fill) @@ -1329,10 +1340,10 @@ static void ui_draw_colorband_handle( immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); - immUniform1i("num_colors", 2); /* "advanced" mode */ + immUniform1i("colors_len", 2); /* "advanced" mode */ immUniformArray4fv("colors", (float *)(float[][4]){{0.8f, 0.8f, 0.8f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2); immUniform1f("dash_width", active ? 4.0f : 2.0f); @@ -1358,7 +1369,7 @@ static void ui_draw_colorband_handle( ui_draw_colorband_handle_box(shdr_pos, x - half_width, y1 - 1, x + half_width, y1 + height, false); /* draw all triangles blended */ - glEnable(GL_BLEND); + GPU_blend(true); ui_draw_colorband_handle_tri(shdr_pos, x, y1 + height, half_width, half_width, true); @@ -1377,7 +1388,7 @@ static void ui_draw_colorband_handle( immUniformColor3ub(0, 0, 0); ui_draw_colorband_handle_tri_hlight(shdr_pos, x, y1 + height, half_width, half_width); - glDisable(GL_BLEND); + GPU_blend(false); immUniformColor3ub(128, 128, 128); ui_draw_colorband_handle_box(shdr_pos, x - (half_width - 1), y1, x + (half_width - 1), y1 + height, true); @@ -1425,7 +1436,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); /* layer: color ramp */ - glEnable(GL_BLEND); + GPU_blend(true); CBData *cbd = coba->data; @@ -1471,7 +1482,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); /* New format */ format = immVertexFormat(); @@ -1483,7 +1494,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti imm_draw_box_wire_2d(position, x1, y1, x1 + sizex, rect->ymax); /* layer: box outline */ - glEnable(GL_BLEND); + GPU_blend(true); immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f); immBegin(GWN_PRIM_LINES, 2); @@ -1498,7 +1509,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti immVertex2f(position, x1 + sizex, y1 - 1); immEnd(); - glDisable(GL_BLEND); + GPU_blend(false); /* layer: draw handles */ for (int a = 0; a < coba->tot; a++, cbd++) { @@ -1561,11 +1572,11 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect) immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv((unsigned char *)wcol->inner); - glEnable(GL_BLEND); - glEnable(GL_LINE_SMOOTH); + GPU_blend(true); + GPU_line_smooth(true); imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, 1.0f, 32); - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); + GPU_blend(false); + GPU_line_smooth(false); /* matrix after circle */ gpuPopMatrix(); @@ -1583,8 +1594,9 @@ static void ui_draw_but_curve_grid(unsigned int pos, const rcti *rect, float zoo float fy = rect->ymin + zoomy * (-offsy); if (fy > rect->ymin) fy -= dy * (floorf(fy - rect->ymin)); - float line_count = floorf((rect->xmax - fx) / dx) + 1.0f + - floorf((rect->ymax - fy) / dy) + 1.0f; + float line_count = ( + floorf((rect->xmax - fx) / dx) + 1.0f + + floorf((rect->ymax - fy) / dy) + 1.0f); immBegin(GWN_PRIM_LINES, (int)line_count * 2); while (fx < rect->xmax) { @@ -1603,9 +1615,10 @@ static void ui_draw_but_curve_grid(unsigned int pos, const rcti *rect, float zoo static void gl_shaded_color(unsigned char *col, int shade) { - immUniformColor3ub(col[0] - shade > 0 ? col[0] - shade : 0, - col[1] - shade > 0 ? col[1] - shade : 0, - col[2] - shade > 0 ? col[2] - shade : 0); + immUniformColor3ub( + col[0] - shade > 0 ? col[0] - shade : 0, + col[1] - shade > 0 ? col[1] - shade : 0, + col[2] - shade > 0 ? col[2] - shade : 0); } void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti *rect) @@ -1622,8 +1635,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti CurveMap *cuma = &cumap->cm[cumap->cur]; /* need scissor test, curve can draw outside of boundary */ - GLint scissor[4]; - glGetIntegerv(GL_SCISSOR_BOX, scissor); + int scissor[4]; + GPU_scissor_get_i(scissor); rcti scissor_new = { .xmin = rect->xmin, .ymin = rect->ymin, @@ -1632,10 +1645,11 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti }; rcti scissor_region = {0, ar->winx, 0, ar->winy}; BLI_rcti_isect(&scissor_new, &scissor_region, &scissor_new); - glScissor(scissor_new.xmin, - scissor_new.ymin, - BLI_rcti_size_x(&scissor_new), - BLI_rcti_size_y(&scissor_new)); + GPU_scissor( + scissor_new.xmin, + scissor_new.ymin, + BLI_rcti_size_x(&scissor_new), + BLI_rcti_size_y(&scissor_new)); /* calculate offset and zoom */ float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / BLI_rctf_size_x(&cumap->curr); @@ -1658,7 +1672,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti ui_draw_gradient(&grid, col, UI_GRAD_H, 1.0f); } - glLineWidth(1.0f); + GPU_line_width(1.0f); Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -1667,21 +1681,22 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti /* backdrop */ if (but->a1 == UI_GRAD_H) { /* grid, hsv uses different grid */ - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); immUniformColor4ub(0, 0, 0, 48); ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 0.1666666f); - glDisable(GL_BLEND); + GPU_blend(false); } else { if (cumap->flag & CUMA_DO_CLIP) { gl_shaded_color((unsigned char *)wcol->inner, -20); immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); immUniformColor3ubv((unsigned char *)wcol->inner); - immRectf(pos, rect->xmin + zoomx * (cumap->clipr.xmin - offsx), - rect->ymin + zoomy * (cumap->clipr.ymin - offsy), - rect->xmin + zoomx * (cumap->clipr.xmax - offsx), - rect->ymin + zoomy * (cumap->clipr.ymax - offsy)); + immRectf(pos, + rect->xmin + zoomx * (cumap->clipr.xmin - offsx), + rect->ymin + zoomy * (cumap->clipr.ymin - offsy), + rect->xmin + zoomx * (cumap->clipr.xmax - offsx), + rect->ymin + zoomy * (cumap->clipr.ymax - offsy)); } else { immUniformColor3ubv((unsigned char *)wcol->inner); @@ -1752,8 +1767,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti /* the curve */ immUniformColor3ubv((unsigned char *)wcol->item); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); + GPU_line_smooth(true); + GPU_blend(true); immBegin(GWN_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2); if (cuma->table == NULL) @@ -1785,8 +1800,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti immVertex2f(pos, fx, fy); } immEnd(); - glDisable(GL_LINE_SMOOTH); - glDisable(GL_BLEND); + GPU_line_smooth(false); + GPU_blend(false); immUnbindProgram(); /* the points, use aspect to make them visible on edges */ @@ -1796,7 +1811,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); cmp = cuma->curve; - glPointSize(3.0f); + GPU_point_size(3.0f); immBegin(GWN_PRIM_POINTS, cuma->totpoint); for (int a = 0; a < cuma->totpoint; a++) { float color[4]; @@ -1813,7 +1828,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti immUnbindProgram(); /* restore scissortest */ - glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); + GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]); /* outline */ format = immVertexFormat(); @@ -1841,16 +1856,17 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U int width = BLI_rctf_size_x(&rect) + 1; int height = BLI_rctf_size_y(&rect); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); /* need scissor test, preview image can draw outside of boundary */ - GLint scissor[4]; - glGetIntegerv(GL_SCISSOR_BOX, scissor); - glScissor((rect.xmin - 1), - (rect.ymin - 1), - (rect.xmax + 1) - (rect.xmin - 1), - (rect.ymax + 1) - (rect.ymin - 1)); + int scissor[4]; + GPU_scissor_get_i(scissor); + GPU_scissor( + (rect.xmin - 1), + (rect.ymin - 1), + (rect.xmax + 1) - (rect.xmin - 1), + (rect.ymax + 1) - (rect.ymin - 1)); if (scopes->track_disabled) { float color[4] = {0.7f, 0.3f, 0.3f, 0.3f}; @@ -1866,10 +1882,11 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U if (scopes->track_preview) IMB_freeImBuf(scopes->track_preview); - ImBuf *tmpibuf = BKE_tracking_sample_pattern(scopes->frame_width, scopes->frame_height, - scopes->track_search, scopes->track, - &scopes->undist_marker, true, scopes->use_track_mask, - width, height, scopes->track_pos); + ImBuf *tmpibuf = BKE_tracking_sample_pattern( + scopes->frame_width, scopes->frame_height, + scopes->track_search, scopes->track, + &scopes->undist_marker, true, scopes->use_track_mask, + width, height, scopes->track_pos); if (tmpibuf) { if (tmpibuf->rect_float) IMB_rect_from_float(tmpibuf); @@ -1885,7 +1902,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U gpuPushMatrix(); /* draw content of pattern area */ - glScissor(rect.xmin, rect.ymin, scissor[2], scissor[3]); + GPU_scissor(rect.xmin, rect.ymin, scissor[2], scissor[3]); if (width > 0 && height > 0) { ImBuf *drawibuf = scopes->track_preview; @@ -1902,10 +1919,11 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U /* draw cross for pixel position */ gpuTranslate2f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1]); - glScissor(rect.xmin, - rect.ymin, - BLI_rctf_size_x(&rect), - BLI_rctf_size_y(&rect)); + GPU_scissor( + rect.xmin, + rect.ymin, + BLI_rctf_size_x(&rect), + BLI_rctf_size_y(&rect)); Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -1953,7 +1971,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U /* outline */ draw_scope_end(&rect, scissor); - glDisable(GL_BLEND); + GPU_blend(false); } void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *recti) @@ -1975,10 +1993,10 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol 0.15142777f, 0.52896401f, 0.82076344f, 0.97952994f, }; - GLint scissor[4]; + int scissor[4]; /* need scissor test, can draw outside of boundary */ - glGetIntegerv(GL_SCISSOR_BOX, scissor); + GPU_scissor_get_i(scissor); rcti scissor_new = { .xmin = recti->xmin, @@ -1990,10 +2008,11 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol rcti scissor_region = {0, ar->winx, 0, ar->winy}; BLI_rcti_isect(&scissor_new, &scissor_region, &scissor_new); - glScissor(scissor_new.xmin, - scissor_new.ymin, - BLI_rcti_size_x(&scissor_new), - BLI_rcti_size_y(&scissor_new)); + GPU_scissor( + scissor_new.xmin, + scissor_new.ymin, + BLI_rcti_size_x(&scissor_new), + BLI_rcti_size_y(&scissor_new)); float x = 0.5f * (recti->xmin + recti->xmax); float y = 0.5f * (recti->ymin + recti->ymax); @@ -2003,26 +2022,26 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv(but->col); - glEnable(GL_BLEND); + GPU_blend(true); immBegin(GWN_PRIM_TRI_FAN, 16); for (int a = 0; a < 16; a++) immVertex2f(pos, x + size * si[a], y + size * co[a]); immEnd(); immUniformColor4ub(0, 0, 0, 150); - glLineWidth(1); - glEnable(GL_LINE_SMOOTH); + GPU_line_width(1); + GPU_line_smooth(true); immBegin(GWN_PRIM_LINE_LOOP, 16); for (int a = 0; a < 16; a++) immVertex2f(pos, x + size * si[a], y + size * co[a]); immEnd(); - glDisable(GL_LINE_SMOOTH); - glDisable(GL_BLEND); + GPU_line_smooth(false); + GPU_blend(false); immUnbindProgram(); /* restore scissortest */ - glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); + GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]); } /* ****************************************************** */ @@ -2093,7 +2112,7 @@ static void ui_shadowbox(unsigned pos, unsigned color, float minx, float miny, f void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, float maxy) { - glEnable(GL_BLEND); + GPU_blend(true); Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -2112,7 +2131,7 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } @@ -2136,7 +2155,7 @@ void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha a = i * aspect; } - glEnable(GL_BLEND); + GPU_blend(true); const float dalpha = alpha * 2.0f / 255.0f; float calpha = dalpha; float visibility = 1.0f; @@ -2173,10 +2192,10 @@ void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha GWN_batch_draw(batch); /* outline emphasis */ - glEnable(GL_LINE_SMOOTH); + GPU_line_smooth(true); float color[4] = {0.0f, 0.0f, 0.0f, 0.4f}; UI_draw_roundbox_4fv(false, rct->xmin - 0.5f, rct->ymin - 0.5f, rct->xmax + 0.5f, rct->ymax + 0.5f, radius + 0.5f, color); - glDisable(GL_LINE_SMOOTH); + GPU_line_smooth(false); - glDisable(GL_BLEND); + GPU_blend(false); } diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c index 8cb55b724fb..eb8fff471e2 100644 --- a/source/blender/editors/interface/interface_eyedropper.c +++ b/source/blender/editors/interface/interface_eyedropper.c @@ -180,4 +180,3 @@ uiBut *eyedropper_get_property_button_under_mouse(bContext *C, const wmEvent *ev } /** \} */ - diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c index a60b6f3f60b..73efc59feb7 100644 --- a/source/blender/editors/interface/interface_eyedropper_color.c +++ b/source/blender/editors/interface/interface_eyedropper_color.c @@ -319,7 +319,7 @@ static int eyedropper_exec(bContext *C, wmOperator *op) } } -static int eyedropper_poll(bContext *C) +static bool eyedropper_poll(bContext *C) { PointerRNA ptr; PropertyRNA *prop; diff --git a/source/blender/editors/interface/interface_eyedropper_colorband.c b/source/blender/editors/interface/interface_eyedropper_colorband.c index b13d552dbeb..f414d524cd8 100644 --- a/source/blender/editors/interface/interface_eyedropper_colorband.c +++ b/source/blender/editors/interface/interface_eyedropper_colorband.c @@ -289,7 +289,7 @@ static int eyedropper_colorband_exec(bContext *C, wmOperator *op) } } -static int eyedropper_colorband_poll(bContext *C) +static bool eyedropper_colorband_poll(bContext *C) { uiBut *but = UI_context_active_but_get(C); return (but && but->type == UI_BTYPE_COLORBAND); diff --git a/source/blender/editors/interface/interface_eyedropper_datablock.c b/source/blender/editors/interface/interface_eyedropper_datablock.c index f814048c0c0..b1e649f4abe 100644 --- a/source/blender/editors/interface/interface_eyedropper_datablock.c +++ b/source/blender/editors/interface/interface_eyedropper_datablock.c @@ -305,7 +305,7 @@ static int datadropper_exec(bContext *C, wmOperator *op) } } -static int datadropper_poll(bContext *C) +static bool datadropper_poll(bContext *C) { PointerRNA ptr; PropertyRNA *prop; diff --git a/source/blender/editors/interface/interface_eyedropper_depth.c b/source/blender/editors/interface/interface_eyedropper_depth.c index df09c327da1..fb125a3845b 100644 --- a/source/blender/editors/interface/interface_eyedropper_depth.c +++ b/source/blender/editors/interface/interface_eyedropper_depth.c @@ -335,7 +335,7 @@ static int depthdropper_exec(bContext *C, wmOperator *op) } } -static int depthdropper_poll(bContext *C) +static bool depthdropper_poll(bContext *C) { PointerRNA ptr; PropertyRNA *prop; diff --git a/source/blender/editors/interface/interface_eyedropper_driver.c b/source/blender/editors/interface/interface_eyedropper_driver.c index 50a8473135a..852f7ea71b6 100644 --- a/source/blender/editors/interface/interface_eyedropper_driver.c +++ b/source/blender/editors/interface/interface_eyedropper_driver.c @@ -205,7 +205,7 @@ static int driverdropper_exec(bContext *C, wmOperator *op) } } -static int driverdropper_poll(bContext *C) +static bool driverdropper_poll(bContext *C) { if (!CTX_wm_window(C)) return 0; else return 1; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 63bf29a26ea..ac7ed3d5106 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -27,7 +27,6 @@ * \ingroup edinterface */ - #include <float.h> #include <limits.h> #include <math.h> @@ -40,31 +39,25 @@ #include "DNA_brush_types.h" -#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "BLI_math.h" #include "BLI_listbase.h" #include "BLI_linklist.h" -#include "BLI_path_util.h" #include "BLI_string.h" #include "BLI_string_utf8.h" #include "BLI_string_cursor_utf8.h" #include "BLI_rect.h" #include "BLI_utildefines.h" -#include "BLT_translation.h" - #include "PIL_time.h" -#include "BKE_addon.h" #include "BKE_colorband.h" #include "BKE_blender_undo.h" #include "BKE_brush.h" #include "BKE_colortools.h" #include "BKE_context.h" -#include "BKE_idprop.h" #include "BKE_report.h" #include "BKE_screen.h" #include "BKE_tracking.h" @@ -73,7 +66,6 @@ #include "ED_screen.h" #include "ED_undo.h" -#include "ED_keyframing.h" #include "UI_interface.h" #include "UI_view2d.h" @@ -90,6 +82,7 @@ #ifdef WITH_INPUT_IME # include "wm_window.h" +# include "BLT_translation.h" # include "BLT_lang.h" #endif @@ -112,9 +105,6 @@ #define UI_MAX_PASSWORD_STR 128 -/* This hack is needed because we don't have a good way to re-reference keymap items once added: T42944 */ -#define USE_KEYMAP_ADD_HACK - /* proto */ static int ui_do_but_EXIT(bContext *C, uiBut *but, struct uiHandleButtonData *data, const wmEvent *event); static bool ui_but_find_select_in_enum__cmp(const uiBut *but_a, const uiBut *but_b); @@ -477,46 +467,6 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val) } } -bool ui_but_is_editable(const uiBut *but) -{ - return !ELEM(but->type, - UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, - UI_BTYPE_ROUNDBOX, UI_BTYPE_LISTBOX, UI_BTYPE_PROGRESS_BAR); -} - -bool ui_but_is_editable_as_text(const uiBut *but) -{ - return ELEM(but->type, - UI_BTYPE_TEXT, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, - UI_BTYPE_SEARCH_MENU); - -} - -bool ui_but_is_toggle(const uiBut *but) -{ - return ELEM( - but->type, - UI_BTYPE_BUT_TOGGLE, - UI_BTYPE_TOGGLE, - UI_BTYPE_ICON_TOGGLE, - UI_BTYPE_ICON_TOGGLE_N, - UI_BTYPE_TOGGLE_N, - UI_BTYPE_CHECKBOX, - UI_BTYPE_CHECKBOX_N, - UI_BTYPE_ROW - ); -} - -#ifdef USE_UI_POPOVER_ONCE -bool ui_but_is_popover_once_compat(const uiBut *but) -{ - return ( - (but->type == UI_BTYPE_BUT) || - ui_but_is_toggle(but) - ); -} -#endif - static uiBut *ui_but_prev(uiBut *but) { while (but->prev) { @@ -1301,7 +1251,6 @@ typedef struct uiDragToggleHandle { bool is_init; bool is_set; float but_cent_start[2]; - eButType but_type_start; bool xy_lock[2]; int xy_init[2]; @@ -1309,7 +1258,7 @@ typedef struct uiDragToggleHandle { } uiDragToggleHandle; static bool ui_drag_toggle_set_xy_xy( - bContext *C, ARegion *ar, const bool is_set, const eButType but_type_start, + bContext *C, ARegion *ar, const bool is_set, const int xy_src[2], const int xy_dst[2]) { /* popups such as layers won't re-evaluate on redraw */ @@ -1333,7 +1282,7 @@ static bool ui_drag_toggle_set_xy_xy( if (BLI_rctf_isect_segment(&but->rect, xy_a_block, xy_b_block)) { /* execute the button */ - if (ui_drag_toggle_but_is_supported(but) && but->type == but_type_start) { + if (ui_drag_toggle_but_is_supported(but)) { /* is it pressed? */ bool is_set_but = ui_drag_toggle_but_is_pushed(but); if (is_set_but != is_set) { @@ -1376,8 +1325,10 @@ static void ui_drag_toggle_set(bContext *C, uiDragToggleHandle *drag_info, const if (but) { if (but->flag & UI_BUT_DRAG_LOCK) { - const float but_cent_new[2] = {BLI_rctf_cent_x(&but->rect), - BLI_rctf_cent_y(&but->rect)}; + const float but_cent_new[2] = { + BLI_rctf_cent_x(&but->rect), + BLI_rctf_cent_y(&but->rect), + }; /* check if this is a different button, chances are high the button wont move about :) */ if (len_manhattan_v2v2(drag_info->but_cent_start, but_cent_new) > 1.0f) { @@ -1405,7 +1356,7 @@ static void ui_drag_toggle_set(bContext *C, uiDragToggleHandle *drag_info, const /* touch all buttons between last mouse coord and this one */ - do_draw = ui_drag_toggle_set_xy_xy(C, ar, drag_info->is_set, drag_info->but_type_start, drag_info->xy_last, xy); + do_draw = ui_drag_toggle_set_xy_xy(C, ar, drag_info->is_set, drag_info->xy_last, xy); if (do_draw) { ED_region_tag_redraw(ar); @@ -1449,10 +1400,11 @@ static int ui_handler_region_drag_toggle(bContext *C, const wmEvent *event, void ui_apply_but_undo(but); } - WM_event_remove_ui_handler(&win->modalhandlers, - ui_handler_region_drag_toggle, - ui_handler_region_drag_toggle_remove, - drag_info, false); + WM_event_remove_ui_handler( + &win->modalhandlers, + ui_handler_region_drag_toggle, + ui_handler_region_drag_toggle_remove, + drag_info, false); ui_handler_region_drag_toggle_remove(C, drag_info); WM_event_add_mousemove(C); @@ -1667,7 +1619,7 @@ static void ui_selectcontext_apply( wmWindow *win = CTX_wm_window(C); if (!win->eventstate->shift) { const int len = RNA_property_array_length(&but->rnapoin, prop); - int *tmparray = MEM_callocN(sizeof(int) * len, __func__); + bool *tmparray = MEM_callocN(sizeof(bool) * len, __func__); tmparray[index] = true; @@ -1784,7 +1736,6 @@ static bool ui_but_drag_init( drag_info->is_set = ui_drag_toggle_but_is_pushed(but); drag_info->but_cent_start[0] = BLI_rctf_cent_x(&but->rect); drag_info->but_cent_start[1] = BLI_rctf_cent_y(&but->rect); - drag_info->but_type_start = but->type; copy_v2_v2_int(drag_info->xy_init, &event->x); copy_v2_v2_int(drag_info->xy_last, &event->x); @@ -3211,13 +3162,15 @@ static void ui_do_but_textedit( } break; case RIGHTARROWKEY: - ui_textedit_move(but, data, STRCUR_DIR_NEXT, - event->shift != 0, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE); + ui_textedit_move( + but, data, STRCUR_DIR_NEXT, + event->shift != 0, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE); retval = WM_UI_HANDLER_BREAK; break; case LEFTARROWKEY: - ui_textedit_move(but, data, STRCUR_DIR_PREV, - event->shift != 0, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE); + ui_textedit_move( + but, data, STRCUR_DIR_PREV, + event->shift != 0, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE); retval = WM_UI_HANDLER_BREAK; break; case WHEELDOWNMOUSE: @@ -3234,8 +3187,9 @@ static void ui_do_but_textedit( } ATTR_FALLTHROUGH; case ENDKEY: - ui_textedit_move(but, data, STRCUR_DIR_NEXT, - event->shift != 0, STRCUR_JUMP_ALL); + ui_textedit_move( + but, data, STRCUR_DIR_NEXT, + event->shift != 0, STRCUR_JUMP_ALL); retval = WM_UI_HANDLER_BREAK; break; case WHEELUPMOUSE: @@ -3252,8 +3206,9 @@ static void ui_do_but_textedit( } ATTR_FALLTHROUGH; case HOMEKEY: - ui_textedit_move(but, data, STRCUR_DIR_PREV, - event->shift != 0, STRCUR_JUMP_ALL); + ui_textedit_move( + but, data, STRCUR_DIR_PREV, + event->shift != 0, STRCUR_JUMP_ALL); retval = WM_UI_HANDLER_BREAK; break; case PADENTER: @@ -3262,14 +3217,16 @@ static void ui_do_but_textedit( retval = WM_UI_HANDLER_BREAK; break; case DELKEY: - changed = ui_textedit_delete(but, data, 1, - event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE); + changed = ui_textedit_delete( + but, data, 1, + event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE); retval = WM_UI_HANDLER_BREAK; break; case BACKSPACEKEY: - changed = ui_textedit_delete(but, data, 0, - event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE); + changed = ui_textedit_delete( + but, data, 0, + event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE); retval = WM_UI_HANDLER_BREAK; break; @@ -3284,10 +3241,12 @@ static void ui_do_but_textedit( if (event->ctrl && !IS_EVENT_MOD(event, shift, alt, oskey)) #endif { - ui_textedit_move(but, data, STRCUR_DIR_PREV, - false, STRCUR_JUMP_ALL); - ui_textedit_move(but, data, STRCUR_DIR_NEXT, - true, STRCUR_JUMP_ALL); + ui_textedit_move( + but, data, STRCUR_DIR_PREV, + false, STRCUR_JUMP_ALL); + ui_textedit_move( + but, data, STRCUR_DIR_NEXT, + true, STRCUR_JUMP_ALL); retval = WM_UI_HANDLER_BREAK; } break; @@ -6496,596 +6455,6 @@ static int ui_do_but_TRACKPREVIEW( return WM_UI_HANDLER_CONTINUE; } -static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event)) -{ - uiBut *but = (uiBut *)arg1; - - if (but->optype) { - char shortcut_str[128]; - - 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, - shortcut_str, sizeof(shortcut_str))) - { - ui_but_add_shortcut(but, shortcut_str, true); - } - else { - /* simply strip the shortcut */ - ui_but_add_shortcut(but, NULL, true); - } - } -} - -static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg) -{ - wmWindowManager *wm = CTX_wm_manager(C); - uiBlock *block; - uiBut *but = (uiBut *)arg; - wmKeyMap *km; - wmKeyMapItem *kmi; - PointerRNA ptr; - uiLayout *layout; - uiStyle *style = UI_style_get_dpi(); - IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; - - kmi = WM_key_event_operator(C, but->optype->idname, but->opcontext, prop, true, &km); - BLI_assert(kmi != NULL); - - RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr); - - block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); - UI_block_func_handle_set(block, but_shortcut_name_func, but); - UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT); - UI_block_direction_set(block, UI_DIR_CENTER_Y); - - layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style); - - uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE); - - UI_block_bounds_set_popup(block, 6, -50, 26); - - return block; -} - -#ifdef USE_KEYMAP_ADD_HACK -static int g_kmi_id_hack; -#endif - -static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg) -{ - wmWindowManager *wm = CTX_wm_manager(C); - uiBlock *block; - uiBut *but = (uiBut *)arg; - wmKeyMap *km; - wmKeyMapItem *kmi; - PointerRNA ptr; - uiLayout *layout; - uiStyle *style = UI_style_get_dpi(); - IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; - int kmi_id; - - /* XXX this guess_opname can potentially return a different keymap than being found on adding later... */ - km = WM_keymap_guess_opname(C, but->optype->idname); - kmi = WM_keymap_add_item(km, but->optype->idname, AKEY, KM_PRESS, 0, 0); - kmi_id = kmi->id; - - /* copy properties, prop can be NULL for reset */ - if (prop) - prop = IDP_CopyProperty(prop); - WM_keymap_properties_reset(kmi, prop); - - /* update and get pointers again */ - WM_keyconfig_update(wm); - - km = WM_keymap_guess_opname(C, but->optype->idname); - kmi = WM_keymap_item_find_id(km, kmi_id); - - RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr); - - block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); - UI_block_func_handle_set(block, but_shortcut_name_func, but); - UI_block_direction_set(block, UI_DIR_CENTER_Y); - - layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style); - - uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE); - - UI_block_bounds_set_popup(block, 6, -50, 26); - -#ifdef USE_KEYMAP_ADD_HACK - g_kmi_id_hack = kmi_id; -#endif - return block; -} - -static void menu_add_shortcut_cancel(struct bContext *C, void *arg1) -{ - uiBut *but = (uiBut *)arg1; - wmKeyMap *km; - wmKeyMapItem *kmi; -#ifndef USE_KEYMAP_ADD_HACK - IDProperty *prop; -#endif - int kmi_id; - -#ifdef USE_KEYMAP_ADD_HACK - km = WM_keymap_guess_opname(C, but->optype->idname); - kmi_id = g_kmi_id_hack; - UNUSED_VARS(but); -#else - prop = (but->opptr) ? but->opptr->data : NULL; - kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, true, &km); -#endif - - kmi = WM_keymap_item_find_id(km, kmi_id); - WM_keymap_remove_item(km, kmi); -} - -static void popup_change_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) -{ - uiBut *but = (uiBut *)arg1; - UI_popup_block_invoke(C, menu_change_shortcut, but); -} - -static void remove_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) -{ - uiBut *but = (uiBut *)arg1; - wmKeyMap *km; - wmKeyMapItem *kmi; - IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; - - kmi = WM_key_event_operator(C, but->optype->idname, but->opcontext, prop, true, &km); - BLI_assert(kmi != NULL); - - WM_keymap_remove_item(km, kmi); - - but_shortcut_name_func(C, but, 0); -} - -static void popup_add_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) -{ - uiBut *but = (uiBut *)arg1; - UI_popup_block_ex(C, menu_add_shortcut, NULL, menu_add_shortcut_cancel, but, NULL); -} - -/** - * menu to chow when right clicking on the panel header - */ -void ui_panel_menu(bContext *C, ARegion *ar, Panel *pa) -{ - bScreen *sc = CTX_wm_screen(C); - const bool has_panel_category = UI_panel_category_is_visible(ar); - const bool any_item_visible = has_panel_category; - PointerRNA ptr; - uiPopupMenu *pup; - uiLayout *layout; - - if (!any_item_visible) { - return; - } - - RNA_pointer_create(&sc->id, &RNA_Panel, pa, &ptr); - - pup = UI_popup_menu_begin(C, IFACE_("Panel"), ICON_NONE); - layout = UI_popup_menu_layout(pup); - - if (has_panel_category) { - char tmpstr[80]; - BLI_snprintf(tmpstr, sizeof(tmpstr), "%s" UI_SEP_CHAR_S "%s", IFACE_("Pin"), IFACE_("Shift+Left Mouse")); - uiItemR(layout, &ptr, "use_pin", 0, tmpstr, ICON_NONE); - - /* evil, force shortcut flag */ - { - uiBlock *block = uiLayoutGetBlock(layout); - uiBut *but = block->buttons.last; - but->flag |= UI_BUT_HAS_SEP_CHAR; - } - } - UI_popup_menu_end(C, pup); -} - -static void ui_but_menu_add_path_operators(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop) -{ - const PropertySubType subtype = RNA_property_subtype(prop); - wmOperatorType *ot = WM_operatortype_find("WM_OT_path_open", true); - char filepath[FILE_MAX]; - char dir[FILE_MAXDIR]; - char file[FILE_MAXFILE]; - PointerRNA props_ptr; - - BLI_assert(ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH)); - UNUSED_VARS_NDEBUG(subtype); - - RNA_property_string_get(ptr, prop, filepath); - BLI_split_dirfile(filepath, dir, file, sizeof(dir), sizeof(file)); - - if (file[0]) { - BLI_assert(subtype == PROP_FILEPATH); - uiItemFullO_ptr( - layout, ot, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open File Externally"), - ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &props_ptr); - RNA_string_set(&props_ptr, "filepath", filepath); - } - - uiItemFullO_ptr( - layout, ot, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Location Externally"), - ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &props_ptr); - RNA_string_set(&props_ptr, "filepath", dir); -} - -static bool ui_but_menu(bContext *C, uiBut *but) -{ - uiPopupMenu *pup; - uiLayout *layout; - MenuType *mt = WM_menutype_find("WM_MT_button_context", true); - bool is_array, is_array_component; - uiStringInfo label = {BUT_GET_LABEL, NULL}; - wmOperatorType *ot; - PointerRNA op_ptr; - -/* if ((but->rnapoin.data && but->rnaprop) == 0 && but->optype == NULL)*/ -/* return 0;*/ - - /* having this menu for some buttons makes no sense */ - if (but->type == UI_BTYPE_IMAGE) { - return false; - } - - /* highly unlikely getting the label ever fails */ - UI_but_string_info_get(C, but, &label, NULL); - - pup = UI_popup_menu_begin(C, label.strinfo ? label.strinfo : "", ICON_NONE); - layout = UI_popup_menu_layout(pup); - if (label.strinfo) - MEM_freeN(label.strinfo); - - uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); - - if (but->rnapoin.data && but->rnaprop) { - PointerRNA *ptr = &but->rnapoin; - PropertyRNA *prop = but->rnaprop; - const PropertyType type = RNA_property_type(prop); - const PropertySubType subtype = RNA_property_subtype(prop); - bool is_anim = RNA_property_animateable(ptr, prop); - bool is_editable = RNA_property_editable(ptr, prop); - /*bool is_idprop = RNA_property_is_idprop(prop);*/ /* XXX does not work as expected, not strictly needed */ - bool is_set = RNA_property_is_set(ptr, prop); - - const int override_status = RNA_property_static_override_status(ptr, prop, -1); - const bool is_overridable = (override_status & RNA_OVERRIDE_STATUS_OVERRIDABLE) != 0; - - /* second slower test, saved people finding keyframe items in menus when its not possible */ - if (is_anim) - is_anim = RNA_property_path_from_ID_check(&but->rnapoin, but->rnaprop); - - /* determine if we can key a single component of an array */ - is_array = RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0; - is_array_component = (is_array && but->rnaindex != -1); - - /* Keyframes */ - if (but->flag & UI_BUT_ANIMATED_KEY) { - /* replace/delete keyfraemes */ - if (is_array_component) { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Keyframes"), - ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Single Keyframe"), - ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Keyframes"), - ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 1); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Single Keyframe"), - ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 0); - } - else { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Keyframe"), - ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Keyframe"), - ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 1); - } - - /* keyframe settings */ - uiItemS(layout); - - - } - else if (but->flag & UI_BUT_DRIVEN) { - /* pass */ - } - else if (is_anim) { - if (is_array_component) { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframes"), - ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Single Keyframe"), - ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0); - } - else { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframe"), - ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1); - } - } - - if ((but->flag & UI_BUT_ANIMATED) && (but->rnapoin.type != &RNA_NlaStrip)) { - if (is_array_component) { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"), - ICON_KEY_DEHLT, "ANIM_OT_keyframe_clear_button", "all", 1); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Single Keyframes"), - ICON_NONE, "ANIM_OT_keyframe_clear_button", "all", 0); - } - else { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"), - ICON_KEY_DEHLT, "ANIM_OT_keyframe_clear_button", "all", 1); - } - } - - /* Drivers */ - if (but->flag & UI_BUT_DRIVEN) { - uiItemS(layout); - - if (is_array_component) { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Drivers"), - ICON_X, "ANIM_OT_driver_button_remove", "all", 1); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Single Driver"), - ICON_NONE, "ANIM_OT_driver_button_remove", "all", 0); - } - else { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Driver"), - ICON_X, "ANIM_OT_driver_button_remove", "all", 1); - } - - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Driver"), - ICON_NONE, "ANIM_OT_copy_driver_button"); - if (ANIM_driver_can_paste()) { - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"), - ICON_NONE, "ANIM_OT_paste_driver_button"); - } - - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Edit Driver"), - ICON_DRIVER, "ANIM_OT_driver_button_edit"); - - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Drivers Editor"), - ICON_NONE, "SCREEN_OT_drivers_editor_show"); - } - else if (but->flag & (UI_BUT_ANIMATED_KEY | UI_BUT_ANIMATED)) { - /* pass */ - } - else if (is_anim) { - uiItemS(layout); - - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Driver"), - ICON_DRIVER, "ANIM_OT_driver_button_add"); - - if (ANIM_driver_can_paste()) { - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"), - ICON_NONE, "ANIM_OT_paste_driver_button"); - } - - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Drivers Editor"), - ICON_NONE, "SCREEN_OT_drivers_editor_show"); - } - - /* Keying Sets */ - /* TODO: check on modifyability of Keying Set when doing this */ - if (is_anim) { - uiItemS(layout); - - if (is_array_component) { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add All to Keying Set"), - ICON_KEYINGSET, "ANIM_OT_keyingset_button_add", "all", 1); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Single to Keying Set"), - ICON_NONE, "ANIM_OT_keyingset_button_add", "all", 0); - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Keying Set"), - ICON_NONE, "ANIM_OT_keyingset_button_remove"); - } - else { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Keying Set"), - ICON_KEYINGSET, "ANIM_OT_keyingset_button_add", "all", 1); - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Keying Set"), - ICON_NONE, "ANIM_OT_keyingset_button_remove"); - } - } - - if (is_overridable) { - /* Override Operators */ - uiItemS(layout); - - if (but->flag & UI_BUT_OVERRIDEN) { - if (is_array_component) { -#if 0 /* Disabled for now. */ - ot = WM_operatortype_find("UI_OT_override_type_set_button", false); - uiItemFullO_ptr(layout, ot, "Overrides Type", ICON_NONE, - NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); - RNA_boolean_set(&op_ptr, "all", true); - uiItemFullO_ptr(layout, ot, "Single Override Type", ICON_NONE, - NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); - RNA_boolean_set(&op_ptr, "all", false); -#endif - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Overrides"), - ICON_X, "UI_OT_override_remove_button", "all", true); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Single Override"), - ICON_X, "UI_OT_override_remove_button", "all", false); - } - else { -#if 0 /* Disabled for now. */ - uiItemFullO(layout, "UI_OT_override_type_set_button", "Override Type", ICON_NONE, - NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); - RNA_boolean_set(&op_ptr, "all", false); -#endif - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Override"), - ICON_X, "UI_OT_override_remove_button", "all", true); - } - } - else { - if (is_array_component) { - ot = WM_operatortype_find("UI_OT_override_type_set_button", false); - uiItemFullO_ptr(layout, ot, "Define Overrides", ICON_NONE, - NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); - RNA_boolean_set(&op_ptr, "all", true); - uiItemFullO_ptr(layout, ot, "Define Single Override", ICON_NONE, - NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); - RNA_boolean_set(&op_ptr, "all", false); - } - else { - uiItemFullO(layout, "UI_OT_override_type_set_button", "Define Override", ICON_NONE, - NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); - RNA_boolean_set(&op_ptr, "all", false); - } - } - } - - uiItemS(layout); - - /* Property Operators */ - - /* Copy Property Value - * Paste Property Value */ - - if (is_array_component) { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset All to Default Values"), - ICON_LOOP_BACK, "UI_OT_reset_default_button", "all", 1); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset Single to Default Value"), - ICON_NONE, "UI_OT_reset_default_button", "all", 0); - } - else { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset to Default Value"), - ICON_LOOP_BACK, "UI_OT_reset_default_button", "all", 1); - } - if (is_editable /*&& is_idprop*/ && is_set) { - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Unset"), - ICON_NONE, "UI_OT_unset_property_button"); - } - - if (is_array_component) { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy All To Selected"), - ICON_NONE, "UI_OT_copy_to_selected_button", "all", true); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Single To Selected"), - ICON_NONE, "UI_OT_copy_to_selected_button", "all", false); - } - else { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy To Selected"), - ICON_NONE, "UI_OT_copy_to_selected_button", "all", true); - } - - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Data Path"), - ICON_NONE, "UI_OT_copy_data_path_button"); - - uiItemS(layout); - - if (type == PROP_STRING && ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH)) { - ui_but_menu_add_path_operators(layout, ptr, prop); - uiItemS(layout); - } - } - - /* Operator buttons */ - if (but->optype) { - uiBlock *block = uiLayoutGetBlock(layout); - uiBut *but2; - IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; - int w = uiLayoutGetWidth(layout); - wmKeyMap *km; - /* We want to know if this op has a shortcut, be it hotkey or not. */ - wmKeyMapItem *kmi = WM_key_event_operator(C, but->optype->idname, but->opcontext, prop, false, &km); - - /* We do have a shortcut, but only keyboard ones are editbale that way... */ - if (kmi) { - if (ISKEYBOARD(kmi->type)) { -#if 0 /* would rather use a block but, but gets weirdly positioned... */ - uiDefBlockBut(block, menu_change_shortcut, but, "Change Shortcut", - 0, 0, uiLayoutGetWidth(layout), UI_UNIT_Y, ""); -#endif - - but2 = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_HAND, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Change Shortcut"), - 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); - UI_but_func_set(but2, popup_change_shortcut_func, but, NULL); - - but2 = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_NONE, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Shortcut"), - 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); - UI_but_func_set(but2, remove_shortcut_func, but, NULL); - } - else { - but2 = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_HAND, IFACE_("Non-Keyboard Shortcut"), - 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, - TIP_("Only keyboard shortcuts can be edited that way, " - "please use User Preferences otherwise")); - UI_but_flag_enable(but2, UI_BUT_DISABLED); - } - } - /* only show 'add' if there's a suitable key map for it to go in */ - else if (WM_keymap_guess_opname(C, but->optype->idname)) { - but2 = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_HAND, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Shortcut"), - 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); - UI_but_func_set(but2, popup_add_shortcut_func, but, NULL); - } - - /* Set the operator pointer for python access */ - uiLayoutSetContextFromBut(layout, but); - - uiItemS(layout); - } - - /* Show header tools for header buttons. */ - if (ui_block_is_menu(but->block) == false) { - ARegion *ar = CTX_wm_region(C); - if (ar && (ar->regiontype == RGN_TYPE_HEADER)) { - uiItemMenuF(layout, IFACE_("Header"), ICON_NONE, ED_screens_header_tools_menu_create, NULL); - uiItemS(layout); - } - } - - { /* Docs */ - char buf[512]; - - if (UI_but_online_manual_id(but, buf, sizeof(buf))) { - PointerRNA ptr_props; - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Online Manual"), - ICON_URL, "WM_OT_doc_view_manual_ui_context"); - - uiItemFullO( - layout, "WM_OT_doc_view", - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Online Python Reference"), - ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &ptr_props); - RNA_string_set(&ptr_props, "doc_id", buf); - - /* XXX inactive option, not for public! */ -#if 0 - uiItemFullO( - layout, "WM_OT_doc_edit", "Submit Description", ICON_NONE, - NULL, WM_OP_INVOKE_DEFAULT, 0, &ptr_props); - RNA_string_set(&ptr_props, "doc_id", buf); - RNA_string_set(&ptr_props, "doc_new", RNA_property_description(but->rnaprop)); -#endif - } - } - - if (but->optype) { - uiItemO(layout, NULL, - ICON_NONE, "UI_OT_copy_python_command_button"); - } - - /* perhaps we should move this into (G.debug & G_DEBUG) - campbell */ - if (ui_block_is_menu(but->block) == false) { - uiItemFullO(layout, "UI_OT_editsource", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL); - } - - if (BKE_addon_find(&U.addons, "ui_translate")) { - uiItemFullO(layout, "UI_OT_edittranslation_init", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL); - } - - mt = WM_menutype_find("WM_MT_button_context", true); - if (mt) { - UI_menutype_draw(C, mt, uiLayoutColumn(layout, false)); - } - - UI_popup_menu_end(C, pup); - - return true; -} - static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *event) { uiHandleButtonData *data; @@ -7129,7 +6498,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * (event->val == KM_PRESS)) { /* RMB has two options now */ - if (ui_but_menu(C, but)) { + if (ui_popup_context_menu_for_button(C, but)) { return WM_UI_HANDLER_BREAK; } } @@ -7724,10 +7093,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s /* highlight has timers for tooltips and auto open */ if (state == BUTTON_STATE_HIGHLIGHT) { - /* for list-items (that are not drawn with regular emboss), don't change selection based on hovering */ - if (((but->flag & UI_BUT_LIST_ITEM) == 0) && (but->dragflag & UI_EMBOSS_NONE)) { - but->flag &= ~UI_SELECT; - } + but->flag &= ~UI_SELECT; button_tooltip_timer_reset(C, but); @@ -9597,6 +8963,11 @@ static int ui_handle_menu_event( } #endif + /* Don't handle double click events, rehandle as regular press/release. */ + if (retval == WM_UI_HANDLER_CONTINUE && event->val == KM_DBL_CLICK) { + return retval; + } + /* if we set a menu return value, ensure we continue passing this on to * lower menus and buttons, so always set continue then, and if we are * inside the region otherwise, ensure we swallow the event */ @@ -10177,6 +9548,7 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE { ARegion *ar; uiBut *but; + int retval = WM_UI_HANDLER_CONTINUE; ar = CTX_wm_menu(C); if (!ar) @@ -10220,29 +9592,32 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE if ((but_other->flag & UI_BUT_DISABLED) == 0) { ui_handle_button_activate(C, ar, but_other, BUTTON_ACTIVATE_OVER); button_activate_state(C, but_other, BUTTON_STATE_MENU_OPEN); + retval = WM_UI_HANDLER_BREAK; } } else if (data->state == BUTTON_STATE_MENU_OPEN) { - int retval; - /* handle events for menus and their buttons recursively, * this will handle events from the top to the bottom menu */ - if (data->menu) + if (data->menu) { retval = ui_handle_menus_recursive(C, event, data->menu, 0, false, false, false); + } /* handle events for the activated button */ if ((data->menu && (retval == WM_UI_HANDLER_CONTINUE)) || (event->type == TIMER)) { - if (data->menu && data->menu->menuretval) + if (data->menu && data->menu->menuretval) { ui_handle_button_return_submenu(C, event, but); - else - ui_handle_button_event(C, event, but); + retval = WM_UI_HANDLER_BREAK; + } + else { + retval = ui_handle_button_event(C, event, but); + } } } else { /* handle events for the activated button */ - ui_handle_button_event(C, event, but); + retval = ui_handle_button_event(C, event, but); } } @@ -10253,6 +9628,14 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE /* delayed apply callbacks */ ui_apply_but_funcs_after(C); + /* Don't handle double-click events, + * these will be converted into regular clicks which we handle. */ + if (retval == WM_UI_HANDLER_CONTINUE) { + if (event->val == KM_DBL_CLICK) { + return WM_UI_HANDLER_CONTINUE; + } + } + /* we block all events, this is modal interaction */ return WM_UI_HANDLER_BREAK; } @@ -10303,8 +9686,9 @@ static int ui_popup_handler(bContext *C, const wmEvent *event, void *userdata) #ifdef USE_DRAG_TOGGLE { - WM_event_free_ui_handler_all(C, &win->modalhandlers, - ui_handler_region_drag_toggle, ui_handler_region_drag_toggle_remove); + WM_event_free_ui_handler_all( + C, &win->modalhandlers, + ui_handler_region_drag_toggle, ui_handler_region_drag_toggle_remove); } #endif @@ -10459,18 +9843,3 @@ void ui_but_clipboard_free(void) { curvemapping_free_data(&but_copypaste_curve); } - -bool UI_but_is_tool(const uiBut *but) -{ - /* very evil! */ - if (but->optype != NULL) { - static wmOperatorType *ot = NULL; - if (ot == NULL) { - ot = WM_operatortype_find("WM_OT_tool_set_by_name", false); - } - if (but->optype == ot) { - return true; - } - } - return false; -} diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 64fca05c082..c3246213d4e 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -37,6 +37,7 @@ #include "GPU_matrix.h" #include "GPU_batch.h" #include "GPU_immediate.h" +#include "GPU_state.h" #include "BLI_blenlib.h" #include "BLI_utildefines.h" @@ -101,11 +102,12 @@ typedef struct IconImage { typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha); -#define ICON_TYPE_PREVIEW 0 -#define ICON_TYPE_TEXTURE 1 -#define ICON_TYPE_BUFFER 2 -#define ICON_TYPE_VECTOR 3 -#define ICON_TYPE_GEOM 4 +#define ICON_TYPE_PREVIEW 0 +#define ICON_TYPE_TEXTURE 1 +#define ICON_TYPE_MONO_TEXTURE 2 +#define ICON_TYPE_BUFFER 3 +#define ICON_TYPE_VECTOR 4 +#define ICON_TYPE_GEOM 5 typedef struct DrawInfo { int type; @@ -159,7 +161,7 @@ static DrawInfo *def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs, di = MEM_callocN(sizeof(DrawInfo), "drawinfo"); di->type = type; - if (type == ICON_TYPE_TEXTURE) { + if (ELEM(type, ICON_TYPE_TEXTURE, ICON_TYPE_MONO_TEXTURE)) { di->data.texture.x = xofs; di->data.texture.y = yofs; di->data.texture.w = size; @@ -458,7 +460,7 @@ static void init_internal_icons(void) { // bTheme *btheme = UI_GetTheme(); ImBuf *b16buf = NULL, *b32buf = NULL; - int x, y, icontype; + int x, y; #if 0 // temp disabled if ((btheme != NULL) && btheme->tui.iconfile[0]) { @@ -492,56 +494,46 @@ static void init_internal_icons(void) IMB_premultiply_alpha(b32buf); if (b16buf && b32buf) { - /* free existing texture if any */ + /* Free existing texture if any. */ if (icongltex.id) { glDeleteTextures(1, &icongltex.id); icongltex.id = 0; } -#if 0 /* should be a compile-time check (if needed at all) */ - /* we only use a texture for cards with non-power of two */ - if (GPU_full_non_power_of_two_support()) { -#else - { -#endif - glGenTextures(1, &icongltex.id); + /* Allocate OpenGL texture. */ + glGenTextures(1, &icongltex.id); - if (icongltex.id) { - int level = 2; + if (icongltex.id) { + int level = 2; - icongltex.w = b32buf->x; - icongltex.h = b32buf->y; - icongltex.invw = 1.0f / b32buf->x; - icongltex.invh = 1.0f / b32buf->y; + icongltex.w = b32buf->x; + icongltex.h = b32buf->y; + icongltex.invw = 1.0f / b32buf->x; + icongltex.invh = 1.0f / b32buf->y; - glBindTexture(GL_TEXTURE_2D, icongltex.id); + glBindTexture(GL_TEXTURE_2D, icongltex.id); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, b32buf->x, b32buf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, b32buf->rect); - glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA8, b16buf->x, b16buf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, b16buf->rect); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, b32buf->x, b32buf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, b32buf->rect); + glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA8, b16buf->x, b16buf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, b16buf->rect); - while (b16buf->x > 1) { - ImBuf *nbuf = IMB_onehalf(b16buf); - glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA8, nbuf->x, nbuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, nbuf->rect); - level++; - IMB_freeImBuf(b16buf); - b16buf = nbuf; - } + while (b16buf->x > 1) { + ImBuf *nbuf = IMB_onehalf(b16buf); + glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA8, nbuf->x, nbuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, nbuf->rect); + level++; + IMB_freeImBuf(b16buf); + b16buf = nbuf; + } - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glBindTexture(GL_TEXTURE_2D, 0); - } + glBindTexture(GL_TEXTURE_2D, 0); } - } - if (icongltex.id) - icontype = ICON_TYPE_TEXTURE; - else - icontype = ICON_TYPE_BUFFER; - - if (b32buf) { + /* Define icons. */ for (y = 0; y < ICON_GRID_ROWS; y++) { + /* Row W has monochrome icons. */ + int icontype = (y == 8) ? ICON_TYPE_MONO_TEXTURE : ICON_TYPE_TEXTURE; for (x = 0; x < ICON_GRID_COLS; x++) { def_internal_icon(b32buf, BIFICONID_FIRST + y * ICON_GRID_COLS + x, x * (ICON_GRID_W + ICON_GRID_MARGIN) + ICON_GRID_MARGIN, @@ -858,7 +850,7 @@ static void ui_studiolight_kill_icon_preview_job(wmWindowManager *wm, int icon_i icon->obj = NULL; } -static void ui_studiolight_free_function(StudioLight * sl, void* data) +static void ui_studiolight_free_function(StudioLight *sl, void *data) { wmWindowManager *wm = data; @@ -920,7 +912,7 @@ void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool bi di->data.buffer.image = img; wmJob *wm_job = WM_jobs_get(wm, CTX_wm_window(C), icon, "StudioLight Icon", 0, WM_JOB_TYPE_STUDIOLIGHT); - Icon** tmp = MEM_callocN(sizeof(Icon*), __func__); + Icon **tmp = MEM_callocN(sizeof(Icon *), __func__); *tmp = icon; WM_jobs_customdata_set(wm_job, tmp, MEM_freeN); WM_jobs_timer(wm_job, 0.01, 0, NC_WINDOW); @@ -1106,10 +1098,10 @@ static void icon_draw_cache_flush_ex(void) return; /* We need to flush widget base first to ensure correct ordering. */ - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); UI_widgetbase_draw_cache_flush(); - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, icongltex.id); @@ -1139,12 +1131,12 @@ void UI_icon_draw_cache_end(void) if (g_icon_draw_cache.calls == 0) return; - glEnable(GL_BLEND); + GPU_blend(true); icon_draw_cache_flush_ex(); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glDisable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(false); } static void icon_draw_texture_cached( @@ -1187,7 +1179,7 @@ static void icon_draw_texture( } /* We need to flush widget base first to ensure correct ordering. */ - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); UI_widgetbase_draw_cache_flush(); float x1, x2, y1, y2; @@ -1291,15 +1283,30 @@ static void icon_draw_size( } glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); icon_draw_rect(x, y, w, h, aspect, w, h, ibuf->rect, alpha, rgb, desaturate); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); } else if (di->type == ICON_TYPE_TEXTURE) { /* texture image use premul alpha for correct scaling */ - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); icon_draw_texture(x, y, (float)w, (float)h, di->data.texture.x, di->data.texture.y, di->data.texture.w, di->data.texture.h, alpha, rgb); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); } + else if (di->type== ICON_TYPE_MONO_TEXTURE) { + /* icon that matches text color, assumed to be white */ + float text_color[4]; + UI_GetThemeColor4fv(TH_TEXT, text_color); + if (rgb) { + mul_v3_v3(text_color, rgb); + } + text_color[3] *= alpha; + + GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + icon_draw_texture(x, y, (float)w, (float)h, di->data.texture.x, di->data.texture.y, + di->data.texture.w, di->data.texture.h, text_color[3], text_color); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + } + else if (di->type == ICON_TYPE_BUFFER) { /* it is a builtin icon */ iimg = di->data.buffer.image; @@ -1308,9 +1315,9 @@ static void icon_draw_size( #endif if (!iimg->rect) return; /* something has gone wrong! */ - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb, desaturate); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); } else if (di->type == ICON_TYPE_PREVIEW) { PreviewImage *pi = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) : icon->obj; @@ -1320,10 +1327,10 @@ static void icon_draw_size( if (!pi->rect[size]) return; /* something has gone wrong! */ /* preview images use premul alpha ... */ - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); icon_draw_rect(x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], alpha, rgb, desaturate); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); } } } @@ -1647,4 +1654,3 @@ void UI_icon_draw_preview_aspect_size(float x, float y, int icon_id, float aspec { icon_draw_size(x, y, icon_id, aspect, alpha, NULL, ICON_SIZE_PREVIEW, size, false); } - diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 6f029b81e92..04e9e2b18b4 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -444,8 +444,6 @@ typedef struct uiSafetyRct { void ui_fontscale(short *points, float aspect); -extern bool ui_block_is_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT; -extern bool ui_block_is_pie_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT; extern void ui_block_to_window_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y); extern void ui_block_to_window(const struct ARegion *ar, uiBlock *block, int *x, int *y); extern void ui_block_to_window_rctf(const struct ARegion *ar, uiBlock *block, rctf *rct_dst, const rctf *rct_src); @@ -696,17 +694,12 @@ extern void ui_but_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut extern uiBut *ui_but_find_select_in_enum(uiBut *but, int direction); extern uiBut *ui_but_find_active_in_region(struct ARegion *ar); extern uiBut *ui_but_find_mouse_over(struct ARegion *ar, const struct wmEvent *event); -bool ui_but_is_editable(const uiBut *but); -bool ui_but_is_editable_as_text(const uiBut *but); -bool ui_but_is_toggle(const uiBut *but); -bool ui_but_is_popover_once_compat(const uiBut *but); void ui_but_pie_dir_visual(RadialDirection dir, float vec[2]); void ui_but_pie_dir(RadialDirection dir, float vec[2]); float ui_block_calc_pie_segment(struct uiBlock *block, const float event_xy[2]); void ui_but_add_shortcut(uiBut *but, const char *key_str, const bool do_strip); void ui_but_clipboard_free(void); -void ui_panel_menu(struct bContext *C, ARegion *ar, Panel *pa); uiBut *ui_but_find_old(uiBlock *block_old, const uiBut *but_new); uiBut *ui_but_find_new(uiBlock *block_old, const uiBut *but_new); @@ -756,19 +749,16 @@ void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float m void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect); void ui_draw_popover_back(ARegion *ar, struct uiStyle *style, uiBlock *block, rcti *rect); void ui_draw_pie_center(uiBlock *block); -uiWidgetColors *ui_tooltip_get_theme(void); +struct uiWidgetColors *ui_tooltip_get_theme(void); void ui_draw_widget_back_color( uiWidgetTypeEnum type, bool use_shadow, const rcti *rect, const float color[4]); void ui_draw_widget_back( uiWidgetTypeEnum type, bool use_shadow, const rcti *rect); -void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *block, rcti *rect); +void ui_draw_tooltip_background(struct uiStyle *UNUSED(style), uiBlock *block, rcti *rect); extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect); -/* theme color init */ -struct ThemeUI; -void ui_widget_color_init(struct ThemeUI *tui); void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state, bool use_sep); void ui_draw_preview_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state); @@ -818,6 +808,19 @@ void ui_but_anim_autokey(struct bContext *C, uiBut *but, struct Scene *scene, fl void ui_but_anim_decorate_cb(struct bContext *C, void *arg_but, void *arg_dummy); void ui_but_anim_decorate_update_from_flag(uiBut *but); +/* interface_query.c */ +bool ui_but_is_editable(const uiBut *but); +bool ui_but_is_editable_as_text(const uiBut *but); +bool ui_but_is_toggle(const uiBut *but); +bool ui_but_is_popover_once_compat(const uiBut *but); + +extern bool ui_block_is_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT; +extern bool ui_block_is_pie_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT; + +/* interface_context_menu.c */ +bool ui_popup_context_menu_for_button(struct bContext *C, uiBut *but); +void ui_popup_context_menu_for_panel(struct bContext *C, struct ARegion *ar, struct Panel *pa); + /* interface_eyedropper.c */ struct wmKeyMap *eyedropper_modal_keymap(struct wmKeyConfig *keyconf); struct wmKeyMap *eyedropper_colorband_modal_keymap(struct wmKeyConfig *keyconf); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 3784ab635be..9b9199538d6 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -67,6 +67,9 @@ /* Show an icon button after each RNA button to use to quickly set keyframes, * this is a way to display animation/driven/override status, see T54951. */ #define UI_PROP_DECORATE +/* Alternate draw mode where some buttons can use single icon width, + * giving more room for the text at the expense of nicely aligned text. */ +#define UI_PROP_SEP_ICON_WIDTH_EXCEPTION /************************ Structs and Defines *************************/ @@ -183,7 +186,7 @@ typedef struct uiLayoutItemGridFlow { /* If positive, absolute fixed number of columns. * If 0, fully automatic (based on available width). * If negative, automatic but only generates number of columns/rows multiple of given (absolute) value. */ - int num_columns; + int columns_len; /* Pure internal runtime storage. */ int tot_items, tot_columns, tot_rows; @@ -390,7 +393,7 @@ static int ui_layout_local_dir(uiLayout *layout) } } -static uiLayout *ui_item_local_sublayout(uiLayout *test, uiLayout *layout, int align) +static uiLayout *ui_item_local_sublayout(uiLayout *test, uiLayout *layout, bool align) { uiLayout *sub; @@ -561,7 +564,7 @@ static void ui_item_array( uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, 0, 0, w, UI_UNIT_Y); } else { - int *boolarr = NULL; + bool *boolarr = NULL; /* even if 'expand' is fale, expanding anyway */ @@ -576,7 +579,7 @@ static void ui_item_array( /* show checkboxes for rna on a non-emboss block (menu for eg) */ if (type == PROP_BOOLEAN && ELEM(layout->root->block->dt, UI_EMBOSS_NONE, UI_EMBOSS_PULLDOWN)) { - boolarr = MEM_callocN(sizeof(int) * len, __func__); + boolarr = MEM_callocN(sizeof(bool) * len, __func__); RNA_property_boolean_get_array(ptr, prop, boolarr); } @@ -591,8 +594,9 @@ static void ui_item_array( icon = boolarr[a] ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT; } - width_item = (compact && type == PROP_BOOLEAN) ? - min_ii(w, ui_text_icon_width(layout, str_buf, icon, false)) : w; + width_item = ( + (compact && type == PROP_BOOLEAN) ? + min_ii(w, ui_text_icon_width(layout, str_buf, icon, false)) : w); but = uiDefAutoButR(block, ptr, prop, a, str_buf, icon, 0, 0, width_item, UI_UNIT_Y); if (slider && but->type == UI_BTYPE_NUM) @@ -773,8 +777,9 @@ static uiBut *ui_item_with_label( but = uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, prop_but_width - UI_UNIT_X, h); /* BUTTONS_OT_file_browse calls UI_context_active_but_prop_get_filebrowser */ - uiDefIconButO(block, UI_BTYPE_BUT, subtype == PROP_DIRPATH ? "BUTTONS_OT_directory_browse" : "BUTTONS_OT_file_browse", - WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL); + uiDefIconButO( + block, UI_BTYPE_BUT, subtype == PROP_DIRPATH ? "BUTTONS_OT_directory_browse" : "BUTTONS_OT_file_browse", + WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL); } else if (flag & UI_ITEM_R_EVENT) { but = uiDefButR_prop(block, UI_BTYPE_KEY_EVENT, 0, name, x, y, prop_but_width, h, ptr, prop, index, 0, 0, -1, -1, NULL); @@ -793,8 +798,9 @@ static uiBut *ui_item_with_label( } else { const char *str = (type == PROP_ENUM && !(flag & UI_ITEM_R_ICON_ONLY)) ? NULL : ""; - but = uiDefAutoButR(block, ptr, prop, index, str, icon, - x, y, prop_but_width, h); + but = uiDefAutoButR( + block, ptr, prop, index, str, icon, + x, y, prop_but_width, h); } UI_block_layout_set_current(block, layout); @@ -1182,8 +1188,9 @@ void uiItemsFullEnumO_items( } else { /* Do not use uiItemL here, as our root layout is a menu one, it will add a fake blank icon! */ - but = uiDefBut(block, UI_BTYPE_LABEL, 0, item->name, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, - 0.0, 0.0, 0, 0, ""); + but = uiDefBut( + block, UI_BTYPE_LABEL, 0, item->name, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, + 0.0, 0.0, 0, 0, ""); } ui_but_tip_from_enum_item(but, item); } @@ -1547,13 +1554,24 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index /* use checkboxes only as a fallback in pie-menu's, when no icon is defined */ ((layout->root->type == UI_LAYOUT_PIEMENU) && (icon == ICON_NONE))) { + int prop_flag = RNA_property_flag(prop); if (type == PROP_BOOLEAN && ((is_array == false) || (index != RNA_NO_INDEX))) { - if (is_array) icon = (RNA_property_boolean_get_index(ptr, prop, index)) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT; - else icon = (RNA_property_boolean_get(ptr, prop)) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT; + if (prop_flag & PROP_ICONS_CONSECUTIVE) { + icon = ICON_CHECKBOX_DEHLT; /* but->iconadd will set to correct icon */ + } + else if (is_array) { + icon = (RNA_property_boolean_get_index(ptr, prop, index)) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT; + } + else { + icon = (RNA_property_boolean_get(ptr, prop)) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT; + } } else if (type == PROP_ENUM && index == RNA_ENUM_VALUE) { int enum_value = RNA_property_enum_get(ptr, prop); - if (RNA_property_flag(prop) & PROP_ENUM_FLAG) { + if (prop_flag & PROP_ICONS_CONSECUTIVE) { + icon = ICON_CHECKBOX_DEHLT; /* but->iconadd will set to correct icon */ + } + else if (prop_flag & PROP_ENUM_FLAG) { icon = (enum_value & value) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT; } else { @@ -1595,9 +1613,19 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index } else { const PropertySubType subtype = RNA_property_subtype(prop); - uiLayout *layout_split = uiLayoutSplit( - layout_row ? layout_row : layout, - UI_ITEM_PROP_SEP_DIVIDE, true); + uiLayout *layout_split; +#ifdef UI_PROP_SEP_ICON_WIDTH_EXCEPTION + if (type == PROP_BOOLEAN && (icon == ICON_NONE) && !icon_only) { + w = UI_UNIT_X; + layout_split = uiLayoutRow(layout_row ? layout_row : layout, true); + } + else +#endif /* UI_PROP_SEP_ICON_WIDTH_EXCEPTION */ + { + layout_split = uiLayoutSplit( + layout_row ? layout_row : layout, + UI_ITEM_PROP_SEP_DIVIDE, true); + } layout_split->space = 0; uiLayout *layout_sub = uiLayoutColumn(layout_split, true); layout_sub->space = 0; @@ -1697,7 +1725,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index } /* Mark non-embossed textfields inside a listbox. */ - if (but && (block->flag & UI_BLOCK_LIST_ITEM) && (but->dt & UI_EMBOSS_NONE)) { + if (but && (block->flag & UI_BLOCK_LIST_ITEM) && (but->type == UI_BTYPE_TEXT) && (but->dt & UI_EMBOSS_NONE)) { UI_but_flag_enable(but, UI_BUT_LIST_ITEM); } @@ -1951,8 +1979,8 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN } UI_but_func_search_set( - but, ui_searchbox_create_generic, ui_rna_collection_search_cb, - coll_search, NULL, NULL); + but, ui_searchbox_create_generic, ui_rna_collection_search_cb, + coll_search, NULL, NULL); but->free_search_arg = true; } else if (but->type == UI_BTYPE_SEARCH_MENU) { @@ -2100,7 +2128,7 @@ static uiBut *ui_item_menu( return but; } -void uiItemM(uiLayout *layout, bContext *UNUSED(C), const char *menuname, const char *name, int icon) +void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon) { MenuType *mt; @@ -2373,8 +2401,9 @@ void uiItemMenuEnumO_ptr( BLI_strncpy(lvl->propname, propname, sizeof(lvl->propname)); lvl->opcontext = layout->root->opcontext; - but = ui_item_menu(layout, name, icon, menu_item_enum_opname_menu, NULL, lvl, - RNA_struct_ui_description(ot->srna), true); + but = ui_item_menu( + layout, name, icon, menu_item_enum_opname_menu, NULL, lvl, + RNA_struct_ui_description(ot->srna), true); /* add hotkey here, lower UI code can't detect it */ if ((layout->root->block->flag & UI_BLOCK_LOOP) && @@ -3171,12 +3200,12 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem) .litem_y = litem->y, .space_x = space_x, .space_y = space_y, - }), + }), &((UILayoutGridFlowOutput) { .tot_items = &gflow->tot_items, .global_avg_w = &avg_w, .global_max_h = &max_h, - })); + })); if (gflow->tot_items == 0) { litem->w = litem->h = 0; @@ -3187,8 +3216,8 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem) /* Even in varying column width case, we fix our columns number from weighted average width of items, * a proper solving of required width would be too costly, and this should give reasonably good results * in all resonable cases... */ - if (gflow->num_columns > 0) { - gflow->tot_columns = gflow->num_columns; + if (gflow->columns_len > 0) { + gflow->tot_columns = gflow->columns_len; } else { if (avg_w == 0.0f) { @@ -3205,7 +3234,7 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem) * Note that modulo does not prevent ending with fewer columns/rows than modulo, if mandatory * to avoid empty column/row. */ { - const int modulo = (gflow->num_columns < -1) ? -gflow->num_columns : 0; + const int modulo = (gflow->columns_len < -1) ? -gflow->columns_len : 0; const int step = modulo ? modulo : 1; if (gflow->row_major) { @@ -3258,11 +3287,11 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem) .space_y = space_y, .tot_columns = gflow->tot_columns, .tot_rows = gflow->tot_rows, - }), + }), &((UILayoutGridFlowOutput) { .tot_w = &tot_w, .tot_h = &tot_h, - })); + })); litem->w = tot_w; litem->h = tot_h; @@ -3306,13 +3335,13 @@ static void ui_litem_layout_grid_flow(uiLayout *litem) .space_y = space_y, .tot_columns = gflow->tot_columns, .tot_rows = gflow->tot_rows, - }), + }), &((UILayoutGridFlowOutput) { .cos_x_array = cos_x, .cos_y_array = cos_y, .widths_array = widths, .heights_array = heights, - })); + })); for (item = litem->items.first, i = 0; item; item = item->next, i++) { const int col = gflow->row_major ? i % gflow->tot_columns : i / gflow->tot_rows; @@ -3520,7 +3549,7 @@ static void ui_litem_init_from_parent(uiLayout *litem, uiLayout *layout, int ali } /* layout create functions */ -uiLayout *uiLayoutRow(uiLayout *layout, int align) +uiLayout *uiLayoutRow(uiLayout *layout, bool align) { uiLayout *litem; @@ -3535,7 +3564,7 @@ uiLayout *uiLayoutRow(uiLayout *layout, int align) return litem; } -uiLayout *uiLayoutColumn(uiLayout *layout, int align) +uiLayout *uiLayoutColumn(uiLayout *layout, bool align) { uiLayout *litem; @@ -3550,7 +3579,7 @@ uiLayout *uiLayoutColumn(uiLayout *layout, int align) return litem; } -uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align) +uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, bool align) { uiLayoutItemFlow *flow; @@ -3567,7 +3596,7 @@ uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align) } uiLayout *uiLayoutGridFlow( - uiLayout *layout, int row_major, int num_columns, int even_columns, int even_rows, int align) + uiLayout *layout, bool row_major, int columns_len, bool even_columns, bool even_rows, bool align) { uiLayoutItemGridFlow *flow; @@ -3577,7 +3606,7 @@ uiLayout *uiLayoutGridFlow( flow->litem.space = (flow->litem.align) ? 0 : layout->root->style->columnspace; flow->row_major = row_major; - flow->num_columns = num_columns; + flow->columns_len = columns_len; flow->even_columns = even_columns; flow->even_rows = even_rows; @@ -3676,7 +3705,7 @@ uiLayout *uiLayoutListBox( return (uiLayout *)box; } -uiLayout *uiLayoutAbsolute(uiLayout *layout, int align) +uiLayout *uiLayoutAbsolute(uiLayout *layout, bool align) { uiLayout *litem; @@ -3714,7 +3743,7 @@ uiLayout *uiLayoutOverlap(uiLayout *layout) return litem; } -uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align) +uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, bool align) { uiLayoutItemSplit *split; @@ -3848,6 +3877,11 @@ static void ui_item_scale(uiLayout *litem, const float scale[2]) int x, y, w, h; for (item = litem->items.last; item; item = item->prev) { + if (item->type != ITEM_BUTTON) { + uiLayout *subitem = (uiLayout *)item; + ui_item_scale(subitem, scale); + } + ui_item_size(item, &w, &h); ui_item_offset(item, &x, &y); @@ -4292,6 +4326,9 @@ static void ui_paneltype_draw_impl( panel->type = pt; panel->flag = PNL_POPOVER; + uiLayout *last_item = layout->items.last; + + /* Draw main panel. */ if (show_header) { uiLayout *row = uiLayoutRow(layout, false); if (pt->draw_header) { @@ -4308,19 +4345,21 @@ static void ui_paneltype_draw_impl( MEM_freeN(panel); - PanelType *pt_iter = pt; - while (pt_iter->prev) { - pt_iter = pt_iter->prev; - } - do { - if (pt_iter != pt && STREQ(pt_iter->parent_id, pt->idname)) { - if (pt_iter->poll == NULL || pt_iter->poll(C, pt_iter)) { + /* Draw child panels. */ + for (LinkData *link = pt->children.first; link; link = link->next) { + PanelType *child_pt = link->data; + + if (child_pt->poll == NULL || child_pt->poll(C, child_pt)) { + /* Add space if something was added to the layout. */ + if (last_item != layout->items.last) { uiItemS(layout); - uiLayout *col = uiLayoutColumn(layout, false); - ui_paneltype_draw_impl(C, pt_iter, col, true); + last_item = layout->items.last; } + + uiLayout *col = uiLayoutColumn(layout, false); + ui_paneltype_draw_impl(C, child_pt, col, true); } - } while ((pt_iter = pt_iter->next)); + } } /** diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index aad48d13277..3457d2e2eeb 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -98,7 +98,7 @@ static void UI_OT_reset_default_theme(wmOperatorType *ot) /* Copy Data Path Operator ------------------------ */ -static int copy_data_path_button_poll(bContext *C) +static bool copy_data_path_button_poll(bContext *C) { PointerRNA ptr; PropertyRNA *prop; @@ -177,7 +177,7 @@ static void UI_OT_copy_data_path_button(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -static int copy_python_command_button_poll(bContext *C) +static bool copy_python_command_button_poll(bContext *C) { uiBut *but = UI_context_active_but_get(C); @@ -248,7 +248,7 @@ static int operator_button_property_finish(bContext *C, PointerRNA *ptr, Propert } } -static int reset_default_button_poll(bContext *C) +static bool reset_default_button_poll(bContext *C) { PointerRNA ptr; PropertyRNA *prop; @@ -347,7 +347,7 @@ enum { static EnumPropertyItem override_type_items[] = { {UIOverride_Type_NOOP, "NOOP", 0, "NoOp", - "'No-Operation', place holder preventing automatic override to ever affect the property"}, + "'No-Operation', place holder preventing automatic override to ever affect the property"}, {UIOverride_Type_Replace, "REPLACE", 0, "Replace", "Completely replace value from linked data by local one"}, {UIOverride_Type_Difference, "DIFFERENCE", 0, "Difference", "Store difference to linked data value"}, {UIOverride_Type_Factor, "FACTOR", 0, "Factor", "Store factor to linked data value (useful e.g. for scale)"}, @@ -355,7 +355,7 @@ static EnumPropertyItem override_type_items[] = { }; -static int override_type_set_button_poll(bContext *C) +static bool override_type_set_button_poll(bContext *C) { PointerRNA ptr; PropertyRNA *prop; @@ -408,7 +408,7 @@ static int override_type_set_button_exec(bContext *C, wmOperator *op) } IDOverrideStaticPropertyOperation *opop = RNA_property_override_property_operation_get( - &ptr, prop, operation, index, true, NULL, &created); + &ptr, prop, operation, index, true, NULL, &created); if (!created) { opop->operation = operation; } @@ -443,13 +443,14 @@ static void UI_OT_override_type_set_button(wmOperatorType *ot) /* properties */ RNA_def_boolean(ot->srna, "all", 1, "All", "Reset to default values all elements of the array"); - ot->prop = RNA_def_enum(ot->srna, "type", override_type_items, UIOverride_Type_Replace, - "Type", "Type of override operation"); + ot->prop = RNA_def_enum( + ot->srna, "type", override_type_items, UIOverride_Type_Replace, + "Type", "Type of override operation"); /* TODO: add itemf callback, not all options are available for all data types... */ } -static int override_remove_button_poll(bContext *C) +static bool override_remove_button_poll(bContext *C) { PointerRNA ptr; PropertyRNA *prop; @@ -464,6 +465,7 @@ static int override_remove_button_poll(bContext *C) static int override_remove_button_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); PointerRNA ptr, id_refptr, src; PropertyRNA *prop; int index; @@ -492,7 +494,7 @@ static int override_remove_button_exec(bContext *C, wmOperator *op) bool is_strict_find; /* Remove override operation for given item, add singular operations for the other items as needed. */ IDOverrideStaticPropertyOperation *opop = BKE_override_static_property_operation_find( - oprop, NULL, NULL, index, index, false, &is_strict_find); + oprop, NULL, NULL, index, index, false, &is_strict_find); BLI_assert(opop != NULL); if (!is_strict_find) { /* No specific override operation, we have to get generic one, @@ -505,7 +507,7 @@ static int override_remove_button_exec(bContext *C, wmOperator *op) } BKE_override_static_property_operation_delete(oprop, opop); if (!is_template) { - RNA_property_copy(&ptr, &src, prop, index); + RNA_property_copy(bmain, &ptr, &src, prop, index); } if (BLI_listbase_is_empty(&oprop->operations)) { BKE_override_static_property_delete(id->override_static, oprop); @@ -515,7 +517,7 @@ static int override_remove_button_exec(bContext *C, wmOperator *op) /* Just remove whole generic override operation of this property. */ BKE_override_static_property_delete(id->override_static, oprop); if (!is_template) { - RNA_property_copy(&ptr, &src, prop, -1); + RNA_property_copy(bmain, &ptr, &src, prop, -1); } } @@ -699,6 +701,7 @@ bool UI_context_copy_to_selected_list( */ static bool copy_to_selected_button(bContext *C, bool all, bool poll) { + Main *bmain = CTX_data_main(C); PointerRNA ptr, lptr, idptr; PropertyRNA *prop, *lprop; bool success = false; @@ -747,7 +750,7 @@ static bool copy_to_selected_button(bContext *C, bool all, bool poll) break; } else { - if (RNA_property_copy(&lptr, &ptr, prop, (all) ? -1 : index)) { + if (RNA_property_copy(bmain, &lptr, &ptr, prop, (all) ? -1 : index)) { RNA_property_update(C, &lptr, prop); success = true; } @@ -764,7 +767,7 @@ static bool copy_to_selected_button(bContext *C, bool all, bool poll) return success; } -static int copy_to_selected_button_poll(bContext *C) +static bool copy_to_selected_button_poll(bContext *C) { return copy_to_selected_button(C, false, true); } @@ -804,7 +807,7 @@ static void UI_OT_copy_to_selected_button(wmOperatorType *ot) * when there are too many to display... */ -static int reports_to_text_poll(bContext *C) +static bool reports_to_text_poll(bContext *C) { return CTX_wm_reports(C) != NULL; } @@ -1022,9 +1025,10 @@ static int editsource_exec(bContext *C, wmOperator *op) if (but_store) { if (but_store->py_dbg_ln != -1) { - ret = editsource_text_edit(C, op, - but_store->py_dbg_fn, - but_store->py_dbg_ln); + ret = editsource_text_edit( + C, op, + but_store->py_dbg_fn, + but_store->py_dbg_ln); } else { BKE_report(op->reports, RPT_ERROR, "Active button is not from a script, cannot edit source"); @@ -1132,14 +1136,18 @@ static int edittranslation_exec(bContext *C, wmOperator *op) uiStringInfo rna_ctxt = {BUT_GET_RNA_LABEL_CONTEXT, NULL}; if (!BLI_is_dir(root)) { - BKE_report(op->reports, RPT_ERROR, "Please set your User Preferences' 'Translation Branches " - "Directory' path to a valid directory"); + BKE_report( + op->reports, RPT_ERROR, + "Please set your User Preferences' 'Translation Branches " + "Directory' path to a valid directory"); return OPERATOR_CANCELLED; } ot = WM_operatortype_find(EDTSRC_I18N_OP_NAME, 0); if (ot == NULL) { - BKE_reportf(op->reports, RPT_ERROR, "Could not find operator '%s'! Please enable ui_translate add-on " - "in the User Preferences", EDTSRC_I18N_OP_NAME); + BKE_reportf( + op->reports, RPT_ERROR, + "Could not find operator '%s'! Please enable ui_translate add-on " + "in the User Preferences", EDTSRC_I18N_OP_NAME); return OPERATOR_CANCELLED; } /* Try to find a valid po file for current language... */ @@ -1150,8 +1158,9 @@ static int edittranslation_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - UI_but_string_info_get(C, but, &but_label, &rna_label, &enum_label, &but_tip, &rna_tip, &enum_tip, - &rna_struct, &rna_prop, &rna_enum, &rna_ctxt, NULL); + UI_but_string_info_get( + C, but, &but_label, &rna_label, &enum_label, &but_tip, &rna_tip, &enum_tip, + &rna_struct, &rna_prop, &rna_enum, &rna_ctxt, NULL); WM_operator_properties_create_ptr(&ptr, ot); RNA_string_set(&ptr, "lang", uilng); @@ -1231,7 +1240,7 @@ static void UI_OT_reloadtranslation(wmOperatorType *ot) ot->exec = reloadtranslation_exec; } -int UI_drop_color_poll(struct bContext *C, wmDrag *drag, const wmEvent *UNUSED(event)) +bool UI_drop_color_poll(struct bContext *C, wmDrag *drag, const wmEvent *UNUSED(event)) { /* should only return true for regions that include buttons, for now * return true always */ diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index e383ae42f8c..8107254f30b 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -63,6 +63,7 @@ #include "UI_resources.h" #include "GPU_immediate.h" +#include "GPU_state.h" #include "interface_intern.h" @@ -486,10 +487,10 @@ static void ui_draw_anti_x(unsigned int pos, float x1, float y1, float x2, float { /* set antialias line */ - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); + GPU_line_smooth(true); + GPU_blend(true); - glLineWidth(2.0); + GPU_line_width(2.0); immBegin(GWN_PRIM_LINES, 4); @@ -501,8 +502,8 @@ static void ui_draw_anti_x(unsigned int pos, float x1, float y1, float x2, float immEnd(); - glDisable(GL_LINE_SMOOTH); - glDisable(GL_BLEND); + GPU_line_smooth(false); + GPU_blend(false); } @@ -529,7 +530,7 @@ static void ui_draw_panel_scalewidget(unsigned int pos, const rcti *rect) dx = 0.5f * (xmax - xmin); dy = 0.5f * (ymax - ymin); - glEnable(GL_BLEND); + GPU_blend(true); immUniformColor4ub(255, 255, 255, 50); immBegin(GWN_PRIM_LINES, 4); @@ -554,11 +555,12 @@ static void ui_draw_panel_scalewidget(unsigned int pos, const rcti *rect) immEnd(); - glDisable(GL_BLEND); + GPU_blend(false); } -static void immRectf_tris_color_ex(unsigned int pos, float x1, float y1, float x2, float y2, - unsigned int col, const float color[3]) +static void immRectf_tris_color_ex( + unsigned int pos, float x1, float y1, float x2, float y2, + unsigned int col, const float color[3]) { immAttrib4fv(col, color); immVertex2f(pos, x1, y1); @@ -603,10 +605,12 @@ static void ui_draw_panel_dragwidget(unsigned int pos, unsigned int col, const r const int x_co = (x_min + x_ofs) + (i_x * (box_size + box_margin)); const int y_co = (y_min + y_ofs) + (i_y * (box_size + box_margin)); - immRectf_tris_color_ex(pos, x_co - box_size, y_co - px_zoom, x_co, (y_co + box_size) - px_zoom, - col, col_dark); - immRectf_tris_color_ex(pos, x_co - box_size, y_co, x_co, y_co + box_size, - col, col_high); + immRectf_tris_color_ex( + pos, x_co - box_size, y_co - px_zoom, x_co, (y_co + box_size) - px_zoom, + col, col_dark); + immRectf_tris_color_ex( + pos, x_co - box_size, y_co, x_co, y_co + box_size, + col, col_high); } } immEnd(); @@ -696,7 +700,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con float maxx = is_closed_x ? (minx + PNL_HEADER / block->aspect) : rect->xmax; float y = headrect.ymax; - glEnable(GL_BLEND); + GPU_blend(true); if (UI_GetThemeValue(TH_PANEL_SHOW_HEADER)) { /* draw with background color */ @@ -736,7 +740,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con immEnd(); } - glDisable(GL_BLEND); + GPU_blend(false); } immUnbindProgram(); @@ -749,11 +753,12 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con if (show_pin) #endif { - glEnable(GL_BLEND); - UI_icon_draw_aspect(headrect.xmax - ((PNL_ICON * 2.2f) / block->aspect), headrect.ymin + (5.0f / block->aspect), - (panel->flag & PNL_PIN) ? ICON_PINNED : ICON_UNPINNED, - (block->aspect / UI_DPI_FAC), 1.0f); - glDisable(GL_BLEND); + GPU_blend(true); + UI_icon_draw_aspect( + headrect.xmax - ((PNL_ICON * 2.2f) / block->aspect), headrect.ymin + (5.0f / block->aspect), + (panel->flag & PNL_PIN) ? ICON_PINNED : ICON_UNPINNED, + (block->aspect / UI_DPI_FAC), 1.0f); + GPU_blend(false); } @@ -809,12 +814,12 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con /* panel backdrop */ if (is_subpanel) { - glEnable(GL_BLEND); + GPU_blend(true); immUniformThemeColor(TH_PANEL_SUB_BACK); immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); } else if (UI_GetThemeValue(TH_PANEL_SHOW_BACK)) { - glEnable(GL_BLEND); + GPU_blend(true); immUniformThemeColor(TH_PANEL_BACK); immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); } @@ -1959,14 +1964,14 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) /* begin drawing */ - glEnable(GL_LINE_SMOOTH); + GPU_line_smooth(true); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* draw the background */ if (is_alpha) { - glEnable(GL_BLEND); + GPU_blend(true); immUniformColor4ubv(theme_col_tab_bg); } else { @@ -1976,7 +1981,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) immRecti(pos, v2d->mask.xmin, v2d->mask.ymin, v2d->mask.xmin + category_tabs_width, v2d->mask.ymax); if (is_alpha) { - glDisable(GL_BLEND); + GPU_blend(false); } immUnbindProgram(); @@ -1997,25 +2002,28 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) } #endif - glEnable(GL_BLEND); + GPU_blend(true); #ifdef USE_FLAT_INACTIVE if (is_active) #endif { - ui_panel_category_draw_tab(true, rct->xmin, rct->ymin, rct->xmax, rct->ymax, - tab_curve_radius - px, roundboxtype, true, true, NULL, - is_active ? theme_col_tab_active : theme_col_tab_inactive); + ui_panel_category_draw_tab( + true, rct->xmin, rct->ymin, rct->xmax, rct->ymax, + tab_curve_radius - px, roundboxtype, true, true, NULL, + is_active ? theme_col_tab_active : theme_col_tab_inactive); /* tab outline */ - ui_panel_category_draw_tab(false, rct->xmin - px, rct->ymin - px, rct->xmax - px, rct->ymax + px, - tab_curve_radius, roundboxtype, true, true, NULL, theme_col_tab_outline); + ui_panel_category_draw_tab( + false, rct->xmin - px, rct->ymin - px, rct->xmax - px, rct->ymax + px, + tab_curve_radius, roundboxtype, true, true, NULL, theme_col_tab_outline); /* tab highlight (3d look) */ - ui_panel_category_draw_tab(false, rct->xmin, rct->ymin, rct->xmax, rct->ymax, - tab_curve_radius, roundboxtype, true, false, - is_active ? theme_col_back : theme_col_tab_inactive, - is_active ? theme_col_tab_highlight : theme_col_tab_highlight_inactive); + ui_panel_category_draw_tab( + false, rct->xmin, rct->ymin, rct->xmax, rct->ymax, + tab_curve_radius, roundboxtype, true, false, + is_active ? theme_col_back : theme_col_tab_inactive, + is_active ? theme_col_tab_highlight : theme_col_tab_highlight_inactive); } /* tab blackline */ @@ -2033,8 +2041,9 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) } if (do_scaletabs) { - category_draw_len = BLF_width_to_strlen(fontid, category_id_draw, category_draw_len, - category_width, NULL); + category_draw_len = BLF_width_to_strlen( + fontid, category_id_draw, category_draw_len, + category_width, NULL); } BLF_position(fontid, rct->xmax - text_v_ofs, rct->ymin + tab_v_pad_text, 0.0f); @@ -2047,7 +2056,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) /* main tab title */ BLF_draw(fontid, category_id_draw, category_draw_len); - glDisable(GL_BLEND); + GPU_blend(false); /* tab blackline remaining (last tab) */ pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); @@ -2085,7 +2094,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) pc_dyn->rect.xmin = v2d->mask.xmin; } - glDisable(GL_LINE_SMOOTH); + GPU_line_smooth(false); BLF_disable(fontid, BLF_ROTATION); @@ -2254,7 +2263,7 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons } else if (event->type == RIGHTMOUSE) { if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) { - ui_panel_menu(C, ar, block->panel); + ui_popup_context_menu_for_panel(C, ar, block->panel); retval = WM_UI_HANDLER_BREAK; break; } diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c new file mode 100644 index 00000000000..66f63fef82d --- /dev/null +++ b/source/blender/editors/interface/interface_query.c @@ -0,0 +1,127 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/interface/interface_query.c + * \ingroup edinterface + * + * Utilities to inspect the interface, extract information. + */ + +#include "BLI_utildefines.h" + +#include "DNA_screen_types.h" + +#include "UI_interface.h" + +#include "interface_intern.h" + +#include "WM_api.h" +#include "WM_types.h" + +/* -------------------------------------------------------------------- */ +/** \name Button (uiBut) + * \{ */ + +bool ui_but_is_editable(const uiBut *but) +{ + return !ELEM( + but->type, + UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, + UI_BTYPE_ROUNDBOX, UI_BTYPE_LISTBOX, UI_BTYPE_PROGRESS_BAR); +} + +bool ui_but_is_editable_as_text(const uiBut *but) +{ + return ELEM( + but->type, + UI_BTYPE_TEXT, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, + UI_BTYPE_SEARCH_MENU); + +} + +bool ui_but_is_toggle(const uiBut *but) +{ + return ELEM( + but->type, + UI_BTYPE_BUT_TOGGLE, + UI_BTYPE_TOGGLE, + UI_BTYPE_ICON_TOGGLE, + UI_BTYPE_ICON_TOGGLE_N, + UI_BTYPE_TOGGLE_N, + UI_BTYPE_CHECKBOX, + UI_BTYPE_CHECKBOX_N, + UI_BTYPE_ROW + ); +} + +#ifdef USE_UI_POPOVER_ONCE +bool ui_but_is_popover_once_compat(const uiBut *but) +{ + return ( + (but->type == UI_BTYPE_BUT) || + ui_but_is_toggle(but) + ); +} +#endif + +bool UI_but_is_tool(const uiBut *but) +{ + /* very evil! */ + if (but->optype != NULL) { + static wmOperatorType *ot = NULL; + if (ot == NULL) { + ot = WM_operatortype_find("WM_OT_tool_set_by_name", false); + } + if (but->optype == ot) { + return true; + } + } + return false; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Block (uiBlock) + * \{ */ + +bool ui_block_is_menu(const uiBlock *block) +{ + return (((block->flag & UI_BLOCK_LOOP) != 0) && + /* non-menu popups use keep-open, so check this is off */ + ((block->flag & UI_BLOCK_KEEP_OPEN) == 0)); +} + +bool ui_block_is_pie_menu(const uiBlock *block) +{ + return ((block->flag & UI_BLOCK_RADIAL) != 0); +} + +bool UI_block_is_empty(const uiBlock *block) +{ + for (const uiBut *but = block->buttons.first; but; but = but->next) { + if (!ELEM(but->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE)) { + return false; + } + } + return true; +} + +/** \} */ diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c index 1a49010ad9d..f3ff6fdf2c0 100644 --- a/source/blender/editors/interface/interface_region_hud.c +++ b/source/blender/editors/interface/interface_region_hud.c @@ -60,6 +60,7 @@ #include "ED_undo.h" #include "interface_intern.h" +#include "GPU_framebuffer.h" /* -------------------------------------------------------------------- */ @@ -87,7 +88,7 @@ static bool last_redo_poll(const bContext *C) /** \name Redo Panel * \{ */ -static int hud_panel_operator_redo_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool hud_panel_operator_redo_poll(const bContext *C, PanelType *UNUSED(pt)) { return last_redo_poll(C); } @@ -194,8 +195,8 @@ static void hud_region_draw(const bContext *C, ARegion *ar) { UI_view2d_view_ortho(&ar->v2d); wmOrtho2_region_pixelspace(ar); - glClearColor(0, 0, 0, 0.0f); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear_color(0, 0, 0, 0.0f); + GPU_clear(GPU_COLOR_BIT); if ((ar->flag & RGN_FLAG_HIDDEN) == 0) { float color[4]; diff --git a/source/blender/editors/interface/interface_region_menu_popup.c b/source/blender/editors/interface/interface_region_menu_popup.c index a6046e551c6..b9222a75803 100644 --- a/source/blender/editors/interface/interface_region_menu_popup.c +++ b/source/blender/editors/interface/interface_region_menu_popup.c @@ -458,6 +458,21 @@ void UI_popup_menu_end(bContext *C, uiPopupMenu *pup) MEM_freeN(pup); } +bool UI_popup_menu_end_or_cancel(bContext *C, uiPopupMenu *pup) +{ + if (!UI_block_is_empty(pup->block)) { + UI_popup_menu_end(C, pup); + return true; + } + else { + UI_block_layout_resolve(pup->block, NULL, NULL); + MEM_freeN(pup->block->handle); + UI_block_free(C, pup->block); + MEM_freeN(pup); + return false; + } +} + uiLayout *UI_popup_menu_layout(uiPopupMenu *pup) { return pup->layout; diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c index e0dc149be17..9ca79a3dc63 100644 --- a/source/blender/editors/interface/interface_region_search.c +++ b/source/blender/editors/interface/interface_region_search.c @@ -64,6 +64,7 @@ #include "interface_intern.h" #include "interface_regions_intern.h" +#include "GPU_state.h" #define MENU_BORDER (int)(0.3f * U.widget_unit) @@ -422,22 +423,23 @@ static void ui_searchbox_region_draw_cb(const bContext *C, ARegion *ar) ui_searchbox_butrect(&rect, data, a); /* widget itself */ - ui_draw_preview_item(&data->fstyle, &rect, data->items.names[a], data->items.icons[a], - (a == data->active) ? UI_ACTIVE : 0); + ui_draw_preview_item( + &data->fstyle, &rect, data->items.names[a], data->items.icons[a], + (a == data->active) ? UI_ACTIVE : 0); } /* indicate more */ if (data->items.more) { ui_searchbox_butrect(&rect, data, data->items.maxitem - 1); - glEnable(GL_BLEND); + GPU_blend(true); UI_icon_draw(rect.xmax - 18, rect.ymin - 7, ICON_TRIA_DOWN); - glDisable(GL_BLEND); + GPU_blend(false); } if (data->items.offset) { ui_searchbox_butrect(&rect, data, 0); - glEnable(GL_BLEND); + GPU_blend(true); UI_icon_draw(rect.xmin, rect.ymax - 9, ICON_TRIA_UP); - glDisable(GL_BLEND); + GPU_blend(false); } } @@ -447,22 +449,23 @@ static void ui_searchbox_region_draw_cb(const bContext *C, ARegion *ar) ui_searchbox_butrect(&rect, data, a); /* widget itself */ - ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], data->items.icons[a], - (a == data->active) ? UI_ACTIVE : 0, data->use_sep); + ui_draw_menu_item( + &data->fstyle, &rect, data->items.names[a], data->items.icons[a], + (a == data->active) ? UI_ACTIVE : 0, data->use_sep); } /* indicate more */ if (data->items.more) { ui_searchbox_butrect(&rect, data, data->items.maxitem - 1); - glEnable(GL_BLEND); + GPU_blend(true); UI_icon_draw((BLI_rcti_size_x(&rect)) / 2, rect.ymin - 9, ICON_TRIA_DOWN); - glDisable(GL_BLEND); + GPU_blend(false); } if (data->items.offset) { ui_searchbox_butrect(&rect, data, 0); - glEnable(GL_BLEND); + GPU_blend(true); UI_icon_draw((BLI_rcti_size_x(&rect)) / 2, rect.ymax - 7, ICON_TRIA_UP); - glDisable(GL_BLEND); + GPU_blend(false); } } } @@ -723,8 +726,9 @@ static void ui_searchbox_region_draw_cb__operator(const bContext *UNUSED(C), ARe } rect_pre.xmax += 4; /* sneaky, avoid showing ugly margin */ - ui_draw_menu_item(&data->fstyle, &rect_pre, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, text_pre), - data->items.icons[a], state, false); + ui_draw_menu_item( + &data->fstyle, &rect_pre, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, text_pre), + data->items.icons[a], state, false); ui_draw_menu_item(&data->fstyle, &rect_post, data->items.names[a], 0, state, data->use_sep); } @@ -732,15 +736,15 @@ static void ui_searchbox_region_draw_cb__operator(const bContext *UNUSED(C), ARe /* indicate more */ if (data->items.more) { ui_searchbox_butrect(&rect, data, data->items.maxitem - 1); - glEnable(GL_BLEND); + GPU_blend(true); UI_icon_draw((BLI_rcti_size_x(&rect)) / 2, rect.ymin - 9, ICON_TRIA_DOWN); - glDisable(GL_BLEND); + GPU_blend(false); } if (data->items.offset) { ui_searchbox_butrect(&rect, data, 0); - glEnable(GL_BLEND); + GPU_blend(true); UI_icon_draw((BLI_rcti_size_x(&rect)) / 2, rect.ymax - 7, ICON_TRIA_UP); - glDisable(GL_BLEND); + GPU_blend(false); } } } diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index adc3a24d1a9..36ad516bf7f 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -540,4 +540,3 @@ void UI_fontstyle_set(const uiFontStyle *fs) BLF_size(font->blf_id, fs->points * U.pixelsize, U.dpi); } - diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 59cb2229905..fbfa64cbdbd 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -381,8 +381,8 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem) } return template_common_search_menu( - C, ar, id_search_cb_p, &template_ui, template_ID_set_property_cb, active_item_ptr.data, - template_ui.prv_rows, template_ui.prv_cols); + C, ar, id_search_cb_p, &template_ui, template_ID_set_property_cb, active_item_ptr.data, + template_ui.prv_rows, template_ui.prv_cols); } /************************ ID Template ***************************/ @@ -492,8 +492,9 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) break; case UI_ID_ALONE: if (id) { - const bool do_scene_obj = (GS(id->name) == ID_OB) && - (template_ui->ptr.type == &RNA_SceneObjects); + const bool do_scene_obj = ( + (GS(id->name) == ID_OB) && + (template_ui->ptr.type == &RNA_SceneObjects)); /* make copy */ if (do_scene_obj) { @@ -584,43 +585,49 @@ static uiBut *template_id_def_new_but( const int but_type = use_tab_but ? UI_BTYPE_TAB : UI_BTYPE_BUT; /* i18n markup, does nothing! */ - BLT_I18N_MSGID_MULTI_CTXT("New", BLT_I18NCONTEXT_DEFAULT, - BLT_I18NCONTEXT_ID_SCENE, - BLT_I18NCONTEXT_ID_OBJECT, - BLT_I18NCONTEXT_ID_MESH, - BLT_I18NCONTEXT_ID_CURVE, - BLT_I18NCONTEXT_ID_METABALL, - BLT_I18NCONTEXT_ID_MATERIAL, - BLT_I18NCONTEXT_ID_TEXTURE, - BLT_I18NCONTEXT_ID_IMAGE, - BLT_I18NCONTEXT_ID_LATTICE, - BLT_I18NCONTEXT_ID_LAMP, - BLT_I18NCONTEXT_ID_CAMERA, - BLT_I18NCONTEXT_ID_WORLD, - BLT_I18NCONTEXT_ID_SCREEN, - BLT_I18NCONTEXT_ID_TEXT, + BLT_I18N_MSGID_MULTI_CTXT( + "New", + BLT_I18NCONTEXT_DEFAULT, + BLT_I18NCONTEXT_ID_SCENE, + BLT_I18NCONTEXT_ID_OBJECT, + BLT_I18NCONTEXT_ID_MESH, + BLT_I18NCONTEXT_ID_CURVE, + BLT_I18NCONTEXT_ID_METABALL, + BLT_I18NCONTEXT_ID_MATERIAL, + BLT_I18NCONTEXT_ID_TEXTURE, + BLT_I18NCONTEXT_ID_IMAGE, + BLT_I18NCONTEXT_ID_LATTICE, + BLT_I18NCONTEXT_ID_LAMP, + BLT_I18NCONTEXT_ID_CAMERA, + BLT_I18NCONTEXT_ID_WORLD, + BLT_I18NCONTEXT_ID_SCREEN, + BLT_I18NCONTEXT_ID_TEXT, ); - BLT_I18N_MSGID_MULTI_CTXT("New", BLT_I18NCONTEXT_ID_SPEAKER, - BLT_I18NCONTEXT_ID_SOUND, - BLT_I18NCONTEXT_ID_ARMATURE, - BLT_I18NCONTEXT_ID_ACTION, - BLT_I18NCONTEXT_ID_NODETREE, - BLT_I18NCONTEXT_ID_BRUSH, - BLT_I18NCONTEXT_ID_PARTICLESETTINGS, - BLT_I18NCONTEXT_ID_GPENCIL, - BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE, - BLT_I18NCONTEXT_ID_WORKSPACE, - BLT_I18NCONTEXT_ID_LIGHTPROBE, + BLT_I18N_MSGID_MULTI_CTXT( + "New", + BLT_I18NCONTEXT_ID_SPEAKER, + BLT_I18NCONTEXT_ID_SOUND, + BLT_I18NCONTEXT_ID_ARMATURE, + BLT_I18NCONTEXT_ID_ACTION, + BLT_I18NCONTEXT_ID_NODETREE, + BLT_I18NCONTEXT_ID_BRUSH, + BLT_I18NCONTEXT_ID_PARTICLESETTINGS, + BLT_I18NCONTEXT_ID_GPENCIL, + BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE, + BLT_I18NCONTEXT_ID_WORKSPACE, + BLT_I18NCONTEXT_ID_LIGHTPROBE, ); if (newop) { - but = uiDefIconTextButO(block, but_type, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN, - (id) ? "" : CTX_IFACE_(template_id_context(type), "New"), 0, 0, w, but_height, NULL); + but = uiDefIconTextButO( + block, but_type, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN, + (id) ? "" : CTX_IFACE_(template_id_context(type), "New"), 0, 0, w, but_height, NULL); UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); } else { - but = uiDefIconTextBut(block, but_type, 0, ICON_ZOOMIN, (id) ? "" : CTX_IFACE_(template_id_context(type), "New"), - 0, 0, w, but_height, NULL, 0, 0, 0, 0, NULL); + but = uiDefIconTextBut( + block, but_type, 0, ICON_ZOOMIN, (id) ? "" : CTX_IFACE_(template_id_context(type), "New"), + 0, 0, w, but_height, NULL, 0, 0, 0, 0, NULL); UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); } @@ -680,17 +687,20 @@ static void template_ID( if (id->lib) { if (id->tag & LIB_TAG_INDIRECT) { - but = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_LIBRARY_DATA_INDIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y, - NULL, 0, 0, 0, 0, TIP_("Indirect library data-block, cannot change")); + but = uiDefIconBut( + block, UI_BTYPE_BUT, 0, ICON_LIBRARY_DATA_INDIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y, + NULL, 0, 0, 0, 0, TIP_("Indirect library data-block, cannot change")); UI_but_flag_enable(but, UI_BUT_DISABLED); } else { - const bool disabled = (!id_make_local(CTX_data_main(C), id, true /* test */, false) || - (idfrom && idfrom->lib)); - but = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_LIBRARY_DATA_DIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y, - NULL, 0, 0, 0, 0, - TIP_("Direct linked library data-block, click to make local, " - "Shift + Click to create a static override")); + const bool disabled = ( + !id_make_local(CTX_data_main(C), id, true /* test */, false) || + (idfrom && idfrom->lib)); + but = uiDefIconBut( + block, UI_BTYPE_BUT, 0, ICON_LIBRARY_DATA_DIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y, + NULL, 0, 0, 0, 0, + TIP_("Direct linked library data-block, click to make local, " + "Shift + Click to create a static override")); if (disabled) { UI_but_flag_enable(but, UI_BUT_DISABLED); } @@ -700,9 +710,10 @@ static void template_ID( } } else if (ID_IS_STATIC_OVERRIDE(id)) { - but = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_LIBRARY_DATA_OVERRIDE, 0, 0, UI_UNIT_X, UI_UNIT_Y, - NULL, 0, 0, 0, 0, - TIP_("Static override of linked library data-block, click to make fully local")); + but = uiDefIconBut( + block, UI_BTYPE_BUT, 0, ICON_LIBRARY_DATA_OVERRIDE, 0, 0, UI_UNIT_X, UI_UNIT_Y, + NULL, 0, 0, 0, 0, + TIP_("Static override of linked library data-block, click to make fully local")); UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_OVERRIDE)); } @@ -712,9 +723,10 @@ static void template_ID( numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%d", id->us); - but = uiDefBut(block, UI_BTYPE_BUT, 0, numstr, 0, 0, - numstr_len * 0.2f * UI_UNIT_X + UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, - TIP_("Display number of users of this data (click to make a single-user copy)")); + but = uiDefBut( + block, UI_BTYPE_BUT, 0, numstr, 0, 0, + numstr_len * 0.2f * UI_UNIT_X + UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, + TIP_("Display number of users of this data (click to make a single-user copy)")); but->flag |= UI_BUT_UNDO; UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ALONE)); @@ -743,8 +755,9 @@ static void template_ID( /* Due to space limit in UI - skip the "open" icon for packed data, and allow to unpack. * Only for images, sound and fonts */ if (id && BKE_pack_check(id)) { - but = uiDefIconButO(block, UI_BTYPE_BUT, "FILE_OT_unpack_item", WM_OP_INVOKE_REGION_WIN, ICON_PACKAGE, 0, 0, - UI_UNIT_X, UI_UNIT_Y, TIP_("Packed File, click to unpack")); + but = uiDefIconButO( + block, UI_BTYPE_BUT, "FILE_OT_unpack_item", WM_OP_INVOKE_REGION_WIN, ICON_PACKAGE, 0, 0, + UI_UNIT_X, UI_UNIT_Y, TIP_("Packed File, click to unpack")); UI_but_operator_ptr_get(but); RNA_string_set(but->opptr, "id_name", id->name + 2); @@ -755,13 +768,15 @@ static void template_ID( int w = id ? UI_UNIT_X : (flag & UI_ID_ADD_NEW) ? UI_UNIT_X * 3 : UI_UNIT_X * 6; if (openop) { - but = uiDefIconTextButO(block, UI_BTYPE_BUT, openop, WM_OP_INVOKE_DEFAULT, ICON_FILESEL, (id) ? "" : IFACE_("Open"), - 0, 0, w, UI_UNIT_Y, NULL); + but = uiDefIconTextButO( + block, UI_BTYPE_BUT, openop, WM_OP_INVOKE_DEFAULT, ICON_FILESEL, (id) ? "" : IFACE_("Open"), + 0, 0, w, UI_UNIT_Y, NULL); UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_OPEN)); } else { - but = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_FILESEL, (id) ? "" : IFACE_("Open"), 0, 0, w, UI_UNIT_Y, - NULL, 0, 0, 0, 0, NULL); + but = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_FILESEL, (id) ? "" : IFACE_("Open"), 0, 0, w, UI_UNIT_Y, + NULL, 0, 0, 0, 0, NULL); UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_OPEN)); } @@ -782,9 +797,10 @@ static void template_ID( } else { if ((RNA_property_flag(template_ui->prop) & PROP_NEVER_UNLINK) == 0) { - but = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, - TIP_("Unlink data-block " - "(Shift + Click to set users to zero, data will then not be saved)")); + but = uiDefIconBut( + block, UI_BTYPE_BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, + TIP_("Unlink data-block " + "(Shift + Click to set users to zero, data will then not be saved)")); UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_DELETE)); if (RNA_property_flag(template_ui->prop) & PROP_NEVER_NULL) { @@ -822,8 +838,9 @@ static void template_ID_tabs( for (ID *id = template->idlb->first; id; id = id->next) { wmOperatorType *unlink_ot = WM_operatortype_find(unlinkop, false); const bool is_active = active_ptr.data == id; - const unsigned int but_width = UI_fontstyle_string_width(&style->widgetlabel, id->name + 2) + UI_UNIT_X + - (is_active ? ICON_DEFAULT_WIDTH_SCALE : 0); + const unsigned int but_width = ( + UI_fontstyle_string_width(&style->widgetlabel, id->name + 2) + UI_UNIT_X + + (is_active ? ICON_DEFAULT_WIDTH_SCALE : 0)); uiButTab *tab; tab = (uiButTab *)uiDefButR_prop( @@ -1047,13 +1064,14 @@ static uiBlock *template_search_menu(bContext *C, ARegion *region, void *arg_tem /* arg_template is malloced, can be freed by parent button */ template_search = *((TemplateSearch *)arg_template); - active_ptr = RNA_property_pointer_get(&template_search.search_data.target_ptr, - template_search.search_data.target_prop); + active_ptr = RNA_property_pointer_get( + &template_search.search_data.target_ptr, + template_search.search_data.target_prop); return template_common_search_menu( - C, region, ui_rna_collection_search_cb, &template_search, - template_search_handle_cb, active_ptr.data, - template_search.preview_rows, template_search.preview_cols); + C, region, ui_rna_collection_search_cb, &template_search, + template_search_handle_cb, active_ptr.data, + template_search.preview_rows, template_search.preview_cols); } static void template_search_add_button_searchmenu( @@ -1232,8 +1250,9 @@ void uiTemplateSearchPreview( * - propname: property identifier for property that path gets stored to * - root_ptr: struct that path gets built from */ -void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *UNUSED(root_ptr), - const char *text) +void uiTemplatePathBuilder( + uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *UNUSED(root_ptr), + const char *text) { PropertyRNA *propPath; uiLayout *row; @@ -1338,8 +1357,9 @@ static uiLayout *draw_modifier( BLI_snprintf(str, sizeof(str), IFACE_("%s parent deform"), md->name); uiDefBut(block, UI_BTYPE_LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Modifier name")); - but = uiDefBut(block, UI_BTYPE_BUT, 0, IFACE_("Make Real"), 0, 0, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0, - TIP_("Convert virtual modifier to a real modifier")); + but = uiDefBut( + block, UI_BTYPE_BUT, 0, IFACE_("Make Real"), 0, 0, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0, + TIP_("Convert virtual modifier to a real modifier")); UI_but_func_set(but, modifiers_convertToReal, ob, md); } else { @@ -1356,8 +1376,7 @@ static uiLayout *draw_modifier( UI_block_emboss_set(block, UI_EMBOSS); /* modifier name */ - md->scene = scene; - if (mti->isDisabled && mti->isDisabled(md, 0)) { + if (mti->isDisabled && mti->isDisabled(scene, md, 0)) { uiLayoutSetRedAlert(row, true); } uiItemR(row, &ptr, "name", 0, "", ICON_NONE); @@ -1395,9 +1414,10 @@ static uiLayout *draw_modifier( if (ELEM(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_MeshDeform)) { /* add disabled pre-tessellated button, so users could have * message for this modifiers */ - but = uiDefIconButBitI(block, UI_BTYPE_TOGGLE, eModifierMode_ApplyOnSpline, 0, ICON_SURFACE_DATA, 0, 0, - UI_UNIT_X - 2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, - TIP_("This modifier can only be applied on splines' points")); + but = uiDefIconButBitI( + block, UI_BTYPE_TOGGLE, eModifierMode_ApplyOnSpline, 0, ICON_SURFACE_DATA, 0, 0, + UI_UNIT_X - 2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, + TIP_("This modifier can only be applied on splines' points")); UI_but_flag_enable(but, UI_BUT_DISABLED); } else if (mti->type != eModifierTypeType_Constructive) { @@ -1455,13 +1475,15 @@ static uiLayout *draw_modifier( } else { uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT); - uiItemEnumO(row, "OBJECT_OT_modifier_apply", CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply"), - 0, "apply_as", MODIFIER_APPLY_DATA); + uiItemEnumO( + row, "OBJECT_OT_modifier_apply", CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply"), + 0, "apply_as", MODIFIER_APPLY_DATA); if (modifier_isSameTopology(md) && !modifier_isNonGeometrical(md)) { - uiItemEnumO(row, "OBJECT_OT_modifier_apply", - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply as Shape Key"), - 0, "apply_as", MODIFIER_APPLY_SHAPE); + uiItemEnumO( + row, "OBJECT_OT_modifier_apply", + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply as Shape Key"), + 0, "apply_as", MODIFIER_APPLY_SHAPE); } } @@ -1840,7 +1862,7 @@ static void do_preview_buttons(bContext *C, void *arg, int event) } void uiTemplatePreview( - uiLayout *layout, bContext *C, ID *id, int show_buttons, ID *parent, MTex *slot, + uiLayout *layout, bContext *C, ID *id, bool show_buttons, ID *parent, MTex *slot, const char *preview_id) { uiLayout *row, *col; @@ -1919,8 +1941,9 @@ void uiTemplatePreview( UI_but_func_drawextra_set(block, ED_preview_draw, pparent, slot); UI_block_func_handle_set(block, do_preview_buttons, NULL); - uiDefIconButS(block, UI_BTYPE_GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10, (short)(UI_UNIT_Y * 0.3f), &ui_preview->height, - UI_UNIT_Y, UI_UNIT_Y * 50.0f, 0.0f, 0.0f, ""); + uiDefIconButS( + block, UI_BTYPE_GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10, (short)(UI_UNIT_Y * 0.3f), &ui_preview->height, + UI_UNIT_Y, UI_UNIT_Y * 50.0f, 0.0f, 0.0f, ""); /* add buttons */ if (pid && show_buttons) { @@ -2068,17 +2091,20 @@ static void colorband_buttons_layout( UI_block_align_begin(block); row = uiLayoutRow(split, false); - bt = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_ZOOMIN, "", 0, 0, 2.0f * unit, UI_UNIT_Y, NULL, - 0, 0, 0, 0, TIP_("Add a new color stop to the colorband")); + bt = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_ZOOMIN, "", 0, 0, 2.0f * unit, UI_UNIT_Y, NULL, + 0, 0, 0, 0, TIP_("Add a new color stop to the colorband")); UI_but_funcN_set(bt, colorband_add_cb, MEM_dupallocN(cb), coba); - bt = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_ZOOMOUT, "", xs + 2.0f * unit, ys + UI_UNIT_Y, 2.0f * unit, UI_UNIT_Y, - NULL, 0, 0, 0, 0, TIP_("Delete the active position")); + bt = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_ZOOMOUT, "", xs + 2.0f * unit, ys + UI_UNIT_Y, 2.0f * unit, UI_UNIT_Y, + NULL, 0, 0, 0, 0, TIP_("Delete the active position")); UI_but_funcN_set(bt, colorband_del_cb, MEM_dupallocN(cb), coba); - bt = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_ARROW_LEFTRIGHT, "", xs + 4.0f * unit, ys + UI_UNIT_Y, 2.0f * unit, UI_UNIT_Y, - NULL, 0, 0, 0, 0, TIP_("Flip the color ramp")); + bt = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_ARROW_LEFTRIGHT, "", xs + 4.0f * unit, ys + UI_UNIT_Y, 2.0f * unit, UI_UNIT_Y, + NULL, 0, 0, 0, 0, TIP_("Flip the color ramp")); UI_but_funcN_set(bt, colorband_flip_cb, MEM_dupallocN(cb), coba); bt = uiDefIconButO(block, UI_BTYPE_BUT, "UI_OT_eyedropper_colorband", WM_OP_INVOKE_DEFAULT, ICON_EYEDROPPER, xs + 6.0f * unit, ys + UI_UNIT_Y, UI_UNIT_X, UI_UNIT_Y, NULL); @@ -2150,7 +2176,7 @@ static void colorband_buttons_layout( } } -void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname, int expand) +void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname, bool expand) { PropertyRNA *prop = RNA_struct_find_property(ptr, propname); PointerRNA cptr; @@ -2263,7 +2289,7 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *ar, void *arg_litem) /** * \param icon_scale: Scale of the icon, 1x == button height. */ -void uiTemplateIconView(uiLayout *layout, PointerRNA *ptr, const char *propname, int show_labels, float icon_scale) +void uiTemplateIconView(uiLayout *layout, PointerRNA *ptr, const char *propname, bool show_labels, float icon_scale) { PropertyRNA *prop = RNA_struct_find_property(ptr, propname); IconViewMenuArgs *cb_args; @@ -2499,8 +2525,9 @@ static uiBlock *curvemap_clipping_func(bContext *C, ARegion *ar, void *cumap_v) /* use this for a fake extra empy space around the buttons */ uiDefBut(block, UI_BTYPE_LABEL, 0, "", -4, 16, width + 8, 6 * UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); - bt = uiDefButBitI(block, UI_BTYPE_TOGGLE, CUMA_DO_CLIP, 1, IFACE_("Use Clipping"), - 0, 5 * UI_UNIT_Y, width, UI_UNIT_Y, &cumap->flag, 0.0, 0.0, 10, 0, ""); + bt = uiDefButBitI( + block, UI_BTYPE_TOGGLE, CUMA_DO_CLIP, 1, IFACE_("Use Clipping"), + 0, 5 * UI_UNIT_Y, width, UI_UNIT_Y, &cumap->flag, 0.0, 0.0, 10, 0, ""); UI_but_func_set(bt, curvemap_buttons_setclip, cumap, NULL); UI_block_align_begin(block); @@ -2663,8 +2690,8 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v) /* still unsure how this call evolves... we use labeltype for defining what curve-channels to show */ static void curvemap_buttons_layout( - uiLayout *layout, PointerRNA *ptr, char labeltype, int levels, - int brush, int neg_slope, RNAUpdateCb *cb) + uiLayout *layout, PointerRNA *ptr, char labeltype, bool levels, + bool brush, bool neg_slope, RNAUpdateCb *cb) { CurveMapping *cumap = ptr->data; CurveMap *cm = &cumap->cm[cumap->cur]; @@ -2759,11 +2786,13 @@ static void curvemap_buttons_layout( if (brush) bt = uiDefIconBlockBut(block, curvemap_brush_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, TIP_("Tools")); else if (neg_slope) - bt = uiDefIconBlockBut(block, curvemap_tools_negslope_func, cumap, 0, ICON_MODIFIER, - 0, 0, dx, dx, TIP_("Tools")); + bt = uiDefIconBlockBut( + block, curvemap_tools_negslope_func, cumap, 0, ICON_MODIFIER, + 0, 0, dx, dx, TIP_("Tools")); else - bt = uiDefIconBlockBut(block, curvemap_tools_posslope_func, cumap, 0, ICON_MODIFIER, - 0, 0, dx, dx, TIP_("Tools")); + bt = uiDefIconBlockBut( + block, curvemap_tools_posslope_func, cumap, 0, ICON_MODIFIER, + 0, 0, dx, dx, TIP_("Tools")); UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL); @@ -2827,7 +2856,7 @@ static void curvemap_buttons_layout( void uiTemplateCurveMapping( uiLayout *layout, PointerRNA *ptr, const char *propname, int type, - int levels, int brush, int neg_slope) + bool levels, bool brush, bool neg_slope) { RNAUpdateCb *cb; PropertyRNA *prop = RNA_struct_find_property(ptr, propname); @@ -2871,8 +2900,8 @@ void uiTemplateCurveMapping( /* This template now follows User Preference for type - name is not correct anymore... */ void uiTemplateColorPicker( - uiLayout *layout, PointerRNA *ptr, const char *propname, int value_slider, - int lock, int lock_luminosity, int cubic) + uiLayout *layout, PointerRNA *ptr, const char *propname, bool value_slider, + bool lock, bool lock_luminosity, bool cubic) { PropertyRNA *prop = RNA_struct_find_property(ptr, propname); uiBlock *block = uiLayoutGetBlock(layout); @@ -2893,24 +2922,28 @@ void uiTemplateColorPicker( switch (U.color_picker_type) { case USER_CP_SQUARE_SV: - but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, - -1, 0.0, 0.0, UI_GRAD_SV, 0, ""); + but = uiDefButR_prop( + block, UI_BTYPE_HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, + -1, 0.0, 0.0, UI_GRAD_SV, 0, ""); break; case USER_CP_SQUARE_HS: - but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, - -1, 0.0, 0.0, UI_GRAD_HS, 0, ""); + but = uiDefButR_prop( + block, UI_BTYPE_HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, + -1, 0.0, 0.0, UI_GRAD_HS, 0, ""); break; case USER_CP_SQUARE_HV: - but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, - -1, 0.0, 0.0, UI_GRAD_HV, 0, ""); + but = uiDefButR_prop( + block, UI_BTYPE_HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, + -1, 0.0, 0.0, UI_GRAD_HV, 0, ""); break; /* user default */ case USER_CP_CIRCLE_HSV: case USER_CP_CIRCLE_HSL: default: - but = uiDefButR_prop(block, UI_BTYPE_HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, - -1, 0.0, 0.0, 0, 0, ""); + but = uiDefButR_prop( + block, UI_BTYPE_HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, + -1, 0.0, 0.0, 0, 0, ""); break; } @@ -2936,31 +2969,36 @@ void uiTemplateColorPicker( switch (U.color_picker_type) { case USER_CP_CIRCLE_HSL: uiItemS(row); - but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14, WHEEL_SIZE, ptr, prop, - -1, softmin, softmax, UI_GRAD_L_ALT, 0, ""); + but = uiDefButR_prop( + block, UI_BTYPE_HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14, WHEEL_SIZE, ptr, prop, + -1, softmin, softmax, UI_GRAD_L_ALT, 0, ""); break; case USER_CP_SQUARE_SV: uiItemS(col); - but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, - -1, softmin, softmax, UI_GRAD_SV + 3, 0, ""); + but = uiDefButR_prop( + block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, + -1, softmin, softmax, UI_GRAD_SV + 3, 0, ""); break; case USER_CP_SQUARE_HS: uiItemS(col); - but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, - -1, softmin, softmax, UI_GRAD_HS + 3, 0, ""); + but = uiDefButR_prop( + block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, + -1, softmin, softmax, UI_GRAD_HS + 3, 0, ""); break; case USER_CP_SQUARE_HV: uiItemS(col); - but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, - -1, softmin, softmax, UI_GRAD_HV + 3, 0, ""); + but = uiDefButR_prop( + block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, + -1, softmin, softmax, UI_GRAD_HV + 3, 0, ""); break; /* user default */ case USER_CP_CIRCLE_HSV: default: uiItemS(row); - but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14, WHEEL_SIZE, ptr, prop, - -1, softmin, softmax, UI_GRAD_V_ALT, 0, ""); + but = uiDefButR_prop( + block, UI_BTYPE_HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14, WHEEL_SIZE, ptr, prop, + -1, softmin, softmax, UI_GRAD_V_ALT, 0, ""); break; } @@ -2968,7 +3006,7 @@ void uiTemplateColorPicker( } } -void uiTemplatePalette(uiLayout *layout, PointerRNA *ptr, const char *propname, int UNUSED(colors)) +void uiTemplatePalette(uiLayout *layout, PointerRNA *ptr, const char *propname, bool UNUSED(colors)) { PropertyRNA *prop = RNA_struct_find_property(ptr, propname); PointerRNA cptr; @@ -3011,8 +3049,9 @@ void uiTemplatePalette(uiLayout *layout, PointerRNA *ptr, const char *propname, } RNA_pointer_create(&palette->id, &RNA_PaletteColor, color, &color_ptr); - uiDefButR(block, UI_BTYPE_COLOR, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, &color_ptr, "color", -1, 0.0, 1.0, - UI_PALETTE_COLOR, col_id, ""); + uiDefButR( + block, UI_BTYPE_COLOR, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, &color_ptr, "color", -1, 0.0, 1.0, + UI_PALETTE_COLOR, col_id, ""); row_cols++; col_id++; } @@ -3173,8 +3212,9 @@ static int cmpstringp(const void *p1, const void *p2) return BLI_strcasecmp(((StringCmp *) p1)->name, ((StringCmp *) p2)->name); } -static void uilist_filter_items_default(struct uiList *ui_list, struct bContext *UNUSED(C), struct PointerRNA *dataptr, - const char *propname) +static void uilist_filter_items_default( + struct uiList *ui_list, struct bContext *UNUSED(C), struct PointerRNA *dataptr, + const char *propname) { uiListDyn *dyn_data = ui_list->dyn_data; PropertyRNA *prop = RNA_struct_find_property(dataptr, propname); @@ -3616,9 +3656,10 @@ void uiTemplateList( /* list item behind label & other buttons */ sub = uiLayoutRow(overlap, false); - but = uiDefButR_prop(subblock, UI_BTYPE_LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, - active_dataptr, activeprop, 0, 0, org_i, 0, 0, - TIP_("Double click to rename")); + but = uiDefButR_prop( + subblock, UI_BTYPE_LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, + active_dataptr, activeprop, 0, 0, org_i, 0, 0, + TIP_("Double click to rename")); if ((dyntip_data = uilist_item_use_dynamic_tooltip(itemptr, item_dyntip_propname))) { UI_but_func_tooltip_set(but, uilist_item_tooltip_func, dyntip_data); } @@ -3674,8 +3715,9 @@ void uiTemplateList( /* next/prev button */ BLI_snprintf(numstr, sizeof(numstr), "%d :", dyn_data->items_shown); - but = uiDefIconTextButR_prop(block, UI_BTYPE_NUM, 0, 0, numstr, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, - active_dataptr, activeprop, 0, 0, 0, 0, 0, ""); + but = uiDefIconTextButR_prop( + block, UI_BTYPE_NUM, 0, 0, numstr, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, + active_dataptr, activeprop, 0, 0, 0, 0, 0, ""); if (dyn_data->items_shown == 0) UI_but_flag_enable(but, UI_BUT_DISABLED); break; @@ -3945,7 +3987,7 @@ eAutoPropButsReturn uiTemplateOperatorPropertyButs( block->ui_operator = op; row = uiLayoutRow(layout, true); - uiItemM(row, (bContext *)C, "WM_MT_operator_presets", NULL, ICON_NONE); + uiItemM(row, "WM_MT_operator_presets", NULL, ICON_NONE); wmOperatorType *ot = WM_operatortype_find("WM_OT_operator_preset_add", false); uiItemFullO_ptr(row, ot, "", ICON_ZOOMIN, NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); @@ -4223,9 +4265,6 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop this job")); } - if (WM_jobs_test(wm, screen, WM_JOB_TYPE_SCREENCAST)) - uiDefIconTextBut(block, UI_BTYPE_BUT, B_STOPCAST, ICON_CANCEL, IFACE_("Capture"), 0, 0, UI_UNIT_X * 4.25f, UI_UNIT_Y, - NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop screencast")); if (screen->animtimer) uiDefIconTextBut(block, UI_BTYPE_BUT, B_STOPANIM, ICON_CANCEL, IFACE_("Anim Player"), 0, 0, UI_UNIT_X * 5.0f, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop animation playback")); @@ -4263,18 +4302,18 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) /* make a box around the report to make it stand out */ UI_block_align_begin(block); - but = uiDefBut(block, UI_BTYPE_ROUNDBOX, 0, "", 0, 0, UI_UNIT_X + 10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); + but = uiDefBut(block, UI_BTYPE_ROUNDBOX, 0, "", 0, 0, UI_UNIT_X + 5, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); /* set the report's bg color in but->col - UI_BTYPE_ROUNDBOX feature */ rgb_float_to_uchar(but->col, rti->col); but->col[3] = 255; - but = uiDefBut(block, UI_BTYPE_ROUNDBOX, 0, "", UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y, + but = uiDefBut(block, UI_BTYPE_ROUNDBOX, 0, "", UI_UNIT_X + 5, 0, UI_UNIT_X + width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); - but->col[0] = but->col[1] = but->col[2] = unit_float_to_uchar_clamp(rti->grayscale); - but->col[3] = 255; UI_block_align_end(block); + UI_GetThemeColorShade3ubv(TH_BACK, 20, but->col); + but->col[3] = 255; /* icon and report message on top */ icon = UI_icon_from_report_type(report->type); @@ -4292,10 +4331,44 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) UI_block_emboss_set(block, UI_EMBOSS); - uiDefBut(block, UI_BTYPE_LABEL, 0, report->message, UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y, + uiDefBut(block, UI_BTYPE_LABEL, 0, report->message, UI_UNIT_X + 5, 0, UI_UNIT_X + width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); } + +void uiTemplateInputStatus(uiLayout *layout, struct bContext *C) +{ + wmWindow *win = CTX_wm_window(C); + WorkSpace *workspace = CTX_wm_workspace(C); + + /* Workspace status text has priority. */ + if (workspace->status_text) { + uiItemL(layout, workspace->status_text, ICON_NONE); + return; + } + + /* Otherwise should cursor keymap status. */ + for (int i = 0; i < 3; i++) { + uiLayout *box = uiLayoutRow(layout, false); + uiLayout *col = uiLayoutColumn(box, false); + uiLayout *row = uiLayoutRow(col, true); + uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT); + + const char *msg = WM_window_cursor_keymap_status_get(win, i, 0); + const char *msg_drag = WM_window_cursor_keymap_status_get(win, i, 1); + + uiItemL(row, msg ? msg : "", (ICON_MOUSE_LMB + i)); + + if (msg_drag) { + uiItemL(row, msg_drag, (ICON_MOUSE_LMB_DRAG + i)); + } + + /* Use trick with empty string to keep icons in same position. */ + row = uiLayoutRow(col, false); + uiItemL(row, " ", ICON_NONE); + } +} + /********************************* Keymap *************************************/ static void keymap_item_modified(bContext *UNUSED(C), void *kmi_p, void *UNUSED(unused)) diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index e049416ce07..d080397c488 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -409,8 +409,9 @@ int UI_calc_float_precision(int prec, double value) bool UI_but_online_manual_id(const uiBut *but, char *r_str, size_t maxlength) { if (but->rnapoin.id.data && but->rnapoin.data && but->rnaprop) { - BLI_snprintf(r_str, maxlength, "%s.%s", RNA_struct_identifier(but->rnapoin.type), - RNA_property_identifier(but->rnaprop)); + BLI_snprintf( + r_str, maxlength, "%s.%s", RNA_struct_identifier(but->rnapoin.type), + RNA_property_identifier(but->rnaprop)); return true; } else if (but->optype) { diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 3b7ccb68fd4..dbd65ade307 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -58,6 +58,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" +#include "GPU_state.h" #ifdef WITH_INPUT_IME # include "WM_types.h" @@ -509,7 +510,7 @@ void UI_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y /* Note: This won't give back the original color. */ draw_color[3] *= 1.0f / WIDGET_AA_JITTER; - glEnable(GL_BLEND); + GPU_blend(true); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -528,7 +529,7 @@ void UI_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } void UI_draw_anti_fan(float tri_array[][2], unsigned int length, const float color[4]) @@ -538,7 +539,7 @@ void UI_draw_anti_fan(float tri_array[][2], unsigned int length, const float col copy_v4_v4(draw_color, color); draw_color[3] *= 2.0f / WIDGET_AA_JITTER; - glEnable(GL_BLEND); + GPU_blend(true); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -562,7 +563,7 @@ void UI_draw_anti_fan(float tri_array[][2], unsigned int length, const float col immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } static void widget_init(uiWidgetBase *wtb) @@ -673,13 +674,16 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, const rcti *re float facxi = (maxxi != minxi) ? 1.0f / (maxxi - minxi) : 0.0f; /* for uv, can divide by zero */ float facyi = (maxyi != minyi) ? 1.0f / (maxyi - minyi) : 0.0f; int a, tot = 0, minsize; - const int hnum = ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT)) == (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT) || - (roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT)) == (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT)) ? 1 : 2; - const int vnum = ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)) == (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT) || - (roundboxalign & (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) == (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) ? 1 : 2; + const int hnum = ( + (roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT)) == (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT) || + (roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT)) == (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT)) ? 1 : 2; + const int vnum = ( + (roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)) == (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT) || + (roundboxalign & (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) == (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) ? 1 : 2; - minsize = min_ii(BLI_rcti_size_x(rect) * hnum, - BLI_rcti_size_y(rect) * vnum); + minsize = min_ii( + BLI_rcti_size_x(rect) * hnum, + BLI_rcti_size_y(rect) * vnum); if (2.0f * rad > minsize) rad = 0.5f * minsize; @@ -1109,11 +1113,11 @@ void UI_widgetbase_draw_cache_end(void) BLI_assert(g_widget_base_batch.enabled == true); g_widget_base_batch.enabled = false; - glEnable(GL_BLEND); + GPU_blend(true); UI_widgetbase_draw_cache_flush(); - glDisable(GL_BLEND); + GPU_blend(false); } static void draw_widgetbase_batch(Gwn_Batch *batch, uiWidgetBase *wtb) @@ -1169,7 +1173,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, const uiWidgetColors *wcol) /* For color widget. */ bool alpha_check = (wcol->alpha_check && (wcol->shaded == 0)); - glEnable(GL_BLEND); + GPU_blend(true); /* backdrop non AA */ if (wtb->draw_inner) { @@ -1213,7 +1217,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, const uiWidgetColors *wcol) draw_widgetbase_batch(roundbox_batch, wtb); } - glDisable(GL_BLEND); + GPU_blend(false); } /* *********************** text/icon ************************************** */ @@ -1258,9 +1262,9 @@ static void widget_draw_icon_ex( float aspect, height; if (but->flag & UI_BUT_ICON_PREVIEW) { - glEnable(GL_BLEND); + GPU_blend(true); widget_draw_preview(icon, alpha, rect); - glDisable(GL_BLEND); + GPU_blend(false); return; } @@ -1288,7 +1292,7 @@ static void widget_draw_icon_ex( } } - glEnable(GL_BLEND); + GPU_blend(true); if (icon && icon != ICON_BLANK1) { float ofs = 1.0f / aspect; @@ -1334,7 +1338,7 @@ static void widget_draw_icon_ex( UI_icon_draw_aspect(xs, ys, ICON_RIGHTARROW_THIN, aspect, alpha); } - glDisable(GL_BLEND); + GPU_blend(false); } static void widget_draw_icon( @@ -1420,8 +1424,8 @@ float UI_text_clip_middle_ex( strwidth = BLF_width(fstyle->uifont_id, str, max_len); if ((okwidth > 0.0f) && (strwidth > okwidth)) { - /* utf8 ellipsis '...', some compilers complain */ - const char sep[] = {0xe2, 0x80, 0xa6, 0x0}; + /* utf8 ellipsis '..', some compilers complain */ + const char sep[] = {0xe2, 0x80, 0xA5, 0x0}; const int sep_len = sizeof(sep) - 1; const float sep_strwidth = BLF_width(fstyle->uifont_id, sep, sep_len + 1); float parts_strwidth; @@ -1500,6 +1504,8 @@ float UI_text_clip_middle_ex( BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT); } + BLI_assert(strwidth <= okwidth); + return strwidth; } @@ -1659,8 +1665,9 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti /* once the label's gone, chop off the least significant digits */ if (but->strwidth > okwidth) { float strwidth; - drawstr_len = BLF_width_to_strlen(fstyle->uifont_id, but->drawstr + but->ofs, - drawstr_len - but->ofs, okwidth, &strwidth) + but->ofs; + drawstr_len = BLF_width_to_strlen( + fstyle->uifont_id, but->drawstr + but->ofs, + drawstr_len - but->ofs, okwidth, &strwidth) + but->ofs; but->strwidth = strwidth; but->drawstr[drawstr_len] = 0; } @@ -1687,8 +1694,9 @@ static void widget_draw_text_ime_underline( ofs_x = 0; } - width = BLF_width(fstyle->uifont_id, drawstr + but->ofs, - ime_data->composite_len + but->pos - but->ofs); + width = BLF_width( + fstyle->uifont_id, drawstr + but->ofs, + ime_data->composite_len + but->pos - but->ofs); rgba_uchar_to_float(fcol, wcol->text); UI_draw_text_underline(rect->xmin + ofs_x, rect->ymin + 6 * U.pixelsize, min_ii(width, rect_x - 2) - ofs_x, 1, fcol); @@ -1705,8 +1713,9 @@ static void widget_draw_text_ime_underline( ofs_x = 0; } - width = BLF_width(fstyle->uifont_id, drawstr + but->ofs, - sel_end + sel_start - but->ofs); + width = BLF_width( + fstyle->uifont_id, drawstr + but->ofs, + sel_end + sel_start - but->ofs); UI_draw_text_underline(rect->xmin + ofs_x, rect->ymin + 6 * U.pixelsize, min_ii(width, rect_x - 2) - ofs_x, 2, fcol); } @@ -1759,9 +1768,10 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b if (ime_data && ime_data->composite_len) { /* insert composite string into cursor pos */ - BLI_snprintf((char *)drawstr, UI_MAX_DRAW_STR, "%s%s%s", - but->editstr, ime_data->str_composite, - but->editstr + but->pos); + BLI_snprintf( + (char *)drawstr, UI_MAX_DRAW_STR, "%s%s%s", + but->editstr, ime_data->str_composite, + but->editstr + but->pos); } else #endif @@ -1783,9 +1793,9 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b if (drawstr[0] != 0) { /* We are drawing on top of widget bases. Flush cache. */ - glEnable(GL_BLEND); + GPU_blend(true); UI_widgetbase_draw_cache_flush(); - glDisable(GL_BLEND); + GPU_blend(false); if (but->selsta >= but->ofs) { selsta_draw = BLF_width(fstyle->uifont_id, drawstr + but->ofs, but->selsta - but->ofs); @@ -1828,9 +1838,9 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b t = 0; } /* We are drawing on top of widget bases. Flush cache. */ - glEnable(GL_BLEND); + GPU_blend(true); UI_widgetbase_draw_cache_flush(); - glDisable(GL_BLEND); + GPU_blend(false); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1993,9 +2003,9 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB /* draw icon in rect above the space reserved for the label */ rect->ymin += text_size; - glEnable(GL_BLEND); + GPU_blend(true); widget_draw_preview(icon, alpha, rect); - glDisable(GL_BLEND); + GPU_blend(false); /* offset rect to draw label in */ rect->ymin -= text_size; @@ -2114,370 +2124,6 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB /* *********************** widget types ************************************* */ -static struct uiWidgetStateColors wcol_state_colors = { - {115, 190, 76, 255}, - {90, 166, 51, 255}, - {240, 235, 100, 255}, - {215, 211, 75, 255}, - {180, 0, 255, 255}, - {153, 0, 230, 255}, - {74, 137, 137, 255}, - {49, 112, 112, 255}, - 0.5f, 0.0f -}; - -static struct uiWidgetColors wcol_num = { - {25, 25, 25, 255}, - {180, 180, 180, 255}, - {153, 153, 153, 255}, - {90, 90, 90, 255}, - - {0, 0, 0, 255}, - {255, 255, 255, 255}, - - 1, - -20, 0, - 0, - 0.5f, -}; - -static struct uiWidgetColors wcol_numslider = { - {25, 25, 25, 255}, - {180, 180, 180, 255}, - {153, 153, 153, 255}, - {128, 128, 128, 255}, - - {0, 0, 0, 255}, - {255, 255, 255, 255}, - - 1, - -20, 0, - 0, - 0.5f, -}; - -static struct uiWidgetColors wcol_text = { - {25, 25, 25, 255}, - {153, 153, 153, 255}, - {153, 153, 153, 255}, - {90, 90, 90, 255}, - - {0, 0, 0, 255}, - {255, 255, 255, 255}, - - 1, - 0, 25, - 0, - 0.2f, -}; - -static struct uiWidgetColors wcol_option = { - {0, 0, 0, 255}, - {70, 70, 70, 255}, - {70, 70, 70, 255}, - {255, 255, 255, 255}, - - {0, 0, 0, 255}, - {255, 255, 255, 255}, - - 1, - 15, -15, - 0, - 0.3333333f, -}; - -/* button that shows popup */ -static struct uiWidgetColors wcol_menu = { - {0, 0, 0, 255}, - {70, 70, 70, 255}, - {70, 70, 70, 255}, - {255, 255, 255, 255}, - - {255, 255, 255, 255}, - {204, 204, 204, 255}, - - 1, - 15, -15, - 0, - 0.2f, -}; - -/* button that starts pulldown */ -static struct uiWidgetColors wcol_pulldown = { - {0, 0, 0, 255}, - {63, 63, 63, 255}, - {86, 128, 194, 255}, - {255, 255, 255, 255}, - - {0, 0, 0, 255}, - {0, 0, 0, 255}, - - 0, - 25, -20, - 0, - 0.2f, -}; - -/* button inside menu */ -static struct uiWidgetColors wcol_menu_item = { - {0, 0, 0, 255}, - {0, 0, 0, 0}, - {86, 128, 194, 255}, - {172, 172, 172, 128}, - - {255, 255, 255, 255}, - {0, 0, 0, 255}, - - 1, - 38, 0, - 0, - 0.2f, -}; - -/* backdrop menu + title text color */ -static struct uiWidgetColors wcol_menu_back = { - {0, 0, 0, 255}, - {25, 25, 25, 230}, - {45, 45, 45, 230}, - {100, 100, 100, 255}, - - {160, 160, 160, 255}, - {255, 255, 255, 255}, - - 0, - 25, -20, - 0, - 0.25f, -}; - -/* pie menus */ -static struct uiWidgetColors wcol_pie_menu = { - {10, 10, 10, 200}, - {25, 25, 25, 230}, - {140, 140, 140, 255}, - {45, 45, 45, 230}, - - {160, 160, 160, 255}, - {255, 255, 255, 255}, - - 1, - 10, -10, - 0, - 0.5f, -}; - - -/* tooltip color */ -static struct uiWidgetColors wcol_tooltip = { - {0, 0, 0, 255}, - {25, 25, 25, 230}, - {45, 45, 45, 230}, - {100, 100, 100, 255}, - - {255, 255, 255, 255}, - {255, 255, 255, 255}, - - 0, - 25, -20, - 0, - 0.25f, -}; - -static struct uiWidgetColors wcol_radio = { - {0, 0, 0, 255}, - {70, 70, 70, 255}, - {86, 128, 194, 255}, - {255, 255, 255, 255}, - - {255, 255, 255, 255}, - {0, 0, 0, 255}, - - 1, - 15, -15, - 0, - 0.2f, -}; - -static struct uiWidgetColors wcol_regular = { - {25, 25, 25, 255}, - {153, 153, 153, 255}, - {100, 100, 100, 255}, - {25, 25, 25, 255}, - - {0, 0, 0, 255}, - {255, 255, 255, 255}, - - 0, - 0, 0, - 0, - 0.25f, -}; - -static struct uiWidgetColors wcol_tool = { - {25, 25, 25, 255}, - {153, 153, 153, 255}, - {100, 100, 100, 255}, - {25, 25, 25, 255}, - - {0, 0, 0, 255}, - {255, 255, 255, 255}, - - 1, - 15, -15, - 0, - 0.2f, -}; - -static struct uiWidgetColors wcol_toolbar_item = { - .outline = {0x19, 0x19, 0x19, 0xff}, - .inner = {0x46, 0x46, 0x46, 0xff}, - .inner_sel = {0xcc, 0xcc, 0xcc, 0xff}, - .item = {0x0, 0x0, 0x0, 0xff}, - - .text = {0xff, 0xff, 0xff, 0xff}, - .text_sel = {0x33, 0x33, 0x33, 0xff}, - - .shaded = 0, - .shadetop = 0, - .shadedown = 0, - .alpha_check = 0, - .roundness = 0.3f, -}; - -static struct uiWidgetColors wcol_box = { - {25, 25, 25, 255}, - {128, 128, 128, 255}, - {100, 100, 100, 255}, - {25, 25, 25, 255}, - - {0, 0, 0, 255}, - {255, 255, 255, 255}, - - 0, - 0, 0, - 0, - 0.2f, -}; - -static struct uiWidgetColors wcol_toggle = { - {25, 25, 25, 255}, - {153, 153, 153, 255}, - {100, 100, 100, 255}, - {25, 25, 25, 255}, - - {0, 0, 0, 255}, - {255, 255, 255, 255}, - - 0, - 0, 0, - 0, - 0.25f, -}; - -static struct uiWidgetColors wcol_scroll = { - {50, 50, 50, 180}, - {80, 80, 80, 180}, - {100, 100, 100, 180}, - {128, 128, 128, 255}, - - {0, 0, 0, 255}, - {255, 255, 255, 255}, - - 1, - 5, -5, - 0, - 0.5f, -}; - -static struct uiWidgetColors wcol_progress = { - {0, 0, 0, 255}, - {190, 190, 190, 255}, - {100, 100, 100, 180}, - {128, 128, 128, 255}, - - {0, 0, 0, 255}, - {255, 255, 255, 255}, - - 0, - 0, 0, - 0, - 0.25f, -}; - -static struct uiWidgetColors wcol_list_item = { - {0, 0, 0, 255}, - {0, 0, 0, 0}, - {86, 128, 194, 255}, - {90, 90, 90, 255}, - - {0, 0, 0, 255}, - {255, 255, 255, 255}, - - 0, - 0, 0, - 0, - 0.2f, -}; - -struct uiWidgetColors wcol_tab = { - {60, 60, 60, 255}, - {83, 83, 83, 255}, - {114, 114, 114, 255}, - {90, 90, 90, 255}, - - {0, 0, 0, 255}, - {0, 0, 0, 255}, - - 0, - 0, 0, - 0, - 0.25f, -}; - -/* free wcol struct to play with */ -static struct uiWidgetColors wcol_tmp = { - {0, 0, 0, 255}, - {128, 128, 128, 255}, - {100, 100, 100, 255}, - {25, 25, 25, 255}, - - {0, 0, 0, 255}, - {255, 255, 255, 255}, - - 0, - 0, 0, - 0, - 0.25f, -}; - - -/* called for theme init (new theme) and versions */ -void ui_widget_color_init(ThemeUI *tui) -{ - tui->wcol_regular = wcol_regular; - tui->wcol_tool = wcol_tool; - tui->wcol_toolbar_item = wcol_toolbar_item; - tui->wcol_text = wcol_text; - tui->wcol_radio = wcol_radio; - tui->wcol_tab = wcol_tab; - tui->wcol_option = wcol_option; - tui->wcol_toggle = wcol_toggle; - tui->wcol_num = wcol_num; - tui->wcol_numslider = wcol_numslider; - tui->wcol_menu = wcol_menu; - tui->wcol_pulldown = wcol_pulldown; - tui->wcol_menu_back = wcol_menu_back; - tui->wcol_pie_menu = wcol_pie_menu; - tui->wcol_tooltip = wcol_tooltip; - tui->wcol_menu_item = wcol_menu_item; - tui->wcol_box = wcol_box; - tui->wcol_scroll = wcol_scroll; - tui->wcol_list_item = wcol_list_item; - tui->wcol_progress = wcol_progress; - - tui->wcol_state = wcol_state_colors; -} - /* ************ button callbacks, state ***************** */ static void widget_state_blend(char cp[3], const char cpstate[3], const float fac) @@ -2775,14 +2421,14 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir rect->ymax += 0.1f * U.widget_unit; } - glEnable(GL_BLEND); + GPU_blend(true); widget_softshadow(rect, roundboxalign, wcol->roundness * U.widget_unit); round_box_edges(&wtb, roundboxalign, rect, wcol->roundness * U.widget_unit); wtb.draw_emboss = false; widgetbase_draw(&wtb, wcol); - glDisable(GL_BLEND); + GPU_blend(false); } static void ui_hsv_cursor(float x, float y) @@ -2794,18 +2440,19 @@ static void ui_hsv_cursor(float x, float y) immUniformColor3f(1.0f, 1.0f, 1.0f); imm_draw_circle_fill_2d(pos, x, y, 3.0f * U.pixelsize, 8); - glEnable(GL_BLEND); - glEnable(GL_LINE_SMOOTH); + GPU_blend(true); + GPU_line_smooth(true); immUniformColor3f(0.0f, 0.0f, 0.0f); imm_draw_circle_wire_2d(pos, x, y, 3.0f * U.pixelsize, 12); - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); + GPU_blend(false); + GPU_line_smooth(false); immUnbindProgram(); } -void ui_hsvcircle_vals_from_pos(float *val_rad, float *val_dist, const rcti *rect, - const float mx, const float my) +void ui_hsvcircle_vals_from_pos( + float *val_rad, float *val_dist, const rcti *rect, + const float mx, const float my) { /* duplication of code... well, simple is better now */ const float centx = BLI_rcti_cent_x_fl(rect); @@ -2913,16 +2560,16 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti * immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - glEnable(GL_BLEND); - glEnable(GL_LINE_SMOOTH); + GPU_blend(true); + GPU_line_smooth(true); immUniformColor3ubv((unsigned char *)wcol->outline); imm_draw_circle_wire_2d(pos, centx, centy, radius, tot); immUnbindProgram(); - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); + GPU_blend(false); + GPU_line_smooth(false); /* cursor */ float xpos, ypos; @@ -3201,18 +2848,21 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect) round_box_edges(&wtb, UI_CNR_ALL, rect, rad); /* setup temp colors */ - wcol_tmp.outline[0] = wcol_tmp.outline[1] = wcol_tmp.outline[2] = 0; - wcol_tmp.inner[0] = wcol_tmp.inner[1] = wcol_tmp.inner[2] = 128; - wcol_tmp.shadetop = 127; - wcol_tmp.shadedown = -128; - wcol_tmp.shaded = 1; - - widgetbase_draw(&wtb, &wcol_tmp); + widgetbase_draw( + &wtb, + &((uiWidgetColors){ + .outline = {0, 0, 0, 255}, + .inner = {128, 128, 128, 255}, + .shadetop = 127, + .shadedown = -128, + .shaded = 1, + }) + ); /* We are drawing on top of widget bases. Flush cache. */ - glEnable(GL_BLEND); + GPU_blend(true); UI_widgetbase_draw_cache_flush(); - glDisable(GL_BLEND); + GPU_blend(false); /* cursor */ x = rect->xmin + 0.5f * BLI_rcti_size_x(rect); @@ -3231,9 +2881,9 @@ static void ui_draw_roundbox(const rcti *rect, const float rad, const uiWidgetCo widgetbase_draw(&wtb, wcol); /* We are drawing on top of widget bases. Flush cache. */ - glEnable(GL_BLEND); + GPU_blend(true); UI_widgetbase_draw_cache_flush(); - glDisable(GL_BLEND); + GPU_blend(false); } @@ -3251,16 +2901,16 @@ static void ui_draw_separator(const rcti *rect, uiWidgetColors *wcol) unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - glEnable(GL_BLEND); + GPU_blend(true); immUniformColor4ubv(col); - glLineWidth(1.0f); + GPU_line_width(1.0f); immBegin(GWN_PRIM_LINES, 2); immVertex2f(pos, rect->xmin, y); immVertex2f(pos, rect->xmax, y); immEnd(); - glDisable(GL_BLEND); + GPU_blend(false); immUnbindProgram(); } @@ -3706,9 +3356,9 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat bw += (bw < 0.5f) ? 0.5f : -0.5f; /* We are drawing on top of widget bases. Flush cache. */ - glEnable(GL_BLEND); + GPU_blend(true); UI_widgetbase_draw_cache_flush(); - glDisable(GL_BLEND); + GPU_blend(false); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -4079,9 +3729,9 @@ static void widget_tab(uiWidgetColors *wcol, rcti *rect, int state, int roundbox widgetbase_draw(&wtb, wcol); /* We are drawing on top of widget bases. Flush cache. */ - glEnable(GL_BLEND); + GPU_blend(true); UI_widgetbase_draw_cache_flush(); - glDisable(GL_BLEND); + GPU_blend(false); #ifdef USE_TAB_SHADED_HIGHLIGHT /* draw outline (3d look) */ @@ -4660,7 +4310,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct wt->draw(&wt->wcol, rect, state, roundboxalign); if (disabled) - glEnable(GL_BLEND); + GPU_blend(true); #ifdef USE_UI_POPOVER_ONCE if (but->block->flag & UI_BLOCK_POPOVER_ONCE) { @@ -4682,7 +4332,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct wt->text(fstyle, &wt->wcol, but, rect); if (disabled) - glDisable(GL_BLEND); + GPU_blend(false); // if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) // if (but->dt != UI_EMBOSS_PULLDOWN) @@ -4739,7 +4389,7 @@ static void ui_draw_popover_back_impl( rect->ymax -= unit_half; rect->ymin += unit_half; - glEnable(GL_BLEND); + GPU_blend(true); /* Extracted from 'widget_menu_back', keep separate to avoid menu changes breaking popovers */ { @@ -4759,7 +4409,7 @@ static void ui_draw_popover_back_impl( unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv((unsigned char *)wcol->inner); - glEnable(GL_BLEND); + GPU_blend(true); immBegin(GWN_PRIM_TRIS, 3); if (direction == UI_DIR_DOWN) { const float y = rect->ymax; @@ -4777,7 +4427,7 @@ static void ui_draw_popover_back_impl( immUnbindProgram(); } - glDisable(GL_BLEND); + GPU_blend(false); } void ui_draw_popover_back(ARegion *ar, uiStyle *UNUSED(style), uiBlock *block, rcti *rect) @@ -4871,7 +4521,7 @@ void ui_draw_pie_center(uiBlock *block) gpuPushMatrix(); gpuTranslate2f(cx, cy); - glEnable(GL_BLEND); + GPU_blend(true); if (btheme->tui.wcol_pie_menu.shaded) { char col1[4], col2[4]; shadecolors4(col1, col2, btheme->tui.wcol_pie_menu.inner, btheme->tui.wcol_pie_menu.shadetop, btheme->tui.wcol_pie_menu.shadedown); @@ -4914,7 +4564,7 @@ void ui_draw_pie_center(uiBlock *block) draw_disk_shaded(angle - range / 2.0f, range, pie_confirm_radius, pie_confirm_external, subd, col, NULL, false); } - glDisable(GL_BLEND); + GPU_blend(false); gpuPopMatrix(); } @@ -4935,9 +4585,9 @@ void ui_draw_widget_back_color( uiWidgetType *wt = widget_type(type); if (use_shadow) { - glEnable(GL_BLEND); + GPU_blend(true); widget_softshadow(rect, UI_CNR_ALL, 0.25f * U.widget_unit); - glDisable(GL_BLEND); + GPU_blend(false); } rcti rect_copy = *rect; @@ -5034,9 +4684,9 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic height = ICON_SIZE_FROM_BUTRECT(rect); aspect = ICON_DEFAULT_HEIGHT / height; - glEnable(GL_BLEND); + GPU_blend(true); UI_icon_draw_aspect(xs, ys, iconid, aspect, 1.0f); /* XXX scale weak get from fstyle? */ - glDisable(GL_BLEND); + GPU_blend(false); } } @@ -5053,9 +4703,9 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int /* draw icon in rect above the space reserved for the label */ rect->ymin += text_size; - glEnable(GL_BLEND); + GPU_blend(true); widget_draw_preview(iconid, 1.0f, rect); - glDisable(GL_BLEND); + GPU_blend(false); BLF_width_and_height(fstyle->uifont_id, name, BLF_DRAW_STR_DUMMY_MAX, &font_dims[0], &font_dims[1]); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 8bd41b874f5..fb4d6e0ea14 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -48,9 +48,9 @@ #include "BKE_addon.h" #include "BKE_appdir.h" #include "BKE_colorband.h" -#include "BKE_DerivedMesh.h" #include "BKE_global.h" #include "BKE_main.h" +#include "BKE_mesh_runtime.h" #include "BIF_gl.h" @@ -62,6 +62,10 @@ #include "UI_interface_icons.h" #include "interface_intern.h" +#include "GPU_framebuffer.h" + + +extern const bTheme U_theme_default; /* global for themes */ typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha); @@ -734,146 +738,6 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo return (const unsigned char *)cp; } -/* use this call to init new bone color sets in Theme */ -static void ui_theme_init_boneColorSets(bTheme *btheme) -{ - int i; - - /* define default color sets - currently we only define 15 of these, though that should be ample */ - /* set 1 */ - rgba_char_args_set(btheme->tarm[0].solid, 0x9a, 0x00, 0x00, 255); - rgba_char_args_set(btheme->tarm[0].select, 0xbd, 0x11, 0x11, 255); - rgba_char_args_set(btheme->tarm[0].active, 0xf7, 0x0a, 0x0a, 255); - /* set 2 */ - rgba_char_args_set(btheme->tarm[1].solid, 0xf7, 0x40, 0x18, 255); - rgba_char_args_set(btheme->tarm[1].select, 0xf6, 0x69, 0x13, 255); - rgba_char_args_set(btheme->tarm[1].active, 0xfa, 0x99, 0x00, 255); - /* set 3 */ - rgba_char_args_set(btheme->tarm[2].solid, 0x1e, 0x91, 0x09, 255); - rgba_char_args_set(btheme->tarm[2].select, 0x59, 0xb7, 0x0b, 255); - rgba_char_args_set(btheme->tarm[2].active, 0x83, 0xef, 0x1d, 255); - /* set 4 */ - rgba_char_args_set(btheme->tarm[3].solid, 0x0a, 0x36, 0x94, 255); - rgba_char_args_set(btheme->tarm[3].select, 0x36, 0x67, 0xdf, 255); - rgba_char_args_set(btheme->tarm[3].active, 0x5e, 0xc1, 0xef, 255); - /* set 5 */ - rgba_char_args_set(btheme->tarm[4].solid, 0xa9, 0x29, 0x4e, 255); - rgba_char_args_set(btheme->tarm[4].select, 0xc1, 0x41, 0x6a, 255); - rgba_char_args_set(btheme->tarm[4].active, 0xf0, 0x5d, 0x91, 255); - /* set 6 */ - rgba_char_args_set(btheme->tarm[5].solid, 0x43, 0x0c, 0x78, 255); - rgba_char_args_set(btheme->tarm[5].select, 0x54, 0x3a, 0xa3, 255); - rgba_char_args_set(btheme->tarm[5].active, 0x87, 0x64, 0xd5, 255); - /* set 7 */ - rgba_char_args_set(btheme->tarm[6].solid, 0x24, 0x78, 0x5a, 255); - rgba_char_args_set(btheme->tarm[6].select, 0x3c, 0x95, 0x79, 255); - rgba_char_args_set(btheme->tarm[6].active, 0x6f, 0xb6, 0xab, 255); - /* set 8 */ - rgba_char_args_set(btheme->tarm[7].solid, 0x4b, 0x70, 0x7c, 255); - rgba_char_args_set(btheme->tarm[7].select, 0x6a, 0x86, 0x91, 255); - rgba_char_args_set(btheme->tarm[7].active, 0x9b, 0xc2, 0xcd, 255); - /* set 9 */ - rgba_char_args_set(btheme->tarm[8].solid, 0xf4, 0xc9, 0x0c, 255); - rgba_char_args_set(btheme->tarm[8].select, 0xee, 0xc2, 0x36, 255); - rgba_char_args_set(btheme->tarm[8].active, 0xf3, 0xff, 0x00, 255); - /* set 10 */ - rgba_char_args_set(btheme->tarm[9].solid, 0x1e, 0x20, 0x24, 255); - rgba_char_args_set(btheme->tarm[9].select, 0x48, 0x4c, 0x56, 255); - rgba_char_args_set(btheme->tarm[9].active, 0xff, 0xff, 0xff, 255); - /* set 11 */ - rgba_char_args_set(btheme->tarm[10].solid, 0x6f, 0x2f, 0x6a, 255); - rgba_char_args_set(btheme->tarm[10].select, 0x98, 0x45, 0xbe, 255); - rgba_char_args_set(btheme->tarm[10].active, 0xd3, 0x30, 0xd6, 255); - /* set 12 */ - rgba_char_args_set(btheme->tarm[11].solid, 0x6c, 0x8e, 0x22, 255); - rgba_char_args_set(btheme->tarm[11].select, 0x7f, 0xb0, 0x22, 255); - rgba_char_args_set(btheme->tarm[11].active, 0xbb, 0xef, 0x5b, 255); - /* set 13 */ - rgba_char_args_set(btheme->tarm[12].solid, 0x8d, 0x8d, 0x8d, 255); - rgba_char_args_set(btheme->tarm[12].select, 0xb0, 0xb0, 0xb0, 255); - rgba_char_args_set(btheme->tarm[12].active, 0xde, 0xde, 0xde, 255); - /* set 14 */ - rgba_char_args_set(btheme->tarm[13].solid, 0x83, 0x43, 0x26, 255); - rgba_char_args_set(btheme->tarm[13].select, 0x8b, 0x58, 0x11, 255); - rgba_char_args_set(btheme->tarm[13].active, 0xbd, 0x6a, 0x11, 255); - /* set 15 */ - rgba_char_args_set(btheme->tarm[14].solid, 0x08, 0x31, 0x0e, 255); - rgba_char_args_set(btheme->tarm[14].select, 0x1c, 0x43, 0x0b, 255); - rgba_char_args_set(btheme->tarm[14].active, 0x34, 0x62, 0x2b, 255); - - /* reset flags too */ - for (i = 0; i < 20; i++) - btheme->tarm[i].flag = 0; -} - -/* use this call to init new variables in themespace, if they're same for all */ -static void ui_theme_init_new_do(ThemeSpace *ts) -{ - rgba_char_args_set(ts->header_text, 0, 0, 0, 255); - rgba_char_args_set(ts->header_title, 0, 0, 0, 255); - rgba_char_args_set(ts->header_text_hi, 255, 255, 255, 255); - -#if 0 - rgba_char_args_set(ts->panel_text, 0, 0, 0, 255); - rgba_char_args_set(ts->panel_title, 0, 0, 0, 255); - rgba_char_args_set(ts->panel_text_hi, 255, 255, 255, 255); -#endif - - ts->panelcolors.show_back = false; - ts->panelcolors.show_header = false; - rgba_char_args_set(ts->panelcolors.back, 114, 114, 114, 128); - rgba_char_args_set(ts->panelcolors.header, 0, 0, 0, 25); - rgba_char_args_set(ts->panelcolors.sub_back, 0, 0, 0, 25); - - rgba_char_args_set(ts->button, 145, 145, 145, 245); - rgba_char_args_set(ts->button_title, 0, 0, 0, 255); - rgba_char_args_set(ts->button_text, 0, 0, 0, 255); - rgba_char_args_set(ts->button_text_hi, 255, 255, 255, 255); - - rgba_char_args_set(ts->list, 165, 165, 165, 255); - rgba_char_args_set(ts->list_title, 0, 0, 0, 255); - rgba_char_args_set(ts->list_text, 0, 0, 0, 255); - rgba_char_args_set(ts->list_text_hi, 255, 255, 255, 255); - - rgba_char_args_set(ts->tab_active, 114, 114, 114, 255); - rgba_char_args_set(ts->tab_inactive, 83, 83, 83, 255); - rgba_char_args_set(ts->tab_back, 64, 64, 64, 255); - rgba_char_args_set(ts->tab_outline, 60, 60, 60, 255); -} - -static void ui_theme_init_new(bTheme *btheme) -{ - ThemeSpace *ts; - - for (ts = UI_THEMESPACE_START(btheme); ts != UI_THEMESPACE_END(btheme); ts++) { - ui_theme_init_new_do(ts); - } -} - -static void ui_theme_space_init_handles_color(ThemeSpace *theme_space) -{ - rgba_char_args_set(theme_space->handle_free, 0, 0, 0, 255); - rgba_char_args_set(theme_space->handle_auto, 0x90, 0x90, 0x00, 255); - rgba_char_args_set(theme_space->handle_vect, 0x40, 0x90, 0x30, 255); - rgba_char_args_set(theme_space->handle_align, 0x80, 0x30, 0x60, 255); - rgba_char_args_set(theme_space->handle_sel_free, 0, 0, 0, 255); - rgba_char_args_set(theme_space->handle_sel_auto, 0xf0, 0xff, 0x40, 255); - rgba_char_args_set(theme_space->handle_sel_vect, 0x40, 0xc0, 0x30, 255); - rgba_char_args_set(theme_space->handle_sel_align, 0xf0, 0x90, 0xa0, 255); - rgba_char_args_set(theme_space->handle_vertex, 0x00, 0x00, 0x00, 0xff); - rgba_char_args_set(theme_space->handle_vertex_select, 0xff, 0xff, 0, 0xff); - rgba_char_args_set(theme_space->act_spline, 0xdb, 0x25, 0x12, 255); -} - -static void ui_theme_space_init_manipulator_colors(bTheme *btheme) -{ - rgba_char_args_set(btheme->tui.manipulator_hi, 255, 255, 255, 255); - rgba_char_args_set(btheme->tui.manipulator_primary, 222, 255, 13, 255); - rgba_char_args_set(btheme->tui.manipulator_secondary, 0, 255, 255, 255); - rgba_char_args_set(btheme->tui.manipulator_a, 23, 127, 23, 255); - rgba_char_args_set(btheme->tui.manipulator_b, 127, 23, 23, 255); -} - /** * initialize default theme * \note: when you add new colors, created & saved themes need initialized @@ -881,381 +745,17 @@ static void ui_theme_space_init_manipulator_colors(bTheme *btheme) */ void ui_theme_init_default(void) { - bTheme *btheme; /* we search for the theme with name Default */ - btheme = BLI_findstring(&U.themes, "Default", offsetof(bTheme, name)); - + bTheme *btheme = BLI_findstring(&U.themes, "Default", offsetof(bTheme, name)); if (btheme == NULL) { - btheme = MEM_callocN(sizeof(bTheme), "theme"); + btheme = MEM_callocN(sizeof(bTheme), __func__); BLI_addtail(&U.themes, btheme); - strcpy(btheme->name, "Default"); } UI_SetTheme(0, 0); /* make sure the global used in this file is set */ - /* UI buttons */ - ui_widget_color_init(&btheme->tui); - - btheme->tui.iconfile[0] = 0; - rgba_char_args_set(btheme->tui.wcol_tooltip.text, 255, 255, 255, 255); - rgba_char_args_set_fl(btheme->tui.widget_emboss, 1.0f, 1.0f, 1.0f, 0.02f); - rgba_char_args_set_fl(btheme->tui.editor_outline, 0.25f, 0.25f, 0.25f, 1.0f); - - rgba_char_args_set(btheme->tui.xaxis, 220, 0, 0, 255); - rgba_char_args_set(btheme->tui.yaxis, 0, 220, 0, 255); - rgba_char_args_set(btheme->tui.zaxis, 0, 0, 220, 255); - - btheme->tui.menu_shadow_fac = 0.5f; - btheme->tui.menu_shadow_width = 12; - - /* Bone Color Sets */ - ui_theme_init_boneColorSets(btheme); - - /* common (new) variables */ - ui_theme_init_new(btheme); - - /* Manipulator. */ - ui_theme_space_init_manipulator_colors(btheme); - - /* space view3d */ - rgba_char_args_set_fl(btheme->tv3d.back, 0.225, 0.225, 0.225, 1.0); - rgba_char_args_set(btheme->tv3d.text, 0, 0, 0, 255); - rgba_char_args_set(btheme->tv3d.text_hi, 255, 255, 255, 255); - - rgba_char_args_set_fl(btheme->tv3d.header, 0.45, 0.45, 0.45, 1.0); - rgba_char_args_set_fl(btheme->tv3d.button, 0.45, 0.45, 0.45, 0.5); -// rgba_char_args_set(btheme->tv3d.panel, 165, 165, 165, 127); - - rgba_char_args_set(btheme->tv3d.shade1, 160, 160, 160, 100); - rgba_char_args_set(btheme->tv3d.shade2, 0x7f, 0x70, 0x70, 100); - - rgba_char_args_set_fl(btheme->tv3d.grid, 0.251, 0.251, 0.251, 1.0); - rgba_char_args_set(btheme->tv3d.view_overlay, 0, 0, 0, 255); - rgba_char_args_set(btheme->tv3d.wire, 0x0, 0x0, 0x0, 255); - rgba_char_args_set(btheme->tv3d.wire_edit, 0x0, 0x0, 0x0, 255); - rgba_char_args_set(btheme->tv3d.lamp, 0, 0, 0, 40); - rgba_char_args_set(btheme->tv3d.speaker, 0, 0, 0, 255); - rgba_char_args_set(btheme->tv3d.camera, 0, 0, 0, 255); - rgba_char_args_set(btheme->tv3d.empty, 0, 0, 0, 255); - rgba_char_args_set(btheme->tv3d.select, 241, 88, 0, 255); - rgba_char_args_set(btheme->tv3d.active, 255, 170, 64, 255); - rgba_char_args_set(btheme->tv3d.group, 8, 48, 8, 255); - rgba_char_args_set(btheme->tv3d.group_active, 85, 187, 85, 255); - rgba_char_args_set(btheme->tv3d.transform, 0xff, 0xff, 0xff, 255); - rgba_char_args_set(btheme->tv3d.vertex, 0, 0, 0, 255); - rgba_char_args_set(btheme->tv3d.vertex_select, 255, 133, 0, 255); - rgba_char_args_set(btheme->tv3d.vertex_bevel, 0, 165, 255, 255); - rgba_char_args_set(btheme->tv3d.vertex_unreferenced, 0, 0, 0, 255); - btheme->tv3d.vertex_size = 3; - btheme->tv3d.outline_width = 1; - rgba_char_args_set(btheme->tv3d.edge, 0x0, 0x0, 0x0, 255); - rgba_char_args_set(btheme->tv3d.edge_select, 255, 160, 0, 255); - rgba_char_args_set(btheme->tv3d.edge_seam, 219, 37, 18, 255); - rgba_char_args_set(btheme->tv3d.edge_bevel, 0, 165, 255, 255); - rgba_char_args_set(btheme->tv3d.edge_facesel, 75, 75, 75, 255); - rgba_char_args_set(btheme->tv3d.face, 0, 0, 0, 18); - rgba_char_args_set(btheme->tv3d.face_select, 255, 133, 0, 60); - rgba_char_args_set(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255); - rgba_char_args_set(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255); - rgba_char_args_set(btheme->tv3d.loop_normal, 0xDD, 0x23, 0xDD, 255); - rgba_char_args_set(btheme->tv3d.face_dot, 255, 133, 0, 255); - rgba_char_args_set(btheme->tv3d.editmesh_active, 255, 255, 255, 128); - rgba_char_args_set_fl(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0); - rgba_char_args_set(btheme->tv3d.edge_sharp, 0, 255, 255, 255); - rgba_char_args_set(btheme->tv3d.header_text, 0, 0, 0, 255); - rgba_char_args_set(btheme->tv3d.header_text_hi, 255, 255, 255, 255); - rgba_char_args_set(btheme->tv3d.button_text, 0, 0, 0, 255); - rgba_char_args_set(btheme->tv3d.button_text_hi, 255, 255, 255, 255); - rgba_char_args_set(btheme->tv3d.button_title, 0, 0, 0, 255); - rgba_char_args_set(btheme->tv3d.title, 0, 0, 0, 255); - rgba_char_args_set(btheme->tv3d.freestyle_edge_mark, 0x7f, 0xff, 0x7f, 255); - rgba_char_args_set(btheme->tv3d.freestyle_face_mark, 0x7f, 0xff, 0x7f, 51); - rgba_char_args_set_fl(btheme->tv3d.paint_curve_handle, 0.5f, 1.0f, 0.5f, 0.5f); - rgba_char_args_set_fl(btheme->tv3d.paint_curve_pivot, 1.0f, 0.5f, 0.5f, 0.5f); - rgba_char_args_set(btheme->tv3d.gp_vertex, 0, 0, 0, 255); - rgba_char_args_set(btheme->tv3d.gp_vertex_select, 255, 133, 0, 255); - btheme->tv3d.gp_vertex_size = 3; - - btheme->tv3d.facedot_size = 4; - - rgba_char_args_set(btheme->tv3d.extra_edge_len, 32, 0, 0, 255); - rgba_char_args_set(btheme->tv3d.extra_edge_angle, 32, 32, 0, 255); - rgba_char_args_set(btheme->tv3d.extra_face_area, 0, 32, 0, 255); - rgba_char_args_set(btheme->tv3d.extra_face_angle, 0, 0, 128, 255); - - rgba_char_args_set(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255); - - rgba_char_args_set(btheme->tv3d.nurb_uline, 0x90, 0x90, 0x00, 255); - rgba_char_args_set(btheme->tv3d.nurb_vline, 0x80, 0x30, 0x60, 255); - rgba_char_args_set(btheme->tv3d.nurb_sel_uline, 0xf0, 0xff, 0x40, 255); - rgba_char_args_set(btheme->tv3d.nurb_sel_vline, 0xf0, 0x90, 0xa0, 255); - - ui_theme_space_init_handles_color(&btheme->tv3d); - - rgba_char_args_set(btheme->tv3d.act_spline, 0xdb, 0x25, 0x12, 255); - rgba_char_args_set(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255); - - rgba_char_args_set(btheme->tv3d.bone_solid, 200, 200, 200, 255); - /* alpha 80 is not meant editable, used for wire+action draw */ - rgba_char_args_set(btheme->tv3d.bone_pose, 80, 200, 255, 80); - rgba_char_args_set(btheme->tv3d.bone_pose_active, 140, 255, 255, 80); - - rgba_char_args_set(btheme->tv3d.bundle_solid, 200, 200, 200, 255); - rgba_char_args_set(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255); - - rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255); - rgba_char_args_set(btheme->tv3d.gradients.gradient, 0, 0, 0, 0); - rgba_char_args_set(btheme->tv3d.gradients.high_gradient, 58, 58, 58, 255); - btheme->tv3d.gradients.show_grad = false; - - rgba_char_args_set(btheme->tv3d.clipping_border_3d, 50, 50, 50, 255); - - rgba_char_args_set(btheme->tv3d.time_keyframe, 0xDD, 0xD7, 0x00, 0xFF); - rgba_char_args_set(btheme->tv3d.time_gp_keyframe, 0xB5, 0xE6, 0x1D, 0xFF); - - /* space buttons */ - /* to have something initialized */ - btheme->tbuts = btheme->tv3d; - - rgba_char_args_set_fl(btheme->tbuts.back, 0.45, 0.45, 0.45, 1.0); -// rgba_char_args_set(btheme->tbuts.panel, 0x82, 0x82, 0x82, 255); - - /* graph editor */ - btheme->tipo = btheme->tv3d; - rgba_char_args_set_fl(btheme->tipo.back, 0.42, 0.42, 0.42, 1.0); - rgba_char_args_set_fl(btheme->tipo.list, 0.4, 0.4, 0.4, 1.0); - rgba_char_args_set(btheme->tipo.grid, 94, 94, 94, 255); -// rgba_char_args_set(btheme->tipo.panel, 255, 255, 255, 150); - rgba_char_args_set(btheme->tipo.shade1, 150, 150, 150, 100); /* scrollbars */ - rgba_char_args_set(btheme->tipo.shade2, 0x70, 0x70, 0x70, 100); - rgba_char_args_set(btheme->tipo.vertex, 0, 0, 0, 255); - rgba_char_args_set(btheme->tipo.vertex_select, 255, 133, 0, 255); - rgba_char_args_set(btheme->tipo.hilite, 0x60, 0xc0, 0x40, 255); - btheme->tipo.vertex_size = 6; - - rgba_char_args_set(btheme->tipo.handle_vertex, 0, 0, 0, 255); - rgba_char_args_set(btheme->tipo.handle_vertex_select, 255, 133, 0, 255); - rgba_char_args_set(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255); - rgba_char_args_set(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255); - btheme->tipo.handle_vertex_size = 5; - - rgba_char_args_set(btheme->tipo.ds_channel, 82, 96, 110, 255); - rgba_char_args_set(btheme->tipo.ds_subchannel, 124, 137, 150, 255); - rgba_char_args_set(btheme->tipo.group, 79, 101, 73, 255); - rgba_char_args_set(btheme->tipo.group_active, 135, 177, 125, 255); - - /* dopesheet */ - btheme->tact = btheme->tipo; - rgba_char_args_set(btheme->tact.strip, 12, 10, 10, 128); - rgba_char_args_set(btheme->tact.strip_select, 255, 140, 0, 255); - - rgba_char_args_set(btheme->tact.anim_active, 204, 112, 26, 102); - - rgba_char_args_set(btheme->tact.keytype_keyframe, 232, 232, 232, 255); - rgba_char_args_set(btheme->tact.keytype_keyframe_select, 255, 190, 50, 255); - rgba_char_args_set(btheme->tact.keytype_extreme, 232, 179, 204, 255); - rgba_char_args_set(btheme->tact.keytype_extreme_select, 242, 128, 128, 255); - rgba_char_args_set(btheme->tact.keytype_breakdown, 179, 219, 232, 255); - rgba_char_args_set(btheme->tact.keytype_breakdown_select, 84, 191, 237, 255); - rgba_char_args_set(btheme->tact.keytype_jitter, 148, 229, 117, 255); - rgba_char_args_set(btheme->tact.keytype_jitter_select, 97, 192, 66, 255); - - rgba_char_args_set(btheme->tact.keyborder, 0, 0, 0, 255); - rgba_char_args_set(btheme->tact.keyborder_select, 0, 0, 0, 255); - - btheme->tact.keyframe_scale_fac = 1.0f; - - /* space nla */ - btheme->tnla = btheme->tact; - - rgba_char_args_set(btheme->tnla.anim_active, 204, 112, 26, 102); /* same as for dopesheet; duplicate here for easier reference */ - rgba_char_args_set(btheme->tnla.anim_non_active, 153, 135, 97, 77); - - rgba_char_args_set(btheme->tnla.nla_tweaking, 77, 243, 26, 77); - rgba_char_args_set(btheme->tnla.nla_tweakdupli, 217, 0, 0, 255); - - rgba_char_args_set(btheme->tnla.nla_transition, 28, 38, 48, 255); - rgba_char_args_set(btheme->tnla.nla_transition_sel, 46, 117, 219, 255); - rgba_char_args_set(btheme->tnla.nla_meta, 51, 38, 66, 255); - rgba_char_args_set(btheme->tnla.nla_meta_sel, 105, 33, 150, 255); - rgba_char_args_set(btheme->tnla.nla_sound, 43, 61, 61, 255); - rgba_char_args_set(btheme->tnla.nla_sound_sel, 31, 122, 122, 255); - - rgba_char_args_set(btheme->tnla.keyborder, 0, 0, 0, 255); - rgba_char_args_set(btheme->tnla.keyborder_select, 0, 0, 0, 255); - - /* space file */ - /* to have something initialized */ - btheme->tfile = btheme->tv3d; - rgba_char_args_set_fl(btheme->tfile.back, 0.3, 0.3, 0.3, 1); -// rgba_char_args_set_fl(btheme->tfile.panel, 0.3, 0.3, 0.3, 1); - rgba_char_args_set_fl(btheme->tfile.list, 0.4, 0.4, 0.4, 1); - rgba_char_args_set(btheme->tfile.text, 250, 250, 250, 255); - rgba_char_args_set(btheme->tfile.text_hi, 15, 15, 15, 255); -// rgba_char_args_set(btheme->tfile.panel, 145, 145, 145, 255); /* bookmark/ui regions */ - rgba_char_args_set(btheme->tfile.hilite, 255, 140, 25, 255); /* selected files */ - - rgba_char_args_set(btheme->tfile.image, 250, 250, 250, 255); - rgba_char_args_set(btheme->tfile.movie, 250, 250, 250, 255); - rgba_char_args_set(btheme->tfile.scene, 250, 250, 250, 255); - - - /* space seq */ - btheme->tseq = btheme->tv3d; - rgba_char_args_set(btheme->tseq.back, 116, 116, 116, 255); - rgba_char_args_set(btheme->tseq.movie, 81, 105, 135, 255); - rgba_char_args_set(btheme->tseq.movieclip, 32, 32, 143, 255); - rgba_char_args_set(btheme->tseq.mask, 152, 78, 62, 255); - rgba_char_args_set(btheme->tseq.image, 109, 88, 129, 255); - rgba_char_args_set(btheme->tseq.scene, 78, 152, 62, 255); - rgba_char_args_set(btheme->tseq.audio, 46, 143, 143, 255); - rgba_char_args_set(btheme->tseq.effect, 169, 84, 124, 255); - rgba_char_args_set(btheme->tseq.transition, 162, 95, 111, 255); - rgba_char_args_set(btheme->tseq.meta, 109, 145, 131, 255); - rgba_char_args_set(btheme->tseq.text_strip, 162, 151, 0, 255); - rgba_char_args_set(btheme->tseq.preview_back, 0, 0, 0, 255); - rgba_char_args_set(btheme->tseq.grid, 64, 64, 64, 255); - - /* space image */ - btheme->tima = btheme->tv3d; - rgba_char_args_set(btheme->tima.back, 53, 53, 53, 255); - rgba_char_args_set(btheme->tima.vertex, 0, 0, 0, 255); - rgba_char_args_set(btheme->tima.vertex_select, 255, 133, 0, 255); - rgba_char_args_set(btheme->tima.wire_edit, 192, 192, 192, 255); - rgba_char_args_set(btheme->tima.edge_select, 255, 133, 0, 255); - btheme->tima.vertex_size = 3; - btheme->tima.facedot_size = 3; - rgba_char_args_set(btheme->tima.face, 255, 255, 255, 10); - rgba_char_args_set(btheme->tima.face_select, 255, 133, 0, 60); - rgba_char_args_set(btheme->tima.editmesh_active, 255, 255, 255, 128); - rgba_char_args_set_fl(btheme->tima.preview_back, 0.0, 0.0, 0.0, 0.3); - rgba_char_args_set_fl(btheme->tima.preview_stitch_face, 0.5, 0.5, 0.0, 0.2); - rgba_char_args_set_fl(btheme->tima.preview_stitch_edge, 1.0, 0.0, 1.0, 0.2); - rgba_char_args_set_fl(btheme->tima.preview_stitch_vert, 0.0, 0.0, 1.0, 0.2); - rgba_char_args_set_fl(btheme->tima.preview_stitch_stitchable, 0.0, 1.0, 0.0, 1.0); - rgba_char_args_set_fl(btheme->tima.preview_stitch_unstitchable, 1.0, 0.0, 0.0, 1.0); - rgba_char_args_set_fl(btheme->tima.preview_stitch_active, 0.886, 0.824, 0.765, 0.140); - - rgba_char_args_test_set(btheme->tima.uv_others, 96, 96, 96, 255); - rgba_char_args_test_set(btheme->tima.uv_shadow, 112, 112, 112, 255); - - ui_theme_space_init_handles_color(&btheme->tima); - btheme->tima.handle_vertex_size = 5; - - /* space text */ - btheme->text = btheme->tv3d; - rgba_char_args_set(btheme->text.back, 153, 153, 153, 255); - rgba_char_args_set(btheme->text.shade1, 143, 143, 143, 255); - rgba_char_args_set(btheme->text.shade2, 0xc6, 0x77, 0x77, 255); - rgba_char_args_set(btheme->text.hilite, 255, 0, 0, 255); - - /* syntax highlighting */ - rgba_char_args_set(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/ - rgba_char_args_set(btheme->text.syntaxl, 100, 0, 0, 255); /* Strings Red */ - rgba_char_args_set(btheme->text.syntaxc, 0, 100, 50, 255); /* Comments Greenish */ - rgba_char_args_set(btheme->text.syntaxv, 95, 95, 0, 255); /* Special Yellow*/ - rgba_char_args_set(btheme->text.syntaxd, 50, 0, 140, 255); /* Decorator/Preprocessor Dir. Blue-purple */ - rgba_char_args_set(btheme->text.syntaxr, 140, 60, 0, 255); /* Reserved Orange*/ - rgba_char_args_set(btheme->text.syntaxb, 128, 0, 80, 255); /* Builtin Red-purple */ - rgba_char_args_set(btheme->text.syntaxs, 76, 76, 76, 255); /* Gray (mix between fg/bg) */ - - /* space oops */ - btheme->toops = btheme->tv3d; - rgba_char_args_set_fl(btheme->toops.back, 0.45, 0.45, 0.45, 1.0); - - rgba_char_args_set_fl(btheme->toops.match, 0.2, 0.5, 0.2, 0.3); /* highlighting search match - soft green*/ - rgba_char_args_set_fl(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3); - - /* space info */ - btheme->tinfo = btheme->tv3d; - rgba_char_args_set_fl(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0); - rgba_char_args_set(btheme->tinfo.info_selected, 96, 128, 255, 255); - rgba_char_args_set(btheme->tinfo.info_selected_text, 255, 255, 255, 255); - rgba_char_args_set(btheme->tinfo.info_error, 220, 0, 0, 255); - rgba_char_args_set(btheme->tinfo.info_error_text, 0, 0, 0, 255); - rgba_char_args_set(btheme->tinfo.info_warning, 220, 128, 96, 255); - rgba_char_args_set(btheme->tinfo.info_warning_text, 0, 0, 0, 255); - rgba_char_args_set(btheme->tinfo.info_info, 0, 170, 0, 255); - rgba_char_args_set(btheme->tinfo.info_info_text, 0, 0, 0, 255); - rgba_char_args_set(btheme->tinfo.info_debug, 196, 196, 196, 255); - rgba_char_args_set(btheme->tinfo.info_debug_text, 0, 0, 0, 255); - - /* space user preferences */ - btheme->tuserpref = btheme->tv3d; - rgba_char_args_set_fl(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0); - - /* space console */ - btheme->tconsole = btheme->tv3d; - rgba_char_args_set(btheme->tconsole.back, 0, 0, 0, 255); - rgba_char_args_set(btheme->tconsole.console_output, 96, 128, 255, 255); - rgba_char_args_set(btheme->tconsole.console_input, 255, 255, 255, 255); - rgba_char_args_set(btheme->tconsole.console_info, 0, 170, 0, 255); - rgba_char_args_set(btheme->tconsole.console_error, 220, 96, 96, 255); - rgba_char_args_set(btheme->tconsole.console_cursor, 220, 96, 96, 255); - rgba_char_args_set(btheme->tconsole.console_select, 255, 255, 255, 48); - - /* space time */ - btheme->ttime = btheme->tv3d; - rgba_char_args_set_fl(btheme->ttime.back, 0.45, 0.45, 0.45, 1.0); - rgba_char_args_set_fl(btheme->ttime.grid, 0.36, 0.36, 0.36, 1.0); - rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); /* sliders */ - - rgba_char_args_set(btheme->ttime.time_keyframe, 0xDD, 0xD7, 0x00, 0xFF); - rgba_char_args_set(btheme->ttime.time_gp_keyframe, 0xB5, 0xE6, 0x1D, 0xFF); - - /* space node, re-uses syntax and console color storage */ - btheme->tnode = btheme->tv3d; - rgba_char_args_set(btheme->tnode.syntaxr, 115, 115, 115, 255); /* wire inner color */ - rgba_char_args_set(btheme->tnode.edge_select, 255, 255, 255, 255); /* wire selected */ - rgba_char_args_set(btheme->tnode.syntaxl, 155, 155, 155, 160); /* TH_NODE, backdrop */ - rgba_char_args_set(btheme->tnode.syntaxn, 100, 100, 100, 255); /* in */ - rgba_char_args_set(btheme->tnode.nodeclass_output, 100, 100, 100, 255); /* output */ - rgba_char_args_set(btheme->tnode.syntaxb, 108, 105, 111, 255); /* operator */ - rgba_char_args_set(btheme->tnode.syntaxv, 104, 106, 117, 255); /* generator */ - rgba_char_args_set(btheme->tnode.syntaxc, 105, 117, 110, 255); /* group */ - rgba_char_args_set(btheme->tnode.nodeclass_texture, 108, 105, 111, 255); /* operator */ - rgba_char_args_set(btheme->tnode.nodeclass_shader, 108, 105, 111, 255); /* operator */ - rgba_char_args_set(btheme->tnode.nodeclass_filter, 108, 105, 111, 255); /* operator */ - rgba_char_args_set(btheme->tnode.nodeclass_script, 108, 105, 111, 255); /* operator */ - rgba_char_args_set(btheme->tnode.nodeclass_pattern, 108, 105, 111, 255); /* operator */ - rgba_char_args_set(btheme->tnode.nodeclass_vector, 108, 105, 111, 255); /* operator */ - rgba_char_args_set(btheme->tnode.nodeclass_layout, 108, 105, 111, 255); /* operator */ - rgba_char_args_set(btheme->tnode.movie, 155, 155, 155, 160); /* frame */ - rgba_char_args_set(btheme->tnode.syntaxs, 151, 116, 116, 255); /* matte nodes */ - rgba_char_args_set(btheme->tnode.syntaxd, 116, 151, 151, 255); /* distort nodes */ - rgba_char_args_set(btheme->tnode.console_output, 223, 202, 53, 255); /* interface nodes */ - btheme->tnode.noodle_curving = 5; - - /* space clip */ - btheme->tclip = btheme->tv3d; - - rgba_char_args_set(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255); - rgba_char_args_set(btheme->tclip.marker, 0x7f, 0x7f, 0x00, 255); - rgba_char_args_set(btheme->tclip.act_marker, 0xff, 0xff, 0xff, 255); - rgba_char_args_set(btheme->tclip.sel_marker, 0xff, 0xff, 0x00, 255); - rgba_char_args_set(btheme->tclip.dis_marker, 0x7f, 0x00, 0x00, 255); - rgba_char_args_set(btheme->tclip.lock_marker, 0x7f, 0x7f, 0x7f, 255); - rgba_char_args_set(btheme->tclip.path_before, 0xff, 0x00, 0x00, 255); - rgba_char_args_set(btheme->tclip.path_after, 0x00, 0x00, 0xff, 255); - rgba_char_args_set(btheme->tclip.grid, 0x5e, 0x5e, 0x5e, 255); - rgba_char_args_set(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255); - rgba_char_args_set(btheme->tclip.list, 0x66, 0x66, 0x66, 0xff); - rgba_char_args_set(btheme->tclip.strip, 0x0c, 0x0a, 0x0a, 0x80); - rgba_char_args_set(btheme->tclip.strip_select, 0xff, 0x8c, 0x00, 0xff); - btheme->tclip.handle_vertex_size = 5; - ui_theme_space_init_handles_color(&btheme->tclip); - - /* space topbar */ - char tmp[4]; - btheme->ttopbar = btheme->tv3d; - /* swap colors */ - copy_v4_v4_char(tmp, btheme->ttopbar.header); - copy_v4_v4_char(btheme->ttopbar.header, btheme->ttopbar.tab_inactive); - copy_v4_v4_char(btheme->ttopbar.back, tmp); - - /* space statusbar */ - btheme->tstatusbar = btheme->tv3d; + memcpy(btheme, &U_theme_default, sizeof(*btheme)); } void ui_style_init_default(void) @@ -1775,14 +1275,14 @@ void UI_ThemeClearColor(int colorid) float col[3]; UI_GetThemeColor3fv(colorid, col); - glClearColor(col[0], col[1], col[2], 0.0f); + GPU_clear_color(col[0], col[1], col[2], 0.0f); } void UI_ThemeClearColorAlpha(int colorid, float alpha) { float col[3]; UI_GetThemeColor3fv(colorid, col); - glClearColor(col[0], col[1], col[2], alpha); + GPU_clear_color(col[0], col[1], col[2], alpha); } @@ -1856,9 +1356,9 @@ void init_userdef_do_versions(Main *bmain) U.fcu_inactive_alpha = 0.25f; } - /* signal for derivedmesh to use colorband */ + /* signal for evaluated mesh to use colorband */ /* run in case this was on and is now off in the user prefs [#28096] */ - vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, UI_GetTheme()->tv3d.vertex_unreferenced); + BKE_mesh_runtime_color_band_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, UI_GetTheme()->tv3d.vertex_unreferenced); if (!USER_VERSION_ATLEAST(192, 0)) { strcpy(U.sounddir, "/"); @@ -1871,121 +1371,19 @@ void init_userdef_do_versions(Main *bmain) /* added seam, normal color, undo */ if (!USER_VERSION_ATLEAST(235, 0)) { - bTheme *btheme; - U.uiflag |= USER_GLOBALUNDO; if (U.undosteps == 0) U.undosteps = 32; - - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* check for (alpha == 0) is safe, then color was never set */ - if (btheme->tv3d.edge_seam[3] == 0) { - rgba_char_args_set(btheme->tv3d.edge_seam, 230, 150, 50, 255); - } - if (btheme->tv3d.normal[3] == 0) { - rgba_char_args_set(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255); - } - if (btheme->tv3d.vertex_normal[3] == 0) { - rgba_char_args_set(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255); - } - if (btheme->tv3d.face_dot[3] == 0) { - rgba_char_args_set(btheme->tv3d.face_dot, 255, 138, 48, 255); - btheme->tv3d.facedot_size = 4; - } - } } if (!USER_VERSION_ATLEAST(236, 0)) { /* illegal combo... */ if (U.flag & USER_LMOUSESELECT) U.flag &= ~USER_TWOBUTTONMOUSE; } - if (!USER_VERSION_ATLEAST(237, 0)) { - bTheme *btheme; - /* new space type */ - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* check for (alpha == 0) is safe, then color was never set */ - if (btheme->ttime.back[3] == 0) { - /* copied from ui_theme_init_default */ - btheme->ttime = btheme->tv3d; - rgba_char_args_set_fl(btheme->ttime.back, 0.45, 0.45, 0.45, 1.0); - rgba_char_args_set_fl(btheme->ttime.grid, 0.36, 0.36, 0.36, 1.0); - rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); /* sliders */ - } - if (btheme->text.syntaxn[3] == 0) { - rgba_char_args_set(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/ - rgba_char_args_set(btheme->text.syntaxl, 100, 0, 0, 255); /* Strings red */ - rgba_char_args_set(btheme->text.syntaxc, 0, 100, 50, 255); /* Comments greenish */ - rgba_char_args_set(btheme->text.syntaxv, 95, 95, 0, 255); /* Special */ - rgba_char_args_set(btheme->text.syntaxb, 128, 0, 80, 255); /* Builtin, red-purple */ - } - } - } - if (!USER_VERSION_ATLEAST(238, 0)) { - bTheme *btheme; - /* bone colors */ - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* check for alpha==0 is safe, then color was never set */ - if (btheme->tv3d.bone_solid[3] == 0) { - rgba_char_args_set(btheme->tv3d.bone_solid, 200, 200, 200, 255); - rgba_char_args_set(btheme->tv3d.bone_pose, 80, 200, 255, 80); - } - } - } - if (!USER_VERSION_ATLEAST(239, 0)) { - bTheme *btheme; - /* bone colors */ - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* check for alpha==0 is safe, then color was never set */ - if (btheme->tnla.strip[3] == 0) { - rgba_char_args_set(btheme->tnla.strip_select, 0xff, 0xff, 0xaa, 255); - rgba_char_args_set(btheme->tnla.strip, 0xe4, 0x9c, 0xc6, 255); - } - } - } if (!USER_VERSION_ATLEAST(240, 0)) { - bTheme *btheme; - - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* Lamp theme, check for alpha==0 is safe, then color was never set */ - if (btheme->tv3d.lamp[3] == 0) { - rgba_char_args_set(btheme->tv3d.lamp, 0, 0, 0, 40); -/* TEMPORAL, remove me! (ton) */ - U.uiflag |= USER_PLAINMENUS; - } - - } + U.uiflag |= USER_PLAINMENUS; if (U.obcenter_dia == 0) U.obcenter_dia = 6; } if (!USER_VERSION_ATLEAST(242, 0)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* Node editor theme, check for alpha==0 is safe, then color was never set */ - if (btheme->tnode.syntaxn[3] == 0) { - /* re-uses syntax color storage */ - btheme->tnode = btheme->tv3d; - rgba_char_args_set(btheme->tnode.edge_select, 255, 255, 255, 255); - rgba_char_args_set(btheme->tnode.syntaxl, 150, 150, 150, 255); /* TH_NODE, backdrop */ - rgba_char_args_set(btheme->tnode.syntaxn, 129, 131, 144, 255); /* in/output */ - rgba_char_args_set(btheme->tnode.syntaxb, 127, 127, 127, 255); /* operator */ - rgba_char_args_set(btheme->tnode.syntaxv, 142, 138, 145, 255); /* generator */ - rgba_char_args_set(btheme->tnode.syntaxc, 120, 145, 120, 255); /* group */ - } - /* Group theme colors */ - if (btheme->tv3d.group[3] == 0) { - rgba_char_args_set(btheme->tv3d.group, 0x0C, 0x30, 0x0C, 255); - rgba_char_args_set(btheme->tv3d.group_active, 0x66, 0xFF, 0x66, 255); - } - /* Sequence editor theme*/ - if (btheme->tseq.movie[3] == 0) { - rgba_char_args_set(btheme->tseq.movie, 81, 105, 135, 255); - rgba_char_args_set(btheme->tseq.image, 109, 88, 129, 255); - rgba_char_args_set(btheme->tseq.scene, 78, 152, 62, 255); - rgba_char_args_set(btheme->tseq.audio, 46, 143, 143, 255); - rgba_char_args_set(btheme->tseq.effect, 169, 84, 124, 255); - rgba_char_args_set(btheme->tseq.transition, 162, 95, 111, 255); - rgba_char_args_set(btheme->tseq.meta, 109, 145, 131, 255); - } - } - /* set defaults for 3D View rotating axis indicator */ /* since size can't be set to 0, this indicates it's not saved in startup.blend */ if (U.rvisize == 0) { @@ -1995,119 +1393,18 @@ void init_userdef_do_versions(Main *bmain) } } - if (!USER_VERSION_ATLEAST(243, 0)) { - bTheme *btheme; - - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* long keyframe color */ - /* check for alpha==0 is safe, then color was never set */ - if (btheme->tact.strip[3] == 0) { - rgba_char_args_set(btheme->tv3d.edge_sharp, 255, 32, 32, 255); - rgba_char_args_set(btheme->tact.strip_select, 0xff, 0xff, 0xaa, 204); - rgba_char_args_set(btheme->tact.strip, 0xe4, 0x9c, 0xc6, 204); - } - - /* IPO-Editor - Vertex Size*/ - if (btheme->tipo.vertex_size == 0) { - btheme->tipo.vertex_size = 3; - } - } - } if (!USER_VERSION_ATLEAST(244, 0)) { /* set default number of recently-used files (if not set) */ if (U.recent_files == 0) U.recent_files = 10; } if (!USER_VERSION_ATLEAST(245, 3)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_set(btheme->tv3d.editmesh_active, 255, 255, 255, 128); - } if (U.coba_weight.tot == 0) BKE_colorband_init(&U.coba_weight, true); } if (!USER_VERSION_ATLEAST(245, 3)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* these should all use the same color */ - rgba_char_args_set(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255); - rgba_char_args_set(btheme->tipo.cframe, 0x60, 0xc0, 0x40, 255); - rgba_char_args_set(btheme->tact.cframe, 0x60, 0xc0, 0x40, 255); - rgba_char_args_set(btheme->tnla.cframe, 0x60, 0xc0, 0x40, 255); - rgba_char_args_set(btheme->tseq.cframe, 0x60, 0xc0, 0x40, 255); - //rgba_char_args_set(btheme->tsnd.cframe, 0x60, 0xc0, 0x40, 255); Not needed anymore - rgba_char_args_set(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255); - } - } - if (!USER_VERSION_ATLEAST(245, 3)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* action channel groups (recolor anyway) */ - rgba_char_args_set(btheme->tact.group, 0x39, 0x7d, 0x1b, 255); - rgba_char_args_set(btheme->tact.group_active, 0x7d, 0xe9, 0x60, 255); - - /* bone custom-color sets */ - if (btheme->tarm[0].solid[3] == 0) - ui_theme_init_boneColorSets(btheme); - } - } - if (!USER_VERSION_ATLEAST(245, 3)) { U.flag |= USER_ADD_VIEWALIGNED | USER_ADD_EDITMODE; } - if (!USER_VERSION_ATLEAST(245, 3)) { - bTheme *btheme; - - /* adjust themes */ - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - const char *col; - - /* IPO Editor: Handles/Vertices */ - col = btheme->tipo.vertex; - rgba_char_args_set(btheme->tipo.handle_vertex, col[0], col[1], col[2], 255); - col = btheme->tipo.vertex_select; - rgba_char_args_set(btheme->tipo.handle_vertex_select, col[0], col[1], col[2], 255); - btheme->tipo.handle_vertex_size = btheme->tipo.vertex_size; - - /* Sequence/Image Editor: colors for GPencil text */ - col = btheme->tv3d.bone_pose; - rgba_char_args_set(btheme->tseq.bone_pose, col[0], col[1], col[2], 255); - rgba_char_args_set(btheme->tima.bone_pose, col[0], col[1], col[2], 255); - col = btheme->tv3d.vertex_select; - rgba_char_args_set(btheme->tseq.vertex_select, col[0], col[1], col[2], 255); - } - } if (!USER_VERSION_ATLEAST(250, 0)) { - bTheme *btheme; - - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* this was not properly initialized in 2.45 */ - if (btheme->tima.face_dot[3] == 0) { - rgba_char_args_set(btheme->tima.editmesh_active, 255, 255, 255, 128); - rgba_char_args_set(btheme->tima.face_dot, 255, 133, 0, 255); - btheme->tima.facedot_size = 2; - } - - /* DopeSheet - (Object) Channel color */ - rgba_char_args_set(btheme->tact.ds_channel, 82, 96, 110, 255); - rgba_char_args_set(btheme->tact.ds_subchannel, 124, 137, 150, 255); - /* DopeSheet - Group Channel color (saner version) */ - rgba_char_args_set(btheme->tact.group, 79, 101, 73, 255); - rgba_char_args_set(btheme->tact.group_active, 135, 177, 125, 255); - - /* Graph Editor - (Object) Channel color */ - rgba_char_args_set(btheme->tipo.ds_channel, 82, 96, 110, 255); - rgba_char_args_set(btheme->tipo.ds_subchannel, 124, 137, 150, 255); - /* Graph Editor - Group Channel color */ - rgba_char_args_set(btheme->tipo.group, 79, 101, 73, 255); - rgba_char_args_set(btheme->tipo.group_active, 135, 177, 125, 255); - - /* Nla Editor - (Object) Channel color */ - rgba_char_args_set(btheme->tnla.ds_channel, 82, 96, 110, 255); - rgba_char_args_set(btheme->tnla.ds_subchannel, 124, 137, 150, 255); - /* NLA Editor - New Strip colors */ - rgba_char_args_set(btheme->tnla.strip, 12, 10, 10, 128); - rgba_char_args_set(btheme->tnla.strip_select, 255, 140, 0, 255); - } - /* adjust grease-pencil distances */ U.gp_manhattendist = 1; U.gp_euclideandist = 2; @@ -2116,22 +1413,6 @@ void init_userdef_do_versions(Main *bmain) U.ipo_new = BEZT_IPO_BEZ; } - if (!USER_VERSION_ATLEAST(250, 1)) { - bTheme *btheme; - - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - - /* common (new) variables, it checks for alpha==0 */ - ui_theme_init_new(btheme); - - if (btheme->tui.wcol_num.outline[3] == 0) - ui_widget_color_init(&btheme->tui); - - rgba_char_args_set_fl(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0); - rgba_char_args_set_fl(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0); - } - } - if (!USER_VERSION_ATLEAST(250, 3)) { /* new audio system */ if (U.audiochannels == 0) @@ -2194,66 +1475,8 @@ void init_userdef_do_versions(Main *bmain) U.flag &= ~USER_TWOBUTTONMOUSE; } if (!USER_VERSION_ATLEAST(252, 4)) { - bTheme *btheme; - /* default new handle type is auto handles */ U.keyhandles_new = HD_AUTO; - - /* init new curve colors */ - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - ui_theme_space_init_handles_color(&btheme->tv3d); - ui_theme_space_init_handles_color(&btheme->tipo); - - /* edge crease */ - rgba_char_args_set_fl(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0); - } - } - if (!USER_VERSION_ATLEAST(253, 0)) { - bTheme *btheme; - - /* init new curve colors */ - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - if (btheme->tv3d.lastsel_point[3] == 0) - rgba_char_args_set(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255); - } - } - if (!USER_VERSION_ATLEAST(252, 5)) { - bTheme *btheme; - - /* interface_widgets.c */ - struct uiWidgetColors wcol_progress = { - {0, 0, 0, 255}, - {190, 190, 190, 255}, - {100, 100, 100, 180}, - {128, 128, 128, 255}, - - {0, 0, 0, 255}, - {255, 255, 255, 255}, - - 0, - 5, -5 - }; - - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* init progress bar theme */ - btheme->tui.wcol_progress = wcol_progress; - } - } - - if (!USER_VERSION_ATLEAST(255, 2)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_set(btheme->tv3d.extra_edge_len, 32, 0, 0, 255); - rgba_char_args_set(btheme->tv3d.extra_face_angle, 0, 32, 0, 255); - rgba_char_args_set(btheme->tv3d.extra_face_area, 0, 0, 128, 255); - } - } - - if (!USER_VERSION_ATLEAST(256, 4)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - if ((btheme->tv3d.outline_width) == 0) btheme->tv3d.outline_width = 1; - } } if (!USER_VERSION_ATLEAST(257, 0)) { @@ -2262,226 +1485,22 @@ void init_userdef_do_versions(Main *bmain) U.autokey_flag &= ~AUTOKEY_FLAG_ONLYKEYINGSET; } - if (!USER_VERSION_ATLEAST(258, 2)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - btheme->tnode.noodle_curving = 5; - } - } - - if (!USER_VERSION_ATLEAST(259, 1)) { - bTheme *btheme; - - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - btheme->tv3d.speaker[3] = 255; - } - } - if (!USER_VERSION_ATLEAST(260, 3)) { - bTheme *btheme; - /* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead * was changed in 260 as part of GSoC11, but version patch was wrong */ if (U.keyhandles_new == HD_AUTO) U.keyhandles_new = HD_AUTO_ANIM; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - if (btheme->tv3d.bundle_solid[3] == 0) - rgba_char_args_set(btheme->tv3d.bundle_solid, 200, 200, 200, 255); - - if (btheme->tv3d.camera_path[3] == 0) - rgba_char_args_set(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255); - - if ((btheme->tclip.back[3]) == 0) { - btheme->tclip = btheme->tv3d; - - rgba_char_args_set(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255); - rgba_char_args_set(btheme->tclip.marker, 0x7f, 0x7f, 0x00, 255); - rgba_char_args_set(btheme->tclip.act_marker, 0xff, 0xff, 0xff, 255); - rgba_char_args_set(btheme->tclip.sel_marker, 0xff, 0xff, 0x00, 255); - rgba_char_args_set(btheme->tclip.dis_marker, 0x7f, 0x00, 0x00, 255); - rgba_char_args_set(btheme->tclip.lock_marker, 0x7f, 0x7f, 0x7f, 255); - rgba_char_args_set(btheme->tclip.path_before, 0xff, 0x00, 0x00, 255); - rgba_char_args_set(btheme->tclip.path_after, 0x00, 0x00, 0xff, 255); - rgba_char_args_set(btheme->tclip.grid, 0x5e, 0x5e, 0x5e, 255); - rgba_char_args_set(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255); - rgba_char_args_set(btheme->tclip.handle_vertex, 0x00, 0x00, 0x00, 0xff); - rgba_char_args_set(btheme->tclip.handle_vertex_select, 0xff, 0xff, 0, 0xff); - btheme->tclip.handle_vertex_size = 5; - } - - /* auto-clamped handles -> based on auto */ - if (btheme->tipo.handle_auto_clamped[3] == 0) - rgba_char_args_set(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255); - if (btheme->tipo.handle_sel_auto_clamped[3] == 0) - rgba_char_args_set(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255); - } - /* enable (Cycles) addon by default */ BKE_addon_ensure(&U.addons, "cycles"); } - if (!USER_VERSION_ATLEAST(260, 5)) { - bTheme *btheme; - - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_set(btheme->tui.panel.header, 0, 0, 0, 25); - btheme->tui.icon_alpha = 1.0; - } - } - if (!USER_VERSION_ATLEAST(261, 4)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_set_fl(btheme->tima.preview_stitch_face, 0.071, 0.259, 0.694, 0.150); - rgba_char_args_set_fl(btheme->tima.preview_stitch_edge, 1.0, 0.522, 0.0, 0.7); - rgba_char_args_set_fl(btheme->tima.preview_stitch_vert, 1.0, 0.522, 0.0, 0.5); - rgba_char_args_set_fl(btheme->tima.preview_stitch_stitchable, 0.0, 1.0, 0.0, 1.0); - rgba_char_args_set_fl(btheme->tima.preview_stitch_unstitchable, 1.0, 0.0, 0.0, 1.0); - rgba_char_args_set_fl(btheme->tima.preview_stitch_active, 0.886, 0.824, 0.765, 0.140); - - rgba_char_args_set_fl(btheme->toops.match, 0.2, 0.5, 0.2, 0.3); - rgba_char_args_set_fl(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3); - } - U.use_16bit_textures = true; } - if (!USER_VERSION_ATLEAST(262, 2)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - if (btheme->tui.wcol_menu_item.item[3] == 255) - rgba_char_args_set(btheme->tui.wcol_menu_item.item, 172, 172, 172, 128); - } - } - - if (!USER_VERSION_ATLEAST(262, 3)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - if (btheme->tui.wcol_tooltip.inner[3] == 0) { - btheme->tui.wcol_tooltip = btheme->tui.wcol_menu_back; - } - if (btheme->tui.wcol_tooltip.text[0] == 160) { /* hrmf */ - rgba_char_args_set(btheme->tui.wcol_tooltip.text, 255, 255, 255, 255); - } - } - } - - if (!USER_VERSION_ATLEAST(262, 4)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - if (btheme->tseq.movieclip[3] == 0) { - rgba_char_args_set(btheme->tseq.movieclip, 32, 32, 143, 255); - } - } - } - - if (!USER_VERSION_ATLEAST(263, 2)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - if (btheme->tclip.strip[0] == 0) { - rgba_char_args_set(btheme->tclip.list, 0x66, 0x66, 0x66, 0xff); - rgba_char_args_set(btheme->tclip.strip, 0x0c, 0x0a, 0x0a, 0x80); - rgba_char_args_set(btheme->tclip.strip_select, 0xff, 0x8c, 0x00, 0xff); - } - } - } - - if (!USER_VERSION_ATLEAST(263, 6)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) - rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255); - } - - if (!USER_VERSION_ATLEAST(263, 7)) { - bTheme *btheme; - - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* DopeSheet Summary */ - rgba_char_args_set(btheme->tact.anim_active, 204, 112, 26, 102); - - /* NLA Colors */ - rgba_char_args_set(btheme->tnla.anim_active, 204, 112, 26, 102); /* same as dopesheet above */ - rgba_char_args_set(btheme->tnla.anim_non_active, 153, 135, 97, 77); - - rgba_char_args_set(btheme->tnla.nla_tweaking, 77, 243, 26, 77); - rgba_char_args_set(btheme->tnla.nla_tweakdupli, 217, 0, 0, 255); - - rgba_char_args_set(btheme->tnla.nla_transition, 28, 38, 48, 255); - rgba_char_args_set(btheme->tnla.nla_transition_sel, 46, 117, 219, 255); - rgba_char_args_set(btheme->tnla.nla_meta, 51, 38, 66, 255); - rgba_char_args_set(btheme->tnla.nla_meta_sel, 105, 33, 150, 255); - rgba_char_args_set(btheme->tnla.nla_sound, 43, 61, 61, 255); - rgba_char_args_set(btheme->tnla.nla_sound_sel, 31, 122, 122, 255); - } - } - - if (!USER_VERSION_ATLEAST(263, 11)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - if (btheme->tseq.mask[3] == 0) { - rgba_char_args_set(btheme->tseq.mask, 152, 78, 62, 255); - } - } - } - - if (!USER_VERSION_ATLEAST(263, 15)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_set(btheme->tv3d.bone_pose_active, 140, 255, 255, 80); - } - } - - if (!USER_VERSION_ATLEAST(263, 16)) { - bTheme *btheme; - - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - if (btheme->tact.anim_active[3] == 0) - rgba_char_args_set(btheme->tact.anim_active, 204, 112, 26, 102); - - if (btheme->tnla.anim_active[3] == 0) - rgba_char_args_set(btheme->tnla.anim_active, 204, 112, 26, 102); - } - } - - if (!USER_VERSION_ATLEAST(263, 22)) { - bTheme *btheme; - - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - if (btheme->tipo.lastsel_point[3] == 0) - rgba_char_args_set(btheme->tipo.lastsel_point, 0xff, 0xff, 0xff, 255); - - if (btheme->tv3d.skin_root[3] == 0) - rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255); - } - } - - if (!USER_VERSION_ATLEAST(264, 9)) { - bTheme *btheme; - - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_set(btheme->tui.xaxis, 220, 0, 0, 255); - rgba_char_args_set(btheme->tui.yaxis, 0, 220, 0, 255); - rgba_char_args_set(btheme->tui.zaxis, 0, 0, 220, 255); - } - } - if (!USER_VERSION_ATLEAST(267, 0)) { - /* Freestyle color settings */ - bTheme *btheme; - - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* check for alpha == 0 is safe, then color was never set */ - if (btheme->tv3d.freestyle_edge_mark[3] == 0) { - rgba_char_args_set(btheme->tv3d.freestyle_edge_mark, 0x7f, 0xff, 0x7f, 255); - rgba_char_args_set(btheme->tv3d.freestyle_face_mark, 0x7f, 0xff, 0x7f, 51); - } - - if (btheme->tv3d.wire_edit[3] == 0) { - rgba_char_args_set(btheme->tv3d.wire_edit, 0x0, 0x0, 0x0, 255); - } - } /* GL Texture Garbage Collection */ if (U.textimeout == 0) { @@ -2494,10 +1513,6 @@ void init_userdef_do_versions(Main *bmain) if (U.dbl_click_time == 0) { U.dbl_click_time = 350; } - if (U.scrcastfps == 0) { - U.scrcastfps = 10; - U.scrcastwait = 50; - } if (U.v2d_min_gridsize == 0) { U.v2d_min_gridsize = 35; } @@ -2523,175 +1538,12 @@ void init_userdef_do_versions(Main *bmain) U.tweak_threshold = 10; } - if (!USER_VERSION_ATLEAST(265, 1)) { - bTheme *btheme; - - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* note: the toggle operator for transparent backdrops limits to these spacetypes */ - if (btheme->tnode.button[3] == 255) { - btheme->tv3d.button[3] = 128; - btheme->tnode.button[3] = 128; - btheme->tima.button[3] = 128; - btheme->tseq.button[3] = 128; - btheme->tclip.button[3] = 128; - } - } - } - - /* panel header/backdrop supported locally per editor now */ - if (!USER_VERSION_ATLEAST(265, 2)) { - bTheme *btheme; - - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - ThemeSpace *ts; - - /* new color, panel backdrop. Not used anywhere yet, until you enable it */ - copy_v3_v3_char(btheme->tui.panel.back, btheme->tbuts.button); - btheme->tui.panel.back[3] = 128; - - for (ts = UI_THEMESPACE_START(btheme); ts != UI_THEMESPACE_END(btheme); ts++) { - ts->panelcolors = btheme->tui.panel; - } - } - } - /* NOTE!! from now on use U.versionfile and U.subversionfile */ #undef USER_VERSION_ATLEAST #define USER_VERSION_ATLEAST(ver, subver) MAIN_VERSION_ATLEAST((&(U)), ver, subver) - if (!USER_VERSION_ATLEAST(266, 0)) { - bTheme *btheme; - - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* rna definition limits fac to 0.01 */ - if (btheme->tui.menu_shadow_fac == 0.0f) { - btheme->tui.menu_shadow_fac = 0.5f; - btheme->tui.menu_shadow_width = 12; - } - } - } - - if (!USER_VERSION_ATLEAST(265, 4)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_set(btheme->text.syntaxd, 50, 0, 140, 255); /* Decorator/Preprocessor Dir. Blue-purple */ - rgba_char_args_set(btheme->text.syntaxr, 140, 60, 0, 255); /* Reserved Orange */ - rgba_char_args_set(btheme->text.syntaxs, 76, 76, 76, 255); /* Gray (mix between fg/bg) */ - } - } - - if (!USER_VERSION_ATLEAST(265, 6)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - copy_v4_v4_char(btheme->tv3d.gradients.high_gradient, btheme->tv3d.back); - } - } - - if (!USER_VERSION_ATLEAST(265, 9)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_test_set(btheme->tnode.syntaxs, 151, 116, 116, 255); /* matte nodes */ - rgba_char_args_test_set(btheme->tnode.syntaxd, 116, 151, 151, 255); /* distort nodes */ - } - } - - if (!USER_VERSION_ATLEAST(265, 11)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_test_set(btheme->tconsole.console_select, 255, 255, 255, 48); - } - } - - if (!USER_VERSION_ATLEAST(266, 2)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_test_set(btheme->tnode.console_output, 223, 202, 53, 255); /* interface nodes */ - } - } - - if (!USER_VERSION_ATLEAST(268, 3)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_test_set(btheme->tima.uv_others, 96, 96, 96, 255); - rgba_char_args_test_set(btheme->tima.uv_shadow, 112, 112, 112, 255); - } - } - - if (!USER_VERSION_ATLEAST(269, 5)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_set(btheme->tima.wire_edit, 192, 192, 192, 255); - rgba_char_args_set(btheme->tima.edge_select, 255, 133, 0, 255); - } - } - - if (!USER_VERSION_ATLEAST(269, 6)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - char r, g, b; - r = btheme->tnode.syntaxn[0]; - g = btheme->tnode.syntaxn[1]; - b = btheme->tnode.syntaxn[2]; - rgba_char_args_test_set(btheme->tnode.nodeclass_output, r, g, b, 255); - r = btheme->tnode.syntaxb[0]; - g = btheme->tnode.syntaxb[1]; - b = btheme->tnode.syntaxb[2]; - rgba_char_args_test_set(btheme->tnode.nodeclass_filter, r, g, b, 255); - rgba_char_args_test_set(btheme->tnode.nodeclass_vector, r, g, b, 255); - rgba_char_args_test_set(btheme->tnode.nodeclass_texture, r, g, b, 255); - rgba_char_args_test_set(btheme->tnode.nodeclass_shader, r, g, b, 255); - rgba_char_args_test_set(btheme->tnode.nodeclass_script, r, g, b, 255); - rgba_char_args_test_set(btheme->tnode.nodeclass_pattern, r, g, b, 255); - rgba_char_args_test_set(btheme->tnode.nodeclass_layout, r, g, b, 255); - } - } - - if (!USER_VERSION_ATLEAST(269, 8)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_test_set(btheme->tinfo.info_selected, 96, 128, 255, 255); - rgba_char_args_test_set(btheme->tinfo.info_selected_text, 255, 255, 255, 255); - rgba_char_args_test_set(btheme->tinfo.info_error, 220, 0, 0, 255); - rgba_char_args_test_set(btheme->tinfo.info_error_text, 0, 0, 0, 255); - rgba_char_args_test_set(btheme->tinfo.info_warning, 220, 128, 96, 255); - rgba_char_args_test_set(btheme->tinfo.info_warning_text, 0, 0, 0, 255); - rgba_char_args_test_set(btheme->tinfo.info_info, 0, 170, 0, 255); - rgba_char_args_test_set(btheme->tinfo.info_info_text, 0, 0, 0, 255); - rgba_char_args_test_set(btheme->tinfo.info_debug, 196, 196, 196, 255); - rgba_char_args_test_set(btheme->tinfo.info_debug_text, 0, 0, 0, 255); - } - } if (!USER_VERSION_ATLEAST(269, 9)) { - bTheme *btheme; - /* Action Editor (and NLA Editor) - Keyframe Colors */ - /* Graph Editor - larger vertex size defaults */ - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* Action Editor ................. */ - /* key types */ - rgba_char_args_set(btheme->tact.keytype_keyframe, 232, 232, 232, 255); - rgba_char_args_set(btheme->tact.keytype_keyframe_select, 255, 190, 50, 255); - rgba_char_args_set(btheme->tact.keytype_extreme, 232, 179, 204, 255); - rgba_char_args_set(btheme->tact.keytype_extreme_select, 242, 128, 128, 255); - rgba_char_args_set(btheme->tact.keytype_breakdown, 179, 219, 232, 255); - rgba_char_args_set(btheme->tact.keytype_breakdown_select, 84, 191, 237, 255); - rgba_char_args_set(btheme->tact.keytype_jitter, 148, 229, 117, 255); - rgba_char_args_set(btheme->tact.keytype_jitter_select, 97, 192, 66, 255); - - /* key border */ - rgba_char_args_set(btheme->tact.keyborder, 0, 0, 0, 255); - rgba_char_args_set(btheme->tact.keyborder_select, 0, 0, 0, 255); - - /* NLA ............................ */ - /* key border */ - rgba_char_args_set(btheme->tnla.keyborder, 0, 0, 0, 255); - rgba_char_args_set(btheme->tnla.keyborder_select, 0, 0, 0, 255); - - /* Graph Editor ................... */ - btheme->tipo.vertex_size = 6; - btheme->tipo.handle_vertex_size = 5; - } - /* grease pencil - new layer color */ if (U.gpencil_new_layer_col[3] < 0.1f) { /* defaults to black, but must at least be visible! */ @@ -2699,139 +1551,10 @@ void init_userdef_do_versions(Main *bmain) } } - if (!USER_VERSION_ATLEAST(269, 10)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - ThemeSpace *ts; - - for (ts = UI_THEMESPACE_START(btheme); ts != UI_THEMESPACE_END(btheme); ts++) { - rgba_char_args_set(ts->tab_active, 114, 114, 114, 255); - rgba_char_args_set(ts->tab_inactive, 83, 83, 83, 255); - rgba_char_args_set(ts->tab_back, 64, 64, 64, 255); - rgba_char_args_set(ts->tab_outline, 60, 60, 60, 255); - } - } - } - - if (!USER_VERSION_ATLEAST(271, 0)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_set(btheme->tui.wcol_tooltip.text, 255, 255, 255, 255); - } - } - - if (!USER_VERSION_ATLEAST(272, 2)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_set_fl(btheme->tv3d.paint_curve_handle, 0.5f, 1.0f, 0.5f, 0.5f); - rgba_char_args_set_fl(btheme->tv3d.paint_curve_pivot, 1.0f, 0.5f, 0.5f, 0.5f); - rgba_char_args_set_fl(btheme->tima.paint_curve_handle, 0.5f, 1.0f, 0.5f, 0.5f); - rgba_char_args_set_fl(btheme->tima.paint_curve_pivot, 1.0f, 0.5f, 0.5f, 0.5f); - rgba_char_args_set(btheme->tnode.syntaxr, 115, 115, 115, 255); - } - } - if (!USER_VERSION_ATLEAST(271, 5)) { - bTheme *btheme; - - struct uiWidgetColors wcol_pie_menu = { - {10, 10, 10, 200}, - {25, 25, 25, 230}, - {140, 140, 140, 255}, - {45, 45, 45, 230}, - - {160, 160, 160, 255}, - {255, 255, 255, 255}, - - 1, - 10, -10 - }; - U.pie_menu_radius = 100; U.pie_menu_threshold = 12; U.pie_animation_timeout = 6; - - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - btheme->tui.wcol_pie_menu = wcol_pie_menu; - - ui_theme_space_init_handles_color(&btheme->tclip); - ui_theme_space_init_handles_color(&btheme->tima); - btheme->tima.handle_vertex_size = 5; - btheme->tclip.handle_vertex_size = 5; - } - } - - if (!USER_VERSION_ATLEAST(271, 6)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* check for (alpha == 0) is safe, then color was never set */ - if (btheme->tv3d.loop_normal[3] == 0) { - rgba_char_args_set(btheme->tv3d.loop_normal, 0xDD, 0x23, 0xDD, 255); - } - } - } - - if (!USER_VERSION_ATLEAST(272, 3)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_set_fl(btheme->tui.widget_emboss, 1.0f, 1.0f, 1.0f, 0.02f); - } - } - - if (!USER_VERSION_ATLEAST(273, 1)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* Grease Pencil vertex settings */ - rgba_char_args_set(btheme->tv3d.gp_vertex, 0, 0, 0, 255); - rgba_char_args_set(btheme->tv3d.gp_vertex_select, 255, 133, 0, 255); - btheme->tv3d.gp_vertex_size = 3; - - rgba_char_args_set(btheme->tseq.gp_vertex, 0, 0, 0, 255); - rgba_char_args_set(btheme->tseq.gp_vertex_select, 255, 133, 0, 255); - btheme->tseq.gp_vertex_size = 3; - - rgba_char_args_set(btheme->tima.gp_vertex, 0, 0, 0, 255); - rgba_char_args_set(btheme->tima.gp_vertex_select, 255, 133, 0, 255); - btheme->tima.gp_vertex_size = 3; - - rgba_char_args_set(btheme->tnode.gp_vertex, 0, 0, 0, 255); - rgba_char_args_set(btheme->tnode.gp_vertex_select, 255, 133, 0, 255); - btheme->tnode.gp_vertex_size = 3; - } - } - - if (!USER_VERSION_ATLEAST(273, 5)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - unsigned char *cp = (unsigned char *)btheme->tv3d.clipping_border_3d; - int c; - copy_v4_v4_char((char *)cp, btheme->tv3d.back); - c = cp[0] - 8; - CLAMP(c, 0, 255); - cp[0] = c; - c = cp[1] - 8; - CLAMP(c, 0, 255); - cp[1] = c; - c = cp[2] - 8; - CLAMP(c, 0, 255); - cp[2] = c; - cp[3] = 255; - } - } - - if (!USER_VERSION_ATLEAST(274, 5)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - copy_v4_v4_char(btheme->tima.metadatatext, btheme->tima.text_hi); - copy_v4_v4_char(btheme->tseq.metadatatext, btheme->tseq.text_hi); - } - } - - if (!USER_VERSION_ATLEAST(275, 1)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - copy_v4_v4_char(btheme->tclip.metadatatext, btheme->tseq.text_hi); - } } if (!USER_VERSION_ATLEAST(275, 2)) { @@ -2842,85 +1565,12 @@ void init_userdef_do_versions(Main *bmain) U.node_margin = 80; } - if (!USER_VERSION_ATLEAST(276, 1)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_set_fl(btheme->tima.preview_back, 0.0f, 0.0f, 0.0f, 0.3f); - } - } - - if (!USER_VERSION_ATLEAST(276, 2)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_set(btheme->tclip.gp_vertex, 0, 0, 0, 255); - rgba_char_args_set(btheme->tclip.gp_vertex_select, 255, 133, 0, 255); - btheme->tclip.gp_vertex_size = 3; - } - } - - if (!USER_VERSION_ATLEAST(276, 3)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_set(btheme->tseq.text_strip, 162, 151, 0, 255); - } - } - - if (!USER_VERSION_ATLEAST(276, 8)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_set(btheme->tui.wcol_progress.item, 128, 128, 128, 255); - } - } - - if (!USER_VERSION_ATLEAST(276, 10)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - /* 3dView Keyframe Indicators */ - rgba_char_args_set(btheme->tv3d.time_keyframe, 0xDD, 0xD7, 0x00, 0xFF); - rgba_char_args_set(btheme->tv3d.time_gp_keyframe, 0xB5, 0xE6, 0x1D, 0xFF); - } - } - - if (!USER_VERSION_ATLEAST(277, 0)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - if (memcmp(btheme->tui.wcol_list_item.item, btheme->tui.wcol_list_item.text_sel, sizeof(char) * 3) == 0) { - copy_v4_v4_char(btheme->tui.wcol_list_item.item, btheme->tui.wcol_text.item); - copy_v4_v4_char(btheme->tui.wcol_list_item.text_sel, btheme->tui.wcol_text.text_sel); - } - } - } - - if (!USER_VERSION_ATLEAST(277, 2)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - if (btheme->tact.keyframe_scale_fac < 0.1f) - btheme->tact.keyframe_scale_fac = 1.0f; - } - } - - if (!USER_VERSION_ATLEAST(278, 2)) { - bTheme *btheme; - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - rgba_char_args_set(btheme->tv3d.vertex_bevel, 0, 165, 255, 255); - rgba_char_args_set(btheme->tv3d.edge_bevel, 0, 165, 255, 255); - } - } - - if (!USER_VERSION_ATLEAST(278, 3)) { - for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { - /* Keyframe Indicators (were using wrong alpha) */ - btheme->tv3d.time_keyframe[3] = btheme->tv3d.time_gp_keyframe[3] = 255; - btheme->ttime.time_keyframe[3] = btheme->ttime.time_gp_keyframe[3] = 255; - } - } - if (!USER_VERSION_ATLEAST(278, 6)) { /* Clear preference flags for re-use. */ U.flag &= ~( USER_FLAG_DEPRECATED_1 | USER_FLAG_DEPRECATED_2 | USER_FLAG_DEPRECATED_3 | USER_FLAG_DEPRECATED_6 | USER_FLAG_DEPRECATED_7 | - USER_FLAG_DEPRECATED_9 | USER_FLAG_DEPRECATED_10); + USER_FLAG_DEPRECATED_9 | USER_DEVELOPER_UI); U.uiflag &= ~( USER_UIFLAG_DEPRECATED_7); U.transopts &= ~( @@ -2930,110 +1580,16 @@ void init_userdef_do_versions(Main *bmain) U.uiflag |= USER_LOCK_CURSOR_ADJUST; } - if (!USER_VERSION_ATLEAST(280, 9)) { - /* interface_widgets.c */ - struct uiWidgetColors wcol_tab = { - {60, 60, 60, 255}, - {83, 83, 83, 255}, - {114, 114, 114, 255}, - {90, 90, 90, 255}, - - {0, 0, 0, 255}, - {0, 0, 0, 255}, - - 0, - 0, 0 - }; - for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { - char tmp[4]; - - btheme->tui.wcol_tab = wcol_tab; - btheme->ttopbar = btheme->tv3d; - /* swap colors */ - copy_v4_v4_char(tmp, btheme->ttopbar.header); - copy_v4_v4_char(btheme->ttopbar.header, btheme->ttopbar.tab_inactive); - copy_v4_v4_char(btheme->ttopbar.back, tmp); - } - } - - if (!USER_VERSION_ATLEAST(280, 9)) { - /* Timeline removal */ - for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { - if (btheme->tipo.anim_active[3] == 0) { - rgba_char_args_set(btheme->tipo.anim_active, 204, 112, 26, 102); - } - if (btheme->tseq.anim_active[3] == 0) { - rgba_char_args_set(btheme->tseq.anim_active, 204, 112, 26, 102); - } - } - } + if (!USER_VERSION_ATLEAST(280, 20)) { + U.gpu_viewport_quality = 0.6f; - if (!USER_VERSION_ATLEAST(280, 10)) { - /* Roundness */ + /* Reset theme, old themes will not be compatible with minor version updates from now on. */ for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { - btheme->tui.wcol_regular.roundness = 0.25f; - btheme->tui.wcol_tool.roundness = 0.2f; - btheme->tui.wcol_text.roundness = 0.2f; - btheme->tui.wcol_radio.roundness = 0.2f; - btheme->tui.wcol_option.roundness = 0.333333f; - btheme->tui.wcol_toggle.roundness = 0.25f; - btheme->tui.wcol_num.roundness = 0.5f; - btheme->tui.wcol_numslider.roundness = 0.5f; - btheme->tui.wcol_tab.roundness = 0.25f; - btheme->tui.wcol_menu.roundness = 0.2f; - btheme->tui.wcol_pulldown.roundness = 0.2f; - btheme->tui.wcol_menu_back.roundness = 0.25f; - btheme->tui.wcol_menu_item.roundness = 0.25f; - btheme->tui.wcol_tooltip.roundness = 0.25f; - btheme->tui.wcol_box.roundness = 0.2f; - btheme->tui.wcol_scroll.roundness = 0.5f; - btheme->tui.wcol_progress.roundness = 0.25f; - btheme->tui.wcol_list_item.roundness = 0.2f; - btheme->tui.wcol_pie_menu.roundness = 0.5f; - rgba_char_args_set_fl(btheme->tui.editor_outline, 0.25f, 0.25f, 0.25f, 1.0f); + memcpy(btheme, &U_theme_default, sizeof(*btheme)); } } - if (((bTheme *)U.themes.first)->tui.wcol_toolbar_item.text[3] == 0) { - struct uiWidgetColors wcol_toolbar_item = { - .outline = {0x0, 0x0, 0x0, 0xff}, - .inner = {0x46, 0x46, 0x46, 0xff}, - .inner_sel = {0xcc, 0xcc, 0xcc, 0xff}, - .item = {0x0, 0x0, 0x0, 0xff}, - - .text = {0xff, 0xff, 0xff, 0xff}, - .text_sel = {0x33, 0x33, 0x33, 0xff}, - - .shaded = 0, - .shadetop = 0, - .shadedown = 0, - .alpha_check = 0, - .roundness = 0.3f, - }; - for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { - btheme->tui.wcol_toolbar_item = wcol_toolbar_item; - btheme->tui.icon_saturation = 1.0f; - } - } - - if (!USER_VERSION_ATLEAST(280, 16)) { - for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { - btheme->tstatusbar = btheme->tv3d; - } - } - - if (!USER_VERSION_ATLEAST(280, 17)) { - for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { - ThemeSpace *ts; - - for (ts = UI_THEMESPACE_START(btheme); ts != UI_THEMESPACE_END(btheme); ts++) { - rgba_char_args_set(ts->panelcolors.sub_back, 0, 0, 0, 25); - } - } - U.gpu_viewport_antialias = USER_AA_FXAA; - } - /** * Include next version bump. */ @@ -3041,12 +1597,6 @@ void init_userdef_do_versions(Main *bmain) /* (keep this block even if it becomes empty). */ } - if (((bTheme *)U.themes.first)->tui.manipulator_hi[3] == 0) { - for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { - ui_theme_space_init_manipulator_colors(btheme); - } - } - if (U.pixelsize == 0.0f) U.pixelsize = 1.0f; diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 530a6e28860..fc282e50ce2 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -51,6 +51,7 @@ #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "WM_api.h" @@ -1535,7 +1536,7 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); - glLineWidth(1.0f); + GPU_line_width(1.0f); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); immBeginAtMost(GWN_PRIM_LINES, vertex_count); @@ -1754,9 +1755,10 @@ View2DScrollers *UI_view2d_scrollers_calc( scrollers->yclamp = yclamp; scrollers->yunits = yunits; - scrollers->grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, - xunits, xclamp, yunits, yclamp, - BLI_rcti_size_x(&hor), BLI_rcti_size_y(&vert)); + scrollers->grid = UI_view2d_grid_calc( + CTX_data_scene(C), v2d, + xunits, xclamp, yunits, yclamp, + BLI_rcti_size_x(&hor), BLI_rcti_size_y(&vert)); } /* return scrollers */ @@ -2131,12 +2133,14 @@ void UI_view2d_listview_visible_cells( /* using 'cur' rect coordinates, call the cell-getting function to get the cells for this */ if (v2d) { /* min */ - UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty, - v2d->cur.xmin, v2d->cur.ymin, column_min, row_min); + UI_view2d_listview_view_to_cell( + v2d, columnwidth, rowheight, startx, starty, + v2d->cur.xmin, v2d->cur.ymin, column_min, row_min); /* max*/ - UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty, - v2d->cur.xmax, v2d->cur.ymax, column_max, row_max); + UI_view2d_listview_view_to_cell( + v2d, columnwidth, rowheight, startx, starty, + v2d->cur.xmax, v2d->cur.ymax, column_max, row_max); } } @@ -2546,8 +2550,9 @@ 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, - v2s->str, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw_default( + (float)(v2s->mval[0] + xofs), (float)(v2s->mval[1] + yofs), 0.0, + v2s->str, BLF_DRAW_STR_DUMMY_MAX); else { BLF_enable(font_id, BLF_CLIPPING); BLF_clipping(font_id, v2s->rect.xmin - 4, v2s->rect.ymin - 4, v2s->rect.xmax + 4, v2s->rect.ymax + 4); @@ -2566,5 +2571,3 @@ void UI_view2d_text_cache_draw(ARegion *ar) /* ******************************************************** */ - - diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index b9e6d43aa87..dfc401c1635 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -33,6 +33,7 @@ #include "MEM_guardedalloc.h" #include "DNA_userdef_types.h" +#include "DNA_windowmanager_types.h" #include "BLI_blenlib.h" #include "BLI_utildefines.h" @@ -53,7 +54,7 @@ #include "PIL_time.h" /* USER_ZOOM_CONT */ -static int view2d_poll(bContext *C) +static bool view2d_poll(bContext *C) { ARegion *ar = CTX_wm_region(C); @@ -128,7 +129,7 @@ static int view_pan_init(bContext *C, wmOperator *op) } #ifdef WITH_INPUT_NDOF -static int view_pan_poll(bContext *C) +static bool view_pan_poll(bContext *C) { ARegion *ar = CTX_wm_region(C); View2D *v2d; @@ -182,9 +183,10 @@ static void view_pan_apply(bContext *C, wmOperator *op) { v2dViewPanData *vpd = op->customdata; - view_pan_apply_ex(C, vpd, - RNA_int_get(op->ptr, "deltax"), - RNA_int_get(op->ptr, "deltay")); + view_pan_apply_ex( + C, vpd, + RNA_int_get(op->ptr, "deltax"), + RNA_int_get(op->ptr, "deltay")); } @@ -604,7 +606,7 @@ static int view_zoomdrag_init(bContext *C, wmOperator *op) } /* check if step-zoom can be applied */ -static int view_zoom_poll(bContext *C) +static bool view_zoom_poll(bContext *C) { ARegion *ar = CTX_wm_region(C); View2D *v2d; @@ -735,9 +737,10 @@ static void view_zoomstep_apply_ex( static void view_zoomstep_apply(bContext *C, wmOperator *op) { v2dViewZoomData *vzd = op->customdata; - view_zoomstep_apply_ex(C, vzd, true, - RNA_float_get(op->ptr, "zoomfacx"), - RNA_float_get(op->ptr, "zoomfacy")); + view_zoomstep_apply_ex( + C, vzd, true, + RNA_float_get(op->ptr, "zoomfacx"), + RNA_float_get(op->ptr, "zoomfacy")); } /* --------------- Individual Operators ------------------- */ @@ -790,9 +793,10 @@ static int view_zoomin_invoke(bContext *C, wmOperator *op, const wmEvent *event) ARegion *ar = CTX_wm_region(C); /* store initial mouse position (in view space) */ - UI_view2d_region_to_view(&ar->v2d, - event->mval[0], event->mval[1], - &vzd->mx_2d, &vzd->my_2d); + UI_view2d_region_to_view( + &ar->v2d, + event->mval[0], event->mval[1], + &vzd->mx_2d, &vzd->my_2d); } return view_zoomin_exec(C, op); @@ -855,9 +859,10 @@ static int view_zoomout_invoke(bContext *C, wmOperator *op, const wmEvent *event ARegion *ar = CTX_wm_region(C); /* store initial mouse position (in view space) */ - UI_view2d_region_to_view(&ar->v2d, - event->mval[0], event->mval[1], - &vzd->mx_2d, &vzd->my_2d); + UI_view2d_region_to_view( + &ar->v2d, + event->mval[0], event->mval[1], + &vzd->mx_2d, &vzd->my_2d); } return view_zoomout_exec(C, op); @@ -1065,9 +1070,10 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even ARegion *ar = CTX_wm_region(C); /* store initial mouse position (in view space) */ - UI_view2d_region_to_view(&ar->v2d, - event->mval[0], event->mval[1], - &vzd->mx_2d, &vzd->my_2d); + UI_view2d_region_to_view( + &ar->v2d, + event->mval[0], event->mval[1], + &vzd->mx_2d, &vzd->my_2d); } if (v2d->keepofs & V2D_LOCKOFS_X) @@ -1354,9 +1360,10 @@ static int view2d_ndof_invoke(bContext *C, wmOperator *op, const wmEvent *event) vzd = op->customdata; - view_zoomstep_apply_ex(C, vzd, false, - do_zoom_xy[0] ? zoom_factor : 0.0f, - do_zoom_xy[1] ? zoom_factor : 0.0f); + view_zoomstep_apply_ex( + C, vzd, false, + do_zoom_xy[0] ? zoom_factor : 0.0f, + do_zoom_xy[1] ? zoom_factor : 0.0f); view_zoomstep_exit(op); } @@ -1401,14 +1408,18 @@ struct SmoothView2DStore { */ static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b) { - const float size_a[2] = {BLI_rctf_size_x(rect_a), - BLI_rctf_size_y(rect_a)}; - const float size_b[2] = {BLI_rctf_size_x(rect_b), - BLI_rctf_size_y(rect_b)}; - const float cent_a[2] = {BLI_rctf_cent_x(rect_a), - BLI_rctf_cent_y(rect_a)}; - const float cent_b[2] = {BLI_rctf_cent_x(rect_b), - BLI_rctf_cent_y(rect_b)}; + const float size_a[2] = { + BLI_rctf_size_x(rect_a), + BLI_rctf_size_y(rect_a)}; + const float size_b[2] = { + BLI_rctf_size_x(rect_b), + BLI_rctf_size_y(rect_b)}; + const float cent_a[2] = { + BLI_rctf_cent_x(rect_a), + BLI_rctf_cent_y(rect_a)}; + const float cent_b[2] = { + BLI_rctf_cent_x(rect_b), + BLI_rctf_cent_y(rect_b)}; float fac_max = 0.0f; float tfac; @@ -1667,6 +1678,21 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_ return SCROLLHANDLE_BAR; } +static bool scroller_activate_poll(bContext *C) +{ + if (!view2d_poll(C)) { + return false; + } + + wmWindow *win = CTX_wm_window(C); + ARegion *ar = CTX_wm_region(C); + View2D *v2d = &ar->v2d; + wmEvent *event = win->eventstate; + + /* check if mouse in scrollbars, if they're enabled */ + return (UI_view2d_mouse_in_scrollers(ar, v2d, event->x, event->y) != 0); +} + /* initialize customdata for scroller manipulation operator */ static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *event, short in_scroller) { @@ -1708,9 +1734,10 @@ static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *e vsm->fac_round = (BLI_rctf_size_x(&v2d->cur)) / (float)(BLI_rcti_size_x(&ar->winrct) + 1); /* get 'zone' (i.e. which part of scroller is activated) */ - vsm->zone = mouse_in_scroller_handle(event->mval[0], - v2d->hor.xmin, v2d->hor.xmax, - scrollers->hor_min, scrollers->hor_max); + vsm->zone = mouse_in_scroller_handle( + event->mval[0], + v2d->hor.xmin, v2d->hor.xmax, + scrollers->hor_min, scrollers->hor_max); if ((v2d->keepzoom & V2D_LOCKZOOM_X) && ELEM(vsm->zone, SCROLLHANDLE_MIN, SCROLLHANDLE_MAX)) { /* default to scroll, as handles not usable */ @@ -1729,9 +1756,10 @@ static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *e vsm->fac_round = (BLI_rctf_size_y(&v2d->cur)) / (float)(BLI_rcti_size_y(&ar->winrct) + 1); /* get 'zone' (i.e. which part of scroller is activated) */ - vsm->zone = mouse_in_scroller_handle(event->mval[1], - v2d->vert.ymin, v2d->vert.ymax, - scrollers->vert_min, scrollers->vert_max); + vsm->zone = mouse_in_scroller_handle( + event->mval[1], + v2d->vert.ymin, v2d->vert.ymax, + scrollers->vert_min, scrollers->vert_max); if ((v2d->keepzoom & V2D_LOCKZOOM_Y) && ELEM(vsm->zone, SCROLLHANDLE_MIN, SCROLLHANDLE_MAX)) { /* default to scroll, as handles not usable */ @@ -1997,7 +2025,7 @@ static void VIEW2D_OT_scroller_activate(wmOperatorType *ot) ot->modal = scroller_activate_modal; ot->cancel = scroller_activate_cancel; - ot->poll = view2d_poll; + ot->poll = scroller_activate_poll; } /* ********************************************************* */ @@ -2184,4 +2212,3 @@ void ED_keymap_view2d(wmKeyConfig *keyconf) 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); } - diff --git a/source/blender/editors/lattice/editlattice_tools.c b/source/blender/editors/lattice/editlattice_tools.c index bf60c1e7da6..c6ba0237a68 100644 --- a/source/blender/editors/lattice/editlattice_tools.c +++ b/source/blender/editors/lattice/editlattice_tools.c @@ -56,7 +56,7 @@ /** \name Make Regular Operator * \{ */ -static int make_regular_poll(bContext *C) +static bool make_regular_poll(bContext *C) { Object *ob; diff --git a/source/blender/editors/manipulator_library/manipulator_draw_utils.c b/source/blender/editors/manipulator_library/manipulator_draw_utils.c index 430841311aa..a0b226b7502 100644 --- a/source/blender/editors/manipulator_library/manipulator_draw_utils.c +++ b/source/blender/editors/manipulator_library/manipulator_draw_utils.c @@ -41,6 +41,7 @@ #include "GPU_batch.h" #include "GPU_glew.h" #include "GPU_immediate.h" +#include "GPU_state.h" #include "MEM_guardedalloc.h" @@ -104,13 +105,13 @@ void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const boo * since it causes issues leaving the GL state modified. */ #if 0 glEnable(GL_CULL_FACE); - glEnable(GL_DEPTH_TEST); + GPU_depth_test(true); #endif GWN_batch_draw(batch); #if 0 - glDisable(GL_DEPTH_TEST); + GPU_depth_test(false); glDisable(GL_CULL_FACE); #endif diff --git a/source/blender/editors/manipulator_library/manipulator_library_intern.h b/source/blender/editors/manipulator_library/manipulator_library_intern.h index 01ca217fc0a..55db99236e0 100644 --- a/source/blender/editors/manipulator_library/manipulator_library_intern.h +++ b/source/blender/editors/manipulator_library/manipulator_library_intern.h @@ -109,4 +109,3 @@ void wm_manipulator_vec_draw( #endif /* __MANIPULATOR_LIBRARY_INTERN_H__ */ - diff --git a/source/blender/editors/manipulator_library/manipulator_library_presets.c b/source/blender/editors/manipulator_library/manipulator_library_presets.c index cccf484f29d..12f07611722 100644 --- a/source/blender/editors/manipulator_library/manipulator_library_presets.c +++ b/source/blender/editors/manipulator_library/manipulator_library_presets.c @@ -148,4 +148,3 @@ void ED_manipulator_draw_preset_facemap( GPU_select_load_id(-1); } } - diff --git a/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c index 749e92e25fb..5acf1ab2d64 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c @@ -44,6 +44,7 @@ #include "GPU_draw.h" #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "MEM_guardedalloc.h" @@ -103,20 +104,20 @@ static void manipulator_arrow2d_draw(const bContext *UNUSED(C), wmManipulator *m manipulator_color_get(mpr, mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT, color); - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); WM_manipulator_calc_matrix_final(mpr, matrix_final); - glEnable(GL_BLEND); + GPU_blend(true); arrow2d_draw_geom(mpr, matrix_final, color); - glDisable(GL_BLEND); + GPU_blend(false); if (mpr->interaction_data) { ManipulatorInteraction *inter = mpr->interaction_data; - glEnable(GL_BLEND); + GPU_blend(true); arrow2d_draw_geom(mpr, inter->init_matrix_final, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); - glDisable(GL_BLEND); + GPU_blend(false); } } diff --git a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c index 8516b9d8244..a5bcef7ed5e 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c @@ -51,6 +51,7 @@ #include "GPU_immediate_util.h" #include "GPU_matrix.h" #include "GPU_select.h" +#include "GPU_state.h" #include "MEM_guardedalloc.h" @@ -118,7 +119,7 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, {-unitx, unity, 0}, }; - glLineWidth(arrow->manipulator.line_width); + GPU_line_width(arrow->manipulator.line_width); wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_LOOP); } else { @@ -133,7 +134,7 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, }; if (draw_options & ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM) { - glLineWidth(arrow->manipulator.line_width); + GPU_line_width(arrow->manipulator.line_width); wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_STRIP); } else { @@ -197,9 +198,9 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons gpuPushMatrix(); gpuMultMatrix(matrix_final); - glEnable(GL_BLEND); + GPU_blend(true); arrow_draw_geom(arrow, select, color); - glDisable(GL_BLEND); + GPU_blend(false); gpuPopMatrix(); @@ -210,9 +211,9 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons gpuMultMatrix(inter->init_matrix_final); - glEnable(GL_BLEND); + GPU_blend(true); arrow_draw_geom(arrow, select, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); - glDisable(GL_BLEND); + GPU_blend(false); gpuPopMatrix(); } diff --git a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c index 86c3b4a09de..db33f457056 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c @@ -45,6 +45,7 @@ #include "GPU_matrix.h" #include "GPU_select.h" #include "GPU_batch.h" +#include "GPU_state.h" #include "RNA_access.h" #include "RNA_define.h" @@ -80,7 +81,7 @@ typedef struct ButtonManipulator2D { static void button2d_geom_draw_backdrop( const wmManipulator *mpr, const float color[4], const bool select) { - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -138,7 +139,7 @@ static void button2d_draw_intern( uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv(color); - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); immUniformColor4fv(color); immBegin(GWN_PRIM_LINE_STRIP, 2); immVertex3fv(pos, matrix_final[3]); @@ -168,11 +169,11 @@ static void button2d_draw_intern( } else { - glEnable(GL_BLEND); + GPU_blend(true); if (button->shape_batch[0] != NULL) { - glEnable(GL_LINE_SMOOTH); - glDisable(GL_POLYGON_SMOOTH); - glLineWidth(1.0f); + GPU_line_smooth(true); + GPU_polygon_smooth(false); + GPU_line_width(1.0f); for (uint i = 0; i < ARRAY_SIZE(button->shape_batch) && button->shape_batch[i]; i++) { /* Invert line color for wire. */ GWN_batch_program_set_builtin(button->shape_batch[i], GPU_SHADER_2D_UNIFORM_COLOR); @@ -185,8 +186,8 @@ static void button2d_draw_intern( color[2] = 1.0f - color[2]; } } - glDisable(GL_LINE_SMOOTH); - glEnable(GL_POLYGON_SMOOTH); + GPU_line_smooth(false); + GPU_polygon_smooth(true); } else if (button->icon != ICON_NONE) { button2d_geom_draw_backdrop(mpr, color, select); @@ -206,7 +207,7 @@ static void button2d_draw_intern( } UI_icon_draw(size[0], size[1], button->icon); } - glDisable(GL_BLEND); + GPU_blend(false); } if (need_to_pop) { @@ -224,9 +225,9 @@ static void manipulator_button2d_draw(const bContext *C, wmManipulator *mpr) { const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; - glEnable(GL_BLEND); + GPU_blend(true); button2d_draw_intern(C, mpr, false, is_highlight); - glDisable(GL_BLEND); + GPU_blend(false); } static int manipulator_button2d_test_select( diff --git a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c index fe748f33d35..b7b19ccd634 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c @@ -49,6 +49,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_select.h" +#include "GPU_state.h" #include "RNA_access.h" #include "RNA_define.h" @@ -420,7 +421,7 @@ static void cage2d_draw_box_interaction( } else { BLI_assert(ELEM(prim_type, GWN_PRIM_LINE_STRIP, GWN_PRIM_LINES)); - glLineWidth(line_width + 3.0f); + GPU_line_width(line_width + 3.0f); immBegin(prim_type, verts_len); immAttrib3f(attr_id.col, 0.0f, 0.0f, 0.0f); @@ -429,7 +430,7 @@ static void cage2d_draw_box_interaction( } immEnd(); - glLineWidth(line_width); + GPU_line_width(line_width); immBegin(prim_type, verts_len); immAttrib3fv(attr_id.col, color); @@ -558,14 +559,14 @@ static void manipulator_cage2d_draw_intern( /* Handy for quick testing draw (if it's outside bounds). */ if (false) { - glEnable(GL_BLEND); + GPU_blend(true); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv((const float[4]){1, 1, 1, 0.5f}); float s = 0.5f; immRectf(pos, -s, -s, s, s); immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } if (select) { @@ -610,13 +611,13 @@ static void manipulator_cage2d_draw_intern( }; if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_BOX) { /* corner manipulators */ - glLineWidth(mpr->line_width + 3.0f); + GPU_line_width(mpr->line_width + 3.0f); cage2d_draw_box_corners(&r, margin, (const float[3]){0, 0, 0}); /* corner manipulators */ float color[4]; manipulator_color_get(mpr, highlight, color); - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); cage2d_draw_box_corners(&r, margin, color); bool show = false; @@ -645,12 +646,12 @@ static void manipulator_cage2d_draw_intern( float color[4]; manipulator_color_get(mpr, highlight, color); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); + GPU_line_smooth(true); + GPU_blend(true); - glLineWidth(mpr->line_width + 3.0f); + GPU_line_width(mpr->line_width + 3.0f); cage2d_draw_circle_wire(&r, margin, (const float[3]){0, 0, 0}, transform_flag, draw_options); - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); cage2d_draw_circle_wire(&r, margin, color, transform_flag, draw_options); @@ -658,15 +659,15 @@ static void manipulator_cage2d_draw_intern( cage2d_draw_circle_handles(&r, margin, color, transform_flag, true); cage2d_draw_circle_handles(&r, margin, (const float[3]){0, 0, 0}, transform_flag, false); - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); + GPU_blend(false); + GPU_line_smooth(false); } else { BLI_assert(0); } } - glLineWidth(1.0); + GPU_line_width(1.0); gpuPopMatrix(); } diff --git a/source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c index 6c2e2bd564d..a907816b08f 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c @@ -48,6 +48,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_select.h" +#include "GPU_state.h" #include "RNA_access.h" #include "RNA_define.h" @@ -303,14 +304,14 @@ static void manipulator_cage3d_draw_intern( /* Handy for quick testing draw (if it's outside bounds). */ if (false) { - glEnable(GL_BLEND); + GPU_blend(true); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv((const float[4]){1, 1, 1, 0.5f}); float s = 0.5f; immRectf(pos, -s, -s, s, s); immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } if (select) { @@ -358,13 +359,13 @@ static void manipulator_cage3d_draw_intern( #endif if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_BOX) { /* corner manipulators */ - glLineWidth(mpr->line_width + 3.0f); + GPU_line_width(mpr->line_width + 3.0f); cage3d_draw_box_corners(size_real, margin, (const float[3]){0, 0, 0}); /* corner manipulators */ float color[4]; manipulator_color_get(mpr, highlight, color); - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); cage3d_draw_box_corners(size_real, margin, color); bool show = false; @@ -388,29 +389,29 @@ static void manipulator_cage3d_draw_intern( float color[4]; manipulator_color_get(mpr, highlight, color); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_POLYGON_SMOOTH); - glEnable(GL_BLEND); + GPU_line_smooth(true); + GPU_polygon_smooth(true); + GPU_blend(true); - glLineWidth(mpr->line_width + 3.0f); + GPU_line_width(mpr->line_width + 3.0f); cage3d_draw_circle_wire(size_real, margin, (const float[3]){0, 0, 0}, transform_flag, draw_options); - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); cage3d_draw_circle_wire(size_real, margin, color, transform_flag, draw_options); /* corner manipulators */ cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, (const float[3]){0, 0, 0}, true, 60); cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, color, true, 40); - glDisable(GL_BLEND); - glDisable(GL_POLYGON_SMOOTH); - glDisable(GL_LINE_SMOOTH); + GPU_blend(false); + GPU_polygon_smooth(false); + GPU_line_smooth(false); } else { BLI_assert(0); } } - glLineWidth(1.0); + GPU_line_width(1.0); gpuPopMatrix(); } diff --git a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c index 643a379cbb0..74ba8bd77a9 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c @@ -51,6 +51,7 @@ #include "GPU_immediate_util.h" #include "GPU_matrix.h" #include "GPU_select.h" +#include "GPU_state.h" #include "RNA_access.h" #include "RNA_define.h" @@ -123,7 +124,7 @@ static void dial_geom_draw( const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); const bool filled = (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL) != 0; - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -158,7 +159,7 @@ static void dial_geom_draw( */ static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[3], const float color[4]) { - glLineWidth(1.0f); + GPU_line_width(1.0f); gpuPushMatrix(); gpuRotate3f(RAD2DEGF(angle), 0.0f, 0.0f, -1.0f); @@ -313,9 +314,9 @@ static void dial_draw_intern( /* draw! */ for (int i = 0; i < 2; i++) { - glDisable(GL_POLYGON_SMOOTH); + GPU_polygon_smooth(false); dial_ghostarc_draw(mpr, angle_ofs, angle_delta, (const float[4]){0.8f, 0.8f, 0.8f, 0.4f}); - glEnable(GL_POLYGON_SMOOTH); + GPU_polygon_smooth(true); dial_ghostarc_draw_helpline(angle_ofs, co_outer, color); /* starting position */ dial_ghostarc_draw_helpline(angle_ofs + angle_delta, co_outer, color); /* starting position + current value */ @@ -382,9 +383,9 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr) glEnable(GL_CLIP_DISTANCE0); } - glEnable(GL_BLEND); + GPU_blend(true); dial_draw_intern(C, mpr, false, is_highlight, clip_plane); - glDisable(GL_BLEND); + GPU_blend(false); if (clip_plane) { glDisable(GL_CLIP_DISTANCE0); diff --git a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c index e2d1979b7a6..458dc2fd1c8 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c @@ -46,6 +46,7 @@ #include "GPU_immediate_util.h" #include "GPU_matrix.h" #include "GPU_select.h" +#include "GPU_state.h" #include "RNA_access.h" #include "RNA_define.h" @@ -102,7 +103,7 @@ static void grab_geom_draw( const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); const bool filled = (draw_options & ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL) != 0; - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -188,9 +189,9 @@ static void grab3d_draw_intern( gpuMultMatrix(matrix_align); } - glEnable(GL_BLEND); + GPU_blend(true); grab_geom_draw(mpr, color, select, draw_options); - glDisable(GL_BLEND); + GPU_blend(false); gpuPopMatrix(); if (mpr->interaction_data) { @@ -201,9 +202,9 @@ static void grab3d_draw_intern( gpuMultMatrix(matrix_align); } - glEnable(GL_BLEND); + GPU_blend(true); grab_geom_draw(mpr, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}, select, draw_options); - glDisable(GL_BLEND); + GPU_blend(false); gpuPopMatrix(); } } @@ -221,9 +222,9 @@ static void manipulator_grab_draw(const bContext *C, wmManipulator *mpr) (void)is_modal; - glEnable(GL_BLEND); + GPU_blend(true); grab3d_draw_intern(C, mpr, false, is_highlight); - glDisable(GL_BLEND); + GPU_blend(false); } static int manipulator_grab_modal( diff --git a/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c index 531cf742e6f..419873ccfff 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c @@ -42,6 +42,7 @@ #include "GPU_immediate.h" #include "GPU_matrix.h" #include "GPU_select.h" +#include "GPU_state.h" #include "RNA_access.h" #include "RNA_define.h" @@ -101,9 +102,9 @@ static void manipulator_primitive_draw_intern( gpuPushMatrix(); gpuMultMatrix(matrix_final); - glEnable(GL_BLEND); + GPU_blend(true); manipulator_primitive_draw_geom(color_inner, color_outer, draw_style); - glDisable(GL_BLEND); + GPU_blend(false); gpuPopMatrix(); @@ -117,9 +118,9 @@ static void manipulator_primitive_draw_intern( gpuPushMatrix(); gpuMultMatrix(inter->init_matrix_final); - glEnable(GL_BLEND); + GPU_blend(true); manipulator_primitive_draw_geom(color_inner, color_outer, draw_style); - glDisable(GL_BLEND); + GPU_blend(false); gpuPopMatrix(); } diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 689a96a3dec..6b5fce26deb 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -56,6 +56,7 @@ #include "GPU_draw.h" #include "GPU_shader.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "UI_resources.h" #include "UI_view2d.h" @@ -132,7 +133,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin /* this could be split into its own loop */ if (draw_type == MASK_DT_OUTLINE) { - glLineWidth(3.0f); + GPU_line_width(3.0f); immBegin(GWN_PRIM_LINES, 2); immVertex2fv(pos, point_pos); immVertex2fv(pos, handle_pos); @@ -152,7 +153,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin break; } - glLineWidth(1.0f); + GPU_line_width(1.0f); immBegin(GWN_PRIM_LINES, 2); immVertex2fv(pos, point_pos); immVertex2fv(pos, handle_pos); @@ -262,7 +263,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline immUnbindProgram(); if (is_smooth) { - glEnable(GL_LINE_SMOOTH); + GPU_line_smooth(true); } /* control points */ @@ -329,7 +330,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline } if (is_smooth) { - glDisable(GL_LINE_SMOOTH); + GPU_line_smooth(false); } if (is_spline_sel) { @@ -412,13 +413,13 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (* */ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - glLineWidth(3.0f); + GPU_line_width(3.0f); mask_color_active_tint(rgb_tmp, rgb_black, is_active); immUniformColor4ubv(rgb_tmp); mask_draw_array(pos, draw_method, points, tot_point); - glLineWidth(1.0f); + GPU_line_width(1.0f); mask_color_active_tint(rgb_tmp, rgb_spline, is_active); immUniformColor4ubv(rgb_tmp); @@ -430,7 +431,7 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (* case MASK_DT_BLACK: case MASK_DT_WHITE: immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - glLineWidth(1.0f); + GPU_line_width(1.0f); if (draw_type == MASK_DT_BLACK) { rgb_tmp[0] = rgb_tmp[1] = rgb_tmp[2] = 0; } else { rgb_tmp[0] = rgb_tmp[1] = rgb_tmp[2] = 255; } @@ -456,7 +457,7 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (* * probably better with geometry shader (after core profile switch) */ #if 0 - glLineWidth(1.0f); + GPU_line_width(1.0f); GPU_basic_shader_bind_enable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE); GPU_basic_shader_line_stipple(3, 0xAAAA); @@ -508,7 +509,7 @@ static void draw_spline_curve(const bContext *C, MaskLayer *masklay, MaskSpline return; if (is_smooth) { - glEnable(GL_LINE_SMOOTH); + GPU_line_smooth(true); } feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution(spline, &tot_feather_point, resol, (is_fill != false)); @@ -547,15 +548,15 @@ static void draw_spline_curve(const bContext *C, MaskLayer *masklay, MaskSpline MEM_freeN(diff_points); if (is_smooth) { - glDisable(GL_LINE_SMOOTH); + GPU_line_smooth(false); } } static void draw_masklays(const bContext *C, Mask *mask, const char draw_flag, const char draw_type, const int width, const int height) { - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_enable_program_point_size(); MaskLayer *masklay; @@ -592,7 +593,7 @@ static void draw_masklays(const bContext *C, Mask *mask, const char draw_flag, c } GPU_disable_program_point_size(); - glDisable(GL_BLEND); + GPU_blend(false); } void ED_mask_draw(const bContext *C, @@ -690,8 +691,8 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar, if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) { /* More blending types could be supported in the future. */ - glEnable(GL_BLEND); - glBlendFunc(GL_DST_COLOR, GL_ZERO); + GPU_blend(true); + GPU_blend_set_func(GPU_DST_COLOR, GPU_ZERO); } gpuPushMatrix(); @@ -707,7 +708,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar, gpuPopMatrix(); if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) { - glDisable(GL_BLEND); + GPU_blend(false); } MEM_freeN(buffer); diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index 9a2635c37d2..85f5836ecd7 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -57,7 +57,7 @@ /********************** generic poll functions *********************/ -int ED_maskedit_poll(bContext *C) +bool ED_maskedit_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); if (sa) { @@ -73,7 +73,7 @@ int ED_maskedit_poll(bContext *C) return false; } -int ED_maskedit_mask_poll(bContext *C) +bool ED_maskedit_mask_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); if (sa) { @@ -540,6 +540,7 @@ void ED_keymap_mask(wmKeyConfig *keyconf) /* geometry */ WM_keymap_add_item(keymap, "MASK_OT_add_vertex_slide", ACTIONMOUSE, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "MASK_OT_add_feather_vertex_slide", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "MASK_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MASK_OT_delete", DELKEY, KM_PRESS, 0, 0); @@ -594,7 +595,11 @@ void ED_keymap_mask(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MASK_OT_slide_point", ACTIONMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MASK_OT_slide_spline_curvature", ACTIONMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MASK_OT_handle_type_set", VKEY, KM_PRESS, 0, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "MASK_OT_normals_make_consistent", NKEY, KM_PRESS, KM_CTRL, 0); +#else + WM_keymap_add_item(keymap, "MASK_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT, 0); +#endif // WM_keymap_add_item(keymap, "MASK_OT_feather_weight_clear", SKEY, KM_PRESS, KM_ALT, 0); /* ... matches curve editmode */ diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c index 364800ed1a2..771deca69b6 100644 --- a/source/blender/editors/mask/mask_editaction.c +++ b/source/blender/editors/mask/mask_editaction.c @@ -336,4 +336,3 @@ void ED_masklayer_snap_frames(MaskLayer *masklay, Scene *scene, short mode) break; } } - diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h index 66a6c75272e..e9ef06a368f 100644 --- a/source/blender/editors/mask/mask_intern.h +++ b/source/blender/editors/mask/mask_intern.h @@ -121,8 +121,8 @@ void ED_mask_select_toggle_all(struct Mask *mask, int action); void ED_mask_select_flush_all(struct Mask *mask); /* mask_editor.c */ -int ED_maskedit_poll(struct bContext *C); -int ED_maskedit_mask_poll(struct bContext *C); +bool ED_maskedit_poll(struct bContext *C); +bool ED_maskedit_mask_poll(struct bContext *C); /* mask_shapekey.c */ void MASK_OT_shape_key_insert(struct wmOperatorType *ot); diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index b6ac23a37e8..a93ef4405dc 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -2106,7 +2106,7 @@ void MASK_OT_feather_weight_clear(wmOperatorType *ot) /******************** move mask layer operator *********************/ -static int mask_layer_move_poll(bContext *C) +static bool mask_layer_move_poll(bContext *C) { if (ED_maskedit_mask_poll(C)) { Mask *mask = CTX_data_edit_mask(C); @@ -2335,7 +2335,7 @@ void MASK_OT_copy_splines(wmOperatorType *ot) /********************** paste tracks from clipboard operator *********************/ -static int paste_splines_poll(bContext *C) +static bool paste_splines_poll(bContext *C) { if (ED_maskedit_mask_poll(C)) { return BKE_mask_clipboard_is_empty() == false; diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index cf4d8ebf05d..405c19f1c1d 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -33,13 +33,14 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" +#include "DNA_meshdata_types.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" -#include "BKE_DerivedMesh.h" +#include "BKE_context.h" +#include "BKE_customdata.h" #include "BKE_global.h" #include "BKE_mesh.h" -#include "BKE_context.h" #include "BIF_gl.h" @@ -61,7 +62,7 @@ void paintface_flush_flags(Object *ob, short flag) { Mesh *me = BKE_mesh_from_object(ob); - DerivedMesh *dm = ob->derivedFinal; + Mesh *me_eval = ob->runtime.mesh_eval; MPoly *polys, *mp_orig; const int *index_array = NULL; int totpoly; @@ -80,14 +81,14 @@ void paintface_flush_flags(Object *ob, short flag) BKE_mesh_flush_select_from_polys(me); } - if (dm == NULL) + if (me_eval == NULL) return; /* Mesh polys => Final derived polys */ - if ((index_array = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX))) { - polys = dm->getPolyArray(dm); - totpoly = dm->getNumPolys(dm); + if ((index_array = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX))) { + polys = me_eval->mpoly; + totpoly = me_eval->totpoly; /* loop over final derived polys */ for (i = 0; i < totpoly; i++) { @@ -474,8 +475,8 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool exten void paintvert_flush_flags(Object *ob) { Mesh *me = BKE_mesh_from_object(ob); - DerivedMesh *dm = ob->derivedFinal; - MVert *dm_mvert, *dm_mv; + Mesh *me_eval = ob->runtime.mesh_eval; + MVert *mvert_eval, *mv; const int *index_array = NULL; int totvert; int i; @@ -487,28 +488,28 @@ void paintvert_flush_flags(Object *ob) * since this could become slow for realtime updates (circle-select for eg) */ BKE_mesh_flush_select_from_verts(me); - if (dm == NULL) + if (me_eval == NULL) return; - index_array = dm->getVertDataArray(dm, CD_ORIGINDEX); + index_array = CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX); - dm_mvert = dm->getVertArray(dm); - totvert = dm->getNumVerts(dm); + mvert_eval = me_eval->mvert; + totvert = me_eval->totvert; - dm_mv = dm_mvert; + mv = mvert_eval; if (index_array) { int orig_index; - for (i = 0; i < totvert; i++, dm_mv++) { + for (i = 0; i < totvert; i++, mv++) { orig_index = index_array[i]; if (orig_index != ORIGINDEX_NONE) { - dm_mv->flag = me->mvert[index_array[i]].flag; + mv->flag = me->mvert[index_array[i]].flag; } } } else { - for (i = 0; i < totvert; i++, dm_mv++) { - dm_mv->flag = me->mvert[i].flag; + for (i = 0; i < totvert; i++, mv++) { + mv->flag = me->mvert[i].flag; } } diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index d92d655641f..f6b69beac71 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -132,7 +132,7 @@ static void edbm_bevel_update_header(bContext *C, wmOperator *op) WM_bool_as_string(opdata->value_mode == PROFILE_VALUE), offset_str, RNA_int_get(op->ptr, "segments"), RNA_float_get(op->ptr, "profile")); - ED_area_headerprint(sa, msg); + ED_area_status_text(sa, msg); } } @@ -364,7 +364,7 @@ static void edbm_bevel_exit(bContext *C, wmOperator *op) ScrArea *sa = CTX_wm_area(C); if (sa) { - ED_area_headerprint(sa, NULL); + ED_area_status_text(sa, NULL); } if (opdata->is_modal) { @@ -775,7 +775,7 @@ void MESH_OT_bevel(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_CURSOR | OPTYPE_BLOCKING; RNA_def_enum(ot->srna, "offset_type", offset_type_items, 0, "Amount Type", "What distance Amount measures"); - prop = RNA_def_float(ot->srna, "offset", 0.0f, -1e6f, 1e6f, "Amount", "", 0.0f, 1.0f); + prop = RNA_def_float(ot->srna, "offset", 0.0f, -1e6f, 1e6f, "Amount", "", 0.0f, 100.0f); RNA_def_property_float_array_funcs_runtime(prop, NULL, NULL, mesh_ot_bevel_offset_range_func); RNA_def_int(ot->srna, "segments", 1, 1, SEGMENTS_HARD_MAX, "Segments", "Segments for curved edge", 1, 8); RNA_def_float(ot->srna, "profile", 0.5f, PROFILE_HARD_MIN, 1.0f, "Profile", diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index ee06f7abd2b..568983e47ee 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -160,7 +160,7 @@ static int mesh_bisect_invoke(bContext *C, wmOperator *op, const wmEvent *event) v3d->twflag = 0; /* initialize modal callout */ - ED_area_headerprint(CTX_wm_area(C), IFACE_("LMB: Click and drag to draw cut line")); + ED_workspace_status_text(C, IFACE_("LMB: Click and drag to draw cut line")); } return ret; } @@ -185,10 +185,10 @@ static int mesh_bisect_modal(bContext *C, wmOperator *op, const wmEvent *event) /* update or clear modal callout */ if (event->type == EVT_MODAL_MAP) { if (event->val == GESTURE_MODAL_BEGIN) { - ED_area_headerprint(CTX_wm_area(C), IFACE_("LMB: Release to confirm cut line")); + ED_workspace_status_text(C, IFACE_("LMB: Release to confirm cut line")); } else { - ED_area_headerprint(CTX_wm_area(C), NULL); + ED_workspace_status_text(C, NULL); } } @@ -368,7 +368,8 @@ void MESH_OT_bisect(struct wmOperatorType *ot) RNA_def_boolean(ot->srna, "clear_inner", false, "Clear Inner", "Remove geometry behind the plane"); RNA_def_boolean(ot->srna, "clear_outer", false, "Clear Outer", "Remove geometry in front of the plane"); - RNA_def_float(ot->srna, "threshold", 0.0001, 0.0, 10.0, "Axis Threshold", "", 0.00001, 0.1); + RNA_def_float(ot->srna, "threshold", 0.0001, 0.0, 10.0, "Axis Threshold", + "Preserves the existing geometry along the cut plane", 0.00001, 0.1); WM_operator_properties_gesture_straightline(ot, CURSOR_EDIT); diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index 4841de3c856..be68bfda09c 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -480,7 +480,7 @@ static void manipulator_mesh_extrude_setup(const bContext *UNUSED(C), wmManipula for (int i = 0; i < 4; i++) { PointerRNA *ptr = WM_manipulator_operator_set(man->invoke_xyz_no[i], 0, man->ot_extrude, NULL); { - int constraint[3] = {0, 0, 0}; + bool constraint[3] = {0, 0, 0}; constraint[MIN2(i, 2)] = 1; PointerRNA macroptr = RNA_pointer_get(ptr, "TRANSFORM_OT_translate"); RNA_boolean_set(¯optr, "release_confirm", true); @@ -492,7 +492,7 @@ static void manipulator_mesh_extrude_setup(const bContext *UNUSED(C), wmManipula for (int i = 0; i < 4; i++) { PointerRNA *ptr = WM_manipulator_operator_set(man->adjust_xyz_no[i], 0, man->ot_extrude, NULL); { - int constraint[3] = {0, 0, 0}; + bool constraint[3] = {0, 0, 0}; constraint[MIN2(i, 2)] = 1; PointerRNA macroptr = RNA_pointer_get(ptr, "TRANSFORM_OT_translate"); RNA_boolean_set(¯optr, "release_confirm", true); @@ -588,7 +588,7 @@ static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGro wmOperator *op_transform = op->macro.last; float value[4]; RNA_float_get_array(op_transform->ptr, "value", value); - int constraint_axis[3]; + bool constraint_axis[3]; RNA_boolean_get_array(op_transform->ptr, "constraint_axis", constraint_axis); int orientation_type = RNA_enum_get(op_transform->ptr, "constraint_orientation"); diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c index 985d873dfc2..8758fa66a14 100644 --- a/source/blender/editors/mesh/editmesh_inset.c +++ b/source/blender/editors/mesh/editmesh_inset.c @@ -112,7 +112,7 @@ static void edbm_inset_update_header(wmOperator *op, bContext *C) WM_bool_as_string(RNA_boolean_get(op->ptr, "use_individual")) ); - ED_area_headerprint(sa, msg); + ED_area_status_text(sa, msg); } } @@ -202,7 +202,7 @@ static void edbm_inset_exit(bContext *C, wmOperator *op) } if (sa) { - ED_area_headerprint(sa, NULL); + ED_area_status_text(sa, NULL); } MEM_SAFE_FREE(opdata->ob_store); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index be54bba7aa4..a511100ff4e 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -48,7 +48,7 @@ #include "BLT_translation.h" -#include "BKE_DerivedMesh.h" +#include "BKE_bvhutils.h" #include "BKE_context.h" #include "BKE_editmesh.h" #include "BKE_editmesh_bvh.h" @@ -58,6 +58,7 @@ #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "ED_screen.h" #include "ED_space_api.h" @@ -301,7 +302,7 @@ static void knife_update_header(bContext *C, wmOperator *op, KnifeTool_OpData *k #undef WM_MODALKEY - ED_area_headerprint(CTX_wm_area(C), header); + ED_workspace_status_text(C, header); } static void knife_project_v2(const KnifeTool_OpData *kcd, const float co[3], float sco[2]) @@ -1010,7 +1011,7 @@ static void knifetool_draw_angle_snapping(const KnifeTool_OpData *kcd) immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformThemeColor(TH_TRANSFORM); - glLineWidth(2.0); + GPU_line_width(2.0); immBegin(GWN_PRIM_LINES, 2); immVertex3fv(pos, v1); @@ -1041,7 +1042,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) View3D *v3d = CTX_wm_view3d(C); const KnifeTool_OpData *kcd = arg; - if (v3d->zbuf) glDisable(GL_DEPTH_TEST); + if (v3d->zbuf) GPU_depth_test(false); glPolygonOffset(1.0f, 1.0f); @@ -1057,7 +1058,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) knifetool_draw_angle_snapping(kcd); immUniformColor3ubv(kcd->colors.line); - glLineWidth(2.0); + GPU_line_width(2.0); immBegin(GWN_PRIM_LINES, 2); immVertex3fv(pos, kcd->prev.cage); @@ -1067,7 +1068,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) if (kcd->prev.vert) { immUniformColor3ubv(kcd->colors.point); - glPointSize(11); + GPU_point_size(11); immBegin(GWN_PRIM_POINTS, 1); immVertex3fv(pos, kcd->prev.cage); @@ -1076,7 +1077,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) if (kcd->prev.bmface) { immUniformColor3ubv(kcd->colors.curpoint); - glPointSize(9); + GPU_point_size(9); immBegin(GWN_PRIM_POINTS, 1); immVertex3fv(pos, kcd->prev.cage); @@ -1085,7 +1086,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) if (kcd->curr.edge) { immUniformColor3ubv(kcd->colors.edge); - glLineWidth(2.0); + GPU_line_width(2.0); immBegin(GWN_PRIM_LINES, 2); immVertex3fv(pos, kcd->curr.edge->v1->cageco); @@ -1094,7 +1095,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) } else if (kcd->curr.vert) { immUniformColor3ubv(kcd->colors.point); - glPointSize(11); + GPU_point_size(11); immBegin(GWN_PRIM_POINTS, 1); immVertex3fv(pos, kcd->curr.cage); @@ -1103,7 +1104,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) if (kcd->curr.bmface) { immUniformColor3ubv(kcd->colors.curpoint); - glPointSize(9); + GPU_point_size(9); immBegin(GWN_PRIM_POINTS, 1); immVertex3fv(pos, kcd->curr.cage); @@ -1114,12 +1115,12 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) KnifeLineHit *lh; int i; - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); /* draw any snapped verts first */ immUniformColor4ubv(kcd->colors.point_a); - glPointSize(11); + GPU_point_size(11); immBeginAtMost(GWN_PRIM_POINTS, kcd->totlinehit); @@ -1134,7 +1135,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) /* now draw the rest */ immUniformColor4ubv(kcd->colors.curpoint_a); - glPointSize(7); + GPU_point_size(7); immBeginAtMost(GWN_PRIM_POINTS, kcd->totlinehit); @@ -1147,7 +1148,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) immEnd(); - glDisable(GL_BLEND); + GPU_blend(false); } if (kcd->totkedge > 0) { @@ -1155,7 +1156,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) KnifeEdge *kfe; immUniformColor3ubv(kcd->colors.line); - glLineWidth(1.0); + GPU_line_width(1.0); immBeginAtMost(GWN_PRIM_LINES, BLI_mempool_len(kcd->kedges) * 2); @@ -1176,7 +1177,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) KnifeVert *kfv; immUniformColor3ubv(kcd->colors.point); - glPointSize(5.0); + GPU_point_size(5.0); immBeginAtMost(GWN_PRIM_POINTS, BLI_mempool_len(kcd->kverts)); @@ -1195,7 +1196,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) gpuPopMatrix(); - if (v3d->zbuf) glEnable(GL_DEPTH_TEST); + if (v3d->zbuf) GPU_depth_test(true); } /** @@ -2787,7 +2788,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) if (!obedit || obedit->type != OB_MESH || BKE_editmesh_from_object(obedit) != kcd->em) { knifetool_exit(C, op); - ED_area_headerprint(CTX_wm_area(C), NULL); + ED_workspace_status_text(C, NULL); return OPERATOR_FINISHED; } @@ -2808,7 +2809,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) ED_region_tag_redraw(kcd->ar); knifetool_exit(C, op); - ED_area_headerprint(CTX_wm_area(C), NULL); + ED_workspace_status_text(C, NULL); return OPERATOR_CANCELLED; case KNF_MODAL_CONFIRM: @@ -2817,7 +2818,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) knifetool_finish(op); knifetool_exit(C, op); - ED_area_headerprint(CTX_wm_area(C), NULL); + ED_workspace_status_text(C, NULL); return OPERATOR_FINISHED; case KNF_MODAL_MIDPOINT_ON: diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 7dac9a09b97..8493d15a3b1 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -48,6 +48,7 @@ #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "UI_interface.h" @@ -112,7 +113,7 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) if ((lcd->totedge > 0) || (lcd->totpoint > 0)) { if (v3d && v3d->zbuf) - glDisable(GL_DEPTH_TEST); + GPU_depth_test(false); gpuPushMatrix(); gpuMultMatrix(lcd->ob->obmat); @@ -134,7 +135,7 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) } if (lcd->totpoint > 0) { - glPointSize(3.0f); + GPU_point_size(3.0f); immBegin(GWN_PRIM_POINTS, lcd->totpoint); @@ -150,7 +151,7 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) gpuPopMatrix(); if (v3d && v3d->zbuf) - glEnable(GL_DEPTH_TEST); + GPU_depth_test(true); } } @@ -692,7 +693,7 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event) { Scene *scene = CTX_data_scene(C); ToolSettings *settings = scene->toolsettings; - const int mesh_select_mode[3] = { + const bool mesh_select_mode[3] = { (settings->selectmode & SCE_SELECT_VERTEX) != 0, (settings->selectmode & SCE_SELECT_EDGE) != 0, (settings->selectmode & SCE_SELECT_FACE) != 0, @@ -703,8 +704,7 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event) #endif if (is_interactive) { - ScrArea *sa = CTX_wm_area(C); - ED_area_headerprint(sa, IFACE_("Select a ring to be cut, use mouse-wheel or page-up/down for number of cuts, " + ED_workspace_status_text(C, IFACE_("Select a ring to be cut, use mouse-wheel or page-up/down for number of cuts, " "hold Alt for smooth")); return OPERATOR_RUNNING_MODAL; } @@ -729,7 +729,7 @@ static int loopcut_finish(RingSelOpData *lcd, bContext *C, wmOperator *op) { /* finish */ ED_region_tag_redraw(lcd->ar); - ED_area_headerprint(CTX_wm_area(C), NULL); + ED_workspace_status_text(C, NULL); if (lcd->eed) { /* set for redo */ @@ -785,14 +785,14 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) case RIGHTMOUSE: /* abort */ // XXX hardcoded ED_region_tag_redraw(lcd->ar); ringsel_exit(C, op); - ED_area_headerprint(CTX_wm_area(C), NULL); + ED_workspace_status_text(C, NULL); return OPERATOR_CANCELLED; case ESCKEY: if (event->val == KM_RELEASE) { /* cancel */ ED_region_tag_redraw(lcd->ar); - ED_area_headerprint(CTX_wm_area(C), NULL); + ED_workspace_status_text(C, NULL); ringcut_cancel(C, op); return OPERATOR_CANCELLED; @@ -897,7 +897,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) } BLI_snprintf(buf, sizeof(buf), IFACE_("Number of Cuts: %s, Smooth: %s (Alt)"), str_rep, str_rep + NUM_STR_REP_LEN); - ED_area_headerprint(CTX_wm_area(C), buf); + ED_workspace_status_text(C, buf); } /* keep going until the user confirms */ diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 99a95c27b7b..2e7cf1fc76f 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -4204,7 +4204,7 @@ void MESH_OT_select_random(wmOperatorType *ot) /** \name Select Ungrouped Operator * \{ */ -static int edbm_select_ungrouped_poll(bContext *C) +static bool edbm_select_ungrouped_poll(bContext *C) { if (ED_operator_editmesh(C)) { Object *obedit = CTX_data_edit_object(C); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 15840f8f9d6..f8c1db30276 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4360,11 +4360,13 @@ void MESH_OT_fill_grid(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - prop = RNA_def_int(ot->srna, "span", 1, 1, 1000, "Span", "Number of sides (zero disables)", 1, 100); + prop = RNA_def_int(ot->srna, "span", 1, 1, 1000, "Span", "Number of grid columns", 1, 100); RNA_def_property_flag(prop, PROP_SKIP_SAVE); - prop = RNA_def_int(ot->srna, "offset", 0, -1000, 1000, "Offset", "Number of sides (zero disables)", -100, 100); + prop = RNA_def_int(ot->srna, "offset", 0, -1000, 1000, "Offset", + "Vertex that is the corner of the grid", -100, 100); RNA_def_property_flag(prop, PROP_SKIP_SAVE); - RNA_def_boolean(ot->srna, "use_interp_simple", false, "Simple Blending", ""); + RNA_def_boolean(ot->srna, "use_interp_simple", false, "Simple Blending", + "Use simple interpolation of grid vertices"); } /** \} */ @@ -6616,7 +6618,8 @@ void MESH_OT_symmetrize(struct wmOperatorType *ot) ot->srna, "direction", rna_enum_symmetrize_direction_items, BMO_SYMMETRIZE_NEGATIVE_X, "Direction", "Which sides to copy from and to"); - RNA_def_float(ot->srna, "threshold", 1e-4f, 0.0f, 10.0f, "Threshold", "", 1e-5f, 0.1f); + RNA_def_float(ot->srna, "threshold", 1e-4f, 0.0f, 10.0f, "Threshold", + "Limit for snap middle vertices to the axis center", 1e-5f, 0.1f); } /** \} */ @@ -6747,9 +6750,11 @@ void MESH_OT_symmetry_snap(struct wmOperatorType *ot) ot->srna, "direction", rna_enum_symmetrize_direction_items, BMO_SYMMETRIZE_NEGATIVE_X, "Direction", "Which sides to copy from and to"); - RNA_def_float_distance(ot->srna, "threshold", 0.05f, 0.0f, 10.0f, "Threshold", "", 1e-4f, 1.0f); - RNA_def_float(ot->srna, "factor", 0.5f, 0.0f, 1.0f, "Factor", "", 0.0f, 1.0f); - RNA_def_boolean(ot->srna, "use_center", true, "Center", "Snap mid verts to the axis center"); + RNA_def_float_distance(ot->srna, "threshold", 0.05f, 0.0f, 10.0f, "Threshold", + "Distance within which matching vertices are searched", 1e-4f, 1.0f); + RNA_def_float(ot->srna, "factor", 0.5f, 0.0f, 1.0f, "Factor", + "Mix factor of the locations of the vertices", 0.0f, 1.0f); + RNA_def_boolean(ot->srna, "use_center", true, "Center", "Snap middle vertices to the axis center"); } /** \} */ diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c index 33864cd1e95..26f3c17a97c 100644 --- a/source/blender/editors/mesh/editmesh_undo.c +++ b/source/blender/editors/mesh/editmesh_undo.c @@ -27,6 +27,7 @@ #include "CLG_log.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_key_types.h" #include "DNA_layer_types.h" @@ -35,7 +36,6 @@ #include "BLI_array_utils.h" #include "BLI_alloca.h" -#include "BKE_DerivedMesh.h" #include "BKE_context.h" #include "BKE_key.h" #include "BKE_layer.h" diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 9524d1b0791..6cae7e8c1ee 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -1035,7 +1035,7 @@ void EDBM_verts_mirror_cache_begin_ex( BM_mesh_elem_index_ensure(bm, BM_VERT); if (use_topology) { - ED_mesh_mirrtopo_init__real_mesh(me, NULL, &mesh_topo_store, true); + ED_mesh_mirrtopo_init(me, NULL, &mesh_topo_store, true); } else { tree = BLI_kdtree_new(bm->totvert); @@ -1385,7 +1385,7 @@ DerivedMesh *EDBM_mesh_deform_dm_get(BMEditMesh *em) * \{ */ /* poll call for mesh operators requiring a view3d context */ -int EDBM_view3d_poll(bContext *C) +bool EDBM_view3d_poll(bContext *C) { if (ED_operator_editmesh(C) && ED_operator_view3d_active(C)) { return 1; diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 46b84f328cc..d4a6267fa6b 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -497,7 +497,7 @@ bool ED_mesh_color_remove_named(Mesh *me, const char *name) /*********************** UV texture operators ************************/ -static int layers_poll(bContext *C) +static bool layers_poll(bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; @@ -584,8 +584,8 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e MEM_freeN(me->edit_btmesh); me->edit_btmesh = NULL; - /* load_editMesh free's pointers used by CustomData layers which might be used by DerivedMesh too, - * so signal to re-create DerivedMesh here (sergey) */ + /* load_editMesh free's pointers used by CustomData layers which might be used by evaluated mesh too, + * so signal to re-create evaluated mesh here (sergey) */ DEG_id_tag_update(&me->id, 0); } @@ -736,7 +736,7 @@ static int mesh_customdata_clear_exec__internal(bContext *C, } /* Clear Mask */ -static int mesh_customdata_mask_clear_poll(bContext *C) +static bool mesh_customdata_mask_clear_poll(bContext *C) { Object *ob = ED_object_context(C); if (ob && ob->type == OB_MESH) { @@ -809,7 +809,7 @@ static int mesh_customdata_skin_state(bContext *C) return -1; } -static int mesh_customdata_skin_add_poll(bContext *C) +static bool mesh_customdata_skin_add_poll(bContext *C) { return (mesh_customdata_skin_state(C) == 0); } @@ -842,7 +842,7 @@ void MESH_OT_customdata_skin_add(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int mesh_customdata_skin_clear_poll(bContext *C) +static bool mesh_customdata_skin_clear_poll(bContext *C) { return (mesh_customdata_skin_state(C) == 1); } @@ -963,7 +963,7 @@ void MESH_OT_customdata_custom_splitnormals_clear(wmOperatorType *ot) /************************** Add Geometry Layers *************************/ -void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface) +void ED_mesh_update(Mesh *mesh, bContext *C, bool calc_edges, bool calc_tessface) { bool tessface_input = false; diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index eb04d62452c..2a9ad4bd3d8 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -73,7 +73,7 @@ bool EDBM_op_finish(struct BMEditMesh *em, struct BMOperator *bmop, void EDBM_stats_update(struct BMEditMesh *em); -int EDBM_view3d_poll(struct bContext *C); +bool EDBM_view3d_poll(struct bContext *C); struct BMElem *EDBM_elem_from_selectmode( struct BMEditMesh *em, diff --git a/source/blender/editors/mesh/mesh_mirror.c b/source/blender/editors/mesh/mesh_mirror.c index 4c078d2ac8b..4b526915551 100644 --- a/source/blender/editors/mesh/mesh_mirror.c +++ b/source/blender/editors/mesh/mesh_mirror.c @@ -32,9 +32,9 @@ #include "BLI_bitmap.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" -#include "BKE_DerivedMesh.h" #include "BLI_kdtree.h" #include "BKE_editmesh.h" #include "BKE_library.h" @@ -52,11 +52,11 @@ static struct { void *tree; } MirrKdStore = {NULL}; /* mode is 's' start, or 'e' end, or 'u' use */ /* if end, ob can be NULL */ -int ED_mesh_mirror_spatial_table(Object *ob, BMEditMesh *em, DerivedMesh *dm, const float co[3], char mode) +int ED_mesh_mirror_spatial_table(Object *ob, BMEditMesh *em, Mesh *me_eval, const float co[3], char mode) { if (mode == 'u') { /* use table */ if (MirrKdStore.tree == NULL) - ED_mesh_mirror_spatial_table(ob, em, dm, NULL, 's'); + ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 's'); if (MirrKdStore.tree) { KDTreeNearest nearest; @@ -72,11 +72,11 @@ int ED_mesh_mirror_spatial_table(Object *ob, BMEditMesh *em, DerivedMesh *dm, co } else if (mode == 's') { /* start table */ Mesh *me = ob->data; - const bool use_em = (!dm && em && me->edit_btmesh == em); - const int totvert = use_em ? em->bm->totvert : dm ? dm->getNumVerts(dm) : me->totvert; + const bool use_em = (!me_eval && em && me->edit_btmesh == em); + const int totvert = use_em ? em->bm->totvert : me_eval ? me_eval->totvert : me->totvert; if (MirrKdStore.tree) /* happens when entering this call without ending it */ - ED_mesh_mirror_spatial_table(ob, em, dm, co, 'e'); + ED_mesh_mirror_spatial_table(ob, em, me_eval, co, 'e'); MirrKdStore.tree = BLI_kdtree_new(totvert); @@ -93,73 +93,7 @@ int ED_mesh_mirror_spatial_table(Object *ob, BMEditMesh *em, DerivedMesh *dm, co } } else { - MVert *mvert = dm ? dm->getVertArray(dm) : me->mvert; - int i; - - for (i = 0; i < totvert; i++, mvert++) { - BLI_kdtree_insert(MirrKdStore.tree, i, mvert->co); - } - } - - BLI_kdtree_balance(MirrKdStore.tree); - } - else if (mode == 'e') { /* end table */ - if (MirrKdStore.tree) { - BLI_kdtree_free(MirrKdStore.tree); - MirrKdStore.tree = NULL; - } - } - else { - BLI_assert(0); - } - - return 0; -} - -/* mode is 's' start, or 'e' end, or 'u' use */ -/* if end, ob can be NULL */ -int ED_mesh_mirror_spatial_table__real_mesh(Object *ob, BMEditMesh *em, Mesh *mesh, const float co[3], char mode) -{ - if (mode == 'u') { /* use table */ - if (MirrKdStore.tree == NULL) - ED_mesh_mirror_spatial_table__real_mesh(ob, em, mesh, NULL, 's'); - - if (MirrKdStore.tree) { - KDTreeNearest nearest; - const int i = BLI_kdtree_find_nearest(MirrKdStore.tree, co, &nearest); - - if (i != -1) { - if (nearest.dist < KD_THRESH) { - return i; - } - } - } - return -1; - } - else if (mode == 's') { /* start table */ - Mesh *me = ob->data; - const bool use_em = (!mesh && em && me->edit_btmesh == em); - const int totvert = use_em ? em->bm->totvert : mesh ? mesh->totvert : me->totvert; - - if (MirrKdStore.tree) /* happens when entering this call without ending it */ - ED_mesh_mirror_spatial_table__real_mesh(ob, em, mesh, co, 'e'); - - MirrKdStore.tree = BLI_kdtree_new(totvert); - - if (use_em) { - BMVert *eve; - BMIter iter; - int i; - - /* this needs to be valid for index lookups later (callers need) */ - BM_mesh_elem_table_ensure(em->bm, BM_VERT); - - BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) { - BLI_kdtree_insert(MirrKdStore.tree, i, eve->co); - } - } - else { - MVert *mvert = mesh ? mesh->mvert : me->mvert; + MVert *mvert = me_eval ? me_eval->mvert : me->mvert; int i; for (i = 0; i < totvert; i++, mvert++) { @@ -209,46 +143,15 @@ static int mirrtopo_vert_sort(const void *v1, const void *v2) return 0; } -bool ED_mesh_mirrtopo_recalc_check(Mesh *me, DerivedMesh *dm, MirrTopoStore_t *mesh_topo_store) -{ - const bool is_editmode = (me->edit_btmesh != NULL); - int totvert; - int totedge; - - if (dm) { - totvert = dm->getNumVerts(dm); - totedge = dm->getNumEdges(dm); - } - else if (me->edit_btmesh) { - totvert = me->edit_btmesh->bm->totvert; - totedge = me->edit_btmesh->bm->totedge; - } - else { - totvert = me->totvert; - totedge = me->totedge; - } - - if ((mesh_topo_store->index_lookup == NULL) || - (mesh_topo_store->prev_is_editmode != is_editmode) || - (totvert != mesh_topo_store->prev_vert_tot) || - (totedge != mesh_topo_store->prev_edge_tot)) - { - return true; - } - else { - return false; - } - -} -bool ED_mesh_mirrtopo_recalc_check__real_mesh(Mesh *me, Mesh *dm, MirrTopoStore_t *mesh_topo_store) +bool ED_mesh_mirrtopo_recalc_check(Mesh *me, Mesh *me_eval, MirrTopoStore_t *mesh_topo_store) { const bool is_editmode = (me->edit_btmesh != NULL); int totvert; int totedge; - if (dm) { - totvert = dm->totvert; - totedge = dm->totedge; + if (me_eval) { + totvert = me_eval->totvert; + totedge = me_eval->totedge; } else if (me->edit_btmesh) { totvert = me->edit_btmesh->bm->totvert; @@ -272,33 +175,13 @@ bool ED_mesh_mirrtopo_recalc_check__real_mesh(Mesh *me, Mesh *dm, MirrTopoStore_ } - void ED_mesh_mirrtopo_init( - Mesh *me, DerivedMesh *dm, MirrTopoStore_t *mesh_topo_store, - const bool skip_em_vert_array_init) -{ - Mesh *fake_mesh = NULL; - - if (dm != NULL) { - /* ED_real_mesh_mirrtopo_init() only uses the counts, not the actual data */ - fake_mesh = BKE_mesh_new_nomain(dm->getNumVerts(dm), dm->getNumEdges(dm), dm->getNumTessFaces(dm), - dm->getNumLoops(dm), dm->getNumPolys(dm)); - } - - ED_mesh_mirrtopo_init__real_mesh(me, fake_mesh, mesh_topo_store, skip_em_vert_array_init); - - if (dm != NULL) { - BKE_id_free(NULL, fake_mesh); - } -} - -void ED_mesh_mirrtopo_init__real_mesh( - Mesh *me, Mesh *dm, MirrTopoStore_t *mesh_topo_store, + Mesh *me, Mesh *me_eval, MirrTopoStore_t *mesh_topo_store, const bool skip_em_vert_array_init) { const bool is_editmode = (me->edit_btmesh != NULL); MEdge *medge = NULL, *med; - BMEditMesh *em = dm ? NULL : me->edit_btmesh; + BMEditMesh *em = me_eval ? NULL : me->edit_btmesh; /* editmode*/ BMEdge *eed; @@ -327,7 +210,7 @@ void ED_mesh_mirrtopo_init__real_mesh( totvert = em->bm->totvert; } else { - totvert = dm ? dm->totvert : me->totvert; + totvert = me_eval ? me_eval->totvert : me->totvert; } topo_hash = MEM_callocN(totvert * sizeof(MirrTopoHash_t), "TopoMirr"); @@ -343,8 +226,8 @@ void ED_mesh_mirrtopo_init__real_mesh( } } else { - totedge = dm ? dm->totedge : me->totedge; - medge = dm ? dm->medge : me->medge; + totedge = me_eval ? me_eval->totedge : me->totedge; + medge = me_eval ? me_eval->medge : me->medge; for (a = 0, med = medge; a < totedge; a++, med++) { const unsigned int i1 = med->v1, i2 = med->v2; diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c deleted file mode 100644 index 5cfb269cbc3..00000000000 --- a/source/blender/editors/mesh/mesh_navmesh.c +++ /dev/null @@ -1,732 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2011 by Blender Foundation - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Benoit Bolsee, - * Nick Samarin - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/mesh/mesh_navmesh.c - * \ingroup edmesh - */ - -#include "MEM_guardedalloc.h" - -#include "DNA_scene_types.h" -#include "DNA_object_types.h" -#include "DNA_mesh_types.h" - -#include "BLI_listbase.h" -#include "BLI_math_vector.h" -#include "BLI_linklist.h" - -#include "BKE_library.h" -#include "BKE_depsgraph.h" -#include "BKE_context.h" -#include "BKE_mesh.h" -#include "BKE_scene.h" -#include "BKE_DerivedMesh.h" -#include "BKE_report.h" -#include "BKE_editmesh.h" - -#include "ED_object.h" -#include "ED_mesh.h" -#include "ED_screen.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "recast-capi.h" - -#include "mesh_intern.h" /* own include */ - - -static void createVertsTrisData(bContext *C, LinkNode *obs, - int *nverts_r, float **verts_r, int *ntris_r, int **tris_r, unsigned int *r_lay) -{ - MVert *mvert; - int nfaces = 0, *tri, i, curnverts, basenverts, curnfaces; - MFace *mface; - float co[3], wco[3]; - Object *ob; - LinkNode *oblink, *dmlink; - DerivedMesh *dm; - Scene *scene = CTX_data_scene(C); - LinkNodePair dms_pair = {NULL, NULL}; - - int nverts, ntris, *tris; - float *verts; - - nverts = 0; - ntris = 0; - - /* calculate number of verts and tris */ - for (oblink = obs; oblink; oblink = oblink->next) { - ob = (Object *) oblink->link; - dm = mesh_create_derived_no_virtual(scene, ob, NULL, CD_MASK_MESH); - DM_ensure_tessface(dm); - BLI_linklist_append(&dms_pair, dm); - - nverts += dm->getNumVerts(dm); - nfaces = dm->getNumTessFaces(dm); - ntris += nfaces; - - /* resolve quad faces */ - mface = dm->getTessFaceArray(dm); - for (i = 0; i < nfaces; i++) { - MFace *mf = &mface[i]; - if (mf->v4) - ntris += 1; - } - - *r_lay |= ob->lay; - } - LinkNode *dms = dms_pair.list; - - /* create data */ - verts = MEM_mallocN(sizeof(float) * 3 * nverts, "createVertsTrisData verts"); - tris = MEM_mallocN(sizeof(int) * 3 * ntris, "createVertsTrisData faces"); - - basenverts = 0; - tri = tris; - for (oblink = obs, dmlink = dms; oblink && dmlink; - oblink = oblink->next, dmlink = dmlink->next) - { - ob = (Object *) oblink->link; - dm = (DerivedMesh *) dmlink->link; - - curnverts = dm->getNumVerts(dm); - mvert = dm->getVertArray(dm); - - /* copy verts */ - for (i = 0; i < curnverts; i++) { - MVert *v = &mvert[i]; - - copy_v3_v3(co, v->co); - mul_v3_m4v3(wco, ob->obmat, co); - - verts[3 * (basenverts + i) + 0] = wco[0]; - verts[3 * (basenverts + i) + 1] = wco[2]; - verts[3 * (basenverts + i) + 2] = wco[1]; - } - - /* create tris */ - curnfaces = dm->getNumTessFaces(dm); - mface = dm->getTessFaceArray(dm); - - for (i = 0; i < curnfaces; i++) { - MFace *mf = &mface[i]; - - tri[0] = basenverts + mf->v1; - tri[1] = basenverts + mf->v3; - tri[2] = basenverts + mf->v2; - tri += 3; - - if (mf->v4) { - tri[0] = basenverts + mf->v1; - tri[1] = basenverts + mf->v4; - tri[2] = basenverts + mf->v3; - tri += 3; - } - } - - basenverts += curnverts; - } - - /* release derived mesh */ - for (dmlink = dms; dmlink; dmlink = dmlink->next) { - dm = (DerivedMesh *) dmlink->link; - dm->release(dm); - } - - BLI_linklist_free(dms, NULL); - - *nverts_r = nverts; - *verts_r = verts; - *ntris_r = ntris; - *tris_r = tris; -} - -static bool buildNavMesh(const RecastData *recastParams, int nverts, float *verts, int ntris, int *tris, - struct recast_polyMesh **pmesh, struct recast_polyMeshDetail **dmesh, - ReportList *reports) -{ - float bmin[3], bmax[3]; - struct recast_heightfield *solid; - unsigned char *triflags; - struct recast_compactHeightfield *chf; - struct recast_contourSet *cset; - int width, height, walkableHeight, walkableClimb, walkableRadius; - int minRegionArea, mergeRegionArea, maxEdgeLen; - float detailSampleDist, detailSampleMaxError; - - recast_calcBounds(verts, nverts, bmin, bmax); - - /* ** Step 1. Initialize build config ** */ - walkableHeight = (int)ceilf(recastParams->agentheight / recastParams->cellheight); - walkableClimb = (int)floorf(recastParams->agentmaxclimb / recastParams->cellheight); - walkableRadius = (int)ceilf(recastParams->agentradius / recastParams->cellsize); - minRegionArea = (int)(recastParams->regionminsize * recastParams->regionminsize); - mergeRegionArea = (int)(recastParams->regionmergesize * recastParams->regionmergesize); - maxEdgeLen = (int)(recastParams->edgemaxlen / recastParams->cellsize); - detailSampleDist = recastParams->detailsampledist < 0.9f ? 0 : - recastParams->cellsize * recastParams->detailsampledist; - detailSampleMaxError = recastParams->cellheight * recastParams->detailsamplemaxerror; - - /* Set the area where the navigation will be build. */ - recast_calcGridSize(bmin, bmax, recastParams->cellsize, &width, &height); - - /* zero dimensions cause zero alloc later on [#33758] */ - if (width <= 0 || height <= 0) { - BKE_report(reports, RPT_ERROR, "Object has a width or height of zero"); - return false; - } - - /* ** Step 2: Rasterize input polygon soup ** */ - /* Allocate voxel heightfield where we rasterize our input data to */ - solid = recast_newHeightfield(); - - if (!recast_createHeightfield(solid, width, height, bmin, bmax, recastParams->cellsize, recastParams->cellheight)) { - recast_destroyHeightfield(solid); - BKE_report(reports, RPT_ERROR, "Failed to create height field"); - return false; - } - - /* Allocate array that can hold triangle flags */ - triflags = MEM_callocN(sizeof(unsigned char) * ntris, "buildNavMesh triflags"); - - /* Find triangles which are walkable based on their slope and rasterize them */ - recast_markWalkableTriangles(RAD2DEGF(recastParams->agentmaxslope), verts, nverts, tris, ntris, triflags); - recast_rasterizeTriangles(verts, nverts, tris, triflags, ntris, solid, 1); - MEM_freeN(triflags); - - /* ** Step 3: Filter walkables surfaces ** */ - recast_filterLowHangingWalkableObstacles(walkableClimb, solid); - recast_filterLedgeSpans(walkableHeight, walkableClimb, solid); - recast_filterWalkableLowHeightSpans(walkableHeight, solid); - - /* ** Step 4: Partition walkable surface to simple regions ** */ - - chf = recast_newCompactHeightfield(); - if (!recast_buildCompactHeightfield(walkableHeight, walkableClimb, solid, chf)) { - recast_destroyHeightfield(solid); - recast_destroyCompactHeightfield(chf); - - BKE_report(reports, RPT_ERROR, "Failed to create compact height field"); - return false; - } - - recast_destroyHeightfield(solid); - solid = NULL; - - if (!recast_erodeWalkableArea(walkableRadius, chf)) { - recast_destroyCompactHeightfield(chf); - - BKE_report(reports, RPT_ERROR, "Failed to erode walkable area"); - return false; - } - - if (recastParams->partitioning == RC_PARTITION_WATERSHED) { - /* Prepare for region partitioning, by calculating distance field along the walkable surface */ - if (!recast_buildDistanceField(chf)) { - recast_destroyCompactHeightfield(chf); - - BKE_report(reports, RPT_ERROR, "Failed to build distance field"); - return false; - } - - /* Partition the walkable surface into simple regions without holes */ - if (!recast_buildRegions(chf, 0, minRegionArea, mergeRegionArea)) { - recast_destroyCompactHeightfield(chf); - - BKE_report(reports, RPT_ERROR, "Failed to build watershed regions"); - return false; - } - } - else if (recastParams->partitioning == RC_PARTITION_MONOTONE) { - /* Partition the walkable surface into simple regions without holes */ - /* Monotone partitioning does not need distancefield. */ - if (!recast_buildRegionsMonotone(chf, 0, minRegionArea, mergeRegionArea)) { - recast_destroyCompactHeightfield(chf); - - BKE_report(reports, RPT_ERROR, "Failed to build monotone regions"); - return false; - } - } - else { /* RC_PARTITION_LAYERS */ - /* Partition the walkable surface into simple regions without holes */ - if (!recast_buildLayerRegions(chf, 0, minRegionArea)) { - recast_destroyCompactHeightfield(chf); - - BKE_report(reports, RPT_ERROR, "Failed to build layer regions"); - return false; - } - } - - /* ** Step 5: Trace and simplify region contours ** */ - /* Create contours */ - cset = recast_newContourSet(); - - if (!recast_buildContours(chf, recastParams->edgemaxerror, maxEdgeLen, cset, RECAST_CONTOUR_TESS_WALL_EDGES)) { - recast_destroyCompactHeightfield(chf); - recast_destroyContourSet(cset); - - BKE_report(reports, RPT_ERROR, "Failed to build contours"); - return false; - } - - /* ** Step 6: Build polygons mesh from contours ** */ - *pmesh = recast_newPolyMesh(); - if (!recast_buildPolyMesh(cset, recastParams->vertsperpoly, *pmesh)) { - recast_destroyCompactHeightfield(chf); - recast_destroyContourSet(cset); - recast_destroyPolyMesh(*pmesh); - - BKE_report(reports, RPT_ERROR, "Failed to build poly mesh"); - return false; - } - - - /* ** Step 7: Create detail mesh which allows to access approximate height on each polygon ** */ - - *dmesh = recast_newPolyMeshDetail(); - if (!recast_buildPolyMeshDetail(*pmesh, chf, detailSampleDist, detailSampleMaxError, *dmesh)) { - recast_destroyCompactHeightfield(chf); - recast_destroyContourSet(cset); - recast_destroyPolyMesh(*pmesh); - recast_destroyPolyMeshDetail(*dmesh); - - BKE_report(reports, RPT_ERROR, "Failed to build poly mesh detail"); - return false; - } - - recast_destroyCompactHeightfield(chf); - recast_destroyContourSet(cset); - - return true; -} - -static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, struct recast_polyMeshDetail *dmesh, - Base *base, unsigned int lay) -{ - float co[3], rot[3]; - BMEditMesh *em; - int i, j, k; - unsigned short *v; - int face[3]; - Scene *scene = CTX_data_scene(C); - Object *obedit; - int createob = base == NULL; - int nverts, nmeshes, nvp; - unsigned short *verts, *polys; - unsigned int *meshes; - float bmin[3], cs, ch, *dverts; - unsigned char *tris; - - zero_v3(co); - zero_v3(rot); - - if (createob) { - /* create new object */ - obedit = ED_object_add_type(C, OB_MESH, "Navmesh", co, rot, false, lay); - } - else { - obedit = base->object; - BKE_scene_base_deselect_all(scene); - BKE_scene_base_select(scene, base); - copy_v3_v3(obedit->loc, co); - copy_v3_v3(obedit->rot, rot); - } - - ED_object_editmode_enter(C, EM_IGNORE_LAYER); - em = BKE_editmesh_from_object(obedit); - - if (!createob) { - /* clear */ - EDBM_mesh_clear(em); - } - - /* create verts for polygon mesh */ - verts = recast_polyMeshGetVerts(pmesh, &nverts); - recast_polyMeshGetBoundbox(pmesh, bmin, NULL); - recast_polyMeshGetCell(pmesh, &cs, &ch); - - for (i = 0; i < nverts; i++) { - v = &verts[3 * i]; - co[0] = bmin[0] + v[0] * cs; - co[1] = bmin[1] + v[1] * ch; - co[2] = bmin[2] + v[2] * cs; - SWAP(float, co[1], co[2]); - BM_vert_create(em->bm, co, NULL, BM_CREATE_NOP); - } - - /* create custom data layer to save polygon idx */ - CustomData_add_layer_named(&em->bm->pdata, CD_RECAST, CD_CALLOC, NULL, 0, "createRepresentation recastData"); - CustomData_bmesh_init_pool(&em->bm->pdata, 0, BM_FACE); - - /* create verts and faces for detailed mesh */ - meshes = recast_polyMeshDetailGetMeshes(dmesh, &nmeshes); - polys = recast_polyMeshGetPolys(pmesh, NULL, &nvp); - dverts = recast_polyMeshDetailGetVerts(dmesh, NULL); - tris = recast_polyMeshDetailGetTris(dmesh, NULL); - - for (i = 0; i < nmeshes; i++) { - int uniquevbase = em->bm->totvert; - unsigned int vbase = meshes[4 * i + 0]; - unsigned short ndv = meshes[4 * i + 1]; - unsigned short tribase = meshes[4 * i + 2]; - unsigned short trinum = meshes[4 * i + 3]; - const unsigned short *p = &polys[i * nvp * 2]; - int nv = 0; - - for (j = 0; j < nvp; ++j) { - if (p[j] == 0xffff) break; - nv++; - } - - /* create unique verts */ - for (j = nv; j < ndv; j++) { - copy_v3_v3(co, &dverts[3 * (vbase + j)]); - SWAP(float, co[1], co[2]); - BM_vert_create(em->bm, co, NULL, BM_CREATE_NOP); - } - - /* need to rebuild entirely because array size changes */ - BM_mesh_elem_table_init(em->bm, BM_VERT); - - /* create faces */ - for (j = 0; j < trinum; j++) { - unsigned char *tri = &tris[4 * (tribase + j)]; - BMFace *newFace; - int *polygonIdx; - - for (k = 0; k < 3; k++) { - if (tri[k] < nv) - face[k] = p[tri[k]]; /* shared vertex */ - else - face[k] = uniquevbase + tri[k] - nv; /* unique vertex */ - } - newFace = BM_face_create_quad_tri(em->bm, - BM_vert_at_index(em->bm, face[0]), - BM_vert_at_index(em->bm, face[2]), - BM_vert_at_index(em->bm, face[1]), NULL, - NULL, BM_CREATE_NOP); - - /* set navigation polygon idx to the custom layer */ - polygonIdx = (int *)CustomData_bmesh_get(&em->bm->pdata, newFace->head.data, CD_RECAST); - *polygonIdx = i + 1; /* add 1 to avoid zero idx */ - } - } - - recast_destroyPolyMesh(pmesh); - recast_destroyPolyMeshDetail(dmesh); - - DAG_id_tag_update((ID *)obedit->data, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); - - - ED_object_editmode_exit(C, EM_FREEDATA); - WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); - - if (createob) { - obedit->gameflag &= ~OB_COLLISION; - obedit->gameflag |= OB_NAVMESH; - obedit->body_type = OB_BODY_TYPE_NAVMESH; - } - - BKE_mesh_ensure_navmesh(obedit->data); - - return obedit; -} - -static int navmesh_create_exec(bContext *C, wmOperator *op) -{ - Scene *scene = CTX_data_scene(C); - LinkNode *obs = NULL; - Base *navmeshBase = NULL; - - CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) - { - if (base->object->type == OB_MESH) { - if (base->object->body_type == OB_BODY_TYPE_NAVMESH) { - if (!navmeshBase || base == scene->basact) { - navmeshBase = base; - } - } - else { - BLI_linklist_prepend(&obs, base->object); - } - } - } - CTX_DATA_END; - - if (obs) { - struct recast_polyMesh *pmesh = NULL; - struct recast_polyMeshDetail *dmesh = NULL; - bool ok; - unsigned int lay = 0; - - int nverts = 0, ntris = 0; - int *tris = NULL; - float *verts = NULL; - - createVertsTrisData(C, obs, &nverts, &verts, &ntris, &tris, &lay); - BLI_linklist_free(obs, NULL); - if ((ok = buildNavMesh(&scene->gm.recastData, nverts, verts, ntris, tris, &pmesh, &dmesh, op->reports))) { - createRepresentation(C, pmesh, dmesh, navmeshBase, lay); - } - - MEM_freeN(verts); - MEM_freeN(tris); - - return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED; - } - else { - BKE_report(op->reports, RPT_ERROR, "No mesh objects found"); - - return OPERATOR_CANCELLED; - } -} - -void MESH_OT_navmesh_make(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Create Navigation Mesh"; - ot->description = "Create navigation mesh for selected objects"; - ot->idname = "MESH_OT_navmesh_make"; - - /* api callbacks */ - ot->exec = navmesh_create_exec; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} - -static int navmesh_face_copy_exec(bContext *C, wmOperator *op) -{ - Object *obedit = CTX_data_edit_object(C); - BMEditMesh *em = BKE_editmesh_from_object(obedit); - - /* do work here */ - BMFace *efa_act = BM_mesh_active_face_get(em->bm, false, false); - - if (efa_act) { - if (CustomData_has_layer(&em->bm->pdata, CD_RECAST)) { - BMFace *efa; - BMIter iter; - int targetPolyIdx = *(int *)CustomData_bmesh_get(&em->bm->pdata, efa_act->head.data, CD_RECAST); - targetPolyIdx = targetPolyIdx >= 0 ? targetPolyIdx : -targetPolyIdx; - - if (targetPolyIdx > 0) { - /* set target poly idx to other selected faces */ - BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - if (BM_elem_flag_test(efa, BM_ELEM_SELECT) && efa != efa_act) { - int *recastDataBlock = (int *)CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_RECAST); - *recastDataBlock = targetPolyIdx; - } - } - } - else { - BKE_report(op->reports, RPT_ERROR, "Active face has no index set"); - } - } - } - - DAG_id_tag_update((ID *)obedit->data, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); - - return OPERATOR_FINISHED; -} - -void MESH_OT_navmesh_face_copy(struct wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "NavMesh Copy Face Index"; - ot->description = "Copy the index from the active face"; - ot->idname = "MESH_OT_navmesh_face_copy"; - - /* api callbacks */ - ot->poll = ED_operator_editmesh; - ot->exec = navmesh_face_copy_exec; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} - -static int compare(const void *a, const void *b) -{ - return (*(int *)a - *(int *)b); -} - -static int findFreeNavPolyIndex(BMEditMesh *em) -{ - /* construct vector of indices */ - int numfaces = em->bm->totface; - int *indices = MEM_callocN(sizeof(int) * numfaces, "findFreeNavPolyIndex(indices)"); - BMFace *ef; - BMIter iter; - int i, idx = em->bm->totface - 1, freeIdx = 1; - - /*XXX this originally went last to first, but that isn't possible anymore*/ - BM_ITER_MESH (ef, &iter, em->bm, BM_FACES_OF_MESH) { - int polyIdx = *(int *)CustomData_bmesh_get(&em->bm->pdata, ef->head.data, CD_RECAST); - indices[idx] = polyIdx; - idx--; - } - - qsort(indices, numfaces, sizeof(int), compare); - - /* search first free index */ - freeIdx = 1; - for (i = 0; i < numfaces; i++) { - if (indices[i] == freeIdx) - freeIdx++; - else if (indices[i] > freeIdx) - break; - } - - MEM_freeN(indices); - - return freeIdx; -} - -static int navmesh_face_add_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Object *obedit = CTX_data_edit_object(C); - BMEditMesh *em = BKE_editmesh_from_object(obedit); - BMFace *ef; - BMIter iter; - - if (CustomData_has_layer(&em->bm->pdata, CD_RECAST)) { - int targetPolyIdx = findFreeNavPolyIndex(em); - - if (targetPolyIdx > 0) { - /* set target poly idx to selected faces */ - /*XXX this originally went last to first, but that isn't possible anymore*/ - - BM_ITER_MESH (ef, &iter, em->bm, BM_FACES_OF_MESH) { - if (BM_elem_flag_test(ef, BM_ELEM_SELECT)) { - int *recastDataBlock = (int *)CustomData_bmesh_get(&em->bm->pdata, ef->head.data, CD_RECAST); - *recastDataBlock = targetPolyIdx; - } - } - } - } - - DAG_id_tag_update((ID *)obedit->data, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); - - return OPERATOR_FINISHED; -} - -void MESH_OT_navmesh_face_add(struct wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "NavMesh New Face Index"; - ot->description = "Add a new index and assign it to selected faces"; - ot->idname = "MESH_OT_navmesh_face_add"; - - /* api callbacks */ - ot->poll = ED_operator_editmesh; - ot->exec = navmesh_face_add_exec; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} - -static int navmesh_obmode_data_poll(bContext *C) -{ - Object *ob = ED_object_active_context(C); - if (ob && (ob->mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) { - Mesh *me = ob->data; - return CustomData_has_layer(&me->pdata, CD_RECAST); - } - return false; -} - -static int navmesh_obmode_poll(bContext *C) -{ - Object *ob = ED_object_active_context(C); - if (ob && (ob->mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) { - return true; - } - return false; -} - -static int navmesh_reset_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Object *ob = ED_object_active_context(C); - Mesh *me = ob->data; - - CustomData_free_layers(&me->pdata, CD_RECAST, me->totpoly); - - BKE_mesh_ensure_navmesh(me); - - DAG_id_tag_update(&me->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, &me->id); - - return OPERATOR_FINISHED; -} - -void MESH_OT_navmesh_reset(struct wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "NavMesh Reset Index Values"; - ot->description = "Assign a new index to every face"; - ot->idname = "MESH_OT_navmesh_reset"; - - /* api callbacks */ - ot->poll = navmesh_obmode_poll; - ot->exec = navmesh_reset_exec; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} - -static int navmesh_clear_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Object *ob = ED_object_active_context(C); - Mesh *me = ob->data; - - CustomData_free_layers(&me->pdata, CD_RECAST, me->totpoly); - - DAG_id_tag_update(&me->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, &me->id); - - return OPERATOR_FINISHED; -} - -void MESH_OT_navmesh_clear(struct wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "NavMesh Clear Data"; - ot->description = "Remove navmesh data from this mesh"; - ot->idname = "MESH_OT_navmesh_clear"; - - /* api callbacks */ - ot->poll = navmesh_obmode_data_poll; - ot->exec = navmesh_clear_exec; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 546c000d726..09d6ea7226a 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -329,7 +329,6 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) { wmKeyMap *keymap; wmKeyMapItem *kmi; - int i; keymap = WM_keymap_find(keyconf, "Mesh", 0, 0); keymap->poll = ED_operator_editmesh; @@ -337,7 +336,9 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MESH_OT_loopcut_slide", RKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "MESH_OT_offset_edge_loops_slide", RKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_item(keymap, "MESH_OT_inset", IKEY, KM_PRESS, 0, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "MESH_OT_poke", PKEY, KM_PRESS, KM_ALT, 0); +#endif kmi = WM_keymap_add_item(keymap, "MESH_OT_bevel", BKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "vertex_only", false); kmi = WM_keymap_add_item(keymap, "MESH_OT_bevel", BKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); @@ -398,7 +399,9 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MESH_OT_select_next_item", PADPLUSKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_item(keymap, "MESH_OT_select_prev_item", PADMINUS, KM_PRESS, KM_CTRL | KM_SHIFT, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "MESH_OT_select_non_manifold", MKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0); +#endif WM_keymap_add_item(keymap, "MESH_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0); kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0); @@ -406,7 +409,9 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "deselect", true); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "MESH_OT_faces_select_linked_flat", FKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0); +#endif WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0); @@ -418,20 +423,31 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MESH_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0); /* tools */ +#ifdef USE_WM_KEYMAP_27X kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "inside", false); kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "inside", true); +#else + kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "inside", false); + kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); + RNA_boolean_set(kmi->ptr, "inside", true); +#endif WM_keymap_add_item(keymap, "VIEW3D_OT_edit_mesh_extrude_move_normal", EKEY, KM_PRESS, 0, 0); /* python operator */ WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_extrude", EKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TRANSFORM_OT_edge_crease", EKEY, KM_PRESS, KM_SHIFT, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "MESH_OT_spin", RKEY, KM_PRESS, KM_ALT, 0); +#endif WM_keymap_add_item(keymap, "MESH_OT_fill", FKEY, KM_PRESS, KM_ALT, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "MESH_OT_beautify_fill", FKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0); +#endif kmi = WM_keymap_add_item(keymap, "MESH_OT_quads_convert_to_tris", TKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "quad_method", MOD_TRIANGULATE_QUAD_BEAUTY); @@ -490,9 +506,11 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "use_occlude_geometry", true); RNA_boolean_set(kmi->ptr, "only_selected", false); +#ifdef USE_WM_KEYMAP_27X kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "use_occlude_geometry", false); RNA_boolean_set(kmi->ptr, "only_selected", true); +#endif WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); @@ -505,11 +523,13 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "VIEW3D_MT_uv_map", UKEY, KM_PRESS, 0, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_vertex_group", GKEY, KM_PRESS, KM_CTRL, 0); +#ifdef USE_WM_KEYMAP_27X /* useful stuff from object-mode */ - for (i = 0; i <= 5; i++) { + for (int i = 0; i <= 5; i++) { kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY + i, KM_PRESS, KM_CTRL, 0); RNA_int_set(kmi->ptr, "level", i); } +#endif ED_keymap_proportional_cycle(keyconf, keymap); ED_keymap_proportional_editmode(keyconf, keymap, true); @@ -517,4 +537,3 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) knifetool_modal_keymap(keyconf); point_normals_modal_keymap(keyconf); } - diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 6c8de1a481e..537056cd1ba 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -34,9 +34,10 @@ #include "MEM_guardedalloc.h" -#include "DNA_mesh_types.h" #include "DNA_key_types.h" #include "DNA_material_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -49,11 +50,11 @@ #include "BKE_context.h" #include "BKE_deform.h" -#include "BKE_DerivedMesh.h" #include "BKE_key.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_mesh.h" +#include "BKE_mesh_iterators.h" #include "BKE_mesh_runtime.h" #include "BKE_material.h" #include "BKE_object.h" @@ -612,7 +613,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) Depsgraph *depsgraph = CTX_data_depsgraph(C); Mesh *me = (Mesh *)ob->data; Mesh *selme = NULL; - DerivedMesh *dm = NULL; + Mesh *me_deformed = NULL; Key *key = me->key; KeyBlock *kb; bool ok = false, nonequal_verts = false; @@ -646,7 +647,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) /* first key added, so it was the basis. initialize it with the existing mesh */ kb = BKE_keyblock_add(key, NULL); - BKE_keyblock_convert_from_mesh(me, kb); + BKE_keyblock_convert_from_mesh(me, key, kb); } /* now ready to add new keys from selected meshes */ @@ -658,15 +659,15 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) selme = (Mesh *)base->object->data; if (selme->totvert == me->totvert) { - dm = mesh_get_derived_deform(depsgraph, scene, base->object, CD_MASK_BAREMESH); + me_deformed = mesh_get_eval_deform(depsgraph, scene, base->object, CD_MASK_BAREMESH); - if (!dm) continue; + if (!me_deformed) { + continue; + } kb = BKE_keyblock_add(key, base->object->id.name + 2); - DM_to_meshkey(dm, me, kb); - - dm->release(dm); + BKE_mesh_runtime_eval_to_meshkey(me_deformed, me, kb); } } } @@ -690,40 +691,15 @@ static MirrTopoStore_t mesh_topo_store = {NULL, -1. - 1, -1}; /* mode is 's' start, or 'e' end, or 'u' use */ /* if end, ob can be NULL */ /* note, is supposed return -1 on error, which callers are currently checking for, but is not used so far */ -int ED_mesh_mirror_topo_table( - Object *ob, DerivedMesh *dm, char mode) +int ED_mesh_mirror_topo_table(Object *ob, Mesh *me_eval, char mode) { if (mode == 'u') { /* use table */ - if (ED_mesh_mirrtopo_recalc_check(ob->data, dm, &mesh_topo_store)) { - ED_mesh_mirror_topo_table(ob, dm, 's'); + if (ED_mesh_mirrtopo_recalc_check(ob->data, me_eval, &mesh_topo_store)) { + ED_mesh_mirror_topo_table(ob, me_eval, 's'); } } else if (mode == 's') { /* start table */ - ED_mesh_mirrtopo_init(ob->data, dm, &mesh_topo_store, false); - } - else if (mode == 'e') { /* end table */ - ED_mesh_mirrtopo_free(&mesh_topo_store); - } - else { - BLI_assert(0); - } - - return 0; -} - -/* mode is 's' start, or 'e' end, or 'u' use */ -/* if end, ob can be NULL */ -/* note, is supposed return -1 on error, which callers are currently checking for, but is not used so far */ -int ED_mesh_mirror_topo_table__real_mesh( - Object *ob, Mesh *mesh, char mode) -{ - if (mode == 'u') { /* use table */ - if (ED_mesh_mirrtopo_recalc_check__real_mesh(ob->data, mesh, &mesh_topo_store)) { - ED_mesh_mirror_topo_table__real_mesh(ob, mesh, 's'); - } - } - else if (mode == 's') { /* start table */ - ED_mesh_mirrtopo_init__real_mesh(ob->data, mesh, &mesh_topo_store, false); + ED_mesh_mirrtopo_init(ob->data, me_eval, &mesh_topo_store, false); } else if (mode == 'e') { /* end table */ ED_mesh_mirrtopo_free(&mesh_topo_store); @@ -738,39 +714,7 @@ int ED_mesh_mirror_topo_table__real_mesh( /** \} */ -static int mesh_get_x_mirror_vert_spatial(Object *ob, DerivedMesh *dm, int index) -{ - Mesh *me = ob->data; - MVert *mvert = dm ? dm->getVertArray(dm) : me->mvert; - float vec[3]; - - mvert = &mvert[index]; - vec[0] = -mvert->co[0]; - vec[1] = mvert->co[1]; - vec[2] = mvert->co[2]; - - return ED_mesh_mirror_spatial_table(ob, NULL, dm, vec, 'u'); -} - -static int mesh_get_x_mirror_vert_topo(Object *ob, DerivedMesh *dm, int index) -{ - if (ED_mesh_mirror_topo_table(ob, dm, 'u') == -1) - return -1; - - return mesh_topo_store.index_lookup[index]; -} - -int mesh_get_x_mirror_vert(Object *ob, DerivedMesh *dm, int index, const bool use_topology) -{ - if (use_topology) { - return mesh_get_x_mirror_vert_topo(ob, dm, index); - } - else { - return mesh_get_x_mirror_vert_spatial(ob, dm, index); - } -} - -static int mesh_get_x_mirror_vert_spatial__real_mesh(Object *ob, Mesh *mesh, int index) +static int mesh_get_x_mirror_vert_spatial(Object *ob, Mesh *mesh, int index) { Mesh *me = ob->data; MVert *mvert = mesh ? mesh->mvert : me->mvert; @@ -781,24 +725,24 @@ static int mesh_get_x_mirror_vert_spatial__real_mesh(Object *ob, Mesh *mesh, int vec[1] = mvert->co[1]; vec[2] = mvert->co[2]; - return ED_mesh_mirror_spatial_table__real_mesh(ob, NULL, mesh, vec, 'u'); + return ED_mesh_mirror_spatial_table(ob, NULL, mesh, vec, 'u'); } -static int mesh_get_x_mirror_vert_topo__real_mesh(Object *ob, Mesh *mesh, int index) +static int mesh_get_x_mirror_vert_topo(Object *ob, Mesh *mesh, int index) { - if (ED_mesh_mirror_topo_table__real_mesh(ob, mesh, 'u') == -1) + if (ED_mesh_mirror_topo_table(ob, mesh, 'u') == -1) return -1; return mesh_topo_store.index_lookup[index]; } -int mesh_get_x_mirror_vert__real_mesh(Object *ob, Mesh *mesh, int index, const bool use_topology) +int mesh_get_x_mirror_vert(Object *ob, Mesh *me_eval, int index, const bool use_topology) { if (use_topology) { - return mesh_get_x_mirror_vert_topo__real_mesh(ob, mesh, index); + return mesh_get_x_mirror_vert_topo(ob, me_eval, index); } else { - return mesh_get_x_mirror_vert_spatial__real_mesh(ob, mesh, index); + return mesh_get_x_mirror_vert_spatial(ob, me_eval, index); } } @@ -995,68 +939,8 @@ static bool mirror_facecmp(const void *a, const void *b) return (mirror_facerotation((MFace *)a, (MFace *)b) == -1); } -/* BMESH_TODO, convert to MPoly (functions above also) */ -int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, DerivedMesh *dm) -{ - Mesh *me = ob->data; - MVert *mv, *mvert; - MFace mirrormf, *mf, *hashmf, *mface; - GHash *fhash; - int *mirrorverts, *mirrorfaces; - - BLI_assert(em == NULL); /* Does not work otherwise, currently... */ - - const bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0; - const int totvert = dm ? dm->getNumVerts(dm) : me->totvert; - const int totface = dm ? dm->getNumTessFaces(dm) : me->totface; - int a; - - mirrorverts = MEM_callocN(sizeof(int) * totvert, "MirrorVerts"); - mirrorfaces = MEM_callocN(sizeof(int) * 2 * totface, "MirrorFaces"); - - mvert = dm ? dm->getVertArray(dm) : me->mvert; - mface = dm ? dm->getTessFaceArray(dm) : me->mface; - - ED_mesh_mirror_spatial_table(ob, em, dm, NULL, 's'); - - for (a = 0, mv = mvert; a < totvert; a++, mv++) - mirrorverts[a] = mesh_get_x_mirror_vert(ob, dm, a, use_topology); - - ED_mesh_mirror_spatial_table(ob, em, dm, NULL, 'e'); - - fhash = BLI_ghash_new_ex(mirror_facehash, mirror_facecmp, "mirror_facehash gh", me->totface); - for (a = 0, mf = mface; a < totface; a++, mf++) - BLI_ghash_insert(fhash, mf, mf); - - for (a = 0, mf = mface; a < totface; a++, mf++) { - mirrormf.v1 = mirrorverts[mf->v3]; - mirrormf.v2 = mirrorverts[mf->v2]; - mirrormf.v3 = mirrorverts[mf->v1]; - mirrormf.v4 = (mf->v4) ? mirrorverts[mf->v4] : 0; - - /* make sure v4 is not 0 if a quad */ - if (mf->v4 && mirrormf.v4 == 0) { - SWAP(unsigned int, mirrormf.v1, mirrormf.v3); - SWAP(unsigned int, mirrormf.v2, mirrormf.v4); - } - - hashmf = BLI_ghash_lookup(fhash, &mirrormf); - if (hashmf) { - mirrorfaces[a * 2] = hashmf - mface; - mirrorfaces[a * 2 + 1] = mirror_facerotation(&mirrormf, hashmf); - } - else - mirrorfaces[a * 2] = -1; - } - - BLI_ghash_free(fhash, NULL, NULL); - MEM_freeN(mirrorverts); - - return mirrorfaces; -} - /* This is a Mesh-based copy of mesh_get_x_mirror_faces() */ -int *mesh_get_x_mirror_faces__real_mesh(Object *ob, BMEditMesh *em, Mesh *mesh) +int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) { Mesh *me = ob->data; MVert *mv, *mvert; @@ -1067,22 +951,22 @@ int *mesh_get_x_mirror_faces__real_mesh(Object *ob, BMEditMesh *em, Mesh *mesh) BLI_assert(em == NULL); /* Does not work otherwise, currently... */ const bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0; - const int totvert = mesh ? mesh->totvert : me->totvert; - const int totface = mesh ? mesh->totface : me->totface; + const int totvert = me_eval ? me_eval->totvert : me->totvert; + const int totface = me_eval ? me_eval->totface : me->totface; int a; mirrorverts = MEM_callocN(sizeof(int) * totvert, "MirrorVerts"); mirrorfaces = MEM_callocN(sizeof(int) * 2 * totface, "MirrorFaces"); - mvert = mesh ? mesh->mvert : me->mvert; - mface = mesh ? mesh->mface : me->mface; + mvert = me_eval ? me_eval->mvert : me->mvert; + mface = me_eval ? me_eval->mface : me->mface; - ED_mesh_mirror_spatial_table__real_mesh(ob, em, mesh, NULL, 's'); + ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 's'); for (a = 0, mv = mvert; a < totvert; a++, mv++) - mirrorverts[a] = mesh_get_x_mirror_vert__real_mesh(ob, mesh, a, use_topology); + mirrorverts[a] = mesh_get_x_mirror_vert(ob, me_eval, a, use_topology); - ED_mesh_mirror_spatial_table__real_mesh(ob, em, mesh, NULL, 'e'); + ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 'e'); fhash = BLI_ghash_new_ex(mirror_facehash, mirror_facecmp, "mirror_facehash gh", me->totface); for (a = 0, mf = mface; a < totface; a++, mf++) @@ -1322,7 +1206,7 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int } else { /* derived mesh to find deformed locations */ - DerivedMesh *dm = mesh_get_derived_final(vc.depsgraph, vc.scene, ob, CD_MASK_BAREMESH); + Mesh *me_eval = mesh_get_eval_final(vc.depsgraph, vc.scene, ob, CD_MASK_BAREMESH); ARegion *ar = vc.ar; RegionView3D *rv3d = ar->regiondata; @@ -1334,7 +1218,7 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int ED_view3d_init_mats_rv3d(ob, rv3d); - if (dm == NULL) { + if (me_eval == NULL) { return false; } @@ -1345,9 +1229,7 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int data.len_best = FLT_MAX; data.v_idx_best = -1; - dm->foreachMappedVert(dm, ed_mesh_pick_vert__mapFunc, &data, DM_FOREACH_NOP); - - dm->release(dm); + BKE_mesh_foreach_mapped_vert(me_eval, ed_mesh_pick_vert__mapFunc, &data, MESH_FOREACH_NOP); if (data.v_idx_best == -1) { return false; diff --git a/source/blender/editors/metaball/mball_intern.h b/source/blender/editors/metaball/mball_intern.h index 6e96514c022..927a8acf5db 100644 --- a/source/blender/editors/metaball/mball_intern.h +++ b/source/blender/editors/metaball/mball_intern.h @@ -47,4 +47,3 @@ void MBALL_OT_select_similar(struct wmOperatorType *ot); void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot); #endif - diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c index 2e1b7299295..567ef3150bf 100644 --- a/source/blender/editors/metaball/mball_ops.c +++ b/source/blender/editors/metaball/mball_ops.c @@ -85,6 +85,7 @@ void ED_keymap_metaball(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MBALL_OT_delete_metaelems", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MBALL_OT_delete_metaelems", DELKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "MBALL_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", AKEY, KM_PRESS, 0, 0); @@ -97,4 +98,3 @@ void ED_keymap_metaball(wmKeyConfig *keyconf) ED_keymap_proportional_cycle(keyconf, keymap); ED_keymap_proportional_editmode(keyconf, keymap, true); } - diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index dd358b95722..a8c3c905dd4 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -333,7 +333,8 @@ bool ED_object_add_generic_get_opts(bContext *C, wmOperator *op, const char view /* Get layers! */ { - int a, layer_values[20]; + int a; + bool layer_values[20]; if (!layer) layer = &_layer; @@ -946,7 +947,7 @@ static int empty_drop_named_image_invoke(bContext *C, wmOperator *op, const wmEv /* add under the mouse */ ED_object_location_from_view(C, ob->loc); - ED_view3d_cursor3d_position(C, ob->loc, event->mval); + ED_view3d_cursor3d_position(C, event->mval, false, ob->loc); } BKE_object_empty_draw_type_set(ob, OB_EMPTY_IMAGE); @@ -1013,7 +1014,21 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; ob = ED_object_add_type(C, OB_LAMP, get_lamp_defname(type), loc, rot, false, layer); - BKE_object_obdata_size_init(ob, RNA_float_get(op->ptr, "radius")); + + float size = RNA_float_get(op->ptr, "radius"); + /* Better defaults for lamp size. */ + switch (type) { + case LA_LOCAL: + case LA_SPOT: + break; + case LA_AREA: + size *= 4.0f; + break; + default: + size *= 0.5f; + break; + } + BKE_object_obdata_size_init(ob, size); la = (Lamp *)ob->data; la->type = type; @@ -1070,7 +1085,7 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op) const int mval[2] = {event->x - ar->winrct.xmin, event->y - ar->winrct.ymin}; ED_object_location_from_view(C, loc); - ED_view3d_cursor3d_position(C, loc, mval); + ED_view3d_cursor3d_position(C, mval, false, loc); RNA_float_set_array(op->ptr, "location", loc); } } @@ -1097,8 +1112,6 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op) /* works without this except if you try render right after, see: 22027 */ DEG_relations_tag_update(bmain); - DEG_id_tag_update(&collection->id, 0); - DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); @@ -1648,7 +1661,7 @@ static void curvetomesh(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object } } -static int convert_poll(bContext *C) +static bool convert_poll(bContext *C) { Scene *scene = CTX_data_scene(C); Base *base_act = CTX_data_active_base(C); @@ -2002,9 +2015,6 @@ static int convert_exec(bContext *C, wmOperator *op) } FOREACH_SCENE_OBJECT_END; } - - /* delete object should renew depsgraph */ - DEG_relations_tag_update(bmain); } // XXX ED_object_editmode_enter(C, 0); @@ -2079,7 +2089,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, ViewLayer DEG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA); base = BKE_view_layer_base_find(view_layer, ob); - if ((base != NULL) && (base->flag & BASE_VISIBLED)) { + if ((base != NULL) && (base->flag & BASE_VISIBLE)) { BKE_collection_object_add_from(bmain, scene, ob, obn); } else { @@ -2426,7 +2436,7 @@ static int add_named_exec(bContext *C, wmOperator *op) const int mval[2] = {event->x - ar->winrct.xmin, event->y - ar->winrct.ymin}; ED_object_location_from_view(C, basen->object->loc); - ED_view3d_cursor3d_position(C, basen->object->loc, mval); + ED_view3d_cursor3d_position(C, mval, false, basen->object->loc); } ED_object_base_select(basen, BA_SELECT); @@ -2466,7 +2476,7 @@ void OBJECT_OT_add_named(wmOperatorType *ot) /**************************** Join *************************/ -static int join_poll(bContext *C) +static bool join_poll(bContext *C) { Object *ob = CTX_data_active_object(C); @@ -2518,7 +2528,7 @@ void OBJECT_OT_join(wmOperatorType *ot) /**************************** Join as Shape Key*************************/ -static int join_shapes_poll(bContext *C) +static bool join_shapes_poll(bContext *C) { Object *ob = CTX_data_active_object(C); diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index a8da5c038b4..8ad0d09a9fb 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -118,6 +118,7 @@ typedef struct MultiresBakerJobData { /* data passing to multires-baker job */ typedef struct { + Scene *scene; ListBase data; bool bake_clear; /* Clear the images before baking */ int bake_filter; /* Bake-filter, aka margin */ @@ -241,7 +242,7 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l tmp_mmd.lvl = *lvl; tmp_mmd.sculptlvl = *lvl; - dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0); + dm = multires_make_derived_from_derived(cddm, &tmp_mmd, scene, ob, 0); cddm->release(cddm); return dm; @@ -268,7 +269,7 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l tmp_mmd.lvl = mmd->totlvl; tmp_mmd.sculptlvl = mmd->totlvl; - dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0); + dm = multires_make_derived_from_derived(cddm, &tmp_mmd, scene, ob, 0); cddm->release(cddm); return dm; @@ -371,6 +372,7 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) multires_force_update(ob); /* copy data stored in job descriptor */ + bkr.scene = scene; bkr.bake_filter = scene->r.bake_filter; bkr.mode = scene->r.bake_mode; bkr.use_lores_mesh = scene->r.bake_flag & R_BAKE_LORES_MESH; @@ -413,6 +415,7 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj) Object *ob; /* backup scene settings, so their changing in UI would take no effect on baker */ + bkj->scene = scene; bkj->bake_filter = scene->r.bake_filter; bkj->mode = scene->r.bake_mode; bkj->use_lores_mesh = scene->r.bake_flag & R_BAKE_LORES_MESH; @@ -474,6 +477,7 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa MultiresBakeRender bkr = {NULL}; /* copy data stored in job descriptor */ + bkr.scene = bkj->scene; bkr.bake_filter = bkj->bake_filter; bkr.mode = bkj->mode; bkr.use_lores_mesh = bkj->use_lores_mesh; diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 3b5a8d190ff..d7bef459b82 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -578,7 +578,7 @@ static const EnumPropertyItem constraint_owner_items[] = { {0, NULL, 0, NULL, NULL}}; -static int edit_constraint_poll_generic(bContext *C, StructRNA *rna_type) +static bool edit_constraint_poll_generic(bContext *C, StructRNA *rna_type) { PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", rna_type); Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C); @@ -606,7 +606,7 @@ static int edit_constraint_poll_generic(bContext *C, StructRNA *rna_type) return 1; } -static int edit_constraint_poll(bContext *C) +static bool edit_constraint_poll(bContext *C) { return edit_constraint_poll_generic(C, &RNA_Constraint); } @@ -1265,7 +1265,7 @@ void ED_object_constraint_dependency_tag_update(Main *bmain, Object *ob, bConstr DEG_relations_tag_update(bmain); } -static int constraint_poll(bContext *C) +static bool constraint_poll(bContext *C) { PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint); return (ptr.id.data && ptr.data); @@ -2102,4 +2102,3 @@ void POSE_OT_ik_clear(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } - diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c index 788f0826848..f56fd560946 100644 --- a/source/blender/editors/object/object_data_transfer.c +++ b/source/blender/editors/object/object_data_transfer.c @@ -442,7 +442,7 @@ static int data_transfer_exec(bContext *C, wmOperator *op) /* Used by both OBJECT_OT_data_transfer and OBJECT_OT_datalayout_transfer */ /* Note this context poll is only really partial, it cannot check for all possible invalid cases. */ -static int data_transfer_poll(bContext *C) +static bool data_transfer_poll(bContext *C) { Object *ob = ED_object_active_context(C); ID *data = (ob) ? ob->data : NULL; @@ -610,7 +610,7 @@ void OBJECT_OT_data_transfer(wmOperatorType *ot) * or as a DataTransfer modifier tool. */ -static int datalayout_transfer_poll(bContext *C) +static bool datalayout_transfer_poll(bContext *C) { return (edit_modifier_poll_generic(C, &RNA_DataTransferModifier, (1 << OB_MESH)) || data_transfer_poll(C)); } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index f050297ee2f..0ca797e43b6 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -148,7 +148,7 @@ Object *ED_object_active_context(bContext *C) /* ********************** object hiding *************************** */ -static int object_hide_poll(bContext *C) +static bool object_hide_poll(bContext *C) { if (CTX_wm_space_outliner(C) != NULL) { return ED_outliner_collections_editor_poll(C); @@ -166,8 +166,8 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *op) bool changed = false; for (Base *base = view_layer->object_bases.first; base; base = base->next) { - if (base->flag & BASE_HIDE) { - base->flag &= ~BASE_HIDE; + if (base->flag & BASE_HIDDEN) { + base->flag &= ~BASE_HIDDEN; changed = true; if (select) { @@ -210,33 +210,42 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); const bool unselected = RNA_boolean_get(op->ptr, "unselected"); - bool changed = false; + /* Do nothing if no objects was selected. */ + bool have_selected = false; + for (Base *base = view_layer->object_bases.first; base; base = base->next) { + if (base->flag & BASE_VISIBLE) { + if (base->flag & BASE_SELECTED) { + have_selected = true; + break; + } + } + } + + if (!have_selected) { + return OPERATOR_CANCELLED; + } + + /* Hide selected or unselected objects. */ for (Base *base = view_layer->object_bases.first; base; base = base->next) { - if (!(base->flag & BASE_VISIBLED)) { + if (!(base->flag & BASE_VISIBLE)) { continue; } if (!unselected) { if (base->flag & BASE_SELECTED) { ED_object_base_select(base, BA_DESELECT); - base->flag |= BASE_HIDE; - changed = true; + base->flag |= BASE_HIDDEN; } } else { if (!(base->flag & BASE_SELECTED)) { ED_object_base_select(base, BA_DESELECT); - base->flag |= BASE_HIDE; - changed = true; + base->flag |= BASE_HIDDEN; } } } - if (!changed) { - return OPERATOR_CANCELLED; - } - BKE_layer_collection_sync(scene, view_layer); DEG_id_tag_update(&scene->id, DEG_TAG_BASE_FLAGS_UPDATE); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); @@ -306,7 +315,8 @@ void ED_hide_collections_menu_draw(const bContext *C, uiLayout *layout) } if ((view_layer->runtime_flag & VIEW_LAYER_HAS_HIDE) && - !(lc->runtime_flag & LAYER_COLLECTION_HAS_VISIBLE_OBJECTS)) { + !(lc->runtime_flag & LAYER_COLLECTION_HAS_VISIBLE_OBJECTS)) + { uiLayoutSetActive(row, false); } @@ -704,7 +714,7 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int editmode_toggle_poll(bContext *C) +static bool editmode_toggle_poll(bContext *C) { Object *ob = CTX_data_active_object(C); @@ -876,7 +886,6 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev Base *base; Curve *cu, *cu1; Nurb *nu; - bool do_depgraph_update = false; if (ID_IS_LINKED(scene)) return; @@ -1033,8 +1042,8 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev else if (event == 22) { /* Copy the constraint channels over */ BKE_constraints_copy(&base->object->constraints, &ob->constraints, true); - - do_depgraph_update = true; + DEG_id_tag_update(&base->object->id, DEG_TAG_COPY_ON_WRITE); + DEG_relations_tag_update(bmain); } else if (event == 23) { base->object->softflag = ob->softflag; @@ -1045,6 +1054,9 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev if (!modifiers_findByType(base->object, eModifierType_Softbody)) { BLI_addhead(&base->object->modifiers, modifier_new(eModifierType_Softbody)); } + + DEG_id_tag_update(&base->object->id, DEG_TAG_COPY_ON_WRITE); + DEG_relations_tag_update(bmain); } else if (event == 26) { #if 0 // XXX old animation system @@ -1085,9 +1097,6 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev } } } - - if (do_depgraph_update) - DEG_relations_tag_update(bmain); } static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, ViewLayer *view_layer, Object *obedit) @@ -1316,7 +1325,7 @@ void OBJECT_OT_paths_calculate(wmOperatorType *ot) /* --------- */ -static int object_update_paths_poll(bContext *C) +static bool object_update_paths_poll(bContext *C) { if (ED_operator_object_active_editable(C)) { Object *ob = ED_object_active_context(C); @@ -1485,7 +1494,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) return (done) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } -static int shade_poll(bContext *C) +static bool shade_poll(bContext *C) { return (CTX_data_edit_object(C) == NULL); } @@ -1572,7 +1581,7 @@ static const EnumPropertyItem *object_mode_set_itemsf( return item; } -static int object_mode_set_poll(bContext *C) +static bool object_mode_set_poll(bContext *C) { /* Since Grease Pencil editmode is also handled here, * we have a special exception for allowing this operator @@ -1770,7 +1779,7 @@ bool ED_object_editmode_calc_active_center(Object *obedit, const bool select_onl return false; } -static int move_to_collection_poll(bContext *C) +static bool move_to_collection_poll(bContext *C) { if (CTX_wm_space_outliner(C) != NULL) { return ED_outliner_collections_editor_poll(C); @@ -1850,7 +1859,7 @@ static int move_to_collection_exec(bContext *C, wmOperator *op) is_link ? "linked" : "moved", collection->id.name + 2); - DEG_relations_tag_update(CTX_data_main(C)); + DEG_relations_tag_update(bmain); DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); @@ -2089,4 +2098,3 @@ void OBJECT_OT_link_to_collection(wmOperatorType *ot) "Name of the newly added collection"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); } - diff --git a/source/blender/editors/object/object_facemap_ops.c b/source/blender/editors/object/object_facemap_ops.c index c5882560083..a561556bba0 100644 --- a/source/blender/editors/object/object_facemap_ops.c +++ b/source/blender/editors/object/object_facemap_ops.c @@ -163,14 +163,14 @@ static void object_facemap_swap(Object *ob, int num1, int num2) object_fmap_swap_object_mode(ob, num1, num2); } -static int face_map_supported_poll(bContext *C) +static bool face_map_supported_poll(bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; return (ob && !ob->id.lib && ob->type == OB_MESH && data && !data->lib); } -static int face_map_supported_edit_mode_poll(bContext *C) +static bool face_map_supported_edit_mode_poll(bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index 8a52b6c5ef5..53cabe3759e 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -47,6 +47,7 @@ #include "BKE_report.h" #include "BKE_object.h" +#include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" #include "ED_screen.h" @@ -153,6 +154,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op) if (!BKE_collection_object_cyclic_check(bmain, base->object, collection)) { BKE_collection_object_add(bmain, collection, base->object); + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); updated = true; } else { @@ -223,6 +225,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { BKE_collection_object_remove(bmain, collection, base->object, false); + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); ok = 1; } CTX_DATA_END; @@ -315,6 +318,7 @@ static int collection_objects_remove_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { BKE_collection_object_remove(bmain, collection, base->object, false); + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); updated = true; } CTX_DATA_END; @@ -366,6 +370,7 @@ static int collection_create_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Base *, base, selected_bases) { BKE_collection_object_add(bmain, collection, base->object); + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); } CTX_DATA_END; @@ -555,7 +560,7 @@ static int select_grouped_exec(bContext *C, wmOperator *UNUSED(op)) /* Select o CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { if (BKE_collection_has_object_recursive(collection, base->object)) { ED_object_base_select(base, BA_SELECT); } diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 6a3cb9aa097..392fde4ceec 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -434,7 +434,7 @@ static void object_hook_select(Object *ob, HookModifierData *hmd) /* special poll operators for hook operators */ /* TODO: check for properties window modifier context too as alternative? */ -static int hook_op_edit_poll(bContext *C) +static bool hook_op_edit_poll(bContext *C) { Object *obedit = CTX_data_edit_object(C); @@ -917,4 +917,3 @@ void OBJECT_OT_hook_select(wmOperatorType *ot) RNA_def_enum_funcs(prop, hook_mod_itemf); RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE); } - diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index f7179912f52..b1ea6d72346 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -145,8 +145,8 @@ void COLLECTION_OT_objects_add_active(struct wmOperatorType *ot); void COLLECTION_OT_objects_remove_active(struct wmOperatorType *ot); /* object_modifier.c */ -int edit_modifier_poll_generic(struct bContext *C, struct StructRNA *rna_type, int obtype_flag); -int edit_modifier_poll(struct bContext *C); +bool edit_modifier_poll_generic(struct bContext *C, struct StructRNA *rna_type, int obtype_flag); +bool edit_modifier_poll(struct bContext *C); void edit_modifier_properties(struct wmOperatorType *ot); int edit_modifier_invoke_properties(struct bContext *C, struct wmOperator *op); struct ModifierData *edit_modifier_property_get(struct wmOperator *op, struct Object *ob, int type); @@ -273,4 +273,3 @@ void OBJECT_OT_data_transfer(struct wmOperatorType *ot); void OBJECT_OT_datalayout_transfer(struct wmOperatorType *ot); #endif /* __OBJECT_INTERN_H__ */ - diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 425a0acff17..2889f798dd8 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -324,8 +324,6 @@ static bool object_modifier_remove(Main *bmain, Object *ob, ModifierData *md, ob->mode &= ~OB_MODE_PARTICLE_EDIT; } - DEG_relations_tag_update(bmain); - BLI_remlink(&ob->modifiers, md); modifier_free(md); BKE_object_free_derived_caches(ob); @@ -529,9 +527,7 @@ static int modifier_apply_shape( { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene = scene; - - if (mti->isDisabled && mti->isDisabled(md, 0)) { + if (mti->isDisabled && mti->isDisabled(scene, md, 0)) { BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply"); return 0; } @@ -570,7 +566,7 @@ static int modifier_apply_shape( /* if that was the first key block added, then it was the basis. * Initialize it with the mesh, and add another for the modifier */ kb = BKE_keyblock_add(key, NULL); - BKE_keyblock_convert_from_mesh(me, kb); + BKE_keyblock_convert_from_mesh(me, key, kb); } kb = BKE_keyblock_add(key, md->name); @@ -589,9 +585,7 @@ static int modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scen { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene = scene; - - if (mti->isDisabled && mti->isDisabled(md, 0)) { + if (mti->isDisabled && mti->isDisabled(scene, md, 0)) { BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply"); return 0; } @@ -644,7 +638,7 @@ static int modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scen BKE_report(reports, RPT_INFO, "Applied modifier only changed CV points, not tessellated/bevel vertices"); vertexCos = BKE_curve_nurbs_vertexCos_get(&cu->nurb, &numVerts); - modifier_deformVerts_DM_deprecated(md, &mectx, NULL, vertexCos, numVerts); + modifier_deformVerts(md, &mectx, NULL, vertexCos, numVerts); BK_curve_nurbs_vertexCos_apply(&cu->nurb, vertexCos); MEM_freeN(vertexCos); @@ -822,7 +816,7 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot) /************************ generic functions for operators using mod names and data context *********************/ -int edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag) +bool edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag) { PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", rna_type); Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C); @@ -844,7 +838,7 @@ int edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag return 1; } -int edit_modifier_poll(bContext *C) +bool edit_modifier_poll(bContext *C) { return edit_modifier_poll_generic(C, &RNA_Modifier, 0); } @@ -1149,20 +1143,21 @@ void OBJECT_OT_modifier_copy(wmOperatorType *ot) /************* multires delete higher levels operator ****************/ -static int multires_poll(bContext *C) +static bool multires_poll(bContext *C) { return edit_modifier_poll_generic(C, &RNA_MultiresModifier, (1 << OB_MESH)); } static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op) { + Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); if (!mmd) return OPERATOR_CANCELLED; - multiresModifier_del_levels(mmd, ob, 1); + multiresModifier_del_levels(mmd, scene, ob, 1); ED_object_iter_other(CTX_data_main(C), ob, true, ED_object_multires_update_totlevels_cb, @@ -1200,13 +1195,14 @@ void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot) static int multires_subdivide_exec(bContext *C, wmOperator *op) { + Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); if (!mmd) return OPERATOR_CANCELLED; - multiresModifier_subdivide(mmd, ob, 0, mmd->simple); + multiresModifier_subdivide(mmd, scene, ob, 0, mmd->simple); ED_object_iter_other(CTX_data_main(C), ob, true, ED_object_multires_update_totlevels_cb, @@ -1423,13 +1419,14 @@ void OBJECT_OT_multires_external_pack(wmOperatorType *ot) /********************* multires apply base ***********************/ static int multires_base_apply_exec(bContext *C, wmOperator *op) { + Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); if (!mmd) return OPERATOR_CANCELLED; - multiresModifier_base_apply(mmd, ob); + multiresModifier_base_apply(mmd, scene, ob); DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); @@ -1475,13 +1472,13 @@ static void modifier_skin_customdata_delete(Object *ob) CustomData_free_layer_active(&me->vdata, CD_MVERT_SKIN, me->totvert); } -static int skin_poll(bContext *C) +static bool skin_poll(bContext *C) { return (!CTX_data_edit_object(C) && edit_modifier_poll_generic(C, &RNA_SkinModifier, (1 << OB_MESH))); } -static int skin_edit_poll(bContext *C) +static bool skin_edit_poll(bContext *C) { return (CTX_data_edit_object(C) && edit_modifier_poll_generic(C, &RNA_SkinModifier, (1 << OB_MESH))); @@ -1849,7 +1846,7 @@ void OBJECT_OT_skin_armature_create(wmOperatorType *ot) } /************************ delta mush bind operator *********************/ -static int correctivesmooth_poll(bContext *C) +static bool correctivesmooth_poll(bContext *C) { return edit_modifier_poll_generic(C, &RNA_CorrectiveSmoothModifier, 0); } @@ -1917,7 +1914,7 @@ void OBJECT_OT_correctivesmooth_bind(wmOperatorType *ot) /************************ mdef bind operator *********************/ -static int meshdeform_poll(bContext *C) +static bool meshdeform_poll(bContext *C) { return edit_modifier_poll_generic(C, &RNA_MeshDeformModifier, 0); } @@ -2013,7 +2010,7 @@ void OBJECT_OT_meshdeform_bind(wmOperatorType *ot) /****************** explode refresh operator *********************/ -static int explode_poll(bContext *C) +static bool explode_poll(bContext *C) { return edit_modifier_poll_generic(C, &RNA_ExplodeModifier, 0); } @@ -2061,7 +2058,7 @@ void OBJECT_OT_explode_refresh(wmOperatorType *ot) /****************** ocean bake operator *********************/ -static int ocean_bake_poll(bContext *C) +static bool ocean_bake_poll(bContext *C) { return edit_modifier_poll_generic(C, &RNA_OceanModifier, 0); } @@ -2279,7 +2276,7 @@ void OBJECT_OT_ocean_bake(wmOperatorType *ot) /************************ LaplacianDeform bind operator *********************/ -static int laplaciandeform_poll(bContext *C) +static bool laplaciandeform_poll(bContext *C) { return edit_modifier_poll_generic(C, &RNA_LaplacianDeformModifier, 0); } @@ -2355,7 +2352,7 @@ void OBJECT_OT_laplaciandeform_bind(wmOperatorType *ot) /************************ sdef bind operator *********************/ -static int surfacedeform_bind_poll(bContext *C) +static bool surfacedeform_bind_poll(bContext *C) { return edit_modifier_poll_generic(C, &RNA_SurfaceDeformModifier, 0); } diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 89dd54b6f64..b52ef7a1abc 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -278,7 +278,7 @@ void ED_operatormacros_object(void) } -static int object_mode_poll(bContext *C) +static bool object_mode_poll(bContext *C) { Object *ob = CTX_data_active_object(C); return (!ob || ob->mode == OB_MODE_OBJECT); @@ -299,7 +299,9 @@ void ED_keymap_object(wmKeyConfig *keyconf) kmi = WM_keymap_add_menu_pie(keymap, "VIEW3D_MT_object_mode_pie", TABKEY, KM_CLICK_DRAG, 0, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "OBJECT_OT_origin_set", CKEY, KM_PRESS, KM_ALT | KM_SHIFT | KM_CTRL, 0); +#endif /* Object Mode ---------------------------------------------------------------- */ /* Note: this keymap gets disabled in non-objectmode, */ @@ -320,7 +322,9 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OBJECT_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "OBJECT_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); +#endif kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0); RNA_enum_set_identifier(NULL, kmi->ptr, "direction", "PARENT"); @@ -339,14 +343,19 @@ void ED_keymap_object(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "extend", true); WM_keymap_verify_item(keymap, "OBJECT_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_verify_item(keymap, "OBJECT_OT_parent_no_inverse_set", PKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); +#endif WM_keymap_verify_item(keymap, "OBJECT_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_verify_item(keymap, "OBJECT_OT_track_set", TKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_track_clear", TKEY, KM_PRESS, KM_ALT, 0); +#endif +#ifdef USE_WM_KEYMAP_27X WM_keymap_verify_item(keymap, "OBJECT_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); - +#endif kmi = WM_keymap_add_item(keymap, "OBJECT_OT_location_clear", GKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "clear_delta", false); @@ -355,11 +364,12 @@ void ED_keymap_object(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "OBJECT_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "clear_delta", false); +#ifdef USE_WM_KEYMAP_27X WM_keymap_verify_item(keymap, "OBJECT_OT_origin_clear", OKEY, KM_PRESS, KM_ALT, 0); +#endif kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "use_global", false); - kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "use_global", true); @@ -370,19 +380,25 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "INFO_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "OBJECT_OT_duplicates_make_real", AKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); +#endif WM_keymap_add_menu(keymap, "VIEW3D_MT_object_apply", AKEY, KM_PRESS, KM_CTRL, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_menu(keymap, "VIEW3D_MT_make_single_user", UKEY, KM_PRESS, 0, 0); +#endif WM_keymap_add_menu(keymap, "VIEW3D_MT_make_links", LKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move_linked", DKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_join", JKEY, KM_PRESS, KM_CTRL, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "OBJECT_OT_convert", CKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_proxy_make", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_make_local", LKEY, KM_PRESS, 0, 0); +#endif /* XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith */ WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0); @@ -397,7 +413,9 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "VIEW3D_MT_object_specials", WKEY, KM_PRESS, 0, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_verify_item(keymap, "OBJECT_OT_data_transfer", TKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); +#endif /* XXX No more available 'T' shortcuts... :/ */ /* WM_keymap_verify_item(keymap, "OBJECT_OT_datalayout_transfer", TKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); */ diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index a114b2cc6d5..324b6eca34a 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -118,7 +118,7 @@ /*********************** Make Vertex Parent Operator ************************/ -static int vertex_parent_set_poll(bContext *C) +static bool vertex_parent_set_poll(bContext *C) { return ED_operator_editmesh(C) || ED_operator_editsurfcurve(C) || ED_operator_editlattice(C); } @@ -1419,6 +1419,7 @@ static bool allow_make_links_data(const int type, Object *ob_src, Object *ob_dst static int make_links_data_exec(bContext *C, wmOperator *op) { + Scene *scene = CTX_data_scene(C); Main *bmain = CTX_data_main(C); const int type = RNA_enum_get(op->ptr, "type"); Object *ob_src; @@ -1503,7 +1504,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) } break; case MAKE_LINKS_MODIFIERS: - BKE_object_link_modifiers(ob_dst, ob_src); + BKE_object_link_modifiers(scene, ob_dst, ob_src); DEG_id_tag_update(&ob_dst->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); break; case MAKE_LINKS_FONTS: @@ -2342,7 +2343,7 @@ static int make_override_static_exec(bContext *C, wmOperator *op) new_ob->id.override_static->flag &= ~STATICOVERRIDE_AUTO; } /* We still want to store all objects' current override status (i.e. change of parent). */ - BKE_override_static_operations_create(&new_ob->id, true); + BKE_override_static_operations_create(bmain, &new_ob->id, true); } } FOREACH_COLLECTION_OBJECT_RECURSIVE_END; @@ -2386,7 +2387,7 @@ static int make_override_static_exec(bContext *C, wmOperator *op) return success ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } -static int make_override_static_poll(bContext *C) +static bool make_override_static_poll(bContext *C) { Object *obact = CTX_data_active_object(C); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index ce29125ac79..b1dee812f45 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -100,7 +100,7 @@ void ED_object_base_select(Base *base, eObjectSelect_Mode mode) if (base) { switch (mode) { case BA_SELECT: - if ((base->flag & BASE_SELECTABLED) != 0) { + if ((base->flag & BASE_SELECTABLE) != 0) { base->flag |= BASE_SELECTED; } break; @@ -134,7 +134,7 @@ void ED_object_base_activate(bContext *C, Base *base) /********************** Selection Operators **********************/ -static int objects_selectable_poll(bContext *C) +static bool objects_selectable_poll(bContext *C) { /* we don't check for linked scenes here, selection is * still allowed then for inspection of scene */ @@ -229,7 +229,7 @@ static bool object_select_all_by_obdata(bContext *C, void *obdata) CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { if (base->object->data == obdata) { ED_object_base_select(base, BA_SELECT); changed = true; @@ -247,7 +247,7 @@ static bool object_select_all_by_material(bContext *C, Material *mat) CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { Object *ob = base->object; Material *mat1; int a; @@ -274,7 +274,7 @@ static bool object_select_all_by_dup_group(bContext *C, Object *ob) CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { Collection *dup_group_other = (base->object->transflag & OB_DUPLICOLLECTION) ? base->object->dup_group : NULL; if (dup_group == dup_group_other) { ED_object_base_select(base, BA_SELECT); @@ -294,7 +294,7 @@ static bool object_select_all_by_particle(bContext *C, Object *ob) CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { /* loop through other particles*/ ParticleSystem *psys; @@ -322,7 +322,7 @@ static bool object_select_all_by_library(bContext *C, Library *lib) CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { if (lib == base->object->id.lib) { ED_object_base_select(base, BA_SELECT); changed = true; @@ -340,7 +340,7 @@ static bool object_select_all_by_library_obdata(bContext *C, Library *lib) CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { if (base->object->data && lib == ((ID *)base->object->data)->lib) { ED_object_base_select(base, BA_SELECT); changed = true; @@ -568,7 +568,7 @@ static bool select_grouped_collection(bContext *C, Object *ob) /* Select object collection = ob_collections[0]; CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { if (BKE_collection_has_object(collection, base->object)) { ED_object_base_select(base, BA_SELECT); changed = true; @@ -931,7 +931,7 @@ static int object_select_same_collection_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { if (BKE_collection_has_object(collection, base->object)) { ED_object_base_select(base, BA_SELECT); } diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 4f985293ec3..5e66dc00fd2 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -224,14 +224,14 @@ static bool object_shape_key_mirror(bContext *C, Object *ob, /********************** shape key operators *********************/ -static int shape_key_mode_poll(bContext *C) +static bool shape_key_mode_poll(bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data) && ob->mode != OB_MODE_EDIT); } -static int shape_key_mode_exists_poll(bContext *C) +static bool shape_key_mode_exists_poll(bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; @@ -242,7 +242,7 @@ static int shape_key_mode_exists_poll(bContext *C) (BKE_keyblock_from_object(ob) != NULL); } -static int shape_key_move_poll(bContext *C) +static bool shape_key_move_poll(bContext *C) { /* Same as shape_key_mode_exists_poll above, but ensure we have at least two shapes! */ Object *ob = ED_object_context(C); @@ -253,7 +253,7 @@ static int shape_key_move_poll(bContext *C) ob->mode != OB_MODE_EDIT && key && key->totkey > 1); } -static int shape_key_poll(bContext *C) +static bool shape_key_poll(bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; @@ -502,4 +502,3 @@ void OBJECT_OT_shape_key_move(wmOperatorType *ot) RNA_def_enum(ot->srna, "type", slot_move, 0, "Type", ""); } - diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index a6f688c49fb..ca5c000819d 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -63,7 +63,6 @@ #include "BKE_layer.h" #include "BKE_modifier.h" #include "BKE_report.h" -#include "BKE_DerivedMesh.h" #include "BKE_object_deform.h" #include "BKE_object.h" #include "BKE_lattice.h" @@ -1258,27 +1257,6 @@ static void getVerticalAndHorizontalChange( changes[index][1] = len_v3v3(projA, projB); } -/* I need the derived mesh to be forgotten so the positions are recalculated - * with weight changes (see dm_deform_recalc) */ -static void dm_deform_clear(DerivedMesh *dm, Object *ob) -{ - if (ob->derivedDeform && (ob->derivedDeform) == dm) { - ob->derivedDeform->needsFree = 1; - ob->derivedDeform->release(ob->derivedDeform); - ob->derivedDeform = NULL; - } - else if (dm) { - dm->needsFree = 1; - dm->release(dm); - } -} - -/* recalculate the deformation */ -static DerivedMesh *dm_deform_recalc(Depsgraph *depsgraph, Scene *scene, Object *ob) -{ - return mesh_get_derived_deform(depsgraph, scene, ob, CD_MASK_BAREMESH); -} - /* by changing nonzero weights, try to move a vertex in me->mverts with index 'index' to * distToBe distance away from the provided plane strength can change distToBe so that it moves * towards distToBe by that percentage cp changes how much the weights are adjusted @@ -1292,7 +1270,7 @@ static void moveCloserToDistanceFromPlane( Depsgraph *depsgraph, Scene *scene, Object *ob, Mesh *me, int index, float norm[3], float coord[3], float d, float distToBe, float strength, float cp) { - DerivedMesh *dm; + Mesh *me_deform; MDeformWeight *dw; MVert m; MDeformVert *dvert = me->dvert + index; @@ -1316,8 +1294,8 @@ static void moveCloserToDistanceFromPlane( float originalDistToBe = distToBe; do { wasChange = false; - dm = dm_deform_recalc(depsgraph, scene, ob); - dm->getVert(dm, index, &m); + me_deform = mesh_get_eval_deform(depsgraph, scene, ob, CD_MASK_BAREMESH); + m = me_deform->mvert[index]; copy_v3_v3(oldPos, m.co); distToStart = dot_v3v3(norm, oldPos) + d; @@ -1335,8 +1313,10 @@ static void moveCloserToDistanceFromPlane( continue; } for (k = 0; k < 2; k++) { - if (dm) { - dm_deform_clear(dm, ob); dm = NULL; + if (me_deform) { + /* DO NOT try to do own cleanup here, this is call for dramatic failures and bugs! + * Better to over-free and recompute a bit. */ + BKE_object_free_derived_caches(ob); } oldw = dw->weight; if (k) { @@ -1354,8 +1334,8 @@ static void moveCloserToDistanceFromPlane( if (dw->weight > 1) { dw->weight = 1; } - dm = dm_deform_recalc(depsgraph, scene, ob); - dm->getVert(dm, index, &m); + me_deform = mesh_get_eval_deform(depsgraph, scene, ob, CD_MASK_BAREMESH); + m = me_deform->mvert[index]; getVerticalAndHorizontalChange(norm, d, coord, oldPos, distToStart, m.co, changes, dists, i); dw->weight = oldw; if (!k) { @@ -1449,8 +1429,10 @@ static void moveCloserToDistanceFromPlane( if (oldw == dw->weight) { wasChange = false; } - if (dm) { - dm_deform_clear(dm, ob); dm = NULL; + if (me_deform) { + /* DO NOT try to do own cleanup here, this is call for dramatic failures and bugs! + * Better to over-free and recompute a bit. */ + BKE_object_free_derived_caches(ob); } } } while (wasChange && ((distToStart - distToBe) / fabsf(distToStart - distToBe) == @@ -1482,11 +1464,10 @@ static void vgroup_fix(const bContext *C, Scene *scene, Object *ob, float distTo MVert *p = MEM_callocN(sizeof(MVert) * (count), "deformedPoints"); int k; - DerivedMesh *dm = mesh_get_derived_deform(depsgraph, scene, ob, CD_MASK_BAREMESH); + Mesh *me_deform = mesh_get_eval_deform(depsgraph, scene, ob, CD_MASK_BAREMESH); k = count; while (k--) { - dm->getVert(dm, verts[k], &m); - p[k] = m; + p[k] = me_deform->mvert[verts[k]]; } if (count >= 3) { @@ -1494,7 +1475,7 @@ static void vgroup_fix(const bContext *C, Scene *scene, Object *ob, float distTo float coord[3]; float norm[3]; getSingleCoordinate(p, count, coord); - dm->getVert(dm, i, &m); + m = me_deform->mvert[i]; sub_v3_v3v3(norm, m.co, coord); mag = normalize_v3(norm); if (mag) { /* zeros fix */ @@ -2485,7 +2466,7 @@ static void vgroup_assign_verts(Object *ob, const float weight) /********************** vertex group operators *********************/ -static int vertex_group_poll(bContext *C) +static bool vertex_group_poll(bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; @@ -2496,7 +2477,7 @@ static int vertex_group_poll(bContext *C) ob->defbase.first); } -static int vertex_group_supported_poll(bContext *C) +static bool vertex_group_supported_poll(bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; @@ -2504,7 +2485,7 @@ static int vertex_group_supported_poll(bContext *C) data && !ID_IS_LINKED(data)); } -static int vertex_group_mesh_poll(bContext *C) +static bool vertex_group_mesh_poll(bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; @@ -2515,7 +2496,7 @@ static int vertex_group_mesh_poll(bContext *C) ob->defbase.first); } -static int UNUSED_FUNCTION(vertex_group_mesh_supported_poll)(bContext *C) +static bool UNUSED_FUNCTION(vertex_group_mesh_supported_poll)(bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; @@ -2523,7 +2504,7 @@ static int UNUSED_FUNCTION(vertex_group_mesh_supported_poll)(bContext *C) } -static int UNUSED_FUNCTION(vertex_group_poll_edit) (bContext *C) +static bool UNUSED_FUNCTION(vertex_group_poll_edit) (bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; @@ -2535,7 +2516,7 @@ static int UNUSED_FUNCTION(vertex_group_poll_edit) (bContext *C) } /* editmode _or_ weight paint vertex sel */ -static int vertex_group_vert_poll_ex(bContext *C, const bool needs_select, const short ob_type_flag) +static bool vertex_group_vert_poll_ex(bContext *C, const bool needs_select, const short ob_type_flag) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; @@ -2570,25 +2551,25 @@ static int vertex_group_vert_poll_ex(bContext *C, const bool needs_select, const } #if 0 -static int vertex_group_vert_poll(bContext *C) +static bool vertex_group_vert_poll(bContext *C) { return vertex_group_vert_poll_ex(C, false, 0); } #endif -static int vertex_group_mesh_vert_poll(bContext *C) +static bool vertex_group_mesh_vert_poll(bContext *C) { return vertex_group_vert_poll_ex(C, false, (1 << OB_MESH)); } -static int vertex_group_vert_select_poll(bContext *C) +static bool vertex_group_vert_select_poll(bContext *C) { return vertex_group_vert_poll_ex(C, true, 0); } #if 0 -static int vertex_group_mesh_vert_select_poll(bContext *C) +static bool vertex_group_mesh_vert_select_poll(bContext *C) { return vertex_group_vert_poll_ex(C, true, (1 << OB_MESH)); } @@ -2596,7 +2577,7 @@ static int vertex_group_mesh_vert_select_poll(bContext *C) /* editmode _or_ weight paint vertex sel and active group unlocked */ -static int vertex_group_vert_select_unlocked_poll(bContext *C) +static bool vertex_group_vert_select_unlocked_poll(bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; @@ -2619,7 +2600,7 @@ static int vertex_group_vert_select_unlocked_poll(bContext *C) return 1; } -static int vertex_group_vert_select_mesh_poll(bContext *C) +static bool vertex_group_vert_select_mesh_poll(bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c index 57b22991f94..ac031079434 100644 --- a/source/blender/editors/physics/particle_boids.c +++ b/source/blender/editors/physics/particle_boids.c @@ -370,4 +370,3 @@ void BOID_OT_state_move_down(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } - diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 08eaaa7284f..e637a58e8c6 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -53,7 +53,6 @@ #include "BLI_utildefines.h" #include "BKE_context.h" -#include "BKE_DerivedMesh.h" #include "BKE_global.h" #include "BKE_object.h" #include "BKE_library.h" @@ -80,6 +79,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" +#include "GPU_state.h" #include "UI_resources.h" @@ -101,7 +101,7 @@ /**************************** utilities *******************************/ -int PE_poll(bContext *C) +bool PE_poll(bContext *C) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); @@ -112,7 +112,7 @@ int PE_poll(bContext *C) return (PE_get_current(scene, ob) != NULL); } -int PE_hair_poll(bContext *C) +bool PE_hair_poll(bContext *C) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); @@ -126,7 +126,7 @@ int PE_hair_poll(bContext *C) return (edit && edit->psys); } -int PE_poll_view3d(bContext *C) +bool PE_poll_view3d(bContext *C) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); @@ -2897,13 +2897,13 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) immUniformColor4ub(255, 255, 255, 128); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); + GPU_line_smooth(true); + GPU_blend(true); imm_draw_circle_wire_2d(pos, (float)x, (float)y, pe_brush_size_get(scene, brush), 40); - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); + GPU_blend(false); + GPU_line_smooth(false); immUnbindProgram(); } @@ -3017,7 +3017,7 @@ static void PE_mirror_x( /* Note: In case psys uses Mesh tessface indices, we mirror final Mesh itself, not orig mesh. Avoids an (impossible) * mesh -> orig -> mesh tessface indices conversion... */ - mirrorfaces = mesh_get_x_mirror_faces__real_mesh(ob, NULL, use_dm_final_indices ? psmd_eval->mesh_final : NULL); + mirrorfaces = mesh_get_x_mirror_faces(ob, NULL, use_dm_final_indices ? psmd_eval->mesh_final : NULL); if (!edit->mirror_cache) PE_update_mirror_cache(ob, psys); @@ -3531,7 +3531,7 @@ static void intersect_dm_quad_weights(const float v1[3], const float v2[3], cons interp_weights_poly_v3(w, vert, 4, co); } -/* check intersection with a derivedmesh */ +/** Check intersection with an evaluated mesh. */ static int particle_intersect_mesh(Depsgraph *depsgraph, Scene *scene, Object *ob, Mesh *mesh, float *vert_cos, const float co1[3], const float co2[3], @@ -3548,18 +3548,16 @@ static int particle_intersect_mesh(Depsgraph *depsgraph, Scene *scene, Object *o if (mesh == NULL) { psys_disable_all(ob); - /* TODO(Sybren): port to Mesh when we have decided how to handle derivedFinal and derivedDeform */ - DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, 0); - if (dm == NULL) - dm = mesh_get_derived_deform(depsgraph, scene, ob, 0); + mesh = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH); + if (mesh == NULL) { + mesh = mesh_get_eval_deform(depsgraph, scene, ob, CD_MASK_BAREMESH); + } psys_enable_all(ob); - if (dm == NULL) + if (mesh == NULL) { return 0; - - mesh = BKE_id_new_nomain(ID_ME, NULL); - DM_to_mesh(dm, mesh, ob, CD_MASK_EVERYTHING, false); + } } /* BMESH_ONLY, deform dm may not have tessface */ @@ -4393,7 +4391,7 @@ void PARTICLE_OT_brush_edit(wmOperatorType *ot) /*********************** cut shape ***************************/ -static int shape_cut_poll(bContext *C) +static bool shape_cut_poll(bContext *C) { if (PE_hair_poll(C)) { Scene *scene = CTX_data_scene(C); @@ -4759,7 +4757,7 @@ void PE_create_particle_edit( } } -static int particle_edit_toggle_poll(bContext *C) +static bool particle_edit_toggle_poll(bContext *C) { Object *ob = CTX_data_active_object(C); @@ -5005,4 +5003,3 @@ void PARTICLE_OT_unify_length(struct wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } - diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 8a9eb369e66..4431e4f4a54 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -43,9 +43,8 @@ #include "BLI_utildefines.h" #include "BLI_string.h" +#include "BKE_bvhutils.h" #include "BKE_context.h" -#include "BKE_DerivedMesh.h" -#include "BKE_cdderivedmesh.h" #include "BKE_global.h" #include "BKE_library.h" #include "BKE_main.h" @@ -160,7 +159,7 @@ void OBJECT_OT_particle_system_remove(wmOperatorType *ot) /********************** new particle settings operator *********************/ -static int psys_poll(bContext *C) +static bool psys_poll(bContext *C) { PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); return (ptr.data != NULL); @@ -388,6 +387,35 @@ void PARTICLE_OT_target_move_down(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } +/************************ refresh dupli objects *********************/ + +static int dupliob_refresh_exec(bContext *C, wmOperator *UNUSED(op)) +{ + PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); + ParticleSystem *psys= ptr.data; + + if (!psys) + return OPERATOR_CANCELLED; + + psys_check_group_weights(psys->part); + DEG_id_tag_update(&psys->part->id, OB_RECALC_DATA | PSYS_RECALC_REDO); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL); + + return OPERATOR_FINISHED; +} + +void PARTICLE_OT_dupliob_refresh(wmOperatorType *ot) +{ + ot->name = "Refresh Dupli Objects"; + ot->idname = "PARTICLE_OT_dupliob_refresh"; + ot->description = "Refresh list of dupli objects and their weights"; + + ot->exec = dupliob_refresh_exec; + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; +} + /************************ move up particle dupliweight operator *********************/ static int dupliob_move_up_exec(bContext *C, wmOperator *UNUSED(op)) @@ -406,6 +434,7 @@ static int dupliob_move_up_exec(bContext *C, wmOperator *UNUSED(op)) BLI_remlink(&part->dupliweights, dw); BLI_insertlinkbefore(&part->dupliweights, dw->prev, dw); + DEG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_REDO); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL); break; } @@ -445,6 +474,7 @@ static int copy_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op)) dw->flag |= PART_DUPLIW_CURRENT; BLI_addhead(&part->dupliweights, dw); + DEG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_REDO); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL); break; } @@ -491,6 +521,7 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op)) if (dw) dw->flag |= PART_DUPLIW_CURRENT; + DEG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_REDO); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL); return OPERATOR_FINISHED; @@ -528,6 +559,7 @@ static int dupliob_move_down_exec(bContext *C, wmOperator *UNUSED(op)) BLI_remlink(&part->dupliweights, dw); BLI_insertlinkafter(&part->dupliweights, dw->next, dw); + DEG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_REDO); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL); break; } @@ -1046,11 +1078,8 @@ static bool copy_particle_systems_to_object(const bContext *C, */ psys_start = totpsys > 0 ? tmp_psys[0] : NULL; - /* get the DM (psys and their modifiers have not been appended yet) */ - /* TODO(Sybren): use mesh_eval instead */ - DerivedMesh *final_dm = mesh_get_derived_final(depsgraph, scene, ob_to, cdmask); - final_mesh = BKE_id_new_nomain(ID_ME, NULL); - DM_to_mesh(final_dm, final_mesh, ob_to, CD_MASK_EVERYTHING, false); + /* Get the evaluated mesh (psys and their modifiers have not been appended yet) */ + final_mesh = mesh_get_eval_final(depsgraph, scene, ob_to, cdmask); /* now append psys to the object and make modifiers */ for (i = 0, psys_from = PSYS_FROM_FIRST; @@ -1138,7 +1167,7 @@ static bool copy_particle_systems_to_object(const bContext *C, return true; } -static int copy_particle_systems_poll(bContext *C) +static bool copy_particle_systems_poll(bContext *C) { Object *ob; if (!ED_operator_object_active_editable(C)) @@ -1214,7 +1243,7 @@ void PARTICLE_OT_copy_particle_systems(wmOperatorType *ot) RNA_def_boolean(ot->srna, "use_active", false, "Use Active", "Use the active particle system from the context"); } -static int duplicate_particle_systems_poll(bContext *C) +static bool duplicate_particle_systems_poll(bContext *C) { if (!ED_operator_object_active_editable(C)) { return false; diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 904e4242ed1..6cc9b9b8e4d 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -1125,4 +1125,3 @@ void FLUID_OT_bake(wmOperatorType *ot) ot->exec = fluid_bake_exec; ot->poll = ED_operator_object_active_editable; } - diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h index e94f582141b..df688d90e44 100644 --- a/source/blender/editors/physics/physics_intern.h +++ b/source/blender/editors/physics/physics_intern.h @@ -95,6 +95,7 @@ void PARTICLE_OT_dupliob_copy(struct wmOperatorType *ot); void PARTICLE_OT_dupliob_remove(struct wmOperatorType *ot); void PARTICLE_OT_dupliob_move_up(struct wmOperatorType *ot); void PARTICLE_OT_dupliob_move_down(struct wmOperatorType *ot); +void PARTICLE_OT_dupliob_refresh(struct wmOperatorType *ot); /* particle_boids.c */ void BOID_OT_rule_add(struct wmOperatorType *ot); diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index ffa73b41bd9..73bb2d14505 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -85,6 +85,7 @@ static void operatortypes_particle(void) WM_operatortype_append(PARTICLE_OT_copy_particle_systems); WM_operatortype_append(PARTICLE_OT_duplicate_particle_system); + WM_operatortype_append(PARTICLE_OT_dupliob_refresh); WM_operatortype_append(PARTICLE_OT_dupliob_copy); WM_operatortype_append(PARTICLE_OT_dupliob_remove); WM_operatortype_append(PARTICLE_OT_dupliob_move_up); @@ -228,6 +229,3 @@ void ED_keymap_physics(wmKeyConfig *keyconf) keymap_particle(keyconf); //keymap_pointcache(keyconf); } - - - diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index 343804726bf..7fc3dc2e1b8 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -57,12 +57,12 @@ #include "physics_intern.h" -static int ptcache_bake_all_poll(bContext *C) +static bool ptcache_bake_all_poll(bContext *C) { return CTX_data_scene(C) != NULL; } -static int ptcache_poll(bContext *C) +static bool ptcache_poll(bContext *C) { PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache); return (ptr.data && ptr.id.data); @@ -440,4 +440,3 @@ void PTCACHE_OT_remove(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } - diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c index f62b72679d0..7ec814bc142 100644 --- a/source/blender/editors/physics/rigidbody_constraint.c +++ b/source/blender/editors/physics/rigidbody_constraint.c @@ -61,7 +61,7 @@ /* ********************************************** */ /* Helper API's for RigidBody Constraint Editing */ -static int ED_operator_rigidbody_con_active_poll(bContext *C) +static bool ED_operator_rigidbody_con_active_poll(bContext *C) { if (ED_operator_object_active_editable(C)) { Object *ob = CTX_data_active_object(C); @@ -84,6 +84,7 @@ bool ED_rigidbody_constraint_add(Main *bmain, Scene *scene, Object *ob, int type /* create constraint group if it doesn't already exits */ if (rbw->constraints == NULL) { rbw->constraints = BKE_collection_add(bmain, NULL, "RigidBodyConstraints"); + id_fake_user_set(&rbw->constraints->id); } /* make rigidbody constraint settings */ ob->rigidbody_constraint = BKE_rigidbody_create_constraint(scene, ob, type); @@ -94,6 +95,8 @@ bool ED_rigidbody_constraint_add(Main *bmain, Scene *scene, Object *ob, int type DEG_relations_tag_update(bmain); DEG_id_tag_update(&ob->id, OB_RECALC_OB); + DEG_id_tag_update(&rbw->constraints->id, DEG_TAG_COPY_ON_WRITE); + return true; } @@ -102,8 +105,10 @@ void ED_rigidbody_constraint_remove(Main *bmain, Scene *scene, Object *ob) RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene); BKE_rigidbody_remove_constraint(scene, ob); - if (rbw) + if (rbw) { BKE_collection_object_remove(bmain, rbw->constraints, ob, false); + DEG_id_tag_update(&rbw->constraints->id, DEG_TAG_COPY_ON_WRITE); + } DEG_relations_tag_update(bmain); DEG_id_tag_update(&ob->id, OB_RECALC_OB); diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c index bdfbc47b22f..56d80e232c0 100644 --- a/source/blender/editors/physics/rigidbody_object.c +++ b/source/blender/editors/physics/rigidbody_object.c @@ -67,7 +67,7 @@ /* ********************************************** */ /* Helper API's for RigidBody Objects Editing */ -static int ED_operator_rigidbody_active_poll(bContext *C) +static bool ED_operator_rigidbody_active_poll(bContext *C) { if (ED_operator_object_active_editable(C)) { Object *ob = ED_object_active_context(C); @@ -77,7 +77,7 @@ static int ED_operator_rigidbody_active_poll(bContext *C) return 0; } -static int ED_operator_rigidbody_add_poll(bContext *C) +static bool ED_operator_rigidbody_add_poll(bContext *C) { if (ED_operator_object_active_editable(C)) { Object *ob = ED_object_active_context(C); @@ -125,6 +125,7 @@ bool ED_rigidbody_object_add(Main *bmain, Scene *scene, Object *ob, int type, Re DEG_relations_tag_update(bmain); DEG_id_tag_update(&ob->id, OB_RECALC_OB); + DEG_id_tag_update(&rbw->group->id, DEG_TAG_COPY_ON_WRITE); return true; } diff --git a/source/blender/editors/physics/rigidbody_world.c b/source/blender/editors/physics/rigidbody_world.c index 8d5258a7522..da0099ba469 100644 --- a/source/blender/editors/physics/rigidbody_world.c +++ b/source/blender/editors/physics/rigidbody_world.c @@ -58,12 +58,12 @@ /* API */ /* check if there is an active rigid body world */ -static int ED_rigidbody_world_active_poll(bContext *C) +static bool ED_rigidbody_world_active_poll(bContext *C) { Scene *scene = CTX_data_scene(C); return (scene && scene->rigidbody_world); } -static int ED_rigidbody_world_add_poll(bContext *C) +static bool ED_rigidbody_world_add_poll(bContext *C) { Scene *scene = CTX_data_scene(C); return (scene && scene->rigidbody_world == NULL); @@ -114,8 +114,7 @@ static int rigidbody_world_remove_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - BKE_rigidbody_free_world(rbw); - scene->rigidbody_world = NULL; + BKE_rigidbody_free_world(scene); /* done */ return OPERATOR_FINISHED; @@ -152,14 +151,14 @@ static int rigidbody_world_export_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No Rigid Body World to export"); return OPERATOR_CANCELLED; } - if (rbw->physics_world == NULL) { + if (rbw->shared->physics_world == NULL) { BKE_report(op->reports, RPT_ERROR, "Rigid Body World has no associated physics data to export"); return OPERATOR_CANCELLED; } RNA_string_get(op->ptr, "filepath", path); #ifdef WITH_BULLET - RB_dworld_export(rbw->physics_world, path); + RB_dworld_export(rbw->shared->physics_world, path); #endif return OPERATOR_FINISHED; } diff --git a/source/blender/editors/render/render_intern.h b/source/blender/editors/render/render_intern.h index d7b92c00ed4..77bf16f5e22 100644 --- a/source/blender/editors/render/render_intern.h +++ b/source/blender/editors/render/render_intern.h @@ -98,4 +98,3 @@ void RENDER_OT_view_cancel(struct wmOperatorType *ot); void RENDER_OT_opengl(struct wmOperatorType *ot); #endif /* __RENDER_INTERN_H__ */ - diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 6a5844e323f..1385baa51ad 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -819,7 +819,7 @@ static void screen_render_cancel(bContext *C, wmOperator *op) static void clean_viewport_memory_base(Base *base) { - if ((base->flag & BASE_VISIBLED) == 0) { + if ((base->flag & BASE_VISIBLE) == 0) { return; } diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index fb007accaeb..b5c1ffc64dd 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -322,8 +322,8 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R DRW_opengl_context_enable(); GPU_offscreen_bind(oglrender->ofs, true); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f); + GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT); wmOrtho2(0, sizex, 0, sizey); gpuTranslate2f(sizex / 2, sizey / 2); diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c index dd5ed5b78f1..fd534dd9129 100644 --- a/source/blender/editors/render/render_ops.c +++ b/source/blender/editors/render/render_ops.c @@ -95,4 +95,3 @@ void ED_operatortypes_render(void) /* render_opengl.c */ WM_operatortype_append(RENDER_OT_opengl); } - diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index cdd79f43a72..04632838cf3 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -176,9 +176,6 @@ typedef struct ShaderPreview { Main *bmain; Main *pr_main; - - void *gl_context; - bool gl_context_owner; } ShaderPreview; typedef struct IconPreviewSize { @@ -194,8 +191,6 @@ typedef struct IconPreview { void *owner; ID *id; ListBase sizes; - - void *gl_context; } IconPreview; /* *************************** Preview for buttons *********************** */ @@ -428,7 +423,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty (*matar)[actcol] = mat; } else if (base->object->type == OB_LAMP) { - base->flag |= BASE_VISIBLED; + base->flag |= BASE_VISIBLE; } } } @@ -746,10 +741,6 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs /* set this for all previews, default is react to G.is_break still */ RE_test_break_cb(re, sp, shader_preview_break); - if (sp->gl_context) { - RE_gl_context_set(re, sp->gl_context); - } - /* lens adjust */ oldlens = ((Camera *)sce->camera->data)->lens; if (sizex > sp->sizey) @@ -869,10 +860,6 @@ static void shader_preview_free(void *customdata) } MEM_freeN(sp->lampcopy); } - if (sp->gl_context_owner && sp->gl_context) { - WM_opengl_context_dispose(sp->gl_context); - sp->gl_context = NULL; - } MEM_freeN(sp); } @@ -1088,8 +1075,6 @@ static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short sp->pr_rect = cur_size->rect; sp->id = ip->id; sp->bmain = ip->bmain; - sp->gl_context = ip->gl_context; - sp->gl_context_owner = false; if (is_render) { BLI_assert(ip->id); @@ -1106,11 +1091,6 @@ static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short common_preview_startjob(sp, stop, do_update, progress); shader_preview_free(sp); } - - if (ip->gl_context) { - WM_opengl_context_dispose(ip->gl_context); - ip->gl_context = NULL; - } } static void icon_preview_endjob(void *customdata) @@ -1194,17 +1174,8 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r /* render all resolutions from suspended job too */ old_ip = WM_jobs_customdata_get(wm_job); - if (old_ip) { + if (old_ip) BLI_movelisttolist(&ip->sizes, &old_ip->sizes); - /* NOTE: This assumes that it will be the same thread - * that will be used when resuming the job. */ - ip->gl_context = old_ip->gl_context; - } - - if (ip->gl_context == NULL) { - /* Create context in the main thread. */ - ip->gl_context = WM_opengl_context_create(); - } /* customdata for preview thread */ ip->bmain = CTX_data_main(C); @@ -1235,7 +1206,7 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M { Object *ob = CTX_data_active_object(C); wmJob *wm_job; - ShaderPreview *sp, *old_sp; + ShaderPreview *sp; Scene *scene = CTX_data_scene(C); short id_type = GS(id->name); @@ -1252,21 +1223,6 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M WM_JOB_EXCL_RENDER, WM_JOB_TYPE_RENDER_PREVIEW); sp = MEM_callocN(sizeof(ShaderPreview), "shader preview"); - /* Reuse previous gl context. */ - old_sp = WM_jobs_customdata_get(wm_job); - if (old_sp) { - /* NOTE: This assumes that it will be the same thread - * that will be used when resuming the job. */ - old_sp->gl_context_owner = false; /* Don't free it */ - sp->gl_context = old_sp->gl_context; - } - - if (sp->gl_context == NULL) { - /* Create context in the main thread. */ - sp->gl_context = WM_opengl_context_create(); - } - sp->gl_context_owner = true; - /* customdata for preview thread */ sp->scene = scene; sp->depsgraph = CTX_data_depsgraph(C); @@ -1304,4 +1260,3 @@ void ED_preview_kill_jobs(wmWindowManager *wm, Main *UNUSED(bmain)) if (wm) WM_jobs_kill(wm, NULL, common_preview_startjob); } - diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index a822dabf7b4..31f25720f8d 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -675,7 +675,7 @@ void SCENE_OT_view_layer_remove(wmOperatorType *ot) /********************** render view operators *********************/ -static int render_view_remove_poll(bContext *C) +static bool render_view_remove_poll(bContext *C) { Scene *scene = CTX_data_scene(C); @@ -753,7 +753,7 @@ static bool freestyle_linestyle_check_report(FreestyleLineSet *lineset, ReportLi return true; } -static int freestyle_active_module_poll(bContext *C) +static bool freestyle_active_module_poll(bContext *C) { PointerRNA ptr = CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings); FreestyleModuleConfig *module = ptr.data; @@ -886,7 +886,7 @@ void SCENE_OT_freestyle_lineset_add(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; } -static int freestyle_active_lineset_poll(bContext *C) +static bool freestyle_active_lineset_poll(bContext *C) { ViewLayer *view_layer = CTX_data_view_layer(C); @@ -1626,7 +1626,7 @@ static int copy_mtex_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static int copy_mtex_poll(bContext *C) +static bool copy_mtex_poll(bContext *C) { ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data; @@ -1694,4 +1694,3 @@ void TEXTURE_OT_slot_paste(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; } - diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index b7e6508117e..97fd7295a7b 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -49,7 +49,6 @@ #include "BLI_utildefines.h" #include "BKE_context.h" -#include "BKE_DerivedMesh.h" #include "BKE_icons.h" #include "BKE_layer.h" #include "BKE_main.h" @@ -371,4 +370,3 @@ void ED_render_id_flush_update(const DEGEditorUpdateContext *update_ctx, ID *id) break; } } - diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c index 351ceda90e3..12f9c8f40c1 100644 --- a/source/blender/editors/render/render_view.c +++ b/source/blender/editors/render/render_view.c @@ -353,4 +353,3 @@ void RENDER_OT_view_show(struct wmOperatorType *ot) ot->invoke = render_view_show_invoke; ot->poll = ED_operator_screenactive; } - diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt index 29b9971eabb..4be65f60b21 100644 --- a/source/blender/editors/screen/CMakeLists.txt +++ b/source/blender/editors/screen/CMakeLists.txt @@ -46,7 +46,9 @@ set(SRC screen_context.c screen_draw.c screen_edit.c + screen_geometry.c screen_ops.c + screen_user_menu.c screendump.c workspace_edit.c workspace_layout_edit.c diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index d9851487569..46bbc0fdf4f 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -62,6 +62,8 @@ #include "GPU_immediate_util.h" #include "GPU_matrix.h" #include "GPU_draw.h" +#include "GPU_state.h" +#include "GPU_framebuffer.h" #include "BLF_api.h" @@ -97,8 +99,8 @@ static void region_draw_emboss(const ARegion *ar, const rcti *scirct, int sides) rect.ymax = scirct->ymax - ar->winrct.ymin; /* set transp line */ - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); float color[4] = {0.0f, 0.0f, 0.0f, 0.25f}; UI_GetThemeColor3fv(TH_EDITOR_OUTLINE, color); @@ -137,7 +139,7 @@ static void region_draw_emboss(const ARegion *ar, const rcti *scirct, int sides) immEnd(); immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } @@ -296,7 +298,7 @@ static void draw_azone_plus(float x1, float y1, float x2, float y2) Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - glEnable(GL_BLEND); + GPU_blend(true); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(0.8f, 0.8f, 0.8f, 0.4f); @@ -305,12 +307,12 @@ static void draw_azone_plus(float x1, float y1, float x2, float y2) immRectf(pos, (x1 + x2 + width) * 0.5f, (y1 + y2 - width) * 0.5f, x2 - pad, (y1 + y2 + width) * 0.5f); immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } static void region_draw_azone_tab_plus(AZone *az) { - glEnable(GL_BLEND); + GPU_blend(true); /* add code to draw region hidden as 'too small' */ switch (az->edge) { @@ -346,9 +348,9 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar) if (!sa) return; - glLineWidth(1.0f); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_line_width(1.0f); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); gpuPushMatrix(); gpuTranslate2f(-ar->winrct.xmin, -ar->winrct.ymin); @@ -388,7 +390,7 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar) gpuPopMatrix(); - glDisable(GL_BLEND); + GPU_blend(false); } /* Follow wmMsgNotifyFn spec */ @@ -419,6 +421,17 @@ void ED_area_do_msg_notify_tag_refresh( ED_area_tag_refresh(sa); } +/** + * Although there's no general support for minimizing areas, the status-bar can + * be snapped to be only a few pixels high. A few pixels rather than 0 so it + * can be un-minimized again. We consider it pseudo-minimalized and don't draw + * it then. + */ +static bool area_is_pseudo_minimized(const ScrArea *area) +{ + return (area->winx < 3) || (area->winy < 3); +} + /* only exported for WM */ void ED_region_do_layout(bContext *C, ARegion *ar) { @@ -430,7 +443,7 @@ void ED_region_do_layout(bContext *C, ARegion *ar) return; } - if (at->do_lock) { + if (at->do_lock || (sa && area_is_pseudo_minimized(sa))) { return; } @@ -460,8 +473,13 @@ void ED_region_do_draw(bContext *C, ARegion *ar) UI_SetTheme(sa ? sa->spacetype : 0, at->regionid); + if (sa && area_is_pseudo_minimized(sa)) { + UI_ThemeClearColor(TH_EDITOR_OUTLINE); + glClear(GL_COLOR_BUFFER_BIT); + return; + } /* optional header info instead? */ - if (ar->headerstr) { + else if (ar->headerstr) { UI_ThemeClearColor(TH_HEADER); glClear(GL_COLOR_BUFFER_BIT); @@ -481,7 +499,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) /* for debugging unneeded area redraws and partial redraw */ #if 0 - glEnable(GL_BLEND); + GPU_blend(true); Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -489,7 +507,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) immRectf(pos, ar->drawrct.xmin - ar->winrct.xmin, ar->drawrct.ymin - ar->winrct.ymin, ar->drawrct.xmax - ar->winrct.xmin, ar->drawrct.ymax - ar->winrct.ymin); immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); #endif memset(&ar->drawrct, 0, sizeof(ar->drawrct)); @@ -639,7 +657,7 @@ void ED_area_tag_refresh(ScrArea *sa) /* *************************************************************** */ /* use NULL to disable it */ -void ED_area_headerprint(ScrArea *sa, const char *str) +void ED_area_status_text(ScrArea *sa, const char *str) { ARegion *ar; @@ -663,6 +681,34 @@ void ED_area_headerprint(ScrArea *sa, const char *str) } } +void ED_workspace_status_text(bContext *C, const char *str) +{ + wmWindow *win = CTX_wm_window(C); + WorkSpace *workspace = CTX_wm_workspace(C); + + /* Can be NULL when running operators in background mode. */ + if (workspace == NULL) + return; + + if (str) { + if (workspace->status_text == NULL) + workspace->status_text = MEM_mallocN(UI_MAX_DRAW_STR, "headerprint"); + BLI_strncpy(workspace->status_text, str, UI_MAX_DRAW_STR); + } + else if (workspace->status_text) { + MEM_freeN(workspace->status_text); + workspace->status_text = NULL; + } + + /* Redraw status bar. */ + for (ScrArea *sa = win->global_areas.areabase.first; sa; sa = sa->next) { + if (sa->spacetype == SPACE_STATUSBAR) { + ED_area_tag_redraw(sa); + break; + } + } +} + /* ************************************************************ */ @@ -1036,7 +1082,7 @@ bool ED_region_is_overlap(int spacetype, int regiontype) return 0; } -static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti *remainder, rcti *overlap_remainder, int quad) +static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, rcti *overlap_remainder, int quad) { rcti *remainder_prev = remainder; int prefsizex, prefsizey; @@ -1287,7 +1333,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti *overlap_remainder = *remainder; } - region_rect_recursive(win, sa, ar->next, remainder, overlap_remainder, quad); + region_rect_recursive(sa, ar->next, remainder, overlap_remainder, quad); } static void area_calc_totrct(ScrArea *sa, const rcti *window_rect) @@ -1417,7 +1463,7 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar /* region rect sizes */ rect = area->totrct; overlap_rect = rect; - region_rect_recursive(win, area, area->regionbase.first, &rect, &overlap_rect, 0); + region_rect_recursive(area, area->regionbase.first, &rect, &overlap_rect, 0); for (ARegion *ar = area->regionbase.first; ar; ar = ar->next) { region_subwindow(ar); @@ -1463,7 +1509,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) /* region rect sizes */ rect = sa->totrct; overlap_rect = rect; - region_rect_recursive(win, sa, sa->regionbase.first, &rect, &overlap_rect, 0); + region_rect_recursive(sa, sa->regionbase.first, &rect, &overlap_rect, 0); sa->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE; /* default area handlers */ @@ -1821,12 +1867,12 @@ static void region_clear_color(const bContext *C, const ARegion *ar, ThemeColorI float back[4]; UI_GetThemeColor4fv(colorid, back); - glClearColor(back[3] * back[0], back[3] * back[1], back[3] * back[2], back[3]); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear_color(back[3] * back[0], back[3] * back[1], back[3] * back[2], back[3]); + GPU_clear(GPU_COLOR_BIT); } else { UI_ThemeClearColor(colorid); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); } } @@ -2152,7 +2198,7 @@ void ED_region_panels_draw(const bContext *C, ARegion *ar) } /* reset line width for drawing tabs */ - glLineWidth(1.0f); + GPU_line_width(1.0f); /* set the view */ UI_view2d_view_ortho(v2d); @@ -2208,26 +2254,33 @@ void ED_region_header_layout(const bContext *C, ARegion *ar) uiLayout *layout; HeaderType *ht; Header header = {NULL}; - int maxco, xco, yco; - int headery = ED_area_headersize(); bool region_layout_based = ar->flag & RGN_FLAG_DYNAMIC_SIZE; - /* set view2d view matrix for scrolling (without scrollers) */ - UI_view2d_view_ortho(&ar->v2d); + /* Height of buttons and scaling needed to achieve it. */ + const int buttony = min_ii(UI_UNIT_Y, ar->winy - 2 * UI_DPI_FAC); + const float buttony_scale = buttony / (float)UI_UNIT_Y; - xco = maxco = UI_HEADER_OFFSET; - yco = headery + (ar->winy - headery) / 2 - floor(0.2f * UI_UNIT_Y); + /* Vertically center buttons. */ + int xco = UI_HEADER_OFFSET; + int yco = buttony + (ar->winy - buttony) / 2; + int maxco = xco; /* XXX workaround for 1 px alignment issue. Not sure what causes it... Would prefer a proper fix - Julian */ - if (CTX_wm_area(C)->spacetype == SPACE_TOPBAR) { - xco += 1; - yco += 1; + if (!ELEM(CTX_wm_area(C)->spacetype, SPACE_TOPBAR, SPACE_STATUSBAR)) { + yco -= 1; } + /* set view2d view matrix for scrolling (without scrollers) */ + UI_view2d_view_ortho(&ar->v2d); + /* draw all headers types */ for (ht = ar->type->headertypes.first; ht; ht = ht->next) { block = UI_block_begin(C, ar, ht->idname, UI_EMBOSS); - layout = UI_block_layout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, UI_UNIT_Y, 1, 0, style); + layout = UI_block_layout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, buttony, 1, 0, style); + + if (buttony_scale != 1.0f) { + uiLayoutSetScaleY(layout, buttony_scale); + } if (ht->draw) { header.type = ht; @@ -2264,7 +2317,7 @@ void ED_region_header_layout(const bContext *C, ARegion *ar) } /* always as last */ - UI_view2d_totRect_set(&ar->v2d, maxco, headery); + UI_view2d_totRect_set(&ar->v2d, maxco, ar->winy); /* restore view matrix */ UI_view2d_view_restore(C); @@ -2325,6 +2378,16 @@ int ED_area_global_size_y(const ScrArea *area) BLI_assert(ED_area_is_global(area)); return round_fl_to_int(area->global->cur_fixed_height * UI_DPI_FAC); } +int ED_area_global_min_size_y(const ScrArea *area) +{ + BLI_assert(ED_area_is_global(area)); + return round_fl_to_int(area->global->size_min * UI_DPI_FAC); +} +int ED_area_global_max_size_y(const ScrArea *area) +{ + BLI_assert(ED_area_is_global(area)); + return round_fl_to_int(area->global->size_max * UI_DPI_FAC); +} bool ED_area_is_global(const ScrArea *area) { @@ -2375,7 +2438,7 @@ void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float const int header_height = UI_UNIT_Y; uiStyle *style = UI_style_get_dpi(); int fontid = style->widget.uifont_id; - GLint scissor[4]; + int scissor[4]; rcti rect; int num_lines = 0; @@ -2403,19 +2466,19 @@ void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float rect.ymin = rect.ymax - header_height * num_lines; /* setup scissor */ - glGetIntegerv(GL_SCISSOR_BOX, scissor); - glScissor(rect.xmin, rect.ymin, + GPU_scissor_get_i(scissor); + GPU_scissor(rect.xmin, rect.ymin, BLI_rcti_size_x(&rect) + 1, BLI_rcti_size_y(&rect) + 1); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(fill_color); immRecti(pos, rect.xmin, rect.ymin, rect.xmax + 1, rect.ymax + 1); immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); /* text */ UI_FontThemeColor(fontid, TH_TEXT_HI); @@ -2435,7 +2498,7 @@ void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float BLF_disable(fontid, BLF_CLIPPING); /* restore scissor as it was before */ - glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); + GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]); } void ED_region_info_draw(ARegion *ar, const char *text, float fill_color[4], const bool full_redraw) diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 1d73566e5a8..6cff82295f0 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -51,6 +51,7 @@ #include "GPU_basic_shader.h" #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "UI_interface.h" @@ -59,11 +60,11 @@ void setlinestyle(int nr) { if (nr == 0) { - glDisable(GL_LINE_STIPPLE); + GPU_line_stipple(false); } else { - glEnable(GL_LINE_STIPPLE); + GPU_line_stipple(true); if (U.pixelsize > 1.0f) glLineStipple(nr, 0xCCCC); else diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 864150be9da..fa18826005e 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -115,7 +115,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } else if (CTX_data_equals(member, "selectable_objects")) { for (Base *base = view_layer->object_bases.first; base; base = base->next) { - if (((base->flag & BASE_VISIBLED) != 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_VISIBLE) != 0) && ((base->flag & BASE_SELECTABLE) != 0)) { CTX_data_id_list_add(result, &base->object->id); } } @@ -165,7 +165,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } else if (CTX_data_equals(member, "selectable_bases")) { for (Base *base = view_layer->object_bases.first; base; base = base->next) { - if ((base->flag & BASE_SELECTABLED) != 0) { + if ((base->flag & BASE_SELECTABLE) != 0) { CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base); } } @@ -195,7 +195,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult else if (CTX_data_equals(member, "editable_bases")) { /* Visible + Editable, but not necessarily selected */ for (Base *base = view_layer->object_bases.first; base; base = base->next) { - if ((base->flag & BASE_VISIBLED) != 0) { + if ((base->flag & BASE_VISIBLE) != 0) { if (0 == BKE_object_is_libdata(base->object)) { CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base); } @@ -665,4 +665,3 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return -1; /* found but not available */ } - diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c index fec39ade110..b5b0d16f6a7 100644 --- a/source/blender/editors/screen/screen_draw.c +++ b/source/blender/editors/screen/screen_draw.c @@ -27,6 +27,7 @@ #include "GPU_framebuffer.h" #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "BLI_math.h" @@ -43,11 +44,11 @@ */ static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos) { + const float width = screen_geom_area_width(sa) - 1; + const float height = screen_geom_area_height(sa) - 1; vec2f points[10]; short i; float w, h; - float width = sa->v3->vec.x - sa->v1->vec.x; - float height = sa->v3->vec.y - sa->v1->vec.y; if (height < width) { h = height / 8; @@ -124,11 +125,11 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos) */ static void draw_vertical_join_shape(ScrArea *sa, char dir, unsigned int pos) { + const float width = screen_geom_area_width(sa) - 1; + const float height = screen_geom_area_height(sa) - 1; vec2f points[10]; short i; float w, h; - float width = sa->v3->vec.x - sa->v1->vec.x; - float height = sa->v3->vec.y - sa->v1->vec.y; if (height < width) { h = height / 4; @@ -353,7 +354,7 @@ static void drawscredge_corner(ScrArea *sa, int sizex, int sizey) */ static void scrarea_draw_shape_dark(ScrArea *sa, char dir, unsigned int pos) { - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); immUniformColor4ub(0, 0, 0, 50); draw_join_shape(sa, dir, pos); @@ -364,7 +365,7 @@ static void scrarea_draw_shape_dark(ScrArea *sa, char dir, unsigned int pos) */ static void scrarea_draw_shape_light(ScrArea *sa, char UNUSED(dir), unsigned int pos) { - glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA); + GPU_blend_set_func(GPU_DST_COLOR, GPU_SRC_ALPHA); /* value 181 was hardly computed: 181~105 */ immUniformColor4ub(255, 255, 255, 50); /* draw_join_shape(sa, dir); */ @@ -444,7 +445,7 @@ void ED_screen_draw_edges(wmWindow *win) /* Note: first loop only draws if U.pixelsize > 1, skip otherwise */ if (U.pixelsize > 1.0f) { /* FIXME: doesn't our glLineWidth already scale by U.pixelsize? */ - glLineWidth((2.0f * U.pixelsize) - 1); + GPU_line_width((2.0f * U.pixelsize) - 1); immUniformThemeColor(TH_EDITOR_OUTLINE); for (sa = screen->areabase.first; sa; sa = sa->next) { @@ -452,7 +453,7 @@ void ED_screen_draw_edges(wmWindow *win) } } - glLineWidth(1); + GPU_line_width(1); immUniformThemeColor(TH_EDITOR_OUTLINE); for (sa = screen->areabase.first; sa; sa = sa->next) { @@ -479,7 +480,7 @@ void ED_screen_draw_join_shape(ScrArea *sa1, ScrArea *sa2) unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - glLineWidth(1); + GPU_line_width(1); /* blended join arrow */ int dir = area_getorientation(sa1, sa2); @@ -504,12 +505,12 @@ void ED_screen_draw_join_shape(ScrArea *sa1, ScrArea *sa2) break; } - glEnable(GL_BLEND); + GPU_blend(true); scrarea_draw_shape_dark(sa2, dir, pos); scrarea_draw_shape_light(sa1, dira, pos); - glDisable(GL_BLEND); + GPU_blend(false); } immUnbindProgram(); @@ -521,7 +522,7 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac) immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* splitpoint */ - glEnable(GL_BLEND); + GPU_blend(true); immUniformColor4ub(255, 255, 255, 100); immBegin(GWN_PRIM_LINES, 2); @@ -562,7 +563,7 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac) immEnd(); } - glDisable(GL_BLEND); + GPU_blend(false); immUnbindProgram(); } @@ -645,8 +646,8 @@ void ED_screen_preview_render(const bScreen *screen, int size_x, int size_y, uns GPUOffScreen *offscreen = GPU_offscreen_create(size_x, size_y, 0, true, false, err_out); GPU_offscreen_bind(offscreen, true); - glClearColor(0.0, 0.0, 0.0, 0.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GPU_clear_color(0.0, 0.0, 0.0, 0.0); + GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT); screen_preview_draw(screen, size_x, size_y); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 53abe3ed4ea..6bc8a6c10cf 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -74,104 +74,6 @@ #include "screen_intern.h" /* own module include */ -/* ******************* screen vert, edge, area managing *********************** */ - -static ScrVert *screen_addvert_ex(ScrAreaMap *area_map, short x, short y) -{ - ScrVert *sv = MEM_callocN(sizeof(ScrVert), "addscrvert"); - sv->vec.x = x; - sv->vec.y = y; - - BLI_addtail(&area_map->vertbase, sv); - return sv; -} -static ScrVert *screen_addvert(bScreen *sc, short x, short y) -{ - return screen_addvert_ex(AREAMAP_FROM_SCREEN(sc), x, y); -} - -static ScrEdge *screen_addedge_ex(ScrAreaMap *area_map, ScrVert *v1, ScrVert *v2) -{ - ScrEdge *se = MEM_callocN(sizeof(ScrEdge), "addscredge"); - - BKE_screen_sort_scrvert(&v1, &v2); - se->v1 = v1; - se->v2 = v2; - - BLI_addtail(&area_map->edgebase, se); - return se; -} -static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2) -{ - return screen_addedge_ex(AREAMAP_FROM_SCREEN(sc), v1, v2); -} - -bool scredge_is_horizontal(ScrEdge *se) -{ - return (se->v1->vec.y == se->v2->vec.y); -} - -/** - * \param bounds_rect: Either window or screen bounds. Used to exclude edges along window/screen edges. - */ -ScrEdge *screen_area_map_find_active_scredge( - const ScrAreaMap *area_map, - const rcti *bounds_rect, - const int mx, const int my) -{ - int safety = U.widget_unit / 10; - - CLAMP_MIN(safety, 2); - - for (ScrEdge *se = area_map->edgebase.first; se; se = se->next) { - if (scredge_is_horizontal(se)) { - if ((se->v1->vec.y > bounds_rect->ymin) && (se->v1->vec.y < (bounds_rect->ymax - 1))) { - short min, max; - min = MIN2(se->v1->vec.x, se->v2->vec.x); - max = MAX2(se->v1->vec.x, se->v2->vec.x); - - if (abs(my - se->v1->vec.y) <= safety && mx >= min && mx <= max) - return se; - } - } - else { - if ((se->v1->vec.x > bounds_rect->xmin) && (se->v1->vec.x < (bounds_rect->xmax - 1))) { - short min, max; - min = MIN2(se->v1->vec.y, se->v2->vec.y); - max = MAX2(se->v1->vec.y, se->v2->vec.y); - - if (abs(mx - se->v1->vec.x) <= safety && my >= min && my <= max) - return se; - } - } - } - - return NULL; -} - -/* need win size to make sure not to include edges along screen edge */ -ScrEdge *screen_find_active_scredge( - const wmWindow *win, const bScreen *screen, - const int mx, const int my) -{ - /* Use layout size (screen excluding global areas) for screen-layout area edges */ - rcti screen_rect; - ScrEdge *se; - - WM_window_screen_rect_calc(win, &screen_rect); - se = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(screen), &screen_rect, mx, my); - - if (!se) { - /* Use entire window size (screen including global areas) for global area edges */ - rcti win_rect; - WM_window_rect_calc(win, &win_rect); - se = screen_area_map_find_active_scredge(&win->global_areas, &win_rect, mx, my); - } - return se; -} - - - /* adds no space data */ static ScrArea *screen_addarea_ex( ScrAreaMap *area_map, @@ -210,54 +112,18 @@ static void screen_delarea(bContext *C, bScreen *sc, ScrArea *sa) MEM_freeN(sa); } -/* return 0: no split possible */ -/* else return (integer) screencoordinate split point */ -static short testsplitpoint(ScrArea *sa, char dir, float fac) -{ - short x, y; - const short area_min_x = AREAMINX; - const short area_min_y = ED_area_headersize(); - - // area big enough? - if (dir == 'v' && (sa->v4->vec.x - sa->v1->vec.x <= 2 * area_min_x)) return 0; - if (dir == 'h' && (sa->v2->vec.y - sa->v1->vec.y <= 2 * area_min_y)) return 0; - - // to be sure - CLAMP(fac, 0.0f, 1.0f); - - if (dir == 'h') { - y = sa->v1->vec.y + - round_fl_to_short(fac * (float)(sa->v2->vec.y - sa->v1->vec.y)); - - if (y - sa->v1->vec.y < area_min_y) - y = sa->v1->vec.y + area_min_y; - else if (sa->v2->vec.y - y < area_min_y) - y = sa->v2->vec.y - area_min_y; - - return y; - } - else { - x = sa->v1->vec.x + - round_fl_to_short(fac * (float)(sa->v4->vec.x - sa->v1->vec.x)); - - if (x - sa->v1->vec.x < area_min_x) - x = sa->v1->vec.x + area_min_x; - else if (sa->v4->vec.x - x < area_min_x) - x = sa->v4->vec.x - area_min_x; - - return x; - } -} - -ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) +ScrArea *area_split(const wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac, int merge) { ScrArea *newa = NULL; ScrVert *sv1, *sv2; short split; + rcti window_rect; if (sa == NULL) return NULL; - split = testsplitpoint(sa, dir, fac); + WM_window_rect_calc(win, &window_rect); + + split = screen_geom_find_area_split_point(sa, &window_rect, dir, fac); if (split == 0) return NULL; /* note regarding (fac > 0.5f) checks below. @@ -266,15 +132,15 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) if (dir == 'h') { /* new vertices */ - sv1 = screen_addvert(sc, sa->v1->vec.x, split); - sv2 = screen_addvert(sc, sa->v4->vec.x, split); + sv1 = screen_geom_vertex_add(sc, sa->v1->vec.x, split); + sv2 = screen_geom_vertex_add(sc, sa->v4->vec.x, split); /* new edges */ - screen_addedge(sc, sa->v1, sv1); - screen_addedge(sc, sv1, sa->v2); - screen_addedge(sc, sa->v3, sv2); - screen_addedge(sc, sv2, sa->v4); - screen_addedge(sc, sv1, sv2); + screen_geom_edge_add(sc, sa->v1, sv1); + screen_geom_edge_add(sc, sv1, sa->v2); + screen_geom_edge_add(sc, sa->v3, sv2); + screen_geom_edge_add(sc, sv2, sa->v4); + screen_geom_edge_add(sc, sv1, sv2); if (fac > 0.5f) { /* new areas: top */ @@ -298,15 +164,15 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) } else { /* new vertices */ - sv1 = screen_addvert(sc, split, sa->v1->vec.y); - sv2 = screen_addvert(sc, split, sa->v2->vec.y); + sv1 = screen_geom_vertex_add(sc, split, sa->v1->vec.y); + sv2 = screen_geom_vertex_add(sc, split, sa->v2->vec.y); /* new edges */ - screen_addedge(sc, sa->v1, sv1); - screen_addedge(sc, sv1, sa->v4); - screen_addedge(sc, sa->v2, sv2); - screen_addedge(sc, sv2, sa->v3); - screen_addedge(sc, sv1, sv2); + screen_geom_edge_add(sc, sa->v1, sv1); + screen_geom_edge_add(sc, sv1, sa->v4); + screen_geom_edge_add(sc, sa->v2, sv2); + screen_geom_edge_add(sc, sv2, sa->v3); + screen_geom_edge_add(sc, sv1, sv2); if (fac > 0.5f) { /* new areas: right */ @@ -349,15 +215,15 @@ bScreen *screen_add(Main *bmain, const char *name, const rcti *rect) sc->do_refresh = true; sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN; - sv1 = screen_addvert(sc, rect->xmin, rect->ymin); - sv2 = screen_addvert(sc, rect->xmin, rect->ymax - 1); - sv3 = screen_addvert(sc, rect->xmax - 1, rect->ymax - 1); - sv4 = screen_addvert(sc, rect->xmax - 1, rect->ymin); + sv1 = screen_geom_vertex_add(sc, rect->xmin, rect->ymin); + sv2 = screen_geom_vertex_add(sc, rect->xmin, rect->ymax - 1); + sv3 = screen_geom_vertex_add(sc, rect->xmax - 1, rect->ymax - 1); + sv4 = screen_geom_vertex_add(sc, rect->xmax - 1, rect->ymin); - screen_addedge(sc, sv1, sv2); - screen_addedge(sc, sv2, sv3); - screen_addedge(sc, sv3, sv4); - screen_addedge(sc, sv4, sv1); + screen_geom_edge_add(sc, sv1, sv2); + screen_geom_edge_add(sc, sv2, sv3); + screen_geom_edge_add(sc, sv3, sv4); + screen_geom_edge_add(sc, sv4, sv1); /* dummy type, no spacedata */ screen_addarea(sc, sv1, sv2, sv3, sv4, SPACE_EMPTY); @@ -473,26 +339,26 @@ int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2) if (dir == 0) { sa1->v1 = sa2->v1; sa1->v2 = sa2->v2; - screen_addedge(scr, sa1->v2, sa1->v3); - screen_addedge(scr, sa1->v1, sa1->v4); + screen_geom_edge_add(scr, sa1->v2, sa1->v3); + screen_geom_edge_add(scr, sa1->v1, sa1->v4); } else if (dir == 1) { sa1->v2 = sa2->v2; sa1->v3 = sa2->v3; - screen_addedge(scr, sa1->v1, sa1->v2); - screen_addedge(scr, sa1->v3, sa1->v4); + screen_geom_edge_add(scr, sa1->v1, sa1->v2); + screen_geom_edge_add(scr, sa1->v3, sa1->v4); } else if (dir == 2) { sa1->v3 = sa2->v3; sa1->v4 = sa2->v4; - screen_addedge(scr, sa1->v2, sa1->v3); - screen_addedge(scr, sa1->v1, sa1->v4); + screen_geom_edge_add(scr, sa1->v2, sa1->v3); + screen_geom_edge_add(scr, sa1->v1, sa1->v4); } else if (dir == 3) { sa1->v1 = sa2->v1; sa1->v4 = sa2->v4; - screen_addedge(scr, sa1->v1, sa1->v2); - screen_addedge(scr, sa1->v3, sa1->v4); + screen_geom_edge_add(scr, sa1->v1, sa1->v2); + screen_geom_edge_add(scr, sa1->v3, sa1->v4); } screen_delarea(C, scr, sa2); @@ -503,232 +369,6 @@ int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2) return 1; } -void select_connected_scredge(const wmWindow *win, ScrEdge *edge) -{ - bScreen *sc = WM_window_get_active_screen(win); - ScrEdge *se; - int oneselected; - char dir; - - /* select connected, only in the right direction */ - /* 'dir' is the direction of EDGE */ - - if (edge->v1->vec.x == edge->v2->vec.x) dir = 'v'; - else dir = 'h'; - - ED_screen_verts_iter(win, sc, sv) { - sv->flag = 0; - } - - edge->v1->flag = 1; - edge->v2->flag = 1; - - oneselected = 1; - while (oneselected) { - se = sc->edgebase.first; - oneselected = 0; - while (se) { - if (se->v1->flag + se->v2->flag == 1) { - if (dir == 'h') { - if (se->v1->vec.y == se->v2->vec.y) { - se->v1->flag = se->v2->flag = 1; - oneselected = 1; - } - } - if (dir == 'v') { - if (se->v1->vec.x == se->v2->vec.x) { - se->v1->flag = se->v2->flag = 1; - oneselected = 1; - } - } - } - se = se->next; - } - } -} - -/** - * Test if screen vertices should be scaled and do if needed. - */ -static void screen_vertices_scale( - const wmWindow *win, bScreen *sc, - const rcti *window_rect, const rcti *screen_rect) -{ - /* clamp Y size of header sized areas when expanding windows - * avoids annoying empty space around file menu */ -#define USE_HEADER_SIZE_CLAMP - - const int headery_init = ED_area_headersize(); - const int screen_size_x = BLI_rcti_size_x(screen_rect); - const int screen_size_y = BLI_rcti_size_y(screen_rect); - ScrVert *sv = NULL; - ScrArea *sa; - int screen_size_x_prev, screen_size_y_prev; - float min[2], max[2]; - - /* calculate size */ - min[0] = min[1] = 20000.0f; - max[0] = max[1] = 0.0f; - - for (sv = sc->vertbase.first; sv; sv = sv->next) { - const float fv[2] = {(float)sv->vec.x, (float)sv->vec.y}; - minmax_v2v2_v2(min, max, fv); - } - - screen_size_x_prev = (max[0] - min[0]) + 1; - screen_size_y_prev = (max[1] - min[1]) + 1; - - -#ifdef USE_HEADER_SIZE_CLAMP -#define TEMP_BOTTOM 1 -#define TEMP_TOP 2 - - /* if the window's Y axis grows, clamp header sized areas */ - if (screen_size_y_prev < screen_size_y) { /* growing? */ - const int headery_margin_max = headery_init + 4; - for (sa = sc->areabase.first; sa; sa = sa->next) { - ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); - sa->temp = 0; - - if (ar && !(ar->flag & RGN_FLAG_HIDDEN)) { - if (sa->v2->vec.y == max[1]) { - if ((sa->v2->vec.y - sa->v1->vec.y) < headery_margin_max) { - sa->temp = TEMP_TOP; - } - } - else if (sa->v1->vec.y == min[1]) { - if ((sa->v2->vec.y - sa->v1->vec.y) < headery_margin_max) { - sa->temp = TEMP_BOTTOM; - } - } - } - } - } -#endif - - - if (screen_size_x_prev != screen_size_x || screen_size_y_prev != screen_size_y) { - const float facx = ((float)screen_size_x - 1) / ((float)screen_size_x_prev - 1); - const float facy = ((float)screen_size_y - 1) / ((float)screen_size_y_prev - 1); - - /* make sure it fits! */ - for (sv = sc->vertbase.first; sv; sv = sv->next) { - sv->vec.x = screen_rect->xmin + round_fl_to_short((sv->vec.x - min[0]) * facx); - CLAMP(sv->vec.x, screen_rect->xmin, screen_rect->xmax - 1); - - sv->vec.y = screen_rect->ymin + round_fl_to_short((sv->vec.y - min[1]) * facy); - CLAMP(sv->vec.y, screen_rect->ymin, screen_rect->ymax - 1); - } - } - - -#ifdef USE_HEADER_SIZE_CLAMP - if (screen_size_y_prev < screen_size_y) { /* growing? */ - for (sa = sc->areabase.first; sa; sa = sa->next) { - ScrEdge *se = NULL; - - if (sa->temp == 0) - continue; - - if (sa->v1 == sa->v2) - continue; - - /* adjust headery if verts are along the edge of window */ - if (sa->temp == TEMP_TOP) { - /* lower edge */ - const int yval = sa->v2->vec.y - headery_init; - se = BKE_screen_find_edge(sc, sa->v4, sa->v1); - if (se != NULL) { - select_connected_scredge(win, se); - } - for (sv = sc->vertbase.first; sv; sv = sv->next) { - if (sv != sa->v2 && sv != sa->v3) { - if (sv->flag) { - sv->vec.y = yval; - } - } - } - } - else { - /* upper edge */ - const int yval = sa->v1->vec.y + headery_init; - se = BKE_screen_find_edge(sc, sa->v2, sa->v3); - if (se != NULL) { - select_connected_scredge(win, se); - } - for (sv = sc->vertbase.first; sv; sv = sv->next) { - if (sv != sa->v1 && sv != sa->v4) { - if (sv->flag) { - sv->vec.y = yval; - } - } - } - } - } - } - -#undef USE_HEADER_SIZE_CLAMP -#undef TEMP_BOTTOM -#undef TEMP_TOP -#endif - - - /* test for collapsed areas. This could happen in some blender version... */ - /* ton: removed option now, it needs Context... */ - - /* make each window at least ED_area_headersize() high */ - for (sa = sc->areabase.first; sa; sa = sa->next) { - int headery = headery_init; - - /* adjust headery if verts are along the edge of window */ - if (sa->v1->vec.y > window_rect->ymin) - headery += U.pixelsize; - if (sa->v2->vec.y < window_rect->ymax) - headery += U.pixelsize; - - if (sa->v2->vec.y - sa->v1->vec.y + 1 < headery) { - /* lower edge */ - ScrEdge *se = BKE_screen_find_edge(sc, sa->v4, sa->v1); - if (se && sa->v1 != sa->v2) { - const int yval = sa->v2->vec.y - headery + 1; - - select_connected_scredge(win, se); - - /* all selected vertices get the right offset */ - for (sv = sc->vertbase.first; sv; sv = sv->next) { - /* if is a collapsed area */ - if (sv != sa->v2 && sv != sa->v3) { - if (sv->flag) { - sv->vec.y = yval; - } - } - } - } - } - } - - /* Global areas have a fixed size that only changes with the DPI. Here we ensure that exactly this size is set. */ - for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) { - if (area->global->flag & GLOBAL_AREA_IS_HIDDEN) { - continue; - } - /* width */ - area->v1->vec.x = area->v2->vec.x = window_rect->xmin; - area->v3->vec.x = area->v4->vec.x = window_rect->xmax - 1; - /* height */ - area->v1->vec.y = area->v4->vec.y = window_rect->ymin; - area->v2->vec.y = area->v3->vec.y = window_rect->ymax - 1; - switch (area->global->align) { - case GLOBAL_AREA_ALIGN_TOP: - area->v1->vec.y = area->v4->vec.y = area->v2->vec.y - ED_area_global_size_y(area); - break; - case GLOBAL_AREA_ALIGN_BOTTOM: - area->v2->vec.y = area->v3->vec.y = area->v1->vec.y + ED_area_global_size_y(area); - break; - } - } -} - /* ****************** EXPORTED API TO OTHER MODULES *************************** */ @@ -808,7 +448,7 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) WM_window_rect_calc(win, &window_rect); WM_window_screen_rect_calc(win, &screen_rect); /* Get screen bounds __after__ updating window DPI! */ - screen_vertices_scale(win, screen, &window_rect, &screen_rect); + screen_geom_vertices_scale(win, screen); ED_screen_areas_iter(win, screen, area) { /* set spacetype and region callbacks, calls init() */ @@ -975,10 +615,10 @@ static void screen_cursor_set(wmWindow *win, const int xy[2]) } } else { - ScrEdge *actedge = screen_find_active_scredge(win, screen, xy[0], xy[1]); + ScrEdge *actedge = screen_geom_find_active_scredge(win, screen, xy[0], xy[1]); if (actedge) { - if (scredge_is_horizontal(actedge)) + if (screen_geom_edge_is_horizontal(actedge)) WM_cursor_set(win, CURSOR_Y_MOVE); else WM_cursor_set(win, CURSOR_X_MOVE); @@ -1094,15 +734,15 @@ static ScrArea *screen_area_create_with_geometry( ScrAreaMap *area_map, const rcti *rect, short spacetype) { - ScrVert *bottom_left = screen_addvert_ex(area_map, rect->xmin, rect->ymin); - ScrVert *top_left = screen_addvert_ex(area_map, rect->xmin, rect->ymax); - ScrVert *top_right = screen_addvert_ex(area_map, rect->xmax, rect->ymax); - ScrVert *bottom_right = screen_addvert_ex(area_map, rect->xmax, rect->ymin); + ScrVert *bottom_left = screen_geom_vertex_add_ex(area_map, rect->xmin, rect->ymin); + ScrVert *top_left = screen_geom_vertex_add_ex(area_map, rect->xmin, rect->ymax); + ScrVert *top_right = screen_geom_vertex_add_ex(area_map, rect->xmax, rect->ymax); + ScrVert *bottom_right = screen_geom_vertex_add_ex(area_map, rect->xmax, rect->ymin); - screen_addedge_ex(area_map, bottom_left, top_left); - screen_addedge_ex(area_map, top_left, top_right); - screen_addedge_ex(area_map, top_right, bottom_right); - screen_addedge_ex(area_map, bottom_right, bottom_left); + screen_geom_edge_add_ex(area_map, bottom_left, top_left); + screen_geom_edge_add_ex(area_map, top_left, top_right); + screen_geom_edge_add_ex(area_map, top_right, bottom_right); + screen_geom_edge_add_ex(area_map, bottom_right, bottom_left); return screen_addarea_ex(area_map, bottom_left, top_left, top_right, bottom_right, spacetype); } @@ -1141,13 +781,13 @@ static void screen_global_topbar_area_create(wmWindow *win) static void screen_global_statusbar_area_create(wmWindow *win) { - const short size_y = HEADERY; + const short size_y = 0.8f * HEADERY; rcti rect; BLI_rcti_init(&rect, 0, WM_window_pixels_x(win) - 1, 0, WM_window_pixels_y(win) - 1); rect.ymax = rect.ymin + size_y; - screen_global_area_create(win, SPACE_STATUSBAR, GLOBAL_AREA_ALIGN_BOTTOM, &rect, size_y, size_y, size_y); + screen_global_area_create(win, SPACE_STATUSBAR, GLOBAL_AREA_ALIGN_BOTTOM, &rect, size_y, 0, size_y); } void ED_screen_global_areas_create(wmWindow *win) @@ -1418,8 +1058,9 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s } } - /* prevent hanging header prints */ - ED_area_headerprint(sa, NULL); + /* prevent hanging status prints */ + ED_area_status_text(sa, NULL); + ED_workspace_status_text(C, NULL); } if (sa && sa->full) { @@ -1680,6 +1321,7 @@ void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph) for (sc = bmain->screen.first; sc; sc = sc->id.next) { BKE_screen_view3d_scene_sync(sc, scene); } + DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE); } #endif diff --git a/source/blender/editors/screen/screen_geometry.c b/source/blender/editors/screen/screen_geometry.c new file mode 100644 index 00000000000..5d87479e371 --- /dev/null +++ b/source/blender/editors/screen/screen_geometry.c @@ -0,0 +1,462 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/screen/screen_geometry.c + * \ingroup edscr + * \brief Functions for screen vertices and edges + * + * Screen geometry refers to the vertices (ScrVert) and edges (ScrEdge) through + * which the flexible screen-layout system of Blender is established. + */ + +#include "BLI_listbase.h" +#include "BLI_math.h" +#include "BLI_rect.h" + +#include "BKE_screen.h" + +#include "DNA_screen_types.h" +#include "DNA_windowmanager_types.h" + +#include "ED_screen.h" + +#include "MEM_guardedalloc.h" + +#include "WM_api.h" + +#include "screen_intern.h" + + +int screen_geom_area_height(const ScrArea *area) +{ + return area->v2->vec.y - area->v1->vec.y + 1; +} +int screen_geom_area_width(const ScrArea *area) +{ + return area->v4->vec.x - area->v1->vec.x + 1; +} + +ScrVert *screen_geom_vertex_add_ex(ScrAreaMap *area_map, short x, short y) +{ + ScrVert *sv = MEM_callocN(sizeof(ScrVert), "addscrvert"); + sv->vec.x = x; + sv->vec.y = y; + + BLI_addtail(&area_map->vertbase, sv); + return sv; +} +ScrVert *screen_geom_vertex_add(bScreen *sc, short x, short y) +{ + return screen_geom_vertex_add_ex(AREAMAP_FROM_SCREEN(sc), x, y); +} + +ScrEdge *screen_geom_edge_add_ex(ScrAreaMap *area_map, ScrVert *v1, ScrVert *v2) +{ + ScrEdge *se = MEM_callocN(sizeof(ScrEdge), "addscredge"); + + BKE_screen_sort_scrvert(&v1, &v2); + se->v1 = v1; + se->v2 = v2; + + BLI_addtail(&area_map->edgebase, se); + return se; +} +ScrEdge *screen_geom_edge_add(bScreen *sc, ScrVert *v1, ScrVert *v2) +{ + return screen_geom_edge_add_ex(AREAMAP_FROM_SCREEN(sc), v1, v2); +} + +bool screen_geom_edge_is_horizontal(ScrEdge *se) +{ + return (se->v1->vec.y == se->v2->vec.y); +} + +/** + * \param bounds_rect: Either window or screen bounds. Used to exclude edges along window/screen edges. + */ +ScrEdge *screen_geom_area_map_find_active_scredge( + const ScrAreaMap *area_map, + const rcti *bounds_rect, + const int mx, const int my) +{ + int safety = U.widget_unit / 10; + + CLAMP_MIN(safety, 2); + + for (ScrEdge *se = area_map->edgebase.first; se; se = se->next) { + if (screen_geom_edge_is_horizontal(se)) { + if ((se->v1->vec.y > bounds_rect->ymin) && (se->v1->vec.y < (bounds_rect->ymax - 1))) { + short min, max; + min = MIN2(se->v1->vec.x, se->v2->vec.x); + max = MAX2(se->v1->vec.x, se->v2->vec.x); + + if (abs(my - se->v1->vec.y) <= safety && mx >= min && mx <= max) + return se; + } + } + else { + if ((se->v1->vec.x > bounds_rect->xmin) && (se->v1->vec.x < (bounds_rect->xmax - 1))) { + short min, max; + min = MIN2(se->v1->vec.y, se->v2->vec.y); + max = MAX2(se->v1->vec.y, se->v2->vec.y); + + if (abs(mx - se->v1->vec.x) <= safety && my >= min && my <= max) + return se; + } + } + } + + return NULL; +} + +/* need win size to make sure not to include edges along screen edge */ +ScrEdge *screen_geom_find_active_scredge( + const wmWindow *win, const bScreen *screen, + const int mx, const int my) +{ + /* Use layout size (screen excluding global areas) for screen-layout area edges */ + rcti screen_rect; + ScrEdge *se; + + WM_window_screen_rect_calc(win, &screen_rect); + se = screen_geom_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(screen), &screen_rect, mx, my); + + if (!se) { + /* Use entire window size (screen including global areas) for global area edges */ + rcti win_rect; + WM_window_rect_calc(win, &win_rect); + se = screen_geom_area_map_find_active_scredge(&win->global_areas, &win_rect, mx, my); + } + return se; +} + +/** + * \brief Main screen-layout calculation function. + * + * * Scale areas nicely on window size and DPI changes. + * * Ensure areas have a minimum height. + * * Correctly set global areas to their fixed height. + */ +void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc) +{ + /* clamp Y size of header sized areas when expanding windows + * avoids annoying empty space around file menu */ +#define USE_HEADER_SIZE_CLAMP + + rcti window_rect, screen_rect; + + WM_window_rect_calc(win, &window_rect); + WM_window_screen_rect_calc(win, &screen_rect); + + const int headery_init = ED_area_headersize(); + const int screen_size_x = BLI_rcti_size_x(&screen_rect); + const int screen_size_y = BLI_rcti_size_y(&screen_rect); + ScrVert *sv = NULL; + ScrArea *sa; + int screen_size_x_prev, screen_size_y_prev; + float min[2], max[2]; + + /* calculate size */ + min[0] = min[1] = 20000.0f; + max[0] = max[1] = 0.0f; + + for (sv = sc->vertbase.first; sv; sv = sv->next) { + const float fv[2] = {(float)sv->vec.x, (float)sv->vec.y}; + minmax_v2v2_v2(min, max, fv); + } + + screen_size_x_prev = (max[0] - min[0]) + 1; + screen_size_y_prev = (max[1] - min[1]) + 1; + + +#ifdef USE_HEADER_SIZE_CLAMP +#define TEMP_BOTTOM 1 +#define TEMP_TOP 2 + + /* if the window's Y axis grows, clamp header sized areas */ + if (screen_size_y_prev < screen_size_y) { /* growing? */ + const int headery_margin_max = headery_init + 5; + for (sa = sc->areabase.first; sa; sa = sa->next) { + ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + sa->temp = 0; + + if (ar && !(ar->flag & RGN_FLAG_HIDDEN)) { + if (sa->v2->vec.y == max[1]) { + if (screen_geom_area_height(sa) < headery_margin_max) { + sa->temp = TEMP_TOP; + } + } + else if (sa->v1->vec.y == min[1]) { + if (screen_geom_area_height(sa) < headery_margin_max) { + sa->temp = TEMP_BOTTOM; + } + } + } + } + } +#endif + + + if (screen_size_x_prev != screen_size_x || screen_size_y_prev != screen_size_y) { + const float facx = ((float)screen_size_x - 1) / ((float)screen_size_x_prev - 1); + const float facy = ((float)screen_size_y - 1) / ((float)screen_size_y_prev - 1); + + /* make sure it fits! */ + for (sv = sc->vertbase.first; sv; sv = sv->next) { + sv->vec.x = screen_rect.xmin + round_fl_to_short((sv->vec.x - min[0]) * facx); + CLAMP(sv->vec.x, screen_rect.xmin, screen_rect.xmax - 1); + + sv->vec.y = screen_rect.ymin + round_fl_to_short((sv->vec.y - min[1]) * facy); + CLAMP(sv->vec.y, screen_rect.ymin, screen_rect.ymax - 1); + } + } + + +#ifdef USE_HEADER_SIZE_CLAMP + if (screen_size_y_prev < screen_size_y) { /* growing? */ + for (sa = sc->areabase.first; sa; sa = sa->next) { + ScrEdge *se = NULL; + + if (sa->temp == 0) + continue; + + if (sa->v1 == sa->v2) + continue; + + /* adjust headery if verts are along the edge of window */ + if (sa->temp == TEMP_TOP) { + /* lower edge */ + const int yval = sa->v2->vec.y - headery_init; + se = BKE_screen_find_edge(sc, sa->v4, sa->v1); + if (se != NULL) { + screen_geom_select_connected_edge(win, se); + } + for (sv = sc->vertbase.first; sv; sv = sv->next) { + if (sv != sa->v2 && sv != sa->v3) { + if (sv->flag) { + sv->vec.y = yval; + } + } + } + } + else { + /* upper edge */ + const int yval = sa->v1->vec.y + headery_init; + se = BKE_screen_find_edge(sc, sa->v2, sa->v3); + if (se != NULL) { + screen_geom_select_connected_edge(win, se); + } + for (sv = sc->vertbase.first; sv; sv = sv->next) { + if (sv != sa->v1 && sv != sa->v4) { + if (sv->flag) { + sv->vec.y = yval; + } + } + } + } + } + } + +#undef USE_HEADER_SIZE_CLAMP +#undef TEMP_BOTTOM +#undef TEMP_TOP +#endif + + + /* test for collapsed areas. This could happen in some blender version... */ + /* ton: removed option now, it needs Context... */ + + /* make each window at least ED_area_headersize() high */ + for (sa = sc->areabase.first; sa; sa = sa->next) { + int headery = headery_init; + + /* adjust headery if verts are along the edge of window */ + if (sa->v1->vec.y > window_rect.ymin) + headery += U.pixelsize; + if (sa->v2->vec.y < (window_rect.ymax - 1)) + headery += U.pixelsize; + + if (screen_geom_area_height(sa) < headery) { + /* lower edge */ + ScrEdge *se = BKE_screen_find_edge(sc, sa->v4, sa->v1); + if (se && sa->v1 != sa->v2) { + const int yval = sa->v2->vec.y - headery + 1; + + screen_geom_select_connected_edge(win, se); + + /* all selected vertices get the right offset */ + for (sv = sc->vertbase.first; sv; sv = sv->next) { + /* if is a collapsed area */ + if (sv != sa->v2 && sv != sa->v3) { + if (sv->flag) { + sv->vec.y = yval; + } + } + } + } + } + } + + /* Global areas have a fixed size that only changes with the DPI. Here we ensure that exactly this size is set. */ + for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) { + if (area->global->flag & GLOBAL_AREA_IS_HIDDEN) { + continue; + } + + int height = ED_area_global_size_y(area) - 1; + + if (area->v1->vec.y > window_rect.ymin) { + height += U.pixelsize; + } + if (area->v2->vec.y < (window_rect.ymax - 1)) { + height += U.pixelsize; + } + + /* width */ + area->v1->vec.x = area->v2->vec.x = window_rect.xmin; + area->v3->vec.x = area->v4->vec.x = window_rect.xmax - 1; + /* height */ + area->v1->vec.y = area->v4->vec.y = window_rect.ymin; + area->v2->vec.y = area->v3->vec.y = window_rect.ymax - 1; + + switch (area->global->align) { + case GLOBAL_AREA_ALIGN_TOP: + area->v1->vec.y = area->v4->vec.y = area->v2->vec.y - height; + break; + case GLOBAL_AREA_ALIGN_BOTTOM: + area->v2->vec.y = area->v3->vec.y = area->v1->vec.y + height; + break; + } + } +} + +/** + * \return 0 if no split is possible, otherwise the screen-coordinate at which to split. + */ +short screen_geom_find_area_split_point(const ScrArea *sa, const rcti *window_rect, char dir, float fac) +{ + short x, y; + const int cur_area_width = screen_geom_area_width(sa); + const int cur_area_height = screen_geom_area_height(sa); + const short area_min_x = AREAMINX; + const short area_min_y = ED_area_headersize(); + int area_min; + + // area big enough? + if ((dir == 'v') && (cur_area_width <= 2 * area_min_x)) { + return 0; + } + if ((dir == 'h') && (cur_area_height <= 2 * area_min_y)) { + return 0; + } + + // to be sure + CLAMP(fac, 0.0f, 1.0f); + + if (dir == 'h') { + y = sa->v1->vec.y + round_fl_to_short(fac * cur_area_height); + + area_min = area_min_y; + + if (sa->v1->vec.y > window_rect->ymin) { + area_min += U.pixelsize; + } + if (sa->v2->vec.y < (window_rect->ymax - 1)) { + area_min += U.pixelsize; + } + + if (y - sa->v1->vec.y < area_min) { + y = sa->v1->vec.y + area_min; + } + else if (sa->v2->vec.y - y < area_min) { + y = sa->v2->vec.y - area_min; + } + + return y; + } + else { + x = sa->v1->vec.x + round_fl_to_short(fac * cur_area_width); + + area_min = area_min_x; + + if (sa->v1->vec.x > window_rect->xmin) { + area_min += U.pixelsize; + } + if (sa->v4->vec.x < (window_rect->xmax - 1)) { + area_min += U.pixelsize; + } + + if (x - sa->v1->vec.x < area_min) { + x = sa->v1->vec.x + area_min; + } + else if (sa->v4->vec.x - x < area_min) { + x = sa->v4->vec.x - area_min; + } + + return x; + } +} + +/** + * Select all edges that are directly or indirectly connected to \a edge. + */ +void screen_geom_select_connected_edge(const wmWindow *win, ScrEdge *edge) +{ + bScreen *sc = WM_window_get_active_screen(win); + bool oneselected = true; + char dir; + + /* select connected, only in the right direction */ + /* 'dir' is the direction of EDGE */ + + if (edge->v1->vec.x == edge->v2->vec.x) { + dir = 'v'; + } + else { + dir = 'h'; + } + + ED_screen_verts_iter(win, sc, sv) { + sv->flag = 0; + } + + edge->v1->flag = 1; + edge->v2->flag = 1; + + while (oneselected) { + oneselected = false; + for (ScrEdge *se = sc->edgebase.first; se; se = se->next) { + if (se->v1->flag + se->v2->flag == 1) { + if (dir == 'h') { + if (se->v1->vec.y == se->v2->vec.y) { + se->v1->flag = se->v2->flag = 1; + oneselected = true; + } + } + if (dir == 'v') { + if (se->v1->vec.x == se->v2->vec.x) { + se->v1->flag = se->v2->flag = 1; + oneselected = true; + } + } + } + } + } +} diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index 2c343fb9d70..cd71c07a3c0 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -53,22 +53,32 @@ void screen_data_copy(bScreen *to, bScreen *from); void screen_new_activate_prepare(const wmWindow *win, bScreen *screen_new); void screen_change_update(struct bContext *C, wmWindow *win, bScreen *sc); bScreen *screen_change_prepare(bScreen *screen_old, bScreen *screen_new, struct Main *bmain, struct bContext *C, wmWindow *win); -ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge); +ScrArea *area_split(const wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac, int merge); int screen_area_join(struct bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2); int area_getorientation(ScrArea *sa, ScrArea *sb); -void select_connected_scredge(const wmWindow *win, ScrEdge *edge); -bool scredge_is_horizontal(ScrEdge *se); -ScrEdge *screen_area_map_find_active_scredge( +struct AZone *ED_area_actionzone_find_xy(ScrArea *sa, const int xy[2]); +struct AZone *ED_area_actionzone_refresh_xy(ScrArea *sa, const int xy[2]); + +/* screen_geometry.c */ +int screen_geom_area_height(const ScrArea *area); +int screen_geom_area_width(const ScrArea *area); +ScrVert *screen_geom_vertex_add_ex(ScrAreaMap *area_map, short x, short y); +ScrVert *screen_geom_vertex_add(bScreen *sc, short x, short y); +ScrEdge *screen_geom_edge_add_ex(ScrAreaMap *area_map, ScrVert *v1, ScrVert *v2); +ScrEdge *screen_geom_edge_add(bScreen *sc, ScrVert *v1, ScrVert *v2); +bool screen_geom_edge_is_horizontal(ScrEdge *se); +ScrEdge *screen_geom_area_map_find_active_scredge( const struct ScrAreaMap *area_map, const rcti *bounds_rect, const int mx, const int my); -ScrEdge *screen_find_active_scredge( +ScrEdge *screen_geom_find_active_scredge( const wmWindow *win, const bScreen *screen, const int mx, const int my); +void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc); +short screen_geom_find_area_split_point(const ScrArea *sa, const rcti *window_rect, char dir, float fac); +void screen_geom_select_connected_edge(const wmWindow *win, ScrEdge *edge); -struct AZone *ED_area_actionzone_find_xy(ScrArea *sa, const int xy[2]); -struct AZone *ED_area_actionzone_refresh_xy(ScrArea *sa, const int xy[2]); /* screen_context.c */ int ed_screen_context( @@ -78,7 +88,6 @@ extern const char *screen_context_dir[]; /* doc access */ /* screendump.c */ void SCREEN_OT_screenshot(struct wmOperatorType *ot); -void SCREEN_OT_screencast(struct wmOperatorType *ot); /* screen_ops.c */ void region_blend_start(struct bContext *C, struct ScrArea *sa, struct ARegion *ar); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index e08755c84c6..fb269740109 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -104,7 +104,7 @@ /** \name Public Poll API * \{ */ -int ED_operator_regionactive(bContext *C) +bool ED_operator_regionactive(bContext *C) { if (CTX_wm_window(C) == NULL) return 0; if (CTX_wm_screen(C) == NULL) return 0; @@ -112,7 +112,7 @@ int ED_operator_regionactive(bContext *C) return 1; } -int ED_operator_areaactive(bContext *C) +bool ED_operator_areaactive(bContext *C) { if (CTX_wm_window(C) == NULL) return 0; if (CTX_wm_screen(C) == NULL) return 0; @@ -120,7 +120,7 @@ int ED_operator_areaactive(bContext *C) return 1; } -int ED_operator_screenactive(bContext *C) +bool ED_operator_screenactive(bContext *C) { if (CTX_wm_window(C) == NULL) return 0; if (CTX_wm_screen(C) == NULL) return 0; @@ -128,7 +128,7 @@ int ED_operator_screenactive(bContext *C) } /* XXX added this to prevent anim state to change during renders */ -static int ED_operator_screenactive_norender(bContext *C) +static bool ED_operator_screenactive_norender(bContext *C) { if (G.is_rendering) return 0; if (CTX_wm_window(C) == NULL) return 0; @@ -137,7 +137,7 @@ static int ED_operator_screenactive_norender(bContext *C) } /* when mouse is over area-edge */ -int ED_operator_screen_mainwinactive(bContext *C) +bool ED_operator_screen_mainwinactive(bContext *C) { bScreen *screen; if (CTX_wm_window(C) == NULL) return 0; @@ -147,7 +147,7 @@ int ED_operator_screen_mainwinactive(bContext *C) return 1; } -int ED_operator_scene(bContext *C) +bool ED_operator_scene(bContext *C) { Scene *scene = CTX_data_scene(C); if (scene) @@ -155,7 +155,7 @@ int ED_operator_scene(bContext *C) return 0; } -int ED_operator_scene_editable(bContext *C) +bool ED_operator_scene_editable(bContext *C) { Scene *scene = CTX_data_scene(C); if (scene && !ID_IS_LINKED(scene)) @@ -163,7 +163,7 @@ int ED_operator_scene_editable(bContext *C) return 0; } -int ED_operator_objectmode(bContext *C) +bool ED_operator_objectmode(bContext *C) { Scene *scene = CTX_data_scene(C); Object *obact = CTX_data_active_object(C); @@ -190,12 +190,12 @@ static bool ed_spacetype_test(bContext *C, int type) return 0; } -int ED_operator_view3d_active(bContext *C) +bool ED_operator_view3d_active(bContext *C) { return ed_spacetype_test(C, SPACE_VIEW3D); } -int ED_operator_region_view3d_active(bContext *C) +bool ED_operator_region_view3d_active(bContext *C) { if (CTX_wm_region_view3d(C)) return true; @@ -205,7 +205,7 @@ int ED_operator_region_view3d_active(bContext *C) } /* generic for any view2d which uses anim_ops */ -int ED_operator_animview_active(bContext *C) +bool ED_operator_animview_active(bContext *C) { if (ED_operator_areaactive(C)) { SpaceLink *sl = (SpaceLink *)CTX_wm_space_data(C); @@ -217,12 +217,12 @@ int ED_operator_animview_active(bContext *C) return 0; } -int ED_operator_outliner_active(bContext *C) +bool ED_operator_outliner_active(bContext *C) { return ed_spacetype_test(C, SPACE_OUTLINER); } -int ED_operator_outliner_active_no_editobject(bContext *C) +bool ED_operator_outliner_active_no_editobject(bContext *C) { if (ed_spacetype_test(C, SPACE_OUTLINER)) { Object *ob = ED_object_active_context(C); @@ -235,22 +235,22 @@ int ED_operator_outliner_active_no_editobject(bContext *C) return 0; } -int ED_operator_file_active(bContext *C) +bool ED_operator_file_active(bContext *C) { return ed_spacetype_test(C, SPACE_FILE); } -int ED_operator_action_active(bContext *C) +bool ED_operator_action_active(bContext *C) { return ed_spacetype_test(C, SPACE_ACTION); } -int ED_operator_buttons_active(bContext *C) +bool ED_operator_buttons_active(bContext *C) { return ed_spacetype_test(C, SPACE_BUTS); } -int ED_operator_node_active(bContext *C) +bool ED_operator_node_active(bContext *C) { SpaceNode *snode = CTX_wm_space_node(C); @@ -260,7 +260,7 @@ int ED_operator_node_active(bContext *C) return 0; } -int ED_operator_node_editable(bContext *C) +bool ED_operator_node_editable(bContext *C) { SpaceNode *snode = CTX_wm_space_node(C); @@ -270,75 +270,75 @@ int ED_operator_node_editable(bContext *C) return 0; } -int ED_operator_graphedit_active(bContext *C) +bool ED_operator_graphedit_active(bContext *C) { return ed_spacetype_test(C, SPACE_IPO); } -int ED_operator_sequencer_active(bContext *C) +bool ED_operator_sequencer_active(bContext *C) { return ed_spacetype_test(C, SPACE_SEQ); } -int ED_operator_sequencer_active_editable(bContext *C) +bool ED_operator_sequencer_active_editable(bContext *C) { return ed_spacetype_test(C, SPACE_SEQ) && ED_operator_scene_editable(C); } -int ED_operator_image_active(bContext *C) +bool ED_operator_image_active(bContext *C) { return ed_spacetype_test(C, SPACE_IMAGE); } -int ED_operator_nla_active(bContext *C) +bool ED_operator_nla_active(bContext *C) { return ed_spacetype_test(C, SPACE_NLA); } -int ED_operator_info_active(bContext *C) +bool ED_operator_info_active(bContext *C) { return ed_spacetype_test(C, SPACE_INFO); } -int ED_operator_console_active(bContext *C) +bool ED_operator_console_active(bContext *C) { return ed_spacetype_test(C, SPACE_CONSOLE); } -static int ed_object_hidden(Object *ob) +static bool ed_object_hidden(Object *ob) { /* if hidden but in edit mode, we still display, can happen with animation */ return ((ob->restrictflag & OB_RESTRICT_VIEW) && !(ob->mode & OB_MODE_EDIT)); } -int ED_operator_object_active(bContext *C) +bool ED_operator_object_active(bContext *C) { Object *ob = ED_object_active_context(C); return ((ob != NULL) && !ed_object_hidden(ob)); } -int ED_operator_object_active_editable(bContext *C) +bool ED_operator_object_active_editable(bContext *C) { Object *ob = ED_object_active_context(C); return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob)); } -int ED_operator_object_active_editable_mesh(bContext *C) +bool ED_operator_object_active_editable_mesh(bContext *C) { Object *ob = ED_object_active_context(C); return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob) && (ob->type == OB_MESH) && !ID_IS_LINKED(ob->data)); } -int ED_operator_object_active_editable_font(bContext *C) +bool ED_operator_object_active_editable_font(bContext *C) { Object *ob = ED_object_active_context(C); return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob) && (ob->type == OB_FONT)); } -int ED_operator_editmesh(bContext *C) +bool ED_operator_editmesh(bContext *C) { Object *obedit = CTX_data_edit_object(C); if (obedit && obedit->type == OB_MESH) @@ -346,12 +346,12 @@ int ED_operator_editmesh(bContext *C) return 0; } -int ED_operator_editmesh_view3d(bContext *C) +bool ED_operator_editmesh_view3d(bContext *C) { return ED_operator_editmesh(C) && ED_operator_view3d_active(C); } -int ED_operator_editmesh_region_view3d(bContext *C) +bool ED_operator_editmesh_region_view3d(bContext *C) { if (ED_operator_editmesh(C) && CTX_wm_region_view3d(C)) return 1; @@ -360,7 +360,7 @@ int ED_operator_editmesh_region_view3d(bContext *C) return 0; } -int ED_operator_editmesh_auto_smooth(bContext *C) +bool ED_operator_editmesh_auto_smooth(bContext *C) { Object *obedit = CTX_data_edit_object(C); if (obedit && obedit->type == OB_MESH && (((Mesh *)(obedit->data))->flag & ME_AUTOSMOOTH)) { @@ -369,7 +369,7 @@ int ED_operator_editmesh_auto_smooth(bContext *C) return 0; } -int ED_operator_editarmature(bContext *C) +bool ED_operator_editarmature(bContext *C) { Object *obedit = CTX_data_edit_object(C); if (obedit && obedit->type == OB_ARMATURE) @@ -384,7 +384,7 @@ int ED_operator_editarmature(bContext *C) * when it comes to transforming bones, but managing bones layers/groups * can be left for pose mode only. (not weight paint mode) */ -int ED_operator_posemode_exclusive(bContext *C) +bool ED_operator_posemode_exclusive(bContext *C) { Object *obact = CTX_data_active_object(C); @@ -402,7 +402,7 @@ int ED_operator_posemode_exclusive(bContext *C) /* allows for pinned pose objects to be used in the object buttons * and the non-active pose object to be used in the 3D view */ -int ED_operator_posemode_context(bContext *C) +bool ED_operator_posemode_context(bContext *C) { Object *obpose = ED_pose_object_from_context(C); @@ -415,7 +415,7 @@ int ED_operator_posemode_context(bContext *C) return 0; } -int ED_operator_posemode(bContext *C) +bool ED_operator_posemode(bContext *C) { Object *obact = CTX_data_active_object(C); @@ -431,7 +431,7 @@ int ED_operator_posemode(bContext *C) return 0; } -int ED_operator_posemode_local(bContext *C) +bool ED_operator_posemode_local(bContext *C) { if (ED_operator_posemode(C)) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); @@ -443,21 +443,21 @@ int ED_operator_posemode_local(bContext *C) } /* wrapper for ED_space_image_show_uvedit */ -int ED_operator_uvedit(bContext *C) +bool ED_operator_uvedit(bContext *C) { SpaceImage *sima = CTX_wm_space_image(C); Object *obedit = CTX_data_edit_object(C); return ED_space_image_show_uvedit(sima, obedit); } -int ED_operator_uvedit_space_image(bContext *C) +bool ED_operator_uvedit_space_image(bContext *C) { SpaceImage *sima = CTX_wm_space_image(C); Object *obedit = CTX_data_edit_object(C); return sima && ED_space_image_show_uvedit(sima, obedit); } -int ED_operator_uvmap(bContext *C) +bool ED_operator_uvmap(bContext *C) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = NULL; @@ -473,7 +473,7 @@ int ED_operator_uvmap(bContext *C) return false; } -int ED_operator_editsurfcurve(bContext *C) +bool ED_operator_editsurfcurve(bContext *C) { Object *obedit = CTX_data_edit_object(C); if (obedit && ELEM(obedit->type, OB_CURVE, OB_SURF)) @@ -481,7 +481,7 @@ int ED_operator_editsurfcurve(bContext *C) return 0; } -int ED_operator_editsurfcurve_region_view3d(bContext *C) +bool ED_operator_editsurfcurve_region_view3d(bContext *C) { if (ED_operator_editsurfcurve(C) && CTX_wm_region_view3d(C)) return 1; @@ -490,7 +490,7 @@ int ED_operator_editsurfcurve_region_view3d(bContext *C) return 0; } -int ED_operator_editcurve(bContext *C) +bool ED_operator_editcurve(bContext *C) { Object *obedit = CTX_data_edit_object(C); if (obedit && obedit->type == OB_CURVE) @@ -498,7 +498,7 @@ int ED_operator_editcurve(bContext *C) return 0; } -int ED_operator_editcurve_3d(bContext *C) +bool ED_operator_editcurve_3d(bContext *C) { Object *obedit = CTX_data_edit_object(C); if (obedit && obedit->type == OB_CURVE) { @@ -509,7 +509,7 @@ int ED_operator_editcurve_3d(bContext *C) return 0; } -int ED_operator_editsurf(bContext *C) +bool ED_operator_editsurf(bContext *C) { Object *obedit = CTX_data_edit_object(C); if (obedit && obedit->type == OB_SURF) @@ -517,7 +517,7 @@ int ED_operator_editsurf(bContext *C) return 0; } -int ED_operator_editfont(bContext *C) +bool ED_operator_editfont(bContext *C) { Object *obedit = CTX_data_edit_object(C); if (obedit && obedit->type == OB_FONT) @@ -525,7 +525,7 @@ int ED_operator_editfont(bContext *C) return 0; } -int ED_operator_editlattice(bContext *C) +bool ED_operator_editlattice(bContext *C) { Object *obedit = CTX_data_edit_object(C); if (obedit && obedit->type == OB_LATTICE) @@ -533,7 +533,7 @@ int ED_operator_editlattice(bContext *C) return 0; } -int ED_operator_editmball(bContext *C) +bool ED_operator_editmball(bContext *C) { Object *obedit = CTX_data_edit_object(C); if (obedit && obedit->type == OB_MBALL) @@ -541,7 +541,7 @@ int ED_operator_editmball(bContext *C) return 0; } -int ED_operator_mask(bContext *C) +bool ED_operator_mask(bContext *C) { ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacedata.first) { @@ -569,7 +569,7 @@ int ED_operator_mask(bContext *C) return false; } -int ED_operator_camera(bContext *C) +bool ED_operator_camera(bContext *C) { struct Camera *cam = CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data; return (cam != NULL); @@ -581,7 +581,7 @@ int ED_operator_camera(bContext *C) /** \name Internal Screen Utilities * \{ */ -static int screen_active_editable(bContext *C) +static bool screen_active_editable(bContext *C) { if (ED_operator_screenactive(C)) { /* no full window splitting allowed */ @@ -645,7 +645,7 @@ typedef struct sActionzoneData { } sActionzoneData; /* quick poll to save operators to be created and handled */ -static int actionzone_area_poll(bContext *C) +static bool actionzone_area_poll(bContext *C) { wmWindow *win = CTX_wm_window(C); ScrArea *sa = CTX_wm_area(C); @@ -854,8 +854,8 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event) AZone *az = ED_area_actionzone_find_xy(sa, &event->x); sActionzoneData *sad; - /* quick escape */ - if (az == NULL) + /* quick escape - Scroll azones only hide/unhide the scroll-bars, they have their own handling. */ + if (az == NULL || ELEM(az->type, AZONE_REGION_SCROLL)) return OPERATOR_PASS_THROUGH; /* ok we do the actionzone */ @@ -870,9 +870,6 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event) actionzone_exit(op); return OPERATOR_FINISHED; } - else if (ELEM(sad->az->type, AZONE_REGION_SCROLL)) { - return OPERATOR_PASS_THROUGH; - } else { /* add modal handler */ WM_event_add_modal_handler(C, op); @@ -913,7 +910,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event) /* once we drag outside the actionzone, register a gesture * check we're not on an edge so join finds the other area */ is_gesture = ((ED_area_actionzone_find_xy(sad->sa1, &event->x) != sad->az) && - (screen_area_map_find_active_scredge( + (screen_geom_area_map_find_active_scredge( AREAMAP_FROM_SCREEN(sc), &screen_rect, event->x, event->y) == NULL)); } else { @@ -1235,10 +1232,10 @@ typedef struct sAreaMoveData { * need window bounds in order to get correct limits */ static void area_move_set_limits( wmWindow *win, bScreen *sc, int dir, - const rcti *screen_rect, int *bigger, int *smaller, bool *use_bigger_smaller_snap) { + rcti window_rect; int areaminy = ED_area_headersize(); int areamin; @@ -1248,8 +1245,11 @@ static void area_move_set_limits( if (use_bigger_smaller_snap != NULL) { *use_bigger_smaller_snap = false; for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) { - const int size_min = round_fl_to_int(area->global->size_min * UI_DPI_FAC); - const int size_max = round_fl_to_int(area->global->size_max * UI_DPI_FAC); + int size_min = ED_area_global_min_size_y(area) - 1; + int size_max = ED_area_global_max_size_y(area) - 1; + + size_min = MAX2(size_min, 0); + BLI_assert(size_min < size_max); /* logic here is only tested for lower edge :) */ /* left edge */ @@ -1283,17 +1283,19 @@ static void area_move_set_limits( } } + WM_window_rect_calc(win, &window_rect); + for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { if (dir == 'h') { int y1; areamin = areaminy; - if (sa->v1->vec.y > screen_rect->ymin) + if (sa->v1->vec.y > window_rect.ymin) areamin += U.pixelsize; - if (sa->v2->vec.y < (screen_rect->ymax - 1)) + if (sa->v2->vec.y < (window_rect.ymax - 1)) areamin += U.pixelsize; - y1 = sa->v2->vec.y - sa->v1->vec.y + 1 - areamin; + y1 = screen_geom_area_height(sa) - areamin; /* if top or down edge selected, test height */ if (sa->v1->editflag && sa->v4->editflag) @@ -1305,12 +1307,12 @@ static void area_move_set_limits( int x1; areamin = AREAMINX; - if (sa->v1->vec.x > screen_rect->xmin) + if (sa->v1->vec.x > window_rect.xmin) areamin += U.pixelsize; - if (sa->v4->vec.x < (screen_rect->xmax - 1)) + if (sa->v4->vec.x < (window_rect.xmax - 1)) areamin += U.pixelsize; - x1 = sa->v4->vec.x - sa->v1->vec.x + 1 - areamin; + x1 = screen_geom_area_width(sa) - areamin; /* if left or right edge selected, test width */ if (sa->v1->editflag && sa->v2->editflag) @@ -1329,7 +1331,6 @@ static int area_move_init(bContext *C, wmOperator *op) wmWindow *win = CTX_wm_window(C); ScrEdge *actedge; sAreaMoveData *md; - rcti screen_rect; int x, y; /* required properties */ @@ -1337,28 +1338,24 @@ static int area_move_init(bContext *C, wmOperator *op) y = RNA_int_get(op->ptr, "y"); /* setup */ - actedge = screen_find_active_scredge(win, sc, x, y); + actedge = screen_geom_find_active_scredge(win, sc, x, y); if (actedge == NULL) return 0; md = MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData"); op->customdata = md; - md->dir = scredge_is_horizontal(actedge) ? 'h' : 'v'; + md->dir = screen_geom_edge_is_horizontal(actedge) ? 'h' : 'v'; if (md->dir == 'h') md->origval = actedge->v1->vec.y; else md->origval = actedge->v1->vec.x; - select_connected_scredge(win, actedge); + screen_geom_select_connected_edge(win, actedge); /* now all vertices with 'flag == 1' are the ones that can be moved. Move this to editflag */ ED_screen_verts_iter(win, sc, v1) { v1->editflag = v1->flag; } - WM_window_screen_rect_calc(win, &screen_rect); - bool use_bigger_smaller_snap = false; - area_move_set_limits(win, sc, md->dir, &screen_rect, - &md->bigger, &md->smaller, - &use_bigger_smaller_snap); + area_move_set_limits(win, sc, md->dir, &md->bigger, &md->smaller, &use_bigger_smaller_snap); md->snap_type = use_bigger_smaller_snap ? SNAP_BIGGER_SMALLER_ONLY : SNAP_AREAGRID; @@ -1379,6 +1376,7 @@ static int area_snap_calc_location( final_loc = m_loc; if (delta != bigger && delta != -smaller) { final_loc -= (m_loc % AREAGRID); + CLAMP(final_loc, origval - smaller, origval + bigger); } break; @@ -1427,6 +1425,9 @@ static int area_snap_calc_location( break; } + BLI_assert(ELEM(snap_type, SNAP_BIGGER_SMALLER_ONLY) || + IN_RANGE_INCL(final_loc, origval - smaller, origval + bigger)); + return final_loc; } @@ -1439,10 +1440,12 @@ static void area_move_apply_do( { wmWindow *win = CTX_wm_window(C); bScreen *sc = CTX_wm_screen(C); + short final_loc = -1; bool doredraw = false; - CLAMP(delta, -smaller, bigger); - short final_loc = -1; + if (snap_type != SNAP_BIGGER_SMALLER_ONLY) { + CLAMP(delta, -smaller, bigger); + } if (snap_type == SNAP_NONE) { final_loc = origval + delta; @@ -1473,7 +1476,7 @@ static void area_move_apply_do( ED_screen_areas_iter(win, sc, sa) { if (sa->v1->editflag || sa->v2->editflag || sa->v3->editflag || sa->v4->editflag) { if (ED_area_is_global(sa)) { - sa->global->cur_fixed_height = round_fl_to_int((sa->v2->vec.y - sa->v1->vec.y) / UI_DPI_FAC); + sa->global->cur_fixed_height = round_fl_to_int(screen_geom_area_height(sa) / UI_DPI_FAC); sc->do_refresh = true; redraw_all = true; } @@ -1766,6 +1769,7 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb) /* do the split, return success */ static int area_split_apply(bContext *C, wmOperator *op) { + const wmWindow *win = CTX_wm_window(C); bScreen *sc = CTX_wm_screen(C); sAreaSplitData *sd = (sAreaSplitData *)op->customdata; float fac; @@ -1774,16 +1778,15 @@ static int area_split_apply(bContext *C, wmOperator *op) fac = RNA_float_get(op->ptr, "factor"); dir = RNA_enum_get(op->ptr, "direction"); - sd->narea = area_split(sc, sd->sarea, dir, fac, 0); /* 0 = no merge */ + sd->narea = area_split(win, sc, sd->sarea, dir, fac, 0); /* 0 = no merge */ if (sd->narea) { - ScrVert *sv; - sd->nedge = area_findsharededge(sc, sd->sarea, sd->narea); /* select newly created edge, prepare for moving edge */ - for (sv = sc->vertbase.first; sv; sv = sv->next) + ED_screen_verts_iter(win, sc, sv) { sv->editflag = 0; + } sd->nedge->v1->editflag = 1; sd->nedge->v2->editflag = 1; @@ -1839,14 +1842,14 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) wmWindow *win = CTX_wm_window(C); bScreen *sc = CTX_wm_screen(C); sAreaSplitData *sd; - rcti screen_rect; int dir; /* no full window splitting allowed */ - if (sc->state != SCREENNORMAL) - return OPERATOR_CANCELLED; + BLI_assert(sc->state == SCREENNORMAL); - WM_window_screen_rect_calc(win, &screen_rect); + PropertyRNA *prop_dir = RNA_struct_find_property(op->ptr, "direction"); + PropertyRNA *prop_factor = RNA_struct_find_property(op->ptr, "factor"); + PropertyRNA *prop_cursor = RNA_struct_find_property(op->ptr, "cursor"); if (event->type == EVT_ACTIONZONE_AREA) { sActionzoneData *sad = event->customdata; @@ -1866,46 +1869,73 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* prepare operator state vars */ if (sad->gesture_dir == 'n' || sad->gesture_dir == 's') { dir = 'h'; - RNA_float_set(op->ptr, "factor", ((float)(event->x - sad->sa1->v1->vec.x)) / (float)sad->sa1->winx); + RNA_property_float_set( + op->ptr, prop_factor, + ((float)(event->x - sad->sa1->v1->vec.x)) / (float)sad->sa1->winx); } else { dir = 'v'; - RNA_float_set(op->ptr, "factor", ((float)(event->y - sad->sa1->v1->vec.y)) / (float)sad->sa1->winy); + RNA_property_float_set( + op->ptr, prop_factor, + ((float)(event->y - sad->sa1->v1->vec.y)) / (float)sad->sa1->winy); } - RNA_enum_set(op->ptr, "direction", dir); + RNA_property_enum_set(op->ptr, prop_dir, dir); /* general init, also non-UI case, adds customdata, sets area and defaults */ - if (!area_split_init(C, op)) + if (!area_split_init(C, op)) { return OPERATOR_PASS_THROUGH; + } + } + else if (RNA_property_is_set(op->ptr, prop_dir)) { + ScrArea *sa = CTX_wm_area(C); + if (sa == NULL) { + return OPERATOR_CANCELLED; + } + dir = RNA_property_enum_get(op->ptr, prop_dir); + if (dir == 'h') { + RNA_property_float_set( + op->ptr, prop_factor, + ((float)(event->x - sa->v1->vec.x)) / (float)sa->winx); + } + else { + RNA_property_float_set( + op->ptr, prop_factor, + ((float)(event->y - sa->v1->vec.y)) / (float)sa->winy); + } + if (!area_split_init(C, op)) { + return OPERATOR_CANCELLED; + } } else { ScrEdge *actedge; - int x, y; + rcti window_rect; + int event_co[2]; /* retrieve initial mouse coord, so we can find the active edge */ - if (RNA_struct_property_is_set(op->ptr, "mouse_x")) - x = RNA_int_get(op->ptr, "mouse_x"); - else - x = event->x; + if (RNA_property_is_set(op->ptr, prop_cursor)) { + RNA_property_int_get_array(op->ptr, prop_cursor, event_co); + } + else { + copy_v2_v2_int(event_co, &event->x); + } - if (RNA_struct_property_is_set(op->ptr, "mouse_y")) - y = RNA_int_get(op->ptr, "mouse_y"); - else - y = event->x; + WM_window_rect_calc(win, &window_rect); - actedge = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(sc), &screen_rect, x, y); - if (actedge == NULL) + actedge = screen_geom_area_map_find_active_scredge( + AREAMAP_FROM_SCREEN(sc), &window_rect, event_co[0], event_co[1]); + if (actedge == NULL) { return OPERATOR_CANCELLED; + } - dir = scredge_is_horizontal(actedge) ? 'v' : 'h'; + dir = screen_geom_edge_is_horizontal(actedge) ? 'v' : 'h'; - RNA_enum_set(op->ptr, "direction", dir); + RNA_property_enum_set(op->ptr, prop_dir, dir); /* special case, adds customdata, sets defaults */ - if (!area_split_menu_init(C, op)) + if (!area_split_menu_init(C, op)) { return OPERATOR_CANCELLED; - + } } sd = (sAreaSplitData *)op->customdata; @@ -1914,7 +1944,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* do the split */ if (area_split_apply(C, op)) { - area_move_set_limits(win, sc, dir, &screen_rect, &sd->bigger, &sd->smaller, NULL); + area_move_set_limits(win, sc, dir, &sd->bigger, &sd->smaller, NULL); /* add temp handler for edge move or cancel */ WM_event_add_modal_handler(C, op); @@ -2105,8 +2135,7 @@ static void SCREEN_OT_area_split(wmOperatorType *ot) /* rna */ RNA_def_enum(ot->srna, "direction", prop_direction_items, 'h', "Direction", ""); RNA_def_float(ot->srna, "factor", 0.5f, 0.0, 1.0, "Factor", "", 0.0, 1.0); - RNA_def_int(ot->srna, "mouse_x", -100, INT_MIN, INT_MAX, "Mouse X", "", INT_MIN, INT_MAX); - RNA_def_int(ot->srna, "mouse_y", -100, INT_MIN, INT_MAX, "Mouse Y", "", INT_MIN, INT_MAX); + RNA_def_int_vector(ot->srna, "cursor", 2, NULL, INT_MIN, INT_MAX, "Cursor", "", INT_MIN, INT_MAX); } /** \} */ @@ -2794,7 +2823,7 @@ static int screen_maximize_area_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int screen_maximize_area_poll(bContext *C) +static bool screen_maximize_area_poll(bContext *C) { const bScreen *screen = CTX_wm_screen(C); const ScrArea *area = CTX_wm_area(C); @@ -2875,6 +2904,8 @@ static void area_join_draw_cb(const struct wmWindow *UNUSED(win), void *userdata /* XXX todo: find edge based on (x,y) and set other area? */ static int area_join_init(bContext *C, wmOperator *op) { + const wmWindow *win = CTX_wm_window(C); + bScreen *screen = CTX_wm_screen(C); ScrArea *sa1, *sa2; sAreaJoinData *jd = NULL; int x1, y1; @@ -2887,10 +2918,21 @@ static int area_join_init(bContext *C, wmOperator *op) x2 = RNA_int_get(op->ptr, "max_x"); y2 = RNA_int_get(op->ptr, "max_y"); - sa1 = BKE_screen_find_area_xy(CTX_wm_screen(C), SPACE_TYPE_ANY, x1, y1); - sa2 = BKE_screen_find_area_xy(CTX_wm_screen(C), SPACE_TYPE_ANY, x2, y2); - if (sa1 == NULL || sa2 == NULL || sa1 == sa2) + sa1 = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, x1, y1); + if (sa1 == NULL) { + sa1 = BKE_screen_area_map_find_area_xy(&win->global_areas, SPACE_TYPE_ANY, x1, y1); + } + sa2 = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, x2, y2); + if (sa2 == NULL) { + sa2 = BKE_screen_area_map_find_area_xy(&win->global_areas, SPACE_TYPE_ANY, x2, y2); + } + if ((sa1 && ED_area_is_global(sa1)) || (sa2 && ED_area_is_global(sa2))) { + BKE_report(op->reports, RPT_ERROR, "Global areas (Top Bar, Status Bar) do not support joining"); return 0; + } + else if (sa1 == NULL || sa2 == NULL || sa1 == sa2) { + return 0; + } /* do areas share an edge? */ if (sa1->v1 == sa2->v1 || sa1->v1 == sa2->v2 || sa1->v1 == sa2->v3 || sa1->v1 == sa2->v4) shared++; @@ -2989,7 +3031,7 @@ static int area_join_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (!area_join_init(C, op)) - return OPERATOR_PASS_THROUGH; + return OPERATOR_CANCELLED; /* add temp handler */ WM_event_add_modal_handler(C, op); @@ -3122,10 +3164,10 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent uiLayout *layout; PointerRNA ptr; ScrEdge *actedge; - rcti screen_rect; + rcti window_rect; - WM_window_screen_rect_calc(win, &screen_rect); - actedge = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(sc), &screen_rect, event->x, event->y); + WM_window_rect_calc(win, &window_rect); + actedge = screen_geom_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(sc), &window_rect, event->x, event->y); if (actedge == NULL) return OPERATOR_CANCELLED; @@ -3134,8 +3176,7 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent uiItemFullO(layout, "SCREEN_OT_area_split", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &ptr); /* store initial mouse cursor position */ - RNA_int_set(&ptr, "mouse_x", event->x); - RNA_int_set(&ptr, "mouse_y", event->y); + RNA_int_set_array(&ptr, "cursor", &event->x); uiItemFullO(layout, "SCREEN_OT_area_join", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &ptr); /* mouse cursor on edge, '4' can fail on wide edges... */ @@ -3529,7 +3570,7 @@ static int region_flip_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static int region_flip_poll(bContext *C) +static bool region_flip_poll(bContext *C) { ScrArea *area = CTX_wm_area(C); @@ -3654,7 +3695,7 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN } } -static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) +static int header_context_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) { uiPopupMenu *pup; uiLayout *layout; @@ -3669,15 +3710,15 @@ static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv return OPERATOR_INTERFACE; } -static void SCREEN_OT_header_toolbox(wmOperatorType *ot) +static void SCREEN_OT_header_context_menu(wmOperatorType *ot) { /* identifiers */ - ot->name = "Header Toolbox"; - ot->description = "Display header region toolbox"; - ot->idname = "SCREEN_OT_header_toolbox"; + ot->name = "Header Context Menu"; + ot->description = "Display header region context menu"; + ot->idname = "SCREEN_OT_header_context_menu"; /* api callbacks */ - ot->invoke = header_toolbox_invoke; + ot->invoke = header_context_menu_invoke; } /** \} */ @@ -4552,7 +4593,7 @@ static const EnumPropertyItem space_context_cycle_direction[] = { {0, NULL, 0, NULL, NULL} }; -static int space_context_cycle_poll(bContext *C) +static bool space_context_cycle_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); /* sa might be NULL if called out of window bounds */ @@ -4692,13 +4733,12 @@ void ED_operatortypes_screen(void) WM_operatortype_append(SCREEN_OT_region_flip); WM_operatortype_append(SCREEN_OT_header); WM_operatortype_append(SCREEN_OT_header_toggle_menus); - WM_operatortype_append(SCREEN_OT_header_toolbox); + WM_operatortype_append(SCREEN_OT_header_context_menu); WM_operatortype_append(SCREEN_OT_screen_set); WM_operatortype_append(SCREEN_OT_screen_full_area); WM_operatortype_append(SCREEN_OT_back_to_previous); WM_operatortype_append(SCREEN_OT_spacedata_cleanup); WM_operatortype_append(SCREEN_OT_screenshot); - WM_operatortype_append(SCREEN_OT_screencast); WM_operatortype_append(SCREEN_OT_userpref_show); WM_operatortype_append(SCREEN_OT_drivers_editor_show); WM_operatortype_append(SCREEN_OT_region_blend); @@ -4761,7 +4801,7 @@ static void keymap_modal_set(wmKeyConfig *keyconf) } -static int open_file_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool open_file_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) { if (drag->type == WM_DRAG_PATH) { if (drag->icon == ICON_FILE_BLEND) @@ -4805,13 +4845,15 @@ void ED_keymap_screen(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "SCREEN_OT_area_options", RIGHTMOUSE, KM_PRESS, 0, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "SCREEN_OT_header", F9KEY, KM_PRESS, KM_ALT, 0); +#endif /* Header Editing ------------------------------------------------ */ /* note: this is only used when the cursor is inside the header */ keymap = WM_keymap_find(keyconf, "Header", 0, 0); - WM_keymap_add_item(keymap, "SCREEN_OT_header_toolbox", RIGHTMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_header_context_menu", RIGHTMOUSE, KM_PRESS, 0, 0); /* Screen General ------------------------------------------------ */ keymap = WM_keymap_find(keyconf, "Screen", 0, 0); @@ -4820,33 +4862,37 @@ void ED_keymap_screen(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SCREEN_OT_animation_step", TIMER0, KM_ANY, KM_ANY, 0); WM_keymap_add_item(keymap, "SCREEN_OT_region_blend", TIMERREGION, KM_ANY, KM_ANY, 0); - +#ifdef USE_WM_KEYMAP_27X RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1); +#endif WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_SHIFT, 0); kmi = WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "use_hide_panels", true); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "SCREEN_OT_screenshot", F3KEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "SCREEN_OT_screencast", F3KEY, KM_PRESS, KM_ALT, 0); +#endif kmi = WM_keymap_add_item(keymap, "SCREEN_OT_space_context_cycle", TABKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "direction", SPACE_CONTEXT_CYCLE_NEXT); kmi = WM_keymap_add_item(keymap, "SCREEN_OT_space_context_cycle", TABKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "direction", SPACE_CONTEXT_CYCLE_PREV); - kmi = WM_keymap_add_item(keymap, "SCREEN_OT_workspace_cycle", TABKEY, KM_PRESS, KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "SCREEN_OT_workspace_cycle", PAGEDOWNKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "direction", SPACE_CONTEXT_CYCLE_NEXT); - kmi = WM_keymap_add_item(keymap, "SCREEN_OT_workspace_cycle", TABKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "SCREEN_OT_workspace_cycle", PAGEUPKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "direction", SPACE_CONTEXT_CYCLE_PREV); /* tests */ WM_keymap_add_item(keymap, "SCREEN_OT_region_quadview", QKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); - WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_history", F3KEY, KM_PRESS, 0, 0); +#ifdef USE_WM_KEYMAP_27X + WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_history", RKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "SCREEN_OT_repeat_last", RKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "SCRIPT_OT_reload", F8KEY, KM_PRESS, 0, 0); +#endif /* files */ WM_keymap_add_item(keymap, "FILE_OT_execute", RETKEY, KM_PRESS, 0, 0); @@ -4857,12 +4903,15 @@ void ED_keymap_screen(wmKeyConfig *keyconf) #ifdef __APPLE__ WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT | KM_OSKEY, 0); #endif +#endif WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT | KM_CTRL, 0); - +#endif /* render */ kmi = WM_keymap_add_item(keymap, "RENDER_OT_render", F12KEY, KM_PRESS, 0, 0); @@ -4878,23 +4927,29 @@ void ED_keymap_screen(wmKeyConfig *keyconf) #ifdef __APPLE__ WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", COMMAKEY, KM_PRESS, KM_OSKEY, 0); #endif +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", UKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); +#endif /* Anim Playback ------------------------------------------------ */ keymap = WM_keymap_find(keyconf, "Frames", 0, 0); /* frame offsets */ +#ifdef USE_WM_KEYMAP_27X RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", UPARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "delta", 10); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", DOWNARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "delta", -10); +#endif RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", -1); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", RIGHTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 1); +#ifdef USE_WM_KEYMAP_27X RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", WHEELDOWNMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", WHEELUPMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "delta", -1); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", UPARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "end", true); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", DOWNARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "end", false); +#endif RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", true); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", false); diff --git a/source/blender/editors/screen/screen_user_menu.c b/source/blender/editors/screen/screen_user_menu.c new file mode 100644 index 00000000000..e945a5ae291 --- /dev/null +++ b/source/blender/editors/screen/screen_user_menu.c @@ -0,0 +1,269 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/screen/screen_user_menu.c + * \ingroup spview3d + */ + +#include <string.h> +#include <stdio.h> +#include <math.h> +#include <float.h> + +#include "DNA_scene_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" +#include "BLI_listbase.h" +#include "BLI_string.h" + +#include "BLT_translation.h" + +#include "BKE_blender_user_menu.h" +#include "BKE_context.h" +#include "BKE_screen.h" +#include "BKE_idprop.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_screen.h" + +#include "UI_interface.h" +#include "UI_resources.h" + +#include "RNA_access.h" + +/* -------------------------------------------------------------------- */ +/** \name Menu Type + * \{ */ + +bUserMenu *ED_screen_user_menu_find(bContext *C) +{ + SpaceLink *sl = CTX_wm_space_data(C); + const char *context = CTX_data_mode_string(C); + return BKE_blender_user_menu_find(&U.user_menus, sl->spacetype, context); +} + +bUserMenu *ED_screen_user_menu_ensure(bContext *C) +{ + SpaceLink *sl = CTX_wm_space_data(C); + const char *context = CTX_data_mode_string(C); + return BKE_blender_user_menu_ensure(&U.user_menus, sl->spacetype, context); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Menu Item + * \{ */ + +bUserMenuItem_Op *ED_screen_user_menu_item_find_operator( + ListBase *lb, + const wmOperatorType *ot, IDProperty *prop, short opcontext) +{ + for (bUserMenuItem *umi = lb->first; umi; umi = umi->next) { + if (umi->type == USER_MENU_TYPE_OPERATOR) { + bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; + if (STREQ(ot->idname, umi_op->op_idname) && + (opcontext == umi_op->opcontext) && + (IDP_EqualsProperties(prop, umi_op->prop))) + { + return umi_op; + } + } + } + return NULL; +} + +struct bUserMenuItem_Menu *ED_screen_user_menu_item_find_menu( + struct ListBase *lb, + const struct MenuType *mt) +{ + for (bUserMenuItem *umi = lb->first; umi; umi = umi->next) { + if (umi->type == USER_MENU_TYPE_MENU) { + bUserMenuItem_Menu *umi_mt = (bUserMenuItem_Menu *)umi; + if (STREQ(mt->idname, umi_mt->mt_idname)) { + return umi_mt; + } + } + } + return NULL; +} + +struct bUserMenuItem_Prop *ED_screen_user_menu_item_find_prop( + struct ListBase *lb, + const char *context_data_path, const char *prop_id, int prop_index) +{ + for (bUserMenuItem *umi = lb->first; umi; umi = umi->next) { + if (umi->type == USER_MENU_TYPE_PROP) { + bUserMenuItem_Prop *umi_pr = (bUserMenuItem_Prop *)umi; + if (STREQ(context_data_path, umi_pr->context_data_path) && + STREQ(prop_id, umi_pr->prop_id) && + (prop_index == umi_pr->prop_index)) + { + return umi_pr; + } + } + } + return NULL; +} + +void ED_screen_user_menu_item_add_operator( + ListBase *lb, const char *ui_name, + const wmOperatorType *ot, const IDProperty *prop, short opcontext) +{ + bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)BKE_blender_user_menu_item_add(lb, USER_MENU_TYPE_OPERATOR); + umi_op->opcontext = opcontext; + if (!STREQ(ui_name, ot->name)) { + STRNCPY(umi_op->item.ui_name, ui_name); + } + STRNCPY(umi_op->op_idname, ot->idname); + umi_op->prop = prop ? IDP_CopyProperty(prop) : NULL; +} + +void ED_screen_user_menu_item_add_menu( + ListBase *lb, const char *ui_name, + const MenuType *mt) +{ + bUserMenuItem_Menu *umi_mt = (bUserMenuItem_Menu *)BKE_blender_user_menu_item_add(lb, USER_MENU_TYPE_MENU); + if (!STREQ(ui_name, mt->label)) { + STRNCPY(umi_mt->item.ui_name, ui_name); + } + STRNCPY(umi_mt->mt_idname, mt->idname); +} + +void ED_screen_user_menu_item_add_prop( + ListBase *lb, const char *ui_name, + const char *context_data_path, const char *prop_id, int prop_index) +{ + bUserMenuItem_Prop *umi_pr = (bUserMenuItem_Prop *)BKE_blender_user_menu_item_add(lb, USER_MENU_TYPE_PROP); + STRNCPY(umi_pr->item.ui_name, ui_name); + STRNCPY(umi_pr->context_data_path, context_data_path); + STRNCPY(umi_pr->prop_id, prop_id); + umi_pr->prop_index = prop_index; +} + +void ED_screen_user_menu_item_remove(ListBase *lb, bUserMenuItem *umi) +{ + BLI_remlink(lb, umi); + BKE_blender_user_menu_item_free(umi); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Menu Definition + * \{ */ + +static void screen_user_menu_draw(const bContext *C, Menu *menu) +{ + SpaceLink *sl = CTX_wm_space_data(C); + const char *context = CTX_data_mode_string(C); + bUserMenu *um_array[] = { + BKE_blender_user_menu_find(&U.user_menus, sl->spacetype, context), + (sl->spacetype != SPACE_TOPBAR) ? BKE_blender_user_menu_find(&U.user_menus, SPACE_TOPBAR, context) : NULL, + (sl->spacetype == SPACE_VIEW3D) ? BKE_blender_user_menu_find(&U.user_menus, SPACE_BUTS, context) : NULL, + }; + for (int um_index = 0; um_index < ARRAY_SIZE(um_array); um_index++) { + bUserMenu *um = um_array[um_index]; + if (um == NULL) { + continue; + } + for (bUserMenuItem *umi = um->items.first; umi; umi = umi->next) { + const char *ui_name = umi->ui_name[0] ? umi->ui_name : NULL; + if (umi->type == USER_MENU_TYPE_OPERATOR) { + bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; + IDProperty *prop = umi_op->prop ? IDP_CopyProperty(umi_op->prop) : NULL; + uiItemFullO( + menu->layout, umi_op->op_idname, ui_name, + ICON_NONE, prop, umi_op->opcontext, 0, NULL); + } + else if (umi->type == USER_MENU_TYPE_MENU) { + bUserMenuItem_Menu *umi_mt = (bUserMenuItem_Menu *)umi; + uiItemM(menu->layout, umi_mt->mt_idname, ui_name, + ICON_NONE); + } + else if (umi->type == USER_MENU_TYPE_PROP) { + bUserMenuItem_Prop *umi_pr = (bUserMenuItem_Prop *)umi; + + char *data_path = strchr(umi_pr->context_data_path, '.'); + if (data_path) { + *data_path = '\0'; + } + PointerRNA ptr = CTX_data_pointer_get(C, umi_pr->context_data_path); + if (ptr.type == NULL) { + PointerRNA ctx_ptr; + RNA_pointer_create(NULL, &RNA_Context, (void *)C, &ctx_ptr); + if (!RNA_path_resolve_full(&ctx_ptr, umi_pr->context_data_path, &ptr, NULL, NULL)) { + ptr.type = NULL; + } + } + if (data_path) { + *data_path = '.'; + data_path += 1; + } + + bool ok = false; + if (ptr.type != NULL) { + PropertyRNA *prop = NULL; + PointerRNA prop_ptr = ptr; + if ((data_path == NULL) || RNA_path_resolve_full(&ptr, data_path, &prop_ptr, NULL, NULL)) { + prop = RNA_struct_find_property(&prop_ptr, umi_pr->prop_id); + if (prop) { + ok = true; + uiItemFullR( + menu->layout, + &prop_ptr, prop, umi_pr->prop_index, + 0, 0, ui_name, ICON_NONE); + } + } + } + if (!ok) { + char label[512]; + SNPRINTF(label, "Missing: %s.%s", umi_pr->context_data_path, umi_pr->prop_id); + uiItemL(menu->layout, label, ICON_NONE); + } + } + else if (umi->type == USER_MENU_TYPE_SEP) { + uiItemS(menu->layout); + } + } + } +} + +void ED_screen_user_menu_register(void) +{ + MenuType *mt = MEM_callocN(sizeof(MenuType), __func__); + strcpy(mt->idname, "SCREEN_MT_user_menu"); + strcpy(mt->label, "Quick Favorites"); + strcpy(mt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); + mt->draw = screen_user_menu_draw; + WM_menutype_add(mt); +} + +/** \} */ diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index e7b075dd5d0..afaad3963d5 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -36,7 +36,6 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" -#include "BLI_math.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -44,20 +43,15 @@ #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" -#include "DNA_userdef_types.h" #include "BKE_context.h" #include "BKE_global.h" #include "BKE_main.h" #include "BKE_image.h" #include "BKE_report.h" -#include "BKE_writeavi.h" #include "BIF_gl.h" -#include "GPU_immediate.h" -#include "GPU_immediate_util.h" - #include "RNA_access.h" #include "RNA_define.h" @@ -66,9 +60,6 @@ #include "WM_types.h" #include "WM_api.h" -#include "PIL_time.h" - - #include "screen_intern.h" typedef struct ScreenshotData { @@ -278,7 +269,7 @@ static void screenshot_draw(bContext *UNUSED(C), wmOperator *op) uiDefAutoButsRNA(layout, &ptr, screenshot_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false); } -static int screenshot_poll(bContext *C) +static bool screenshot_poll(bContext *C) { if (G.background) return false; @@ -307,258 +298,3 @@ void SCREEN_OT_screenshot(wmOperatorType *ot) RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "Capture the whole window (otherwise only capture the active area)"); } - -/* *************** screenshot movie job ************************* */ - -typedef struct ScreenshotJob { - Main *bmain; - Scene *scene; - wmWindowManager *wm; - unsigned int *dumprect; - int x, y, dumpsx, dumpsy; - const short *stop; - const short *do_update; - ReportList reports; - - bMovieHandle *movie_handle; - void *movie_ctx; -} ScreenshotJob; - - -static void screenshot_freejob(void *sjv) -{ - ScreenshotJob *sj = sjv; - - if (sj->dumprect) - MEM_freeN(sj->dumprect); - - if (sj->movie_handle) { - bMovieHandle *mh = sj->movie_handle; - mh->end_movie(sj->movie_ctx); - mh->context_free(sj->movie_ctx); - } - - MEM_freeN(sj); -} - - -/* called before redraw notifiers, copies a new dumprect */ -static void screenshot_updatejob(void *sjv) -{ - ScreenshotJob *sj = sjv; - unsigned int *dumprect; - - if (sj->dumprect == NULL) { - dumprect = MEM_mallocN(sizeof(int) * sj->dumpsx * sj->dumpsy, "dumprect"); - screenshot_read_pixels(sj->x, sj->y, sj->dumpsx, sj->dumpsy, (unsigned char *)dumprect); - - sj->dumprect = dumprect; - } -} - - -/* only this runs inside thread */ -static void screenshot_startjob(void *sjv, short *stop, short *do_update, float *UNUSED(progress)) -{ - ScreenshotJob *sj = sjv; - RenderData rd = sj->scene->r; - bMovieHandle *mh = NULL; - - /* we need this as local variables for renderdata */ - rd.frs_sec = U.scrcastfps; - rd.frs_sec_base = 1.0f; - - if (BKE_imtype_is_movie(rd.im_format.imtype)) { - mh = BKE_movie_handle_get(sj->scene->r.im_format.imtype); - if (mh == NULL) { - printf("Movie format unsupported\n"); - return; - } - sj->movie_ctx = mh->context_create(); - sj->movie_handle = mh; - - if (!mh->start_movie(sj->movie_ctx, sj->scene, &rd, sj->dumpsx, sj->dumpsy, &sj->reports, false, "")) { - printf("screencast job stopped\n"); - return; - } - } - - sj->stop = stop; - sj->do_update = do_update; - - *do_update = true; /* wait for opengl rect */ - - while (*stop == 0) { - - if (sj->dumprect) { - - if (mh) { - if (mh->append_movie(sj->movie_ctx, &rd, rd.sfra, rd.cfra, (int *)sj->dumprect, - sj->dumpsx, sj->dumpsy, "", &sj->reports)) - { - BKE_reportf(&sj->reports, RPT_INFO, "Appended frame: %d", rd.cfra); - printf("Appended frame %d\n", rd.cfra); - } - else { - break; - } - } - else { - ImBuf *ibuf = IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.im_format.planes, 0); - char name[FILE_MAX]; - int ok; - - BKE_image_path_from_imformat( - name, rd.pic, BKE_main_blendfile_path(sj->bmain), rd.cfra, - &rd.im_format, (rd.scemode & R_EXTENSION) != 0, true, NULL); - - ibuf->rect = sj->dumprect; - ok = BKE_imbuf_write(ibuf, name, &rd.im_format); - - if (ok == 0) { - printf("Write error: cannot save %s\n", name); - BKE_reportf(&sj->reports, RPT_INFO, "Write error: cannot save %s", name); - break; - } - else { - printf("Saved file: %s\n", name); - BKE_reportf(&sj->reports, RPT_INFO, "Saved file: %s", name); - } - - /* imbuf knows which rects are not part of ibuf */ - IMB_freeImBuf(ibuf); - } - - MEM_freeN(sj->dumprect); - sj->dumprect = NULL; - - *do_update = true; - - rd.cfra++; - - } - else - PIL_sleep_ms(U.scrcastwait); - } - - if (mh) { - mh->end_movie(sj->movie_ctx); - mh->context_free(sj->movie_ctx); - sj->movie_handle = NULL; - } - - BKE_report(&sj->reports, RPT_INFO, "Screencast job stopped"); -} - -/* Helper callback for drawing the cursor itself */ -static void screencast_draw_cursor(bContext *UNUSED(C), int x, int y, void *UNUSED(p_ptr)) -{ - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); - - Gwn_VertFormat *format = immVertexFormat(); - unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - - immUniformColor4ub(0, 0, 0, 32); - imm_draw_circle_fill_2d(pos, (float)x, (float)y, 20, 40); - - immUniformColor4ub(255, 255, 255, 128); - imm_draw_circle_wire_2d(pos, (float)x, (float)y, 20, 40); - - immUnbindProgram(); - - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); -} - -/* Turn brush cursor in 3D view on/off */ -static void screencast_cursor_toggle(wmWindowManager *wm, short enable) -{ - static void *cursor = NULL; - - if (cursor && !enable) { - /* clear cursor */ - WM_paint_cursor_end(wm, cursor); - cursor = NULL; - } - else if (enable) { - /* enable cursor */ - cursor = WM_paint_cursor_activate(wm, NULL, screencast_draw_cursor, NULL); - } -} - -static void screenshot_endjob(void *sjv) -{ - ScreenshotJob *sj = sjv; - - screencast_cursor_toggle(sj->wm, 0); -} - - -static int screencast_exec(bContext *C, wmOperator *op) -{ - wmWindowManager *wm = CTX_wm_manager(C); - wmWindow *win = CTX_wm_window(C); - bScreen *screen = CTX_wm_screen(C); - wmJob *wm_job; - ScreenshotJob *sj; - - /* if called again, stop the running job */ - if (WM_jobs_test(wm, screen, WM_JOB_TYPE_SCREENCAST)) - WM_jobs_stop(wm, screen, screenshot_startjob); - - wm_job = WM_jobs_get(wm, win, screen, "Screencast", 0, WM_JOB_TYPE_SCREENCAST); - sj = MEM_callocN(sizeof(ScreenshotJob), "screenshot job"); - - /* setup sj */ - if (RNA_boolean_get(op->ptr, "full")) { - sj->x = 0; - sj->y = 0; - sj->dumpsx = WM_window_pixels_x(win); - sj->dumpsy = WM_window_pixels_y(win); - } - else { - ScrArea *curarea = CTX_wm_area(C); - sj->x = curarea->totrct.xmin; - sj->y = curarea->totrct.ymin; - sj->dumpsx = curarea->totrct.xmax - sj->x; - sj->dumpsy = curarea->totrct.ymax - sj->y; - } - sj->bmain = CTX_data_main(C); - sj->scene = CTX_data_scene(C); - sj->wm = wm; - - BKE_reports_init(&sj->reports, RPT_PRINT); - - /* setup job */ - WM_jobs_customdata_set(wm_job, sj, screenshot_freejob); - WM_jobs_timer(wm_job, 0.1, 0, NC_SCREEN | ND_SCREENCAST); - WM_jobs_callbacks(wm_job, screenshot_startjob, NULL, screenshot_updatejob, screenshot_endjob); - - WM_jobs_start(sj->wm, wm_job); - - screencast_cursor_toggle(sj->wm, 1); - - WM_event_add_notifier(C, NC_SCREEN | ND_SCREENCAST, screen); - - return OPERATOR_FINISHED; -} - -void SCREEN_OT_screencast(wmOperatorType *ot) -{ - ot->name = "Make Screencast"; - ot->idname = "SCREEN_OT_screencast"; - ot->description = "Capture a video of the active area or whole Blender window"; - - ot->invoke = WM_operator_confirm; - ot->exec = screencast_exec; - ot->poll = screenshot_poll; /* shared poll */ - - ot->flag = 0; - - RNA_def_property(ot->srna, "filepath", PROP_STRING, PROP_FILEPATH); - RNA_def_boolean(ot->srna, "full", 1, "Full Screen", - "Capture the whole window (otherwise only capture the active area)"); -} diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index a044a7d377a..9d329355500 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -332,7 +332,7 @@ static void WORKSPACE_OT_workspace_delete(wmOperatorType *ot) ot->exec = workspace_delete_exec; } -static int workspace_append_activate_poll(bContext *C) +static bool workspace_append_activate_poll(bContext *C) { wmOperatorType *ot = WM_operatortype_find("WM_OT_append", false); return WM_operator_poll(C, ot); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 848d12bcfaa..815bcd8a050 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -62,6 +62,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "UI_resources.h" @@ -257,9 +258,10 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima int size; bool refresh; - eOverlayControlFlags invalid = (primary) ? (overlay_flags & PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY) : - (overlay_flags & PAINT_INVALID_OVERLAY_TEXTURE_SECONDARY); - + eOverlayControlFlags invalid = ( + (primary) ? + (overlay_flags & PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY) : + (overlay_flags & PAINT_INVALID_OVERLAY_TEXTURE_SECONDARY)); target = (primary) ? &primary_snap : &secondary_snap; refresh = @@ -493,9 +495,10 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) -static int project_brush_radius(ViewContext *vc, - float radius, - const float location[3]) +static int project_brush_radius( + ViewContext *vc, + float radius, + const float location[3]) { float view[3], nonortho[3], ortho[3], offset[3], p1[2], p2[2]; @@ -566,10 +569,8 @@ static bool sculpt_get_brush_geometry( if (hit) { Brush *brush = BKE_paint_brush(paint); - *pixel_radius = - project_brush_radius(vc, - BKE_brush_unprojected_radius_get(scene, brush), - location); + *pixel_radius = project_brush_radius( + vc, BKE_brush_unprojected_radius_get(scene, brush), location); if (*pixel_radius == 0) *pixel_radius = BKE_brush_size_get(scene, brush); @@ -588,15 +589,18 @@ static bool sculpt_get_brush_geometry( /* Draw an overlay that shows what effect the brush's texture will * have on brush strength */ -static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush, - ViewContext *vc, int x, int y, float zoom, bool col, bool primary) +static void paint_draw_tex_overlay( + UnifiedPaintSettings *ups, Brush *brush, + ViewContext *vc, int x, int y, float zoom, bool col, bool primary) { rctf quad; /* check for overlay mode */ MTex *mtex = (primary) ? &brush->mtex : &brush->mask_mtex; - bool valid = (primary) ? (brush->overlay_flags & BRUSH_OVERLAY_PRIMARY) != 0 : - (brush->overlay_flags & BRUSH_OVERLAY_SECONDARY) != 0; + bool valid = ( + (primary) ? + (brush->overlay_flags & BRUSH_OVERLAY_PRIMARY) != 0 : + (brush->overlay_flags & BRUSH_OVERLAY_SECONDARY) != 0); int overlay_alpha = (primary) ? brush->texture_overlay_alpha : brush->mask_overlay_alpha; if (!(mtex->tex) || !((mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) || @@ -607,7 +611,7 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush, } if (load_tex(brush, vc, zoom, col, primary)) { - glEnable(GL_BLEND); + GPU_blend(true); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDepthMask(GL_FALSE); @@ -713,8 +717,9 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush, /* Draw an overlay that shows what effect the brush's texture will * have on brush strength */ -static void paint_draw_cursor_overlay(UnifiedPaintSettings *ups, Brush *brush, - ViewContext *vc, int x, int y, float zoom) +static void paint_draw_cursor_overlay( + UnifiedPaintSettings *ups, Brush *brush, + ViewContext *vc, int x, int y, float zoom) { rctf quad; /* check for overlay mode */ @@ -726,7 +731,7 @@ static void paint_draw_cursor_overlay(UnifiedPaintSettings *ups, Brush *brush, if (load_tex_cursor(brush, vc, zoom)) { bool do_pop = false; float center[2]; - glEnable(GL_BLEND); + GPU_blend(true); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDepthMask(GL_FALSE); @@ -795,8 +800,9 @@ static void paint_draw_cursor_overlay(UnifiedPaintSettings *ups, Brush *brush, } } -static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups, Brush *brush, - ViewContext *vc, int x, int y, float zoom, ePaintMode mode) +static void paint_draw_alpha_overlay( + UnifiedPaintSettings *ups, Brush *brush, + ViewContext *vc, int x, int y, float zoom, ePaintMode mode) { /* color means that primary brush texture is colured and secondary is used for alpha/mask control */ bool col = ELEM(mode, ePaintTextureProjective, ePaintTexture2D, ePaintVertex) ? true : false; @@ -829,7 +835,7 @@ BLI_INLINE void draw_tri_point( { immUniformColor4fv(selected ? sel_col : pivot_col); - glLineWidth(3.0f); + GPU_line_width(3.0f); float w = width / 2.0f; float tri[3][2] = { @@ -845,7 +851,7 @@ BLI_INLINE void draw_tri_point( immEnd(); immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f); - glLineWidth(1.0f); + GPU_line_width(1.0f); immBegin(GWN_PRIM_LINE_LOOP, 3); immVertex2fv(pos, tri[0]); @@ -860,7 +866,7 @@ BLI_INLINE void draw_rect_point( { immUniformColor4fv(selected ? sel_col : handle_col); - glLineWidth(3.0f); + GPU_line_width(3.0f); float w = width / 2.0f; float minx = co[0] - w; @@ -871,7 +877,7 @@ BLI_INLINE void draw_rect_point( imm_draw_box_wire_2d(pos, minx, miny, maxx, maxy); immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f); - glLineWidth(1.0f); + GPU_line_width(1.0f); imm_draw_box_wire_2d(pos, minx, miny, maxx, maxy); } @@ -880,7 +886,7 @@ BLI_INLINE void draw_rect_point( BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], BezTriple *bez) { immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f); - glLineWidth(3.0f); + GPU_line_width(3.0f); immBegin(GWN_PRIM_LINE_STRIP, 3); immVertex2fv(pos, bez->vec[0]); @@ -888,7 +894,7 @@ BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], Bez immVertex2fv(pos, bez->vec[2]); immEnd(); - glLineWidth(1.0f); + GPU_line_width(1.0f); if (bez->f1 || bez->f2) { immUniformColor4fv(sel_col); @@ -920,8 +926,8 @@ static void paint_draw_curve_cursor(Brush *brush) PaintCurve *pc = brush->paint_curve; PaintCurvePoint *cp = pc->points; - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); + GPU_line_smooth(true); + GPU_blend(true); /* draw the bezier handles and the curve segment between the current and next point */ unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -954,7 +960,7 @@ static void paint_draw_curve_cursor(Brush *brush) float (*v)[2] = (float(*)[2])data; immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f); - glLineWidth(3.0f); + GPU_line_width(3.0f); immBegin(GWN_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1); for (j = 0; j <= PAINT_CURVE_NUM_SEGMENTS; j++) { immVertex2fv(pos, v[j]); @@ -962,7 +968,7 @@ static void paint_draw_curve_cursor(Brush *brush) immEnd(); immUniformColor4f(0.9f, 0.9f, 1.0f, 0.5f); - glLineWidth(1.0f); + GPU_line_width(1.0f); immBegin(GWN_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1); for (j = 0; j <= PAINT_CURVE_NUM_SEGMENTS; j++) { immVertex2fv(pos, v[j]); @@ -976,8 +982,8 @@ static void paint_draw_curve_cursor(Brush *brush) draw_rect_point(pos, selec_col, handle_col, &cp->bez.vec[0][0], 8.0f, cp->bez.f1 || cp->bez.f2); draw_rect_point(pos, selec_col, handle_col, &cp->bez.vec[2][0], 8.0f, cp->bez.f3 || cp->bez.f2); - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); + GPU_blend(false); + GPU_line_smooth(false); immUnbindProgram(); } @@ -985,8 +991,9 @@ static void paint_draw_curve_cursor(Brush *brush) /* Special actions taken when paint cursor goes over mesh */ /* TODO: sculpt only for now */ -static void paint_cursor_on_hit(UnifiedPaintSettings *ups, Brush *brush, ViewContext *vc, - const float location[3]) +static void paint_cursor_on_hit( + UnifiedPaintSettings *ups, Brush *brush, ViewContext *vc, + const float location[3]) { float unprojected_radius, projected_radius; @@ -1003,8 +1010,8 @@ static void paint_cursor_on_hit(UnifiedPaintSettings *ups, Brush *brush, ViewCon } /* convert brush radius from 2D to 3D */ - unprojected_radius = paint_calc_object_space_radius(vc, location, - projected_radius); + unprojected_radius = paint_calc_object_space_radius( + vc, location, projected_radius); /* scale 3D brush radius by pressure */ if (ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) @@ -1107,9 +1114,9 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) } /* make lines pretty */ - glLineWidth(1.0f); - glEnable(GL_BLEND); /* TODO: also set blend mode? */ - glEnable(GL_LINE_SMOOTH); + GPU_line_width(1.0f); + GPU_blend(true); /* TODO: also set blend mode? */ + GPU_line_smooth(true); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1129,13 +1136,13 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) immUnbindProgram(); /* restore GL state */ - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); + GPU_blend(false); + GPU_line_smooth(false); } /* Public API */ -void paint_cursor_start(bContext *C, int (*poll)(bContext *C)) +void paint_cursor_start(bContext *C, bool (*poll)(bContext *C)) { Paint *p = BKE_paint_get_active_from_context(C); @@ -1146,7 +1153,7 @@ void paint_cursor_start(bContext *C, int (*poll)(bContext *C)) BKE_paint_invalidate_overlay_all(); } -void paint_cursor_start_explicit(Paint *p, wmWindowManager *wm, int (*poll)(bContext *C)) +void paint_cursor_start_explicit(Paint *p, wmWindowManager *wm, bool (*poll)(bContext *C)) { if (p && !p->paint_cursor) p->paint_cursor = WM_paint_cursor_activate(wm, poll, paint_draw_cursor, NULL); diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c index af0b828ae39..3213ee005cf 100644 --- a/source/blender/editors/sculpt_paint/paint_curve.c +++ b/source/blender/editors/sculpt_paint/paint_curve.c @@ -57,7 +57,7 @@ #define PAINT_CURVE_SELECT_THRESHOLD 40.0f #define PAINT_CURVE_POINT_SELECT(pcp, i) (*(&pcp->bez.f1 + i) = SELECT) -int paint_curve_poll(bContext *C) +bool paint_curve_poll(bContext *C) { Object *ob = CTX_data_active_object(C); Paint *p; @@ -605,8 +605,9 @@ static int paintcurve_slide_modal(bContext *C, wmOperator *op, const wmEvent *ev { ARegion *ar = CTX_wm_region(C); wmWindow *window = CTX_wm_window(C); - float diff[2] = {event->mval[0] - psd->initial_loc[0], - event->mval[1] - psd->initial_loc[1]}; + float diff[2] = { + event->mval[0] - psd->initial_loc[0], + event->mval[1] - psd->initial_loc[1]}; if (psd->select == 1) { int i; for (i = 0; i < 3; i++) @@ -714,7 +715,7 @@ static int paintcurve_cursor_invoke(bContext *C, wmOperator *UNUSED(op), const w break; } default: - ED_view3d_cursor3d_update(C, event->mval); + ED_view3d_cursor3d_update(C, event->mval, true, V3D_CURSOR_ORIENT_VIEW); break; } diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index ac5b0624d56..a0589623f92 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -46,7 +46,6 @@ #include "BKE_pbvh.h" #include "BKE_ccg.h" #include "BKE_context.h" -#include "BKE_DerivedMesh.h" #include "BKE_mesh.h" #include "BKE_mesh_runtime.h" #include "BKE_multires.h" @@ -72,10 +71,11 @@ #include <assert.h> /* return true if the element should be hidden/shown */ -static bool is_effected(PartialVisArea area, - float planes[4][4], - const float co[3], - const float mask) +static bool is_effected( + PartialVisArea area, + float planes[4][4], + const float co[3], + const float mask) { if (area == PARTIALVIS_ALL) return 1; @@ -89,12 +89,13 @@ static bool is_effected(PartialVisArea area, } } -static void partialvis_update_mesh(Object *ob, - PBVH *pbvh, - PBVHNode *node, - PartialVisAction action, - PartialVisArea area, - float planes[4][4]) +static void partialvis_update_mesh( + Object *ob, + PBVH *pbvh, + PBVHNode *node, + PartialVisAction action, + PartialVisArea area, + float planes[4][4]) { Mesh *me = ob->data; MVert *mvert; @@ -134,12 +135,13 @@ static void partialvis_update_mesh(Object *ob, /* Hide or show elements in multires grids with a special GridFlags * customdata layer. */ -static void partialvis_update_grids(Object *ob, - PBVH *pbvh, - PBVHNode *node, - PartialVisAction action, - PartialVisArea area, - float planes[4][4]) +static void partialvis_update_grids( + Object *ob, + PBVH *pbvh, + PBVHNode *node, + PartialVisAction action, + PartialVisArea area, + float planes[4][4]) { CCGElem **grids; CCGKey key; @@ -149,9 +151,10 @@ static void partialvis_update_grids(Object *ob, /* get PBVH data */ - BKE_pbvh_node_get_grids(pbvh, node, - &grid_indices, &totgrid, NULL, NULL, - &grids); + BKE_pbvh_node_get_grids( + pbvh, node, + &grid_indices, &totgrid, NULL, NULL, + &grids); grid_hidden = BKE_pbvh_grid_hidden(pbvh); BKE_pbvh_get_grid_key(pbvh, &key); @@ -166,8 +169,9 @@ static void partialvis_update_grids(Object *ob, switch (action) { case PARTIALVIS_HIDE: /* create grid flags data */ - gh = grid_hidden[g] = BLI_BITMAP_NEW(key.grid_area, - "partialvis_update_grids"); + gh = grid_hidden[g] = BLI_BITMAP_NEW( + key.grid_area, + "partialvis_update_grids"); break; case PARTIALVIS_SHOW: /* entire grid is visible, nothing to show */ @@ -193,8 +197,9 @@ static void partialvis_update_grids(Object *ob, /* skip grid element if not in the effected area */ if (is_effected(area, planes, co, mask)) { /* set or clear the hide flag */ - BLI_BITMAP_SET(gh, y * key.grid_size + x, - action == PARTIALVIS_HIDE); + BLI_BITMAP_SET( + gh, y * key.grid_size + x, + action == PARTIALVIS_HIDE); any_changed = true; } @@ -223,21 +228,21 @@ static void partialvis_update_grids(Object *ob, } } -static void partialvis_update_bmesh_verts(BMesh *bm, - GSet *verts, - PartialVisAction action, - PartialVisArea area, - float planes[4][4], - bool *any_changed, - bool *any_visible) +static void partialvis_update_bmesh_verts( + BMesh *bm, + GSet *verts, + PartialVisAction action, + PartialVisArea area, + float planes[4][4], + bool *any_changed, + bool *any_visible) { GSetIterator gs_iter; GSET_ITER (gs_iter, verts) { BMVert *v = BLI_gsetIterator_getKey(&gs_iter); - float *vmask = CustomData_bmesh_get(&bm->vdata, - v->head.data, - CD_PAINT_MASK); + float *vmask = CustomData_bmesh_get( + &bm->vdata, v->head.data, CD_PAINT_MASK); /* hide vertex if in the hide volume */ if (is_effected(area, planes, v->co, *vmask)) { @@ -267,12 +272,13 @@ static void partialvis_update_bmesh_faces(GSet *faces) } } -static void partialvis_update_bmesh(Object *ob, - PBVH *pbvh, - PBVHNode *node, - PartialVisAction action, - PartialVisArea area, - float planes[4][4]) +static void partialvis_update_bmesh( + Object *ob, + PBVH *pbvh, + PBVHNode *node, + PartialVisAction action, + PartialVisArea area, + float planes[4][4]) { BMesh *bm; GSet *unique, *other, *faces; @@ -285,21 +291,23 @@ static void partialvis_update_bmesh(Object *ob, sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN); - partialvis_update_bmesh_verts(bm, - unique, - action, - area, - planes, - &any_changed, - &any_visible); - - partialvis_update_bmesh_verts(bm, - other, - action, - area, - planes, - &any_changed, - &any_visible); + partialvis_update_bmesh_verts( + bm, + unique, + action, + area, + planes, + &any_changed, + &any_visible); + + partialvis_update_bmesh_verts( + bm, + other, + action, + area, + planes, + &any_changed, + &any_visible); /* finally loop over node faces and tag the ones that are fully hidden */ partialvis_update_bmesh_faces(faces); @@ -318,9 +326,10 @@ static void rect_from_props(rcti *rect, PointerRNA *ptr) rect->ymax = RNA_int_get(ptr, "ymax"); } -static void clip_planes_from_rect(bContext *C, - float clip_planes[4][4], - const rcti *rect) +static void clip_planes_from_rect( + bContext *C, + float clip_planes[4][4], + const rcti *rect) { ViewContext vc; BoundBox bb; @@ -335,11 +344,12 @@ static void clip_planes_from_rect(bContext *C, * inside the clip_planes volume. If mode is outside, get all nodes * that lie at least partially outside the volume. If showing all, get * all nodes. */ -static void get_pbvh_nodes(PBVH *pbvh, - PBVHNode ***nodes, - int *totnode, - float clip_planes[4][4], - PartialVisArea mode) +static void get_pbvh_nodes( + PBVH *pbvh, + PBVHNode ***nodes, + int *totnode, + float clip_planes[4][4], + PartialVisArea mode) { BKE_pbvh_SearchCallback cb = NULL; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 93fa3aac0d7..7f71270c52d 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -46,15 +46,16 @@ #include "IMB_imbuf_types.h" #include "DNA_brush_types.h" +#include "DNA_mesh_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" #include "BKE_colorband.h" #include "BKE_context.h" -#include "BKE_DerivedMesh.h" #include "BKE_brush.h" #include "BKE_main.h" #include "BKE_material.h" +#include "BKE_mesh.h" #include "BKE_node.h" #include "BKE_paint.h" #include "BKE_undo_system.h" @@ -81,6 +82,7 @@ #include "GPU_draw.h" #include "GPU_immediate.h" +#include "GPU_state.h" #include "BIF_gl.h" @@ -166,8 +168,9 @@ void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short te if (imapaintpartial.x1 != imapaintpartial.x2 && imapaintpartial.y1 != imapaintpartial.y2) { - IMB_partial_display_buffer_update_delayed(ibuf, imapaintpartial.x1, imapaintpartial.y1, - imapaintpartial.x2, imapaintpartial.y2); + IMB_partial_display_buffer_update_delayed( + ibuf, imapaintpartial.x1, imapaintpartial.y1, + imapaintpartial.x2, imapaintpartial.y2); } if (ibuf->mipmap[0]) @@ -266,7 +269,7 @@ static Brush *image_paint_brush(bContext *C) return BKE_paint_brush(&settings->imapaint.paint); } -static int image_paint_poll_ex(bContext *C, bool check_tool) +static bool image_paint_poll_ex(bContext *C, bool check_tool) { Object *obact; @@ -294,17 +297,17 @@ static int image_paint_poll_ex(bContext *C, bool check_tool) return 0; } -static int image_paint_poll(bContext *C) +static bool image_paint_poll(bContext *C) { return image_paint_poll_ex(C, true); } -static int image_paint_ignore_tool_poll(bContext *C) +static bool image_paint_ignore_tool_poll(bContext *C) { return image_paint_poll_ex(C, false); } -static int image_paint_2d_clone_poll(bContext *C) +static bool image_paint_2d_clone_poll(bContext *C) { Brush *brush = image_paint_brush(C); @@ -337,15 +340,16 @@ typedef struct PaintOperation { bool paint_use_opacity_masking(Brush *brush) { - return (brush->flag & BRUSH_AIRBRUSH) || - (brush->flag & BRUSH_DRAG_DOT) || - (brush->flag & BRUSH_ANCHORED) || - (brush->imagepaint_tool == PAINT_TOOL_SMEAR) || - (brush->imagepaint_tool == PAINT_TOOL_SOFTEN) || - (brush->imagepaint_tool == PAINT_TOOL_FILL) || - (brush->flag & BRUSH_USE_GRADIENT) || - (brush->mtex.tex && !ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_TILED, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_3D)) ? - false : true; + return ((brush->flag & BRUSH_AIRBRUSH) || + (brush->flag & BRUSH_DRAG_DOT) || + (brush->flag & BRUSH_ANCHORED) || + (brush->imagepaint_tool == PAINT_TOOL_SMEAR) || + (brush->imagepaint_tool == PAINT_TOOL_SOFTEN) || + (brush->imagepaint_tool == PAINT_TOOL_FILL) || + (brush->flag & BRUSH_USE_GRADIENT) || + (brush->mtex.tex && + !ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_TILED, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_3D)) ? + false : true); } void paint_brush_color_get( @@ -412,15 +416,15 @@ static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customda PaintOperation *pop = (PaintOperation *)customdata; if (pop) { - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); + GPU_line_smooth(true); + GPU_blend(true); Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - glLineWidth(4.0); + GPU_line_width(4.0); immUniformColor4ub(0, 0, 0, 255); immBegin(GWN_PRIM_LINES, 2); @@ -428,7 +432,7 @@ static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customda immVertex2i(pos, pop->startmouse[0], pop->startmouse[1]); immEnd(); - glLineWidth(2.0); + GPU_line_width(2.0); immUniformColor4ub(255, 255, 255, 255); immBegin(GWN_PRIM_LINES, 2); @@ -438,8 +442,8 @@ static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customda immUnbindProgram(); - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); + GPU_blend(false); + GPU_line_smooth(false); } } @@ -570,8 +574,9 @@ static void paint_stroke_done(const bContext *C, struct PaintStroke *stroke) paint_2d_gradient_fill(C, brush, pop->startmouse, pop->prevmouse, pop->custom_paint); } else { - paint_proj_stroke(C, pop->custom_paint, pop->startmouse, pop->prevmouse, paint_stroke_flipped(stroke), - 1.0, 0.0, BKE_brush_size_get(scene, brush)); + paint_proj_stroke( + C, pop->custom_paint, pop->startmouse, pop->prevmouse, paint_stroke_flipped(stroke), + 1.0, 0.0, BKE_brush_size_get(scene, brush)); /* two redraws, one for GPU update, one for notification */ paint_proj_redraw(C, pop->custom_paint, false); paint_proj_redraw(C, pop->custom_paint, true); @@ -585,8 +590,9 @@ static void paint_stroke_done(const bContext *C, struct PaintStroke *stroke) paint_2d_bucket_fill(C, color, brush, pop->prevmouse, pop->custom_paint); } else { - paint_proj_stroke(C, pop->custom_paint, pop->startmouse, pop->prevmouse, paint_stroke_flipped(stroke), - 1.0, 0.0, BKE_brush_size_get(scene, brush)); + paint_proj_stroke( + C, pop->custom_paint, pop->startmouse, pop->prevmouse, paint_stroke_flipped(stroke), + 1.0, 0.0, BKE_brush_size_get(scene, brush)); /* two redraws, one for GPU update, one for notification */ paint_proj_redraw(C, pop->custom_paint, false); paint_proj_redraw(C, pop->custom_paint, true); @@ -637,10 +643,11 @@ static int paint_invoke(bContext *C, wmOperator *op, const wmEvent *event) { int retval; - op->customdata = paint_stroke_new(C, op, NULL, paint_stroke_test_start, - paint_stroke_update_step, - paint_stroke_redraw, - paint_stroke_done, event->type); + op->customdata = paint_stroke_new( + C, op, NULL, paint_stroke_test_start, + paint_stroke_update_step, + paint_stroke_redraw, + paint_stroke_done, event->type); if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) { paint_stroke_data_free(op); @@ -668,10 +675,11 @@ static int paint_exec(bContext *C, wmOperator *op) RNA_float_get_array(&firstpoint, "mouse", mouse); - op->customdata = paint_stroke_new(C, op, NULL, paint_stroke_test_start, - paint_stroke_update_step, - paint_stroke_redraw, - paint_stroke_done, 0); + op->customdata = paint_stroke_new( + C, op, NULL, paint_stroke_test_start, + paint_stroke_update_step, + paint_stroke_redraw, + paint_stroke_done, 0); /* frees op->customdata */ return paint_stroke_exec(C, op); } @@ -880,12 +888,13 @@ static void sample_color_update_header(SampleColorData *data, bContext *C) ScrArea *sa = CTX_wm_area(C); if (sa) { - BLI_snprintf(msg, sizeof(msg), - IFACE_("Sample color for %s"), - !data->sample_palette ? - IFACE_("Brush. Use Left Click to sample for palette instead") : - IFACE_("Palette. Use Left Click to sample more colors")); - ED_area_headerprint(sa, msg); + BLI_snprintf( + msg, sizeof(msg), + IFACE_("Sample color for %s"), + !data->sample_palette ? + IFACE_("Brush. Use Left Click to sample for palette instead") : + IFACE_("Palette. Use Left Click to sample more colors")); + ED_workspace_status_text(C, msg); } } @@ -964,8 +973,6 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event) Brush *brush = BKE_paint_brush(paint); if ((event->type == data->event_type) && (event->val == KM_RELEASE)) { - ScrArea *sa = CTX_wm_area(C); - if (data->show_cursor) { paint->flags |= PAINT_SHOW_BRUSH; } @@ -976,7 +983,7 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event) } WM_cursor_modal_restore(CTX_wm_window(C)); MEM_freeN(data); - ED_area_headerprint(sa, NULL); + ED_workspace_status_text(C, NULL); return OPERATOR_FINISHED; } @@ -1039,7 +1046,7 @@ void PAINT_OT_sample_color(wmOperatorType *ot) /******************** texture paint toggle operator ********************/ -static int texture_paint_toggle_poll(bContext *C) +static bool texture_paint_toggle_poll(bContext *C) { Object *ob = CTX_data_active_object(C); if (ob == NULL || ob->type != OB_MESH) @@ -1055,6 +1062,7 @@ static int texture_paint_toggle_poll(bContext *C) static int texture_paint_toggle_exec(bContext *C, wmOperator *op) { struct wmMsgBus *mbus = CTX_wm_message_bus(C); + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); const int mode_flag = OB_MODE_TEXTURE_PAINT; @@ -1070,14 +1078,13 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) ob->mode &= ~mode_flag; if (U.glreslimit != 0) - GPU_free_images(); - GPU_paint_set_mipmap(1); + GPU_free_images(bmain); + GPU_paint_set_mipmap(bmain, 1); toggle_paint_cursor(C, 0); } else { bScreen *sc; - Main *bmain = CTX_data_main(C); Image *ima = NULL; ImagePaintSettings *imapaint = &scene->toolsettings->imapaint; @@ -1122,12 +1129,16 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) BKE_paint_init(bmain, scene, ePaintTextureProjective, PAINT_CURSOR_TEXTURE_PAINT); if (U.glreslimit != 0) - GPU_free_images(); - GPU_paint_set_mipmap(0); + GPU_free_images(bmain); + GPU_paint_set_mipmap(bmain, 0); toggle_paint_cursor(C, 1); } + Mesh *me = BKE_mesh_from_object(ob); + BLI_assert(me != NULL); + DEG_id_tag_update(&me->id, DEG_TAG_COPY_ON_WRITE); + WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene); WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); @@ -1181,7 +1192,7 @@ static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static int brush_colors_flip_poll(bContext *C) +static bool brush_colors_flip_poll(bContext *C) { if (image_paint_poll(C)) { Brush *br = image_paint_brush(C); @@ -1231,7 +1242,7 @@ void ED_imapaint_bucket_fill(struct bContext *C, float color[3], wmOperator *op) } -static int texture_paint_poll(bContext *C) +static bool texture_paint_poll(bContext *C) { if (texture_paint_toggle_poll(C)) if (CTX_data_active_object(C)->mode & OB_MODE_TEXTURE_PAINT) @@ -1240,23 +1251,22 @@ static int texture_paint_poll(bContext *C) return 0; } -int image_texture_paint_poll(bContext *C) +bool image_texture_paint_poll(bContext *C) { return (texture_paint_poll(C) || image_paint_poll(C)); } -int facemask_paint_poll(bContext *C) +bool facemask_paint_poll(bContext *C) { return BKE_paint_select_face_test(CTX_data_active_object(C)); } -int vert_paint_poll(bContext *C) +bool vert_paint_poll(bContext *C) { return BKE_paint_select_vert_test(CTX_data_active_object(C)); } -int mask_paint_poll(bContext *C) +bool mask_paint_poll(bContext *C) { return BKE_paint_select_elem_test(CTX_data_active_object(C)); } - diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index a75d6344849..da08766b322 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -442,8 +442,9 @@ static ImBuf *brush_painter_imbuf_new(BrushPainter *painter, int size, float pre } /* update rectangular section of the brush image */ -static void brush_painter_imbuf_update(BrushPainter *painter, ImBuf *oldtexibuf, - int origx, int origy, int w, int h, int xt, int yt) +static void brush_painter_imbuf_update( + BrushPainter *painter, ImBuf *oldtexibuf, + int origx, int origy, int w, int h, int xt, int yt) { Scene *scene = painter->scene; Brush *brush = painter->brush; @@ -660,11 +661,12 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s, BrushPainter *pai bool do_random = false; bool do_partial_update = false; - bool update_color = (brush->flag & BRUSH_USE_GRADIENT) && - ((ELEM(brush->gradient_stroke_mode, - BRUSH_GRADIENT_SPACING_REPEAT, - BRUSH_GRADIENT_SPACING_CLAMP)) || - (cache->last_pressure != pressure)); + bool update_color = ( + (brush->flag & BRUSH_USE_GRADIENT) && + ((ELEM(brush->gradient_stroke_mode, + BRUSH_GRADIENT_SPACING_REPEAT, + BRUSH_GRADIENT_SPACING_CLAMP)) || + (cache->last_pressure != pressure))); float tex_rotation = -brush->mtex.rot; float mask_rotation = -brush->mask_mtex.rot; @@ -680,8 +682,9 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s, BrushPainter *pai else if (!((brush->flag & BRUSH_ANCHORED) || update_color)) do_partial_update = true; - brush_painter_2d_tex_mapping(s, diameter, painter->startpaintpos, pos, mouse, - brush->mtex.brush_map_mode, &painter->tex_mapping); + brush_painter_2d_tex_mapping( + s, diameter, painter->startpaintpos, pos, mouse, + brush->mtex.brush_map_mode, &painter->tex_mapping); } if (painter->cache.is_maskbrush) { @@ -713,8 +716,9 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s, BrushPainter *pai cache->tex_mask = NULL; } - brush_painter_2d_tex_mapping(s, diameter, painter->startpaintpos, pos, mouse, - brush->mask_mtex.brush_map_mode, &painter->mask_mapping); + brush_painter_2d_tex_mapping( + s, diameter, painter->startpaintpos, pos, mouse, + brush->mask_mtex.brush_map_mode, &painter->mask_mapping); if (do_partial_update_mask) brush_painter_mask_imbuf_partial_update(painter, pos, diameter); @@ -862,8 +866,9 @@ static void paint_2d_lift_soften(ImagePaintState *s, ImBuf *ibuf, ImBuf *ibufb, out_off[0] = out_off[1] = 0; if (!tile) { - IMB_rectclip(ibuf, ibufb, &in_off[0], &in_off[1], &out_off[0], - &out_off[1], &dim[0], &dim[1]); + IMB_rectclip( + ibuf, ibufb, &in_off[0], &in_off[1], &out_off[0], + &out_off[1], &dim[0], &dim[1]); if ((dim[0] == 0) || (dim[1] == 0)) return; @@ -894,9 +899,10 @@ static void paint_2d_lift_soften(ImagePaintState *s, ImBuf *ibuf, ImBuf *ibufb, for (yk = 0; yk < kernel->side; yk++) { for (xk = 0; xk < kernel->side; xk++) { - count += paint_2d_ibuf_add_if(ibuf, xi + xk - kernel->pixel_len, - yi + yk - kernel->pixel_len, outrgb, tile, - kernel->wdata[xk + yk * kernel->side]); + count += paint_2d_ibuf_add_if( + ibuf, xi + xk - kernel->pixel_len, + yi + yk - kernel->pixel_len, outrgb, tile, + kernel->wdata[xk + yk * kernel->side]); } } @@ -995,10 +1001,11 @@ static void paint_2d_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos, short tile) tot = paint_2d_torus_split_region(region, ibufb, ibuf, tile); for (a = 0; a < tot; a++) - IMB_rectblend(ibufb, ibufb, ibuf, NULL, NULL, NULL, 0, region[a].destx, region[a].desty, - region[a].destx, region[a].desty, - region[a].srcx, region[a].srcy, - region[a].width, region[a].height, IMB_BLEND_COPY, false); + IMB_rectblend( + ibufb, ibufb, ibuf, NULL, NULL, NULL, 0, region[a].destx, region[a].desty, + region[a].destx, region[a].desty, + region[a].srcx, region[a].srcy, + region[a].width, region[a].height, IMB_BLEND_COPY, false); } static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, int *pos) @@ -1009,10 +1016,12 @@ static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, int *pos) ImBuf *clonebuf = IMB_allocImBuf(w, h, ibufb->planes, ibufb->flags); IMB_rectclip(clonebuf, ibuf, &destx, &desty, &srcx, &srcy, &w, &h); - IMB_rectblend(clonebuf, clonebuf, ibufb, NULL, NULL, NULL, 0, destx, desty, destx, desty, destx, desty, w, h, - IMB_BLEND_COPY_ALPHA, false); - IMB_rectblend(clonebuf, clonebuf, ibuf, NULL, NULL, NULL, 0, destx, desty, destx, desty, srcx, srcy, w, h, - IMB_BLEND_COPY_RGB, false); + IMB_rectblend( + clonebuf, clonebuf, ibufb, NULL, NULL, NULL, 0, destx, desty, destx, desty, destx, desty, w, h, + IMB_BLEND_COPY_ALPHA, false); + IMB_rectblend( + clonebuf, clonebuf, ibuf, NULL, NULL, NULL, 0, destx, desty, destx, desty, srcx, srcy, w, h, + IMB_BLEND_COPY_RGB, false); return clonebuf; } @@ -1023,15 +1032,16 @@ static void paint_2d_convert_brushco(ImBuf *ibufb, const float pos[2], int ipos[ ipos[1] = (int)floorf((pos[1] - ibufb->y / 2)); } -static void paint_2d_do_making_brush(ImagePaintState *s, - ImagePaintRegion *region, - unsigned short *curveb, - unsigned short *texmaskb, - ImBuf *frombuf, - float mask_max, - short blend, - int tilex, int tiley, - int tilew, int tileh) +static void paint_2d_do_making_brush( + ImagePaintState *s, + ImagePaintRegion *region, + unsigned short *curveb, + unsigned short *texmaskb, + ImBuf *frombuf, + float mask_max, + short blend, + int tilex, int tiley, + int tilew, int tileh) { ImBuf tmpbuf; IMB_initImBuf(&tmpbuf, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, 0); @@ -1050,13 +1060,14 @@ static void paint_2d_do_making_brush(ImagePaintState *s, else tmpbuf.rect = image_undo_find_tile(undo_tiles, s->image, s->canvas, tx, ty, &mask, false); - IMB_rectblend(s->canvas, &tmpbuf, frombuf, mask, - curveb, texmaskb, mask_max, - region->destx, region->desty, - origx, origy, - region->srcx, region->srcy, - region->width, region->height, - blend, ((s->brush->flag & BRUSH_ACCUMULATE) != 0)); + IMB_rectblend( + s->canvas, &tmpbuf, frombuf, mask, + curveb, texmaskb, mask_max, + region->destx, region->desty, + origx, origy, + region->srcx, region->srcy, + region->width, region->height, + blend, ((s->brush->flag & BRUSH_ACCUMULATE) != 0)); } } } @@ -1079,11 +1090,12 @@ static void paint_2d_op_foreach_do( const ParallelRangeTLS *__restrict UNUSED(tls)) { Paint2DForeachData *data = (Paint2DForeachData *)data_v; - paint_2d_do_making_brush(data->s, data->region, data->curveb, - data->texmaskb, data->frombuf, data->mask_max, - data->blend, - data->tilex, iter, - data->tilew, iter); + paint_2d_do_making_brush( + data->s, data->region, data->curveb, + data->texmaskb, data->frombuf, data->mask_max, + data->blend, + data->tilex, iter, + data->tilew, iter); } static int paint_2d_op(void *state, ImBuf *ibufb, unsigned short *curveb, unsigned short *texmaskb, const float lastpos[2], const float pos[2]) @@ -1135,21 +1147,24 @@ static int paint_2d_op(void *state, ImBuf *ibufb, unsigned short *curveb, unsign /* blend into canvas */ for (a = 0; a < tot; a++) { - ED_imapaint_dirty_region(s->image, s->canvas, - region[a].destx, region[a].desty, - region[a].width, region[a].height, true); + ED_imapaint_dirty_region( + s->image, s->canvas, + region[a].destx, region[a].desty, + region[a].width, region[a].height, true); if (s->do_masking) { /* masking, find original pixels tiles from undo buffer to composite over */ int tilex, tiley, tilew, tileh; - imapaint_region_tiles(s->canvas, region[a].destx, region[a].desty, - region[a].width, region[a].height, - &tilex, &tiley, &tilew, &tileh); + imapaint_region_tiles( + s->canvas, region[a].destx, region[a].desty, + region[a].width, region[a].height, + &tilex, &tiley, &tilew, &tileh); if (tiley == tileh) { - paint_2d_do_making_brush(s, ®ion[a], curveb, texmaskb, frombuf, - mask_max, blend, tilex, tiley, tilew, tileh); + paint_2d_do_making_brush( + s, ®ion[a], curveb, texmaskb, frombuf, + mask_max, blend, tilex, tiley, tilew, tileh); } else { Paint2DForeachData data; @@ -1165,19 +1180,21 @@ static int paint_2d_op(void *state, ImBuf *ibufb, unsigned short *curveb, unsign ParallelRangeSettings settings; BLI_parallel_range_settings_defaults(&settings); - BLI_task_parallel_range(tiley, tileh + 1, &data, - paint_2d_op_foreach_do, - &settings); + BLI_task_parallel_range( + tiley, tileh + 1, &data, + paint_2d_op_foreach_do, + &settings); } } else { /* no masking, composite brush directly onto canvas */ - IMB_rectblend_threaded(s->canvas, s->canvas, frombuf, NULL, curveb, texmaskb, mask_max, - region[a].destx, region[a].desty, - region[a].destx, region[a].desty, - region[a].srcx, region[a].srcy, - region[a].width, region[a].height, blend, false); + IMB_rectblend_threaded( + s->canvas, s->canvas, frombuf, NULL, curveb, texmaskb, mask_max, + region[a].destx, region[a].desty, + region[a].destx, region[a].desty, + region[a].srcx, region[a].srcy, + region[a].width, region[a].height, blend, false); } } @@ -1478,16 +1495,18 @@ void paint_2d_bucket_fill( if (do_float) { for (x_px = 0; x_px < ibuf->x; x_px++) { for (y_px = 0; y_px < ibuf->y; y_px++) { - blend_color_mix_float(ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px), - ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px), color_f); + blend_color_mix_float( + ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px), + ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px), color_f); } } } else { for (x_px = 0; x_px < ibuf->x; x_px++) { for (y_px = 0; y_px < ibuf->y; y_px++) { - blend_color_mix_byte((unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), - (unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), (unsigned char *)&color_b); + blend_color_mix_byte( + (unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), + (unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), (unsigned char *)&color_b); } } } @@ -1538,9 +1557,10 @@ void paint_2d_bucket_fill( while (!BLI_stack_is_empty(stack)) { BLI_stack_pop(stack, &coordinate); - IMB_blend_color_float(ibuf->rect_float + 4 * (coordinate), - ibuf->rect_float + 4 * (coordinate), - color_f, br->blend); + IMB_blend_color_float( + ibuf->rect_float + 4 * (coordinate), + ibuf->rect_float + 4 * (coordinate), + color_f, br->blend); /* reconstruct the coordinates here */ x_px = coordinate % width; @@ -1569,9 +1589,10 @@ void paint_2d_bucket_fill( while (!BLI_stack_is_empty(stack)) { BLI_stack_pop(stack, &coordinate); - IMB_blend_color_byte((unsigned char *)(ibuf->rect + coordinate), - (unsigned char *)(ibuf->rect + coordinate), - (unsigned char *)&color_b, br->blend); + IMB_blend_color_byte( + (unsigned char *)(ibuf->rect + coordinate), + (unsigned char *)(ibuf->rect + coordinate), + (unsigned char *)&color_b, br->blend); /* reconstruct the coordinates here */ x_px = coordinate % width; @@ -1679,9 +1700,10 @@ void paint_2d_gradient_fill( /* convert to premultiplied */ mul_v3_fl(color_f, color_f[3]); color_f[3] *= br->alpha; - IMB_blend_color_float(ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px), - ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px), - color_f, br->blend); + IMB_blend_color_float( + ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px), + ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px), + color_f, br->blend); } } } @@ -1709,9 +1731,10 @@ void paint_2d_gradient_fill( linearrgb_to_srgb_v3_v3(color_f, color_f); rgba_float_to_uchar((unsigned char *)&color_b, color_f); ((unsigned char *)&color_b)[3] *= br->alpha; - IMB_blend_color_byte((unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), - (unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), - (unsigned char *)&color_b, br->blend); + IMB_blend_color_byte( + (unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), + (unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), + (unsigned char *)&color_b, br->blend); } } } diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 62bc379241f..04329697b54 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -58,6 +58,7 @@ #include "DNA_brush_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" @@ -65,7 +66,6 @@ #include "BKE_colorband.h" #include "BKE_context.h" #include "BKE_colortools.h" -#include "BKE_DerivedMesh.h" #include "BKE_idprop.h" #include "BKE_brush.h" #include "BKE_image.h" @@ -2604,8 +2604,9 @@ static void project_paint_face_init( if (pixel_bounds_array(uv_clip, &bounds_px, ibuf->x, ibuf->y, uv_clip_tot)) { #if 0 - project_paint_undo_tiles_init(&bounds_px, ps->projImages + image_index, tmpibuf, - tile_width, threaded, ps->do_masking); + project_paint_undo_tiles_init( + &bounds_px, ps->projImages + image_index, tmpibuf, + tile_width, threaded, ps->do_masking); #endif /* clip face and */ @@ -2654,10 +2655,10 @@ static void project_paint_face_init( if (mask > 0.0f) { BLI_linklist_prepend_arena( bucketPixelNodes, - project_paint_uvpixel_init(ps, arena, &tinf, x, y, mask, tri_index, - pixelScreenCo, wco, w), - arena - ); + project_paint_uvpixel_init( + ps, arena, &tinf, x, y, mask, tri_index, + pixelScreenCo, wco, w), + arena); } } @@ -4187,8 +4188,9 @@ static void do_projectpaint_clone_f(ProjPaintState *ps, ProjPixel *projPixel, fl * accumulation of color greater than 'projPixel->mask' however in the case of smear its not * really that important to be correct as it is with clone and painting */ -static void do_projectpaint_smear(ProjPaintState *ps, ProjPixel *projPixel, float mask, - MemArena *smearArena, LinkNode **smearPixels, const float co[2]) +static void do_projectpaint_smear( + ProjPaintState *ps, ProjPixel *projPixel, float mask, + MemArena *smearArena, LinkNode **smearPixels, const float co[2]) { unsigned char rgba_ub[4]; @@ -4199,8 +4201,9 @@ static void do_projectpaint_smear(ProjPaintState *ps, ProjPixel *projPixel, floa BLI_linklist_prepend_arena(smearPixels, (void *)projPixel, smearArena); } -static void do_projectpaint_smear_f(ProjPaintState *ps, ProjPixel *projPixel, float mask, - MemArena *smearArena, LinkNode **smearPixels_f, const float co[2]) +static void do_projectpaint_smear_f( + ProjPaintState *ps, ProjPixel *projPixel, float mask, + MemArena *smearArena, LinkNode **smearPixels_f, const float co[2]) { float rgba[4]; @@ -4211,8 +4214,9 @@ static void do_projectpaint_smear_f(ProjPaintState *ps, ProjPixel *projPixel, fl BLI_linklist_prepend_arena(smearPixels_f, (void *)projPixel, smearArena); } -static void do_projectpaint_soften_f(ProjPaintState *ps, ProjPixel *projPixel, float mask, - MemArena *softenArena, LinkNode **softenPixels) +static void do_projectpaint_soften_f( + ProjPaintState *ps, ProjPixel *projPixel, float mask, + MemArena *softenArena, LinkNode **softenPixels) { float accum_tot = 0.0f; int xk, yk; @@ -4267,8 +4271,9 @@ static void do_projectpaint_soften_f(ProjPaintState *ps, ProjPixel *projPixel, f } } -static void do_projectpaint_soften(ProjPaintState *ps, ProjPixel *projPixel, float mask, - MemArena *softenArena, LinkNode **softenPixels) +static void do_projectpaint_soften( + ProjPaintState *ps, ProjPixel *projPixel, float mask, + MemArena *softenArena, LinkNode **softenPixels) { float accum_tot = 0; int xk, yk; @@ -4549,8 +4554,9 @@ static void *do_projectpaint_thread(void *ph_v) if (is_floatbuf) { /* convert to premultipied */ mul_v3_fl(color_f, color_f[3]); - IMB_blend_color_float(projPixel->pixel.f_pt, projPixel->origColor.f_pt, - color_f, ps->blend); + IMB_blend_color_float( + projPixel->pixel.f_pt, projPixel->origColor.f_pt, + color_f, ps->blend); } else { linearrgb_to_srgb_v3_v3(color_f, color_f); @@ -4562,8 +4568,9 @@ static void *do_projectpaint_thread(void *ph_v) unit_float_to_uchar_clamp_v3(projPixel->newColor.ch, color_f); } projPixel->newColor.ch[3] = unit_float_to_uchar_clamp(color_f[3]); - IMB_blend_color_byte(projPixel->pixel.ch_pt, projPixel->origColor.ch_pt, - projPixel->newColor.ch, ps->blend); + IMB_blend_color_byte( + projPixel->pixel.ch_pt, projPixel->origColor.ch_pt, + projPixel->newColor.ch, ps->blend); } } else { @@ -4572,16 +4579,18 @@ static void *do_projectpaint_thread(void *ph_v) newColor_f[3] = ((float)projPixel->mask) * (1.0f / 65535.0f) * brush->alpha; copy_v3_v3(newColor_f, ps->paint_color_linear); - IMB_blend_color_float(projPixel->pixel.f_pt, projPixel->origColor.f_pt, - newColor_f, ps->blend); + IMB_blend_color_float( + projPixel->pixel.f_pt, projPixel->origColor.f_pt, + newColor_f, ps->blend); } else { float mask = ((float)projPixel->mask) * (1.0f / 65535.0f); projPixel->newColor.ch[3] = mask * 255 * brush->alpha; rgb_float_to_uchar(projPixel->newColor.ch, ps->paint_color); - IMB_blend_color_byte(projPixel->pixel.ch_pt, projPixel->origColor.ch_pt, - projPixel->newColor.ch, ps->blend); + IMB_blend_color_byte( + projPixel->pixel.ch_pt, projPixel->origColor.ch_pt, + projPixel->newColor.ch, ps->blend); } } @@ -4609,15 +4618,17 @@ static void *do_projectpaint_thread(void *ph_v) ps->reproject_ibuf_free_float = true; } - bicubic_interpolation_color(ps->reproject_ibuf, NULL, projPixel->newColor.f, - projPixel->projCoSS[0], projPixel->projCoSS[1]); + bicubic_interpolation_color( + ps->reproject_ibuf, NULL, projPixel->newColor.f, + projPixel->projCoSS[0], projPixel->projCoSS[1]); if (projPixel->newColor.f[3]) { float mask = ((float)projPixel->mask) * (1.0f / 65535.0f); mul_v4_v4fl(projPixel->newColor.f, projPixel->newColor.f, mask); - blend_color_mix_float(projPixel->pixel.f_pt, projPixel->origColor.f_pt, - projPixel->newColor.f); + blend_color_mix_float( + projPixel->pixel.f_pt, projPixel->origColor.f_pt, + projPixel->newColor.f); } } else { @@ -4626,14 +4637,16 @@ static void *do_projectpaint_thread(void *ph_v) ps->reproject_ibuf_free_uchar = true; } - bicubic_interpolation_color(ps->reproject_ibuf, projPixel->newColor.ch, NULL, - projPixel->projCoSS[0], projPixel->projCoSS[1]); + bicubic_interpolation_color( + ps->reproject_ibuf, projPixel->newColor.ch, NULL, + projPixel->projCoSS[0], projPixel->projCoSS[1]); if (projPixel->newColor.ch[3]) { float mask = ((float)projPixel->mask) * (1.0f / 65535.0f); projPixel->newColor.ch[3] *= mask; - blend_color_mix_byte(projPixel->pixel.ch_pt, projPixel->origColor.ch_pt, - projPixel->newColor.ch); + blend_color_mix_byte( + projPixel->pixel.ch_pt, projPixel->origColor.ch_pt, + projPixel->newColor.ch); } } } @@ -5495,12 +5508,13 @@ void PAINT_OT_image_from_view(wmOperatorType *ot) void BKE_paint_data_warning(struct ReportList *reports, bool uvs, bool mat, bool tex, bool stencil) { - BKE_reportf(reports, RPT_WARNING, "Missing%s%s%s%s detected!", - !uvs ? " UVs," : "", - !mat ? " Materials," : "", - !tex ? " Textures," : "", - !stencil ? " Stencil," : "" - ); + BKE_reportf( + reports, RPT_WARNING, "Missing%s%s%s%s detected!", + !uvs ? " UVs," : "", + !mat ? " Materials," : "", + !tex ? " Textures," : "", + !stencil ? " Stencil," : "" + ); } /* Make sure that active object has a material, and assign UVs and image layers if they do not exist */ @@ -5628,8 +5642,9 @@ static Image *proj_paint_image_create(wmOperator *op, Main *bmain) alpha = RNA_boolean_get(op->ptr, "alpha"); RNA_string_get(op->ptr, "name", imagename); } - ima = BKE_image_add_generated(bmain, width, height, imagename, alpha ? 32 : 24, use_float, - gen_type, color, false); + ima = BKE_image_add_generated( + bmain, width, height, imagename, alpha ? 32 : 24, use_float, + gen_type, color, false); return ima; } @@ -5803,7 +5818,7 @@ static int add_simple_uvs_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static int add_simple_uvs_poll(bContext *C) +static bool add_simple_uvs_poll(bContext *C) { Object *ob = CTX_data_active_object(C); @@ -5827,4 +5842,3 @@ void PAINT_OT_add_simple_uvs(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } - diff --git a/source/blender/editors/sculpt_paint/paint_image_undo.c b/source/blender/editors/sculpt_paint/paint_image_undo.c index ade775d14e6..e26a4811afc 100644 --- a/source/blender/editors/sculpt_paint/paint_image_undo.c +++ b/source/blender/editors/sculpt_paint/paint_image_undo.c @@ -105,8 +105,9 @@ static void undo_copy_tile(UndoImageTile *tile, ImBuf *tmpibuf, ImBuf *ibuf, Cop { if (mode == COPY) { /* copy or swap contents of tile->rect and region in ibuf->rect */ - IMB_rectcpy(tmpibuf, ibuf, 0, 0, tile->x * IMAPAINT_TILE_SIZE, - tile->y * IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE); + IMB_rectcpy( + tmpibuf, ibuf, 0, 0, tile->x * IMAPAINT_TILE_SIZE, + tile->y * IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE); if (ibuf->rect_float) { SWAP(float *, tmpibuf->rect_float, tile->rect.fp); @@ -117,8 +118,9 @@ static void undo_copy_tile(UndoImageTile *tile, ImBuf *tmpibuf, ImBuf *ibuf, Cop } else { if (mode == RESTORE_COPY) { - IMB_rectcpy(tmpibuf, ibuf, 0, 0, tile->x * IMAPAINT_TILE_SIZE, - tile->y * IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE); + IMB_rectcpy( + tmpibuf, ibuf, 0, 0, tile->x * IMAPAINT_TILE_SIZE, + tile->y * IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE); } /* swap to the tmpbuf for easy copying */ if (ibuf->rect_float) { @@ -128,8 +130,9 @@ static void undo_copy_tile(UndoImageTile *tile, ImBuf *tmpibuf, ImBuf *ibuf, Cop SWAP(unsigned int *, tmpibuf->rect, tile->rect.uint); } - IMB_rectcpy(ibuf, tmpibuf, tile->x * IMAPAINT_TILE_SIZE, - tile->y * IMAPAINT_TILE_SIZE, 0, 0, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE); + IMB_rectcpy( + ibuf, tmpibuf, tile->x * IMAPAINT_TILE_SIZE, + tile->y * IMAPAINT_TILE_SIZE, 0, 0, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE); if (mode == RESTORE) { if (ibuf->rect_float) { @@ -156,8 +159,9 @@ void *image_undo_find_tile( if (mask) { /* allocate mask if requested */ if (!tile->mask) { - tile->mask = MEM_callocN(sizeof(unsigned short) * IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE, - "UndoImageTile.mask"); + tile->mask = MEM_callocN( + sizeof(unsigned short) * IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE, + "UndoImageTile.mask"); } *mask = tile->mask; @@ -204,8 +208,9 @@ void *image_undo_push_tile( /* add mask explicitly here */ if (mask) { - *mask = tile->mask = MEM_callocN(sizeof(unsigned short) * IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE, - "UndoImageTile.mask"); + *mask = tile->mask = MEM_callocN( + sizeof(unsigned short) * IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE, + "UndoImageTile.mask"); } allocsize = IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE * 4; allocsize *= (ibuf->rect_float) ? sizeof(float) : sizeof(char); @@ -253,8 +258,9 @@ static void image_undo_restore_runtime(ListBase *lb) ImBuf *ibuf, *tmpibuf; UndoImageTile *tile; - tmpibuf = IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, - IB_rectfloat | IB_rect); + tmpibuf = IMB_allocImBuf( + IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, + IB_rectfloat | IB_rect); for (tile = lb->first; tile; tile = tile->next) { Image *ima = tile->ima; diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 8d94978f5c6..7d3049434d6 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -65,10 +65,11 @@ typedef void (*StrokeUpdateStep)(struct bContext *C, struct PaintStroke *stroke, typedef void (*StrokeRedraw)(const struct bContext *C, struct PaintStroke *stroke, bool final); typedef void (*StrokeDone)(const struct bContext *C, struct PaintStroke *stroke); -struct PaintStroke *paint_stroke_new(struct bContext *C, struct wmOperator *op, - StrokeGetLocation get_location, StrokeTestStart test_start, - StrokeUpdateStep update_step, StrokeRedraw redraw, - StrokeDone done, int event_type); +struct PaintStroke *paint_stroke_new( + struct bContext *C, struct wmOperator *op, + StrokeGetLocation get_location, StrokeTestStart test_start, + StrokeUpdateStep update_step, StrokeRedraw redraw, + StrokeDone done, int event_type); void paint_stroke_data_free(struct wmOperator *op); bool paint_space_stroke_enabled(struct Brush *br, enum ePaintMode mode); @@ -87,18 +88,18 @@ struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke); void *paint_stroke_mode_data(struct PaintStroke *stroke); float paint_stroke_distance_get(struct PaintStroke *stroke); void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data); -int paint_poll(struct bContext *C); -void paint_cursor_start(struct bContext *C, int (*poll)(struct bContext *C)); -void paint_cursor_start_explicit(struct Paint *p, struct wmWindowManager *wm, int (*poll)(struct bContext *C)); +bool paint_poll(struct bContext *C); +void paint_cursor_start(struct bContext *C, bool (*poll)(struct bContext *C)); +void paint_cursor_start_explicit(struct Paint *p, struct wmWindowManager *wm, bool (*poll)(struct bContext *C)); void paint_cursor_delete_textures(void); /* paint_vertex.c */ -int weight_paint_poll(struct bContext *C); -int weight_paint_poll_ignore_tool(bContext *C); -int weight_paint_mode_poll(struct bContext *C); -int vertex_paint_poll(struct bContext *C); -int vertex_paint_poll_ignore_tool(struct bContext *C); -int vertex_paint_mode_poll(struct bContext *C); +bool weight_paint_poll(struct bContext *C); +bool weight_paint_poll_ignore_tool(bContext *C); +bool weight_paint_mode_poll(struct bContext *C); +bool vertex_paint_poll(struct bContext *C); +bool vertex_paint_poll_ignore_tool(struct bContext *C); +bool vertex_paint_mode_poll(struct bContext *C); typedef void (*VPaintTransform_Callback)(const float col[3], const void *user_data, float r_col[3]); @@ -179,7 +180,7 @@ typedef struct ImagePaintPartialRedraw { #define IMAPAINT_TILE_SIZE (1 << IMAPAINT_TILE_BITS) #define IMAPAINT_TILE_NUMBER(size) (((size) + IMAPAINT_TILE_SIZE - 1) >> IMAPAINT_TILE_BITS) -int image_texture_paint_poll(struct bContext *C); +bool image_texture_paint_poll(struct bContext *C); void imapaint_image_update(struct SpaceImage *sima, struct Image *image, struct ImBuf *ibuf, short texpaint); struct ImagePaintPartialRedraw *get_imapaintpartial(void); void set_imapaintpartial(struct ImagePaintPartialRedraw *ippr); @@ -238,8 +239,8 @@ struct ListBase *ED_image_undosys_step_get_tiles(struct UndoStep *us_p); struct ListBase *ED_image_undo_get_tiles(void); /* sculpt_uv.c */ -int uv_sculpt_poll(struct bContext *C); -int uv_sculpt_keymap_poll(struct bContext *C); +bool uv_sculpt_poll(struct bContext *C); +bool uv_sculpt_keymap_poll(struct bContext *C); void SCULPT_OT_uv_sculpt_stroke(struct wmOperatorType *ot); @@ -248,24 +249,28 @@ void SCULPT_OT_uv_sculpt_stroke(struct wmOperatorType *ot); /* Convert the object-space axis-aligned bounding box (expressed as * its minimum and maximum corners) into a screen-space rectangle, * returns zero if the result is empty */ -bool paint_convert_bb_to_rect(struct rcti *rect, - const float bb_min[3], - const float bb_max[3], - const struct ARegion *ar, - struct RegionView3D *rv3d, - struct Object *ob); +bool paint_convert_bb_to_rect( + struct rcti *rect, + const float bb_min[3], + const float bb_max[3], + const struct ARegion *ar, + struct RegionView3D *rv3d, + struct Object *ob); /* Get four planes in object-space that describe the projection of * screen_rect from screen into object-space (essentially converting a * 2D screens-space bounding box into four 3D planes) */ -void paint_calc_redraw_planes(float planes[4][4], - const struct ARegion *ar, - struct Object *ob, - const struct rcti *screen_rect); +void paint_calc_redraw_planes( + float planes[4][4], + const struct ARegion *ar, + struct Object *ob, + const struct rcti *screen_rect); float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius); float paint_get_tex_pixel(const struct MTex *mtex, float u, float v, struct ImagePool *pool, int thread); -void paint_get_tex_pixel_col(const struct MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert, struct ColorSpace *colorspace); +void paint_get_tex_pixel_col( + const struct MTex *mtex, float u, float v, float rgba[4], + struct ImagePool *pool, int thread, bool convert, struct ColorSpace *colorspace); void paint_sample_color(struct bContext *C, struct ARegion *ar, int x, int y, bool texpaint_proj, bool palette); @@ -282,11 +287,11 @@ void PAINT_OT_face_select_reveal(struct wmOperatorType *ot); void PAINT_OT_vert_select_all(struct wmOperatorType *ot); void PAINT_OT_vert_select_ungrouped(struct wmOperatorType *ot); -int vert_paint_poll(struct bContext *C); -int mask_paint_poll(struct bContext *C); -int paint_curve_poll(struct bContext *C); +bool vert_paint_poll(struct bContext *C); +bool mask_paint_poll(struct bContext *C); +bool paint_curve_poll(struct bContext *C); -int facemask_paint_poll(struct bContext *C); +bool facemask_paint_poll(struct bContext *C); void flip_v3_v3(float out[3], const float in[3], const char symm); void flip_qt_qt(float out[3], const float in[3], const char symm); @@ -307,8 +312,9 @@ typedef enum { RC_COLOR_OVERRIDE = 32, } RCFlags; -void set_brush_rc_props(struct PointerRNA *ptr, const char *paint, const char *prop, const char *secondary_prop, - RCFlags flags); +void set_brush_rc_props( + struct PointerRNA *ptr, const char *paint, const char *prop, const char *secondary_prop, + RCFlags flags); /* paint_hide.c */ diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index f22e6f514e6..aed48aef3a9 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -45,7 +45,6 @@ #include "BKE_pbvh.h" #include "BKE_ccg.h" #include "BKE_context.h" -#include "BKE_DerivedMesh.h" #include "BKE_multires.h" #include "BKE_paint.h" #include "BKE_subsurf.h" @@ -76,9 +75,10 @@ static const EnumPropertyItem mode_items[] = { {0}}; -static void mask_flood_fill_set_elem(float *elem, - PaintMaskFloodMode mode, - float value) +static void mask_flood_fill_set_elem( + float *elem, + PaintMaskFloodMode mode, + float value) { switch (mode) { case PAINT_MASK_FLOOD_VALUE: @@ -163,8 +163,9 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op) BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range( - 0, totnode, &data, mask_flood_fill_task_cb, - &settings); + + 0, totnode, &data, mask_flood_fill_task_cb, + &settings); if (multires) multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 3a8ab12b96d..9f14a821613 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -184,7 +184,7 @@ static void PALETTE_OT_new(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int palette_poll(bContext *C) +static bool palette_poll(bContext *C) { Paint *paint = BKE_paint_get_active_from_context(C); @@ -366,10 +366,11 @@ static Brush *brush_tool_toggle(Main *bmain, Brush *brush_orig, const int tool, return NULL; } -static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, - const size_t tool_offset, const int ob_mode, - const char *tool_name, const bool create_missing, - const bool toggle) +static int brush_generic_tool_set( + Main *bmain, Paint *paint, const int tool, + const size_t tool_offset, const int ob_mode, + const char *tool_name, const bool create_missing, + const bool toggle) { Brush *brush, *brush_orig = BKE_paint_brush(paint); @@ -455,21 +456,19 @@ static int brush_select_exec(bContext *C, wmOperator *op) /* TODO(campbell): Use the toolsystem for now, ideally the toolsystem will display brushes directly * so we don't need to sync between tools and brushes. */ - if (false) { - return brush_generic_tool_set( - bmain, paint, tool, tool_offset, - paint_mode, tool_name, create_missing, - toggle); - } - else { + int ret = brush_generic_tool_set( + bmain, paint, tool, tool_offset, + paint_mode, tool_name, create_missing, + toggle); + + if ((ret == OPERATOR_FINISHED) && (paint->brush != NULL)) { + Brush *brush = paint->brush; WorkSpace *workspace = CTX_wm_workspace(C); - if (WM_toolsystem_ref_set_by_name(C, workspace, NULL, tool_name, true)) { - return OPERATOR_FINISHED; - } - else { - return OPERATOR_CANCELLED; + if (WM_toolsystem_ref_set_by_name(C, workspace, NULL, brush->id.name + 2, true)) { + /* ok */ } } + return ret; } static void PAINT_OT_brush_select(wmOperatorType *ot) @@ -514,8 +513,9 @@ static wmKeyMapItem *keymap_brush_select( int keymap_modifier) { wmKeyMapItem *kmi; - kmi = WM_keymap_add_item(keymap, "PAINT_OT_brush_select", - keymap_type, KM_PRESS, keymap_modifier, 0); + kmi = WM_keymap_add_item( + keymap, "PAINT_OT_brush_select", + keymap_type, KM_PRESS, keymap_modifier, 0); RNA_enum_set(kmi->ptr, "paint_mode", paint_mode); @@ -699,8 +699,7 @@ static void stencil_control_calculate(StencilControlData *scd, const int mval[2] switch (scd->mode) { case STENCIL_TRANSLATE: sub_v2_v2v2(mdiff, mvalf, scd->init_mouse); - add_v2_v2v2(scd->pos_target, scd->init_spos, - mdiff); + add_v2_v2v2(scd->pos_target, scd->init_spos, mdiff); CLAMP(scd->pos_target[0], -scd->dim_target[0] + PIXEL_MARGIN, scd->area_size[0] + scd->dim_target[0] - PIXEL_MARGIN); @@ -794,7 +793,7 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve return OPERATOR_RUNNING_MODAL; } -static int stencil_control_poll(bContext *C) +static bool stencil_control_poll(bContext *C) { ePaintMode mode = BKE_paintmode_get_active_from_context(C); @@ -1003,8 +1002,9 @@ void ED_operatormacros_paint(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("PAINTCURVE_OT_add_point_slide", "Add Curve Point and Slide", - "Add new curve point and slide it", OPTYPE_UNDO); + ot = WM_operatortype_append_macro( + "PAINTCURVE_OT_add_point_slide", "Add Curve Point and Slide", + "Add new curve point and slide it", OPTYPE_UNDO); ot->description = "Add new curve point and slide it"; WM_operatortype_macro_define(ot, "PAINTCURVE_OT_add_point"); otmacro = WM_operatortype_macro_define(ot, "PAINTCURVE_OT_slide"); @@ -1107,8 +1107,9 @@ static void ed_keymap_paint_brush_size(wmKeyMap *keymap, const char *UNUSED(path RNA_float_set(kmi->ptr, "scalar", 10.0 / 9.0); // 1.1111.... } -static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path, - const char *output_name, const char *input_name) +static void set_brush_rc_path( + PointerRNA *ptr, const char *brush_path, + const char *output_name, const char *input_name) { char *path; @@ -1117,9 +1118,10 @@ static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path, MEM_freeN(path); } -void set_brush_rc_props(PointerRNA *ptr, const char *paint, - const char *prop, const char *secondary_prop, - RCFlags flags) +void set_brush_rc_props( + PointerRNA *ptr, const char *paint, + const char *prop, const char *secondary_prop, + RCFlags flags) { const char *ups_path = "tool_settings.unified_paint_settings"; char *brush_path; @@ -1168,8 +1170,9 @@ void set_brush_rc_props(PointerRNA *ptr, const char *paint, MEM_freeN(brush_path); } -static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *paint, - RCFlags flags) +static void ed_keymap_paint_brush_radial_control( + wmKeyMap *keymap, const char *paint, + RCFlags flags) { wmKeyMapItem *kmi; /* only size needs to follow zoom, strength shows fixed size circle */ @@ -1230,6 +1233,7 @@ static void paint_keymap_curve(wmKeyMap *keymap) RNA_boolean_set(kmi->ptr, "toggle", true); WM_keymap_add_item(keymap, "PAINTCURVE_OT_cursor", ACTIONMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "PAINTCURVE_OT_delete_point", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "PAINTCURVE_OT_delete_point", DELKEY, KM_PRESS, 0, 0); @@ -1336,8 +1340,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "PAINT_OT_brush_colors_flip", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "PAINT_OT_sample_color", SKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, - "PAINT_OT_vertex_color_set", KKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "PAINT_OT_vertex_color_set", KKEY, KM_PRESS, KM_SHIFT, 0); ed_keymap_paint_brush_size(keymap, "tool_settings.vertex_paint.brush.size"); ed_keymap_paint_brush_radial_control(keymap, "vertex_paint", RC_COLOR | RC_COLOR_OVERRIDE | RC_ROTATION); @@ -1368,8 +1371,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_gradient", LEFTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "type", WPAINT_GRADIENT_TYPE_LINEAR); RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_gradient", LEFTMOUSE, KM_PRESS, KM_ALT | KM_CTRL, 0)->ptr, "type", WPAINT_GRADIENT_TYPE_RADIAL); - WM_keymap_add_item(keymap, - "PAINT_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "PAINT_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0); ed_keymap_paint_brush_size(keymap, "tool_settings.weight_paint.brush.size"); ed_keymap_paint_brush_radial_control(keymap, "weight_paint", RC_WEIGHT); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index a7aa19807dd..8db78a41252 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -62,6 +62,7 @@ #include "BIF_glutil.h" #include "GPU_immediate.h" +#include "GPU_state.h" #include "ED_screen.h" #include "ED_view3d.h" @@ -149,8 +150,8 @@ static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata PaintStroke *stroke = customdata; if (stroke && brush) { - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); + GPU_line_smooth(true); + GPU_blend(true); ARegion *ar = stroke->vc.ar; @@ -168,8 +169,8 @@ static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata immUnbindProgram(); - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); + GPU_blend(false); + GPU_line_smooth(false); } } @@ -178,17 +179,17 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata) Paint *paint = BKE_paint_get_active_from_context(C); PaintStroke *stroke = customdata; - glEnable(GL_LINE_SMOOTH); + GPU_line_smooth(true); uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); - immUniform1i("num_colors", 2); /* "advanced" mode */ + immUniform1i("colors_len", 2); /* "advanced" mode */ const float alpha = (float)paint->paint_cursor_col[3] / 255.0f; immUniformArray4fv("colors", (float *)(float[][4]){{0.0f, 0.0f, 0.0f, alpha}, {1.0f, 1.0f, 1.0f, alpha}}, 2); immUniform1f("dash_width", 6.0f); @@ -218,15 +219,16 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata) immUnbindProgram(); - glDisable(GL_LINE_SMOOTH); + GPU_line_smooth(false); } static bool paint_tool_require_location(Brush *brush, ePaintMode mode) { switch (mode) { case ePaintSculpt: - if (ELEM(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, - SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)) + if (ELEM(brush->sculpt_tool, + SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, + SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)) { return false; } @@ -241,13 +243,14 @@ static bool paint_tool_require_location(Brush *brush, ePaintMode mode) } /* Initialize the stroke cache variants from operator properties */ -static bool paint_brush_update(bContext *C, - Brush *brush, - ePaintMode mode, - struct PaintStroke *stroke, - const float mouse_init[2], - float mouse[2], float pressure, - float location[3]) +static bool paint_brush_update( + bContext *C, + Brush *brush, + ePaintMode mode, + struct PaintStroke *stroke, + const float mouse_init[2], + float mouse[2], float pressure, + float r_location[3], bool *r_location_is_set) { Scene *scene = CTX_data_scene(C); UnifiedPaintSettings *ups = stroke->ups; @@ -258,6 +261,7 @@ static bool paint_brush_update(bContext *C, bool is_dry_run = false; bool do_random = false; bool do_random_mask = false; + *r_location_is_set = false; /* XXX: Use pressure value from first brush step for brushes which don't * support strokes (grab, thumb). They depends on initial state and * brush coord/pressure/etc. @@ -356,10 +360,11 @@ static bool paint_brush_update(bContext *C, halfway[1] = dy * 0.5f + stroke->initial_mouse[1]; if (stroke->get_location) { - if (stroke->get_location(C, location, halfway)) { + if (stroke->get_location(C, r_location, halfway)) { hit = true; location_sampled = true; location_success = true; + *r_location_is_set = true; } else if (!paint_tool_require_location(brush, mode)) { hit = true; @@ -429,14 +434,17 @@ static bool paint_brush_update(bContext *C, if (!location_sampled) { if (stroke->get_location) { - if (stroke->get_location(C, location, mouse)) + if (stroke->get_location(C, r_location, mouse)) { location_success = true; + *r_location_is_set = true; + } else if (!paint_tool_require_location(brush, mode)) location_success = true; } else { - zero_v3(location); + zero_v3(r_location); location_success = true; + /* don't set 'r_location_is_set', since we don't want to use the value. */ } } @@ -477,14 +485,24 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, const float #if 0 /* special exception here for too high pressure values on first touch in * windows for some tablets, then we just skip first touch .. */ - if (tablet && (pressure >= 0.99f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || BKE_brush_use_alpha_pressure(scene, pop->s.brush) || BKE_brush_use_size_pressure(scene, pop->s.brush))) + if (tablet && (pressure >= 0.99f) && + ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || + BKE_brush_use_alpha_pressure(scene, pop->s.brush) || + BKE_brush_use_size_pressure(scene, pop->s.brush))) + { return; + } /* This can be removed once fixed properly in * BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, double time, float pressure, void *user) * at zero pressure we should do nothing 1/2^12 is 0.0002 which is the sensitivity of the most sensitive pen tablet available */ - if (tablet && (pressure < 0.0002f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || BKE_brush_use_alpha_pressure(scene, pop->s.brush) || BKE_brush_use_size_pressure(scene, pop->s.brush))) + if (tablet && (pressure < 0.0002f) && + ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || + BKE_brush_use_alpha_pressure(scene, pop->s.brush) || + BKE_brush_use_size_pressure(scene, pop->s.brush))) + { return; + } #endif /* copy last position -before- jittering, or space fill code @@ -515,8 +533,13 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, const float } - ups->last_hit = paint_brush_update(C, brush, mode, stroke, mouse_in, mouse_out, pressure, location); - copy_v3_v3(ups->last_location, location); + bool is_location_is_set; + ups->last_hit = paint_brush_update( + C, brush, mode, stroke, mouse_in, mouse_out, pressure, + location, &is_location_is_set); + if (is_location_is_set) { + copy_v3_v3(ups->last_location, location); + } if (!ups->last_hit) { return; } @@ -563,7 +586,8 @@ static bool paint_smooth_stroke( return true; } -static float paint_space_stroke_spacing(const Scene *scene, PaintStroke *stroke, float size_pressure, float spacing_pressure) +static float paint_space_stroke_spacing( + const Scene *scene, PaintStroke *stroke, float size_pressure, float spacing_pressure) { /* brushes can have a minimum size of 1.0 but with pressure it can be smaller then a pixel * causing very high step sizes, hanging blender [#32381] */ @@ -633,7 +657,8 @@ static float paint_stroke_integrate_overlap(Brush *br, float factor) return 1.0f / max; } -static float paint_space_stroke_spacing_variable(const Scene *scene, PaintStroke *stroke, float pressure, float dpressure, float length) +static float paint_space_stroke_spacing_variable( + const Scene *scene, PaintStroke *stroke, float pressure, float dpressure, float length) { if (BKE_brush_use_size_pressure(scene, stroke->brush)) { /* use pressure to modify size. set spacing so that at 100%, the circles @@ -708,13 +733,14 @@ static int paint_space_stroke(bContext *C, wmOperator *op, const float final_mou /**** Public API ****/ -PaintStroke *paint_stroke_new(bContext *C, - wmOperator *op, - StrokeGetLocation get_location, - StrokeTestStart test_start, - StrokeUpdateStep update_step, - StrokeRedraw redraw, - StrokeDone done, int event_type) +PaintStroke *paint_stroke_new( + bContext *C, + wmOperator *op, + StrokeGetLocation get_location, + StrokeTestStart test_start, + StrokeUpdateStep update_step, + StrokeRedraw redraw, + StrokeDone done, int event_type) { PaintStroke *stroke = MEM_callocN(sizeof(PaintStroke), "PaintStroke"); ToolSettings *toolsettings = CTX_data_tool_settings(C); @@ -815,11 +841,12 @@ bool paint_space_stroke_enabled(Brush *br, ePaintMode mode) static bool sculpt_is_grab_tool(Brush *br) { - return ELEM(br->sculpt_tool, - SCULPT_TOOL_GRAB, - SCULPT_TOOL_THUMB, - SCULPT_TOOL_ROTATE, - SCULPT_TOOL_SNAKE_HOOK); + return ELEM( + br->sculpt_tool, + SCULPT_TOOL_GRAB, + SCULPT_TOOL_THUMB, + SCULPT_TOOL_ROTATE, + SCULPT_TOOL_SNAKE_HOOK); } /* return true if the brush size can change during paint (normally used for pressure) */ @@ -920,9 +947,10 @@ struct wmKeyMap *paint_stroke_modal_keymap(struct wmKeyConfig *keyconf) return keymap; } -static void paint_stroke_add_sample(const Paint *paint, - PaintStroke *stroke, - float x, float y, float pressure) +static void paint_stroke_add_sample( + const Paint *paint, + PaintStroke *stroke, + float x, float y, float pressure) { PaintSample *sample = &stroke->samples[stroke->cur_sample]; int max_samples = CLAMPIS(paint->num_input_samples, 1, PAINT_MAX_INPUT_SAMPLES); @@ -938,8 +966,9 @@ static void paint_stroke_add_sample(const Paint *paint, stroke->num_samples++; } -static void paint_stroke_sample_average(const PaintStroke *stroke, - PaintSample *average) +static void paint_stroke_sample_average( + const PaintStroke *stroke, + PaintSample *average) { int i; @@ -1084,11 +1113,13 @@ static bool paint_stroke_curve_end(bContext *C, wmOperator *op, PaintStroke *str if (stroke->stroke_started) { paint_brush_stroke_add_step(C, op, data + 2 * j, 1.0); - paint_line_strokes_spacing(C, op, stroke, spacing, &length_residue, data + 2 * j, data + 2 * (j + 1)); + paint_line_strokes_spacing( + C, op, stroke, spacing, &length_residue, data + 2 * j, data + 2 * (j + 1)); } } else { - paint_line_strokes_spacing(C, op, stroke, spacing, &length_residue, data + 2 * j, data + 2 * (j + 1)); + paint_line_strokes_spacing( + C, op, stroke, spacing, &length_residue, data + 2 * j, data + 2 * (j + 1)); } } } @@ -1148,7 +1179,9 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) float pressure; /* see if tablet affects event. Line, anchored and drag dot strokes do not support pressure */ - pressure = (br->flag & (BRUSH_LINE | BRUSH_ANCHORED | BRUSH_DRAG_DOT)) ? 1.0f : WM_event_tablet_data(event, &stroke->pen_flip, NULL); + pressure = ( + (br->flag & (BRUSH_LINE | BRUSH_ANCHORED | BRUSH_DRAG_DOT)) ? + 1.0f : WM_event_tablet_data(event, &stroke->pen_flip, NULL)); paint_stroke_add_sample(p, stroke, event->mval[0], event->mval[1], pressure); paint_stroke_sample_average(stroke, &sample_average); @@ -1350,7 +1383,7 @@ void paint_stroke_set_mode_data(PaintStroke *stroke, void *mode_data) stroke->mode_data = mode_data; } -int paint_poll(bContext *C) +bool paint_poll(bContext *C) { Paint *p = BKE_paint_get_active_from_context(C); Object *ob = CTX_data_active_object(C); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 80c4d4099a2..697ffc32759 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -65,6 +65,7 @@ #include "GPU_glew.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "IMB_colormanagement.h" #include "IMB_imbuf_types.h" @@ -86,12 +87,13 @@ /* Convert the object-space axis-aligned bounding box (expressed as * its minimum and maximum corners) into a screen-space rectangle, * returns zero if the result is empty */ -bool paint_convert_bb_to_rect(rcti *rect, - const float bb_min[3], - const float bb_max[3], - const ARegion *ar, - RegionView3D *rv3d, - Object *ob) +bool paint_convert_bb_to_rect( + rcti *rect, + const float bb_min[3], + const float bb_max[3], + const ARegion *ar, + RegionView3D *rv3d, + Object *ob) { float projection_mat[4][4]; int i, j, k; @@ -132,10 +134,11 @@ bool paint_convert_bb_to_rect(rcti *rect, /* Get four planes in object-space that describe the projection of * screen_rect from screen into object-space (essentially converting a * 2D screens-space bounding box into four 3D planes) */ -void paint_calc_redraw_planes(float planes[4][4], - const ARegion *ar, - Object *ob, - const rcti *screen_rect) +void paint_calc_redraw_planes( + float planes[4][4], + const ARegion *ar, + Object *ob, + const rcti *screen_rect) { BoundBox bb; rcti rect; @@ -151,8 +154,9 @@ void paint_calc_redraw_planes(float planes[4][4], negate_m4(planes); } -float paint_calc_object_space_radius(ViewContext *vc, const float center[3], - float pixel_radius) +float paint_calc_object_space_radius( + ViewContext *vc, const float center[3], + float pixel_radius) { Object *ob = vc->obact; float delta[3], scale, loc[3]; @@ -181,7 +185,9 @@ float paint_get_tex_pixel(const MTex *mtex, float u, float v, struct ImagePool * return intensity; } -void paint_get_tex_pixel_col(const MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert_to_linear, struct ColorSpace *colorspace) +void paint_get_tex_pixel_col( + const MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, + int thread, bool convert_to_linear, struct ColorSpace *colorspace) { float co[3] = {u, v, 0.0f}; int hasrgb; @@ -237,9 +243,10 @@ static void imapaint_project(float matrix[4][4], const float co[3], float pco[4] mul_m4_v4(matrix, pco); } -static void imapaint_tri_weights(float matrix[4][4], GLint view[4], - const float v1[3], const float v2[3], const float v3[3], - const float co[2], float w[3]) +static void imapaint_tri_weights( + float matrix[4][4], GLint view[4], + const float v1[3], const float v2[3], const float v3[3], + const float co[2], float w[3]) { float pv1[4], pv2[4], pv3[4], h[3], divw; float wmat[3][3], invwmat[3][3]; @@ -291,7 +298,7 @@ static void imapaint_pick_uv(Mesh *me_eval, Scene *scene, Object *ob_eval, unsig const int *index_mp_to_orig = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX); /* get the needed opengl matrices */ - glGetIntegerv(GL_VIEWPORT, view); + GPU_viewport_size_get_i(view); gpuGetModelViewMatrix(matrix); gpuGetProjectionMatrix(proj); view[0] = view[1] = 0; @@ -567,7 +574,7 @@ static int brush_curve_preset_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int brush_curve_preset_poll(bContext *C) +static bool brush_curve_preset_poll(bContext *C) { Brush *br = BKE_paint_brush(BKE_paint_get_active_from_context(C)); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 85a1f11be4b..dd03c07a43f 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -201,14 +201,14 @@ static void paint_last_stroke_update(Scene *scene, ARegion *ar, const float mval /* polling - retrieve whether cursor should be set or operator should be done */ /* Returns true if vertex paint mode is active */ -int vertex_paint_mode_poll(bContext *C) +bool vertex_paint_mode_poll(bContext *C) { Object *ob = CTX_data_active_object(C); return ob && ob->mode == OB_MODE_VERTEX_PAINT && ((Mesh *)ob->data)->totpoly; } -static int vertex_paint_poll_ex(bContext *C, bool check_tool) +static bool vertex_paint_poll_ex(bContext *C, bool check_tool) { if (vertex_paint_mode_poll(C) && BKE_paint_brush(&CTX_data_tool_settings(C)->vpaint->paint)) @@ -226,24 +226,24 @@ static int vertex_paint_poll_ex(bContext *C, bool check_tool) return 0; } -int vertex_paint_poll(bContext *C) +bool vertex_paint_poll(bContext *C) { return vertex_paint_poll_ex(C, true); } -int vertex_paint_poll_ignore_tool(bContext *C) +bool vertex_paint_poll_ignore_tool(bContext *C) { return vertex_paint_poll_ex(C, true); } -int weight_paint_mode_poll(bContext *C) +bool weight_paint_mode_poll(bContext *C) { Object *ob = CTX_data_active_object(C); return ob && ob->mode == OB_MODE_WEIGHT_PAINT && ((Mesh *)ob->data)->totpoly; } -static int weight_paint_poll_ex(bContext *C, bool check_tool) +static bool weight_paint_poll_ex(bContext *C, bool check_tool) { Object *ob = CTX_data_active_object(C); ScrArea *sa; @@ -264,12 +264,12 @@ static int weight_paint_poll_ex(bContext *C, bool check_tool) return 0; } -int weight_paint_poll(bContext *C) +bool weight_paint_poll(bContext *C) { return weight_paint_poll_ex(C, true); } -int weight_paint_poll_ignore_tool(bContext *C) +bool weight_paint_poll_ignore_tool(bContext *C) { return weight_paint_poll_ex(C, false); } @@ -1282,7 +1282,7 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op) } /* for switching to/from mode */ -static int paint_poll_test(bContext *C) +static bool paint_poll_test(bContext *C) { Object *ob = CTX_data_active_object(C); if (ob == NULL || ob->type != OB_MESH) @@ -1510,8 +1510,9 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo wpd = MEM_callocN(sizeof(struct WPaintData), "WPaintData"); paint_stroke_set_mode_data(stroke, wpd); ED_view3d_viewcontext_init(C, &wpd->vc); - view_angle_limits_init(&wpd->normal_angle_precalc, vp->paint.brush->falloff_angle, - (vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0); + view_angle_limits_init( + &wpd->normal_angle_precalc, vp->paint.brush->falloff_angle, + (vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0); wpd->active.index = vgroup_index.active; wpd->mirror.index = vgroup_index.mirror; @@ -2512,13 +2513,13 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f vpd = MEM_callocN(sizeof(*vpd), "VPaintData"); paint_stroke_set_mode_data(stroke, vpd); ED_view3d_viewcontext_init(C, &vpd->vc); - view_angle_limits_init(&vpd->normal_angle_precalc, vp->paint.brush->falloff_angle, - (vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0); + view_angle_limits_init( + &vpd->normal_angle_precalc, vp->paint.brush->falloff_angle, + (vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0); vpd->paintcol = vpaint_get_current_col(scene, vp); - vpd->is_texbrush = !(brush->vertexpaint_tool == PAINT_BLEND_BLUR) && - brush->mtex.tex; + vpd->is_texbrush = !(brush->vertexpaint_tool == PAINT_BLEND_BLUR) && brush->mtex.tex; /* are we painting onto a modified mesh?, * if not we can skip face map trickiness */ @@ -3258,4 +3259,3 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot) paint_stroke_operator_properties(ot); } - diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c index 8516d92214d..4c8ca493cd1 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c @@ -49,7 +49,7 @@ #include "paint_intern.h" /* own include */ -static int vertex_weight_paint_mode_poll(bContext *C) +static bool vertex_weight_paint_mode_poll(bContext *C) { Object *ob = CTX_data_active_object(C); Mesh *me = BKE_mesh_from_object(ob); diff --git a/source/blender/editors/sculpt_paint/paint_vertex_proj.c b/source/blender/editors/sculpt_paint/paint_vertex_proj.c index cacfdc2dbba..602bfe1ab8e 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_proj.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_proj.c @@ -28,7 +28,7 @@ * \ingroup edsculpt * * Utility functions for getting vertex locations while painting - * (since they may be instanced multiple times in a DerivedMesh) + * (since they may be instanced multiple times in an evaluated mesh) */ #include "MEM_guardedalloc.h" @@ -39,8 +39,9 @@ #include "DNA_mesh_types.h" #include "DNA_object_types.h" -#include "BKE_DerivedMesh.h" +#include "BKE_DerivedMesh.h" /* XXX To be removed, only used for DMCoNo struct */ #include "BKE_context.h" +#include "BKE_mesh_iterators.h" #include "BKE_mesh_runtime.h" #include "DEG_depsgraph.h" @@ -107,24 +108,10 @@ static void vpaint_proj_dm_map_cosnos_init( struct VertProjHandle *vp_handle) { Mesh *me = ob->data; - DerivedMesh *dm; + Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); - dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); - - if (dm->foreachMappedVert) { - memset(vp_handle->vcosnos, 0, sizeof(DMCoNo) * me->totvert); - dm->foreachMappedVert(dm, vpaint_proj_dm_map_cosnos_init__map_cb, vp_handle, DM_FOREACH_USE_NORMAL); - } - else { - DMCoNo *v_co_no = vp_handle->vcosnos; - int a; - for (a = 0; a < me->totvert; a++, v_co_no++) { - dm->getVertCo(dm, a, v_co_no->co); - dm->getVertNo(dm, a, v_co_no->no); - } - } - - dm->release(dm); + memset(vp_handle->vcosnos, 0, sizeof(*vp_handle->vcosnos) * me->totvert); + BKE_mesh_foreach_mapped_vert(me_eval, vpaint_proj_dm_map_cosnos_init__map_cb, vp_handle, MESH_FOREACH_USE_NORMAL); } @@ -185,21 +172,13 @@ static void vpaint_proj_dm_map_cosnos_update( Scene *scene = vp_handle->scene; Object *ob = vp_handle->ob; Mesh *me = ob->data; - DerivedMesh *dm; + Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); /* quick sanity check - we shouldn't have to run this if there are no modifiers */ BLI_assert(BLI_listbase_is_empty(&ob->modifiers) == false); - dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); - - /* highly unlikely this will become unavailable once painting starts (perhaps with animated modifiers) */ - if (LIKELY(dm->foreachMappedVert)) { - copy_vn_fl(vp_handle->dists_sq, me->totvert, FLT_MAX); - - dm->foreachMappedVert(dm, vpaint_proj_dm_map_cosnos_update__map_cb, &vp_update, DM_FOREACH_USE_NORMAL); - } - - dm->release(dm); + copy_vn_fl(vp_handle->dists_sq, me->totvert, FLT_MAX); + BKE_mesh_foreach_mapped_vert(me_eval, vpaint_proj_dm_map_cosnos_update__map_cb, &vp_update, MESH_FOREACH_USE_NORMAL); } diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c index 01c62704db3..436f4ac5993 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c @@ -35,8 +35,8 @@ #include "IMB_imbuf_types.h" #include "IMB_colormanagement.h" -//#include "DNA_armature_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_particle_types.h" #include "DNA_brush_types.h" #include "DNA_object_types.h" @@ -46,7 +46,6 @@ #include "RNA_define.h" #include "RNA_enum_types.h" -#include "BKE_DerivedMesh.h" #include "BKE_brush.h" #include "BKE_context.h" #include "BKE_deform.h" @@ -118,7 +117,7 @@ static void wpaint_prev_destroy(struct WPaintPrev *wpp) /** \name Weight from Bones Operator * \{ */ -static int weight_from_bones_poll(bContext *C) +static bool weight_from_bones_poll(bContext *C) { Object *ob = CTX_data_active_object(C); @@ -152,8 +151,9 @@ void PAINT_OT_weight_from_bones(wmOperatorType *ot) /* identifiers */ ot->name = "Weight from Bones"; ot->idname = "PAINT_OT_weight_from_bones"; - ot->description = "Set the weights of the groups matching the attached armature's selected bones, " - "using the distance between the vertices and the bones"; + ot->description = ( + "Set the weights of the groups matching the attached armature's selected bones, " + "using the distance between the vertices and the bones"); /* api callbacks */ ot->exec = weight_from_bones_exec; @@ -644,9 +644,10 @@ static void gradientVertInit__mapFunc( if (BLI_BITMAP_TEST(grad_data->vert_visit, index) == 0) { WPGradient_vertStore *vs = &grad_data->vert_cache->elem[index]; - if (ED_view3d_project_float_object(grad_data->ar, - co, vs->sco, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) + if (ED_view3d_project_float_object( + grad_data->ar, + co, vs->sco, + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) { /* ok */ MDeformVert *dv = &me->dvert[index]; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 414b9f2062f..a5871c90d56 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4082,25 +4082,25 @@ static void sculpt_update_tex(const Scene *scene, Sculpt *sd, SculptSession *ss) -int sculpt_mode_poll(bContext *C) +bool sculpt_mode_poll(bContext *C) { Object *ob = CTX_data_active_object(C); return ob && ob->mode & OB_MODE_SCULPT; } -int sculpt_mode_poll_view3d(bContext *C) +bool sculpt_mode_poll_view3d(bContext *C) { return (sculpt_mode_poll(C) && CTX_wm_region_view3d(C)); } -int sculpt_poll_view3d(bContext *C) +bool sculpt_poll_view3d(bContext *C) { return (sculpt_poll(C) && CTX_wm_region_view3d(C)); } -int sculpt_poll(bContext *C) +bool sculpt_poll(bContext *C) { return sculpt_mode_poll(C) && paint_poll(C); } @@ -5537,7 +5537,7 @@ static int sculpt_optimize_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static int sculpt_and_dynamic_topology_poll(bContext *C) +static bool sculpt_and_dynamic_topology_poll(bContext *C) { Object *ob = CTX_data_active_object(C); @@ -5853,7 +5853,7 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot) } -static int sculpt_and_dynamic_topology_constant_detail_poll(bContext *C) +static bool sculpt_and_dynamic_topology_constant_detail_poll(bContext *C) { Object *ob = CTX_data_active_object(C); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; @@ -5970,8 +5970,7 @@ static int sculpt_sample_detail_size_exec(bContext *C, wmOperator *op) static int sculpt_sample_detail_size_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e)) { - ScrArea *sa = CTX_wm_area(C); - ED_area_headerprint(sa, "Click on the mesh to set the detail"); + ED_workspace_status_text(C, "Click on the mesh to set the detail"); WM_cursor_modal_set(CTX_wm_window(C), BC_EYEDROPPER_CURSOR); WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; @@ -5982,14 +5981,13 @@ static int sculpt_sample_detail_size_modal(bContext *C, wmOperator *op, const wm switch (e->type) { case LEFTMOUSE: if (e->val == KM_PRESS) { - ScrArea *sa = CTX_wm_area(C); int ss_co[2] = {e->mval[0], e->mval[1]}; sample_detail(C, ss_co); RNA_int_set_array(op->ptr, "location", ss_co); WM_cursor_modal_restore(CTX_wm_window(C)); - ED_area_headerprint(sa, NULL); + ED_workspace_status_text(C, NULL); WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL); return OPERATOR_FINISHED; @@ -5998,9 +5996,8 @@ static int sculpt_sample_detail_size_modal(bContext *C, wmOperator *op, const wm case RIGHTMOUSE: { - ScrArea *sa = CTX_wm_area(C); WM_cursor_modal_restore(CTX_wm_window(C)); - ED_area_headerprint(sa, NULL); + ED_workspace_status_text(C, NULL); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index ff6b5a6f374..2154061da1b 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -48,11 +48,11 @@ struct Object; struct SculptUndoNode; struct SculptOrigVertData; -int sculpt_mode_poll(struct bContext *C); -int sculpt_mode_poll_view3d(struct bContext *C); +bool sculpt_mode_poll(struct bContext *C); +bool sculpt_mode_poll_view3d(struct bContext *C); /* checks for a brush, not just sculpt mode */ -int sculpt_poll(struct bContext *C); -int sculpt_poll_view3d(struct bContext *C); +bool sculpt_poll(struct bContext *C); +bool sculpt_poll_view3d(struct bContext *C); /* Stroke */ bool sculpt_stroke_get_location(struct bContext *C, float out[3], const float mouse[2]); diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 2872ad4fb9c..bc22147b15d 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -561,7 +561,7 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb) else { BKE_pbvh_search_callback(ss->pbvh, NULL, NULL, update_cb, &rebuild); } - BKE_pbvh_update(ss->pbvh, PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateRedraw, NULL); + BKE_pbvh_update(ss->pbvh, PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateRedraw | PBVH_UpdateNormals, NULL); if (BKE_sculpt_multires_active(scene, ob)) { if (rebuild) diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index cf9feae62b5..29b258fc80d 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -59,6 +59,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" +#include "GPU_state.h" #include "WM_api.h" #include "WM_types.h" @@ -159,7 +160,7 @@ static Brush *uv_sculpt_brush(bContext *C) } -static int uv_sculpt_brush_poll_do(bContext *C, const bool check_region) +static bool uv_sculpt_brush_poll_do(bContext *C, const bool check_region) { BMEditMesh *em; int ret; @@ -187,7 +188,7 @@ static int uv_sculpt_brush_poll_do(bContext *C, const bool check_region) return ret; } -static int uv_sculpt_brush_poll(bContext *C) +static bool uv_sculpt_brush_poll(bContext *C) { return uv_sculpt_brush_poll_do(C, true); } @@ -218,11 +219,11 @@ static void brush_drawcursor_uvsculpt(bContext *C, int x, int y, void *UNUSED(cu immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3fvAlpha(brush->add_col, alpha); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); + GPU_line_smooth(true); + GPU_blend(true); imm_draw_circle_wire_2d(pos, (float)x, (float)y, size, 40); - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); + GPU_blend(false); + GPU_line_smooth(false); immUnbindProgram(); } @@ -246,8 +247,9 @@ void ED_space_image_uv_sculpt_update(Main *bmain, wmWindowManager *wm, Scene *sc BKE_paint_init(bmain, scene, ePaintSculptUV, PAINT_CURSOR_SCULPT); - settings->uvsculpt->paint.paint_cursor = WM_paint_cursor_activate(wm, uv_sculpt_brush_poll, - brush_drawcursor_uvsculpt, NULL); + settings->uvsculpt->paint.paint_cursor = WM_paint_cursor_activate( + wm, uv_sculpt_brush_poll, + brush_drawcursor_uvsculpt, NULL); } else { if (settings->uvsculpt) { @@ -257,12 +259,12 @@ void ED_space_image_uv_sculpt_update(Main *bmain, wmWindowManager *wm, Scene *sc } } -int uv_sculpt_poll(bContext *C) +bool uv_sculpt_poll(bContext *C) { return uv_sculpt_brush_poll_do(C, true); } -int uv_sculpt_keymap_poll(bContext *C) +bool uv_sculpt_keymap_poll(bContext *C) { return uv_sculpt_brush_poll_do(C, false); } diff --git a/source/blender/editors/sound/sound_intern.h b/source/blender/editors/sound/sound_intern.h index c1516c0f25e..d95f473e4d9 100644 --- a/source/blender/editors/sound/sound_intern.h +++ b/source/blender/editors/sound/sound_intern.h @@ -34,4 +34,3 @@ #endif /* __SOUND_INTERN_H__ */ - diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 049feea2d8a..3fc68a50057 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -703,7 +703,7 @@ static void SOUND_OT_mixdown(wmOperatorType *ot) /* ******************************************************* */ -static int sound_poll(bContext *C) +static bool sound_poll(bContext *C) { Editing *ed = CTX_data_scene(C)->ed; diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c index 74c9f2f8cfb..8d4596a79a7 100644 --- a/source/blender/editors/space_action/action_data.c +++ b/source/blender/editors/space_action/action_data.c @@ -175,7 +175,7 @@ static void actedit_change_action(bContext *C, bAction *act) * The NLA Editor is active (i.e. Animation Data panel -> new action) * 2) The associated AnimData block must not be in tweakmode */ -static int action_new_poll(bContext *C) +static bool action_new_poll(bContext *C) { Scene *scene = CTX_data_scene(C); @@ -295,7 +295,7 @@ void ACTION_OT_new(wmOperatorType *ot) * 2) There must be an action active * 3) The associated AnimData block must not be in tweakmode */ -static int action_pushdown_poll(bContext *C) +static bool action_pushdown_poll(bContext *C) { if (ED_operator_action_active(C)) { SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); @@ -426,7 +426,7 @@ void ACTION_OT_stash(wmOperatorType *ot) * 1) There must be an dopesheet/action editor, and it must be in a mode which uses actions * 2) The associated AnimData block must not be in tweakmode */ -static int action_stash_create_poll(bContext *C) +static bool action_stash_create_poll(bContext *C) { if (ED_operator_action_active(C)) { AnimData *adt = ED_actedit_animdata_from_context(C); @@ -618,7 +618,7 @@ void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act, /* -------------------------- */ -static int action_unlink_poll(bContext *C) +static bool action_unlink_poll(bContext *C) { if (ED_operator_action_active(C)) { SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); @@ -749,7 +749,7 @@ static void action_layer_switch_strip(AnimData *adt, /* ********************** One Layer Up Operator ************************** */ -static int action_layer_next_poll(bContext *C) +static bool action_layer_next_poll(bContext *C) { /* Action Editor's action editing modes only */ if (ED_operator_action_active(C)) { @@ -860,7 +860,7 @@ void ACTION_OT_layer_next(wmOperatorType *ot) /* ********************* One Layer Down Operator ************************* */ -static int action_layer_prev_poll(bContext *C) +static bool action_layer_prev_poll(bContext *C) { /* Action Editor's action editing modes only */ if (ED_operator_action_active(C)) { diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 35ebb62a7cc..6105652a4c7 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -59,6 +59,7 @@ #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "UI_interface.h" #include "UI_resources.h" @@ -215,7 +216,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - glEnable(GL_BLEND); + GPU_blend(true); for (ale = anim_data.first; ale; ale = ale->next) { const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); @@ -319,7 +320,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) /* Increment the step */ y -= ACHANNEL_STEP(ac); } - glDisable(GL_BLEND); + GPU_blend(false); /* black line marking 'current frame' for Time-Slide transform mode */ if (saction->flag & SACTION_MOVING) { @@ -475,7 +476,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene) const int sta = pid->cache->startframe, end = pid->cache->endframe; const int len = (end - sta + 1) * 6; - glEnable(GL_BLEND); + GPU_blend(true); immUniformColor4fv(col); immRectf(pos, (float)sta, 0.0, (float)end, 1.0); @@ -509,7 +510,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene) immEnd(); } - glDisable(GL_BLEND); + GPU_blend(false); gpuPopMatrix(); diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index a9f9488d049..1d8766ba773 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -93,7 +93,7 @@ * 3) that the set of markers being shown are the scene markers, not the list we're merging * 4) that there are some selected markers */ -static int act_markers_make_local_poll(bContext *C) +static bool act_markers_make_local_poll(bContext *C) { SpaceAction *sact = CTX_wm_space_action(C); @@ -1491,7 +1491,7 @@ void ACTION_OT_keyframe_type(wmOperatorType *ot) /* ***************** Jump to Selected Frames Operator *********************** */ -static int actkeys_framejump_poll(bContext *C) +static bool actkeys_framejump_poll(bContext *C) { /* prevent changes during render */ if (G.is_rendering) diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index 25d3560b175..fc1f40cdb5a 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -153,4 +153,3 @@ void action_operatortypes(void); void action_keymap(struct wmKeyConfig *keyconf); #endif /* __ACTION_INTERN_H__ */ - diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 83bda4d63a5..11145e29627 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -1590,7 +1590,7 @@ void ACTION_OT_clickselect(wmOperatorType *ot) PropertyRNA *prop; /* identifiers */ - ot->name = "Mouse Select Keys"; + ot->name = "Select Keyframes"; ot->idname = "ACTION_OT_clickselect"; ot->description = "Select keyframes by clicking on them"; diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 527e382ec1e..876b73a4a76 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -47,6 +47,8 @@ #include "BKE_screen.h" #include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" #include "WM_api.h" #include "WM_types.h" @@ -63,6 +65,7 @@ #include "ED_markers.h" #include "action_intern.h" /* own include */ +#include "GPU_framebuffer.h" /* ******************** manage regions ********************* */ @@ -102,6 +105,7 @@ static SpaceLink *action_new(const ScrArea *sa, const Scene *scene) saction->autosnap = SACTSNAP_FRAME; saction->mode = SACTCONT_DOPESHEET; + saction->mode_prev = SACTCONT_DOPESHEET; saction->ads.filterflag |= ADS_FILTER_SUMMARY; @@ -223,7 +227,7 @@ static void action_main_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); @@ -309,7 +313,7 @@ static void action_channel_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); @@ -835,6 +839,37 @@ static void action_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, I } +/** + * \note Used for splitting out a subset of modes is more involved, + * The previous non-timeline mode is stored so switching back to the + * dope-sheet doesn't always reset the sub-mode. + */ +static int action_space_subtype_get(ScrArea *sa) +{ + SpaceAction *sact = sa->spacedata.first; + return sact->mode == SACTCONT_TIMELINE ? SACTCONT_TIMELINE : SACTCONT_DOPESHEET; +} + +static void action_space_subtype_set(ScrArea *sa, int value) +{ + SpaceAction *sact = sa->spacedata.first; + if (value == SACTCONT_TIMELINE) { + if (sact->mode != SACTCONT_TIMELINE) { + sact->mode_prev = sact->mode; + } + sact->mode = value; + } + else { + sact->mode = sact->mode_prev; + } +} + +static void action_space_subtype_item_extend( + bContext *UNUSED(C), EnumPropertyItem **item, int *totitem) +{ + RNA_enum_items_add(item, totitem, rna_enum_space_action_mode_items); +} + /* only called once, from space/spacetypes.c */ void ED_spacetype_action(void) { @@ -853,6 +888,9 @@ void ED_spacetype_action(void) st->listener = action_listener; st->refresh = action_refresh; st->id_remap = action_id_remap; + st->space_subtype_item_extend = action_space_subtype_item_extend; + st->space_subtype_get = action_space_subtype_get; + st->space_subtype_set = action_space_subtype_set; /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype action region"); diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 33ec7f771ba..2ee791e81d6 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -127,6 +127,8 @@ void ED_spacetypes_init(void) ED_operatortypes_view2d(); ED_operatortypes_ui(); + ED_screen_user_menu_register(); + /* manipulator types */ ED_manipulatortypes_button_2d(); ED_manipulatortypes_dial_3d(); diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h index 2219b2a932c..aab7b39484d 100644 --- a/source/blender/editors/space_buttons/buttons_intern.h +++ b/source/blender/editors/space_buttons/buttons_intern.h @@ -98,7 +98,6 @@ void buttons_texture_context_compute(const struct bContext *C, struct SpaceButs /* buttons_ops.c */ void BUTTONS_OT_file_browse(struct wmOperatorType *ot); void BUTTONS_OT_directory_browse(struct wmOperatorType *ot); -void BUTTONS_OT_toolbox(struct wmOperatorType *ot); +void BUTTONS_OT_context_menu(struct wmOperatorType *ot); #endif /* __BUTTONS_INTERN_H__ */ - diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 47f97b8087f..93670919d4c 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -60,9 +60,9 @@ #include "buttons_intern.h" /* own include */ -/********************** toolbox operator *********************/ +/********************** context_menu operator *********************/ -static int toolbox_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) +static int context_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) { bScreen *sc = CTX_wm_screen(C); SpaceButs *sbuts = CTX_wm_space_buts(C); @@ -80,15 +80,15 @@ static int toolbox_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UN return OPERATOR_INTERFACE; } -void BUTTONS_OT_toolbox(wmOperatorType *ot) +void BUTTONS_OT_context_menu(wmOperatorType *ot) { /* identifiers */ - ot->name = "Toolbox"; - ot->description = "Display button panel toolbox"; - ot->idname = "BUTTONS_OT_toolbox"; + ot->name = "Context Menu"; + ot->description = "Display button panel context_menu"; + ot->idname = "BUTTONS_OT_context_menu"; /* api callbacks */ - ot->invoke = toolbox_invoke; + ot->invoke = context_menu_invoke; ot->poll = ED_operator_buttons_active; } diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 4fe3423e730..a951c2a8524 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -298,7 +298,7 @@ static void buttons_main_region_listener( static void buttons_operatortypes(void) { - WM_operatortype_append(BUTTONS_OT_toolbox); + WM_operatortype_append(BUTTONS_OT_context_menu); WM_operatortype_append(BUTTONS_OT_file_browse); WM_operatortype_append(BUTTONS_OT_directory_browse); } @@ -307,7 +307,7 @@ static void buttons_keymap(struct wmKeyConfig *keyconf) { wmKeyMap *keymap = WM_keymap_find(keyconf, "Property Editor", SPACE_BUTS, 0); - WM_keymap_add_item(keymap, "BUTTONS_OT_toolbox", RIGHTMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "BUTTONS_OT_context_menu", RIGHTMOUSE, KM_PRESS, 0, 0); } /* add handlers, stuff you only do once or on area/region changes */ @@ -632,4 +632,3 @@ void ED_spacetype_buttons(void) BKE_spacetype_register(st); } - diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index f2fe06874d7..db5f6c2451c 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -77,7 +77,7 @@ void ED_clip_buttons_register(ARegionType *UNUSED(art)) /********************* MovieClip Template ************************/ -void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, int compact) +void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, bool compact) { PropertyRNA *prop; PointerRNA clipptr; @@ -333,7 +333,7 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) } void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *userptr, - PointerRNA *trackptr, int compact) + PointerRNA *trackptr, bool compact) { PropertyRNA *prop; uiBlock *block; diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index bc2aa3ae67f..d50d10d5cc3 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -54,6 +54,7 @@ #include "GPU_draw.h" #include "GPU_immediate.h" +#include "GPU_state.h" #include "clip_intern.h" /* own include */ @@ -147,7 +148,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) strip[3] = 0.5f; selected_strip[3] = 1.0f; - glEnable(GL_BLEND); + GPU_blend(true); clip_draw_dopesheet_background(ar, clip, pos_id); @@ -279,7 +280,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) immUnbindProgram(); } - glDisable(GL_BLEND); + GPU_blend(false); } } @@ -378,7 +379,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) PropertyRNA *chan_prop_lock = RNA_struct_type_find_property(&RNA_MovieTrackingTrack, "lock"); BLI_assert(chan_prop_lock); - glEnable(GL_BLEND); + GPU_blend(true); for (channel = dopesheet->channels.first; channel; channel = channel->next) { float yminc = (float)(y - CHANNEL_HEIGHT_HALF); float ymaxc = (float)(y + CHANNEL_HEIGHT_HALF); @@ -403,7 +404,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) /* adjust y-position for next one */ y -= CHANNEL_STEP; } - glDisable(GL_BLEND); + GPU_blend(false); UI_block_end(C, block); UI_block_draw(C, block); diff --git a/source/blender/editors/space_clip/clip_dopesheet_ops.c b/source/blender/editors/space_clip/clip_dopesheet_ops.c index c8675fc390b..a12e8db6daf 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_ops.c +++ b/source/blender/editors/space_clip/clip_dopesheet_ops.c @@ -53,7 +53,7 @@ #include "clip_intern.h" // own include -static int space_clip_dopesheet_poll(bContext *C) +static bool space_clip_dopesheet_poll(bContext *C) { if (ED_space_clip_tracking_poll(C)) { SpaceClip *sc = CTX_wm_space_clip(C); @@ -70,7 +70,7 @@ static int space_clip_dopesheet_poll(bContext *C) /********************** select channel operator *********************/ -static int dopesheet_select_channel_poll(bContext *C) +static bool dopesheet_select_channel_poll(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 5962bfe33f3..909f0a55c1c 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -60,6 +60,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "WM_types.h" @@ -156,8 +157,8 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc MovieTrackingPlaneTrack *act_plane_track = BKE_tracking_plane_track_get_active(&clip->tracking); MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); /* cache background */ ED_region_cache_draw_background(ar); @@ -235,7 +236,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc } } - glDisable(GL_BLEND); + GPU_blend(false); /* current frame */ x = (sc->user.framenr - sfra) / (efra - sfra + 1) * ar->winx; @@ -313,8 +314,8 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, /* checkerboard for case alpha */ if (ibuf->planes == 32) { - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); imm_draw_box_checker_2d(x, y, x + zoomx * ibuf->x, y + zoomy * ibuf->y); } @@ -335,7 +336,7 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, } if (ibuf->planes == 32) - glDisable(GL_BLEND); + GPU_blend(false); } static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int height, float zoomx, float zoomy) @@ -364,10 +365,10 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); - immUniform1i("num_colors", 0); /* "simple" mode */ + immUniform1i("colors_len", 0); /* "simple" mode */ immUniformColor4f(1.0f, 1.0f, 1.0f, 0.0f); immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); @@ -460,7 +461,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if (TRACK_VIEW_SELECTED(sc, track)) { if ((b - a - 1) >= 1) { - glPointSize(5.0f); + GPU_point_size(5.0f); immBegin(GWN_PRIM_POINTS, b - a - 1); @@ -475,7 +476,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin } if ((b - a) >= 2) { - glLineWidth(3.0f); + GPU_line_width(3.0f); immBegin(GWN_PRIM_LINE_STRIP, b - a); @@ -488,7 +489,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin } if (TRACK_VIEW_SELECTED(sc, track)) { - glPointSize(3.0f); + GPU_point_size(3.0f); if ((curindex - a) >= 1) { immUniformThemeColor(TH_PATH_BEFORE); @@ -515,7 +516,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin } } - glLineWidth(1); + GPU_line_width(1); if ((curindex - a + 1) >= 2) { immUniformThemeColor(TH_PATH_BEFORE); @@ -559,7 +560,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT px[0] = 1.0f / width / sc->zoom; px[1] = 1.0f / height / sc->zoom; - glLineWidth(tiny ? 1.0f : 3.0f); + GPU_line_width(tiny ? 1.0f : 3.0f); immUniformThemeColor(TH_MARKER_OUTLINE); @@ -576,7 +577,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT if (isect_point_quad_v2(p, marker->pattern_corners[0], marker->pattern_corners[1], marker->pattern_corners[2], marker->pattern_corners[3])) { - glPointSize(tiny ? 3.0f : 4.0f); + GPU_point_size(tiny ? 3.0f : 4.0f); immBegin(GWN_PRIM_POINTS, 1); immVertex2f(position, pos[0], pos[1]); @@ -660,7 +661,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra px[0] = 1.0f / width / sc->zoom; px[1] = 1.0f / height / sc->zoom; - glLineWidth(1.0f); + GPU_line_width(1.0f); /* Since we are switching solid and dashed lines in rather complex logic here, just always go with dashed shader. */ immUnbindProgram(); @@ -668,10 +669,10 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); - immUniform1i("num_colors", 0); /* "simple" mode */ + immUniform1i("colors_len", 0); /* "simple" mode */ /* marker position and offset position */ if ((track->flag & SELECT) == sel && (marker->flag & MARKER_DISABLED) == 0) { @@ -700,7 +701,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra if (isect_point_quad_v2(p, marker->pattern_corners[0], marker->pattern_corners[1], marker->pattern_corners[2], marker->pattern_corners[3])) { - glPointSize(tiny ? 1.0f : 2.0f); + GPU_point_size(tiny ? 1.0f : 2.0f); immUniform1f("dash_factor", 2.0f); /* Solid "line" */ @@ -932,7 +933,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max); - glLineWidth(outline ? 3.0f : 1.0f); + GPU_line_width(outline ? 3.0f : 1.0f); immBegin(GWN_PRIM_LINES, 2); immVertex2f(pos, 0.0f, 0.0f); @@ -1125,8 +1126,8 @@ static void draw_plane_marker_image(Scene *scene, if (plane_track->image_opacity != 1.0f || ibuf->planes == 32) { transparent = true; - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); } glGenTextures(1, (GLuint *)&texid); @@ -1174,7 +1175,7 @@ static void draw_plane_marker_image(Scene *scene, glBindTexture(GL_TEXTURE_2D, 0); if (transparent) { - glDisable(GL_BLEND); + GPU_blend(false); } } @@ -1210,16 +1211,16 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); - immUniform1i("num_colors", 0); /* "simple" mode */ + immUniform1i("colors_len", 0); /* "simple" mode */ if (draw_plane_quad) { const bool stipple = !draw_outline && tiny; const bool thick = draw_outline && !tiny; - glLineWidth(thick ? 3.0f : 1.0f); + GPU_line_width(thick ? 3.0f : 1.0f); if (stipple) { immUniform1f("dash_width", 6.0f); @@ -1483,7 +1484,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie MovieTrackingObject *object = BKE_tracking_object_get_active(tracking); float pos[4], vec[4], mat[4][4], aspy; - glPointSize(3.0f); + GPU_point_size(3.0f); aspy = 1.0f / clip->tracking.camera.pixel_aspect; BKE_tracking_get_projection_matrix(tracking, object, framenr, width, height, mat); @@ -1711,8 +1712,8 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, immUniformColor4fv(layer->color); - glLineWidth(layer->thickness); - glPointSize((float)(layer->thickness + 2)); + GPU_line_width(layer->thickness); + GPU_point_size((float)(layer->thickness + 2)); while (frame) { bGPDstroke *stroke = frame->strokes.first; diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 67aa7e19de7..0fb7d63180f 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -76,7 +76,7 @@ /* ******** operactor poll functions ******** */ -int ED_space_clip_poll(bContext *C) +bool ED_space_clip_poll(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); @@ -86,7 +86,7 @@ int ED_space_clip_poll(bContext *C) return false; } -int ED_space_clip_view_clip_poll(bContext *C) +bool ED_space_clip_view_clip_poll(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); @@ -97,7 +97,7 @@ int ED_space_clip_view_clip_poll(bContext *C) return false; } -int ED_space_clip_tracking_poll(bContext *C) +bool ED_space_clip_tracking_poll(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); @@ -107,7 +107,7 @@ int ED_space_clip_tracking_poll(bContext *C) return false; } -int ED_space_clip_maskedit_poll(bContext *C) +bool ED_space_clip_maskedit_poll(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); @@ -118,7 +118,7 @@ int ED_space_clip_maskedit_poll(bContext *C) return false; } -int ED_space_clip_maskedit_mask_poll(bContext *C) +bool ED_space_clip_maskedit_mask_poll(bContext *C) { if (ED_space_clip_maskedit_poll(C)) { MovieClip *clip = CTX_data_edit_movieclip(C); diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 8d29cb73a68..d463f585470 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -45,6 +45,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "WM_types.h" @@ -80,11 +81,11 @@ static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, if (track == data->act_track) { col[3] = 1.0f; - glLineWidth(2.0f); + GPU_line_width(2.0f); } else { col[3] = 0.5f; - glLineWidth(1.0f); + GPU_line_width(1.0f); } immUniformColor4fv(col); @@ -152,13 +153,13 @@ static void draw_tracks_motion_curves(View2D *v2d, SpaceClip *sc, unsigned int p (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0, &userdata, tracking_segment_knot_cb, NULL, NULL); /* draw graph lines */ - glEnable(GL_BLEND); + GPU_blend(true); clip_graph_tracking_values_iterate(sc, (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0, (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0, &userdata, tracking_segment_point_cb, tracking_segment_start_cb, tracking_segment_end_cb); - glDisable(GL_BLEND); + GPU_blend(false); /* selected knot handles on top of curves */ userdata.sel = true; @@ -226,11 +227,11 @@ static void tracking_error_segment_start_cb(void *userdata, MovieTrackingTrack * if (track == data->active_track) { col[3] = 1.0f; - glLineWidth(2.0f); + GPU_line_width(2.0f); } else { col[3] = 0.5f; - glLineWidth(1.0f); + GPU_line_width(1.0f); } immUniformColor4fv(col); @@ -330,7 +331,7 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene) unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - glPointSize(3.0f); + GPU_point_size(3.0f); if (sc->flag & SC_SHOW_GRAPH_TRACKS_MOTION) { draw_tracks_motion_curves(v2d, sc, pos); diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index 02ea340eb57..b5a0e374431 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -55,7 +55,7 @@ /******************** common graph-editing utilities ********************/ -static int ED_space_clip_graph_poll(bContext *C) +static bool ED_space_clip_graph_poll(bContext *C) { if (ED_space_clip_tracking_poll(C)) { SpaceClip *sc = CTX_wm_space_clip(C); @@ -66,7 +66,7 @@ static int ED_space_clip_graph_poll(bContext *C) return false; } -static int clip_graph_knots_poll(bContext *C) +static bool clip_graph_knots_poll(bContext *C) { if (ED_space_clip_graph_poll(C)) { SpaceClip *sc = CTX_wm_space_clip(C); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 498a4d6fbbd..26327dc9b41 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -468,7 +468,7 @@ static void view_pan_cancel(bContext *C, wmOperator *op) void CLIP_OT_view_pan(wmOperatorType *ot) { /* identifiers */ - ot->name = "View Pan"; + ot->name = "Pan View"; ot->idname = "CLIP_OT_view_pan"; ot->description = "Pan the view"; @@ -899,7 +899,7 @@ void CLIP_OT_view_selected(wmOperatorType *ot) /********************** change frame operator *********************/ -static int change_frame_poll(bContext *C) +static bool change_frame_poll(bContext *C) { /* prevent changes during render */ if (G.is_rendering) diff --git a/source/blender/editors/space_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c index 3e4d0cd5bb4..304954b56e3 100644 --- a/source/blender/editors/space_clip/clip_toolbar.c +++ b/source/blender/editors/space_clip/clip_toolbar.c @@ -87,7 +87,7 @@ ARegion *ED_clip_has_properties_region(ScrArea *sa) return arnew; } -static int properties_poll(bContext *C) +static bool properties_poll(bContext *C) { return (CTX_wm_space_clip(C) != NULL); } @@ -151,7 +151,7 @@ static ARegion *clip_has_tools_region(ScrArea *sa) return artool; } -static int tools_poll(bContext *C) +static bool tools_poll(bContext *C) { return (CTX_wm_space_clip(C) != NULL); } diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index a666b20dfa4..c3208260b3b 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -46,6 +46,7 @@ #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "WM_api.h" #include "WM_types.h" @@ -269,8 +270,8 @@ void clip_draw_sfra_efra(View2D *v2d, Scene *scene) UI_view2d_view_ortho(v2d); /* currently clip editor supposes that editing clip length is equal to scene frame range */ - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -279,12 +280,12 @@ void clip_draw_sfra_efra(View2D *v2d, Scene *scene) immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax); immRectf(pos, (float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); - glDisable(GL_BLEND); + GPU_blend(false); immUniformThemeColorShade(TH_BACK, -60); /* thin lines where the actual frames are */ - glLineWidth(1.0f); + GPU_line_width(1.0f); immBegin(GWN_PRIM_LINES, 4); immVertex2f(pos, (float)SFRA, v2d->cur.ymin); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index b050e991140..c66a9a42292 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -63,6 +63,7 @@ #include "GPU_glew.h" #include "GPU_matrix.h" +#include "GPU_framebuffer.h" #include "WM_api.h" #include "WM_types.h" @@ -660,8 +661,8 @@ static void clip_keymap(struct wmKeyConfig *keyconf) /* marker */ WM_keymap_add_item(keymap, "CLIP_OT_add_marker_slide", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "CLIP_OT_delete_marker", DELKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "CLIP_OT_delete_marker", XKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "CLIP_OT_delete_marker", DELKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "CLIP_OT_slide_marker", LEFTMOUSE, KM_PRESS, 0, 0); @@ -669,8 +670,8 @@ static void clip_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(kmi->ptr, "action", 2); /* toggle */ /* tracks */ - WM_keymap_add_item(keymap, "CLIP_OT_delete_track", DELKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "CLIP_OT_delete_track", XKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "CLIP_OT_delete_track", DELKEY, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "CLIP_OT_lock_tracks", LKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", 0); /* lock */ @@ -769,11 +770,11 @@ static void clip_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "CLIP_OT_graph_select_border", BKEY, KM_PRESS, 0, 0); /* delete */ - WM_keymap_add_item(keymap, "CLIP_OT_graph_delete_curve", DELKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "CLIP_OT_graph_delete_curve", XKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "CLIP_OT_graph_delete_curve", DELKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "CLIP_OT_graph_delete_knot", DELKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "CLIP_OT_graph_delete_knot", XKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "CLIP_OT_graph_delete_knot", DELKEY, KM_PRESS, KM_SHIFT, 0); /* view */ WM_keymap_add_item(keymap, "CLIP_OT_graph_view_all", HOMEKEY, KM_PRESS, 0, 0); @@ -842,7 +843,7 @@ static int clip_context(const bContext *C, const char *member, bContextDataResul } /* dropboxes */ -static int clip_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool clip_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) { if (drag->type == WM_DRAG_PATH) if (ELEM(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_MOVIE, ICON_FILE_BLANK)) /* rule might not work? */ @@ -1146,7 +1147,7 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); /* data... */ movieclip_main_area_set_view2d(C, ar); @@ -1253,7 +1254,7 @@ static void graph_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); @@ -1295,7 +1296,7 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); @@ -1368,7 +1369,7 @@ static void clip_channels_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index bfce5a862d0..42077280cca 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -155,8 +155,8 @@ static int add_marker_at_click_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - ED_area_headerprint( - CTX_wm_area(C), + ED_workspace_status_text( + C, IFACE_("Use LMB click to define location where place the marker")); /* Add modal handler for ESC. */ @@ -180,7 +180,7 @@ static int add_marker_at_click_modal(bContext *C, ARegion *ar = CTX_wm_region(C); float pos[2]; - ED_area_headerprint(CTX_wm_area(C), NULL); + ED_workspace_status_text(C, NULL); ED_clip_point_stable_pos(sc, ar, event->x - ar->winrct.xmin, @@ -196,7 +196,7 @@ static int add_marker_at_click_modal(bContext *C, } case ESCKEY: - ED_area_headerprint(CTX_wm_area(C), NULL); + ED_workspace_status_text(C, NULL); return OPERATOR_CANCELLED; } @@ -2107,7 +2107,7 @@ void CLIP_OT_copy_tracks(wmOperatorType *ot) /********************* paste tracks from clipboard operator ********************/ -static int paste_tracks_poll(bContext *C) +static bool paste_tracks_poll(bContext *C) { if (ED_space_clip_tracking_poll(C)) { return BKE_tracking_clipboard_has_tracks(); diff --git a/source/blender/editors/space_clip/tracking_ops_orient.c b/source/blender/editors/space_clip/tracking_ops_orient.c index 3db52e6a39b..4d1c3e0b137 100644 --- a/source/blender/editors/space_clip/tracking_ops_orient.c +++ b/source/blender/editors/space_clip/tracking_ops_orient.c @@ -108,7 +108,7 @@ static Object *get_orientation_object(bContext *C) return object; } -static int set_orientation_poll(bContext *C) +static bool set_orientation_poll(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); if (sc != NULL) { @@ -754,7 +754,7 @@ void CLIP_OT_set_scale(wmOperatorType *ot) /********************** set solution scale operator *********************/ -static int set_solution_scale_poll(bContext *C) +static bool set_solution_scale_poll(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); if (sc != NULL) { @@ -814,7 +814,7 @@ void CLIP_OT_set_solution_scale(wmOperatorType *ot) /********************** apply solution scale operator *********************/ -static int apply_solution_scale_poll(bContext *C) +static bool apply_solution_scale_poll(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); if (sc != NULL) { diff --git a/source/blender/editors/space_clip/tracking_ops_stabilize.c b/source/blender/editors/space_clip/tracking_ops_stabilize.c index 4eb6a4fbb24..2888607a049 100644 --- a/source/blender/editors/space_clip/tracking_ops_stabilize.c +++ b/source/blender/editors/space_clip/tracking_ops_stabilize.c @@ -50,7 +50,7 @@ /********************* add 2d stabilization tracks operator ********************/ -static int stabilize_2d_poll(bContext *C) +static bool stabilize_2d_poll(bContext *C) { if (ED_space_clip_tracking_poll(C)) { SpaceClip *sc = CTX_wm_space_clip(C); @@ -345,4 +345,3 @@ void CLIP_OT_stabilize_2d_rotation_select(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } - diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index ecbc1f5ae1e..cf4687dca31 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -350,7 +350,7 @@ static int mouse_select(bContext *C, float co[2], int extend) return OPERATOR_FINISHED; } -static int select_poll(bContext *C) +static bool select_poll(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index c65c9a175a0..4b577a7cb7e 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -49,6 +49,7 @@ #include "UI_view2d.h" #include "console_intern.h" // own include +#include "GPU_framebuffer.h" /* ******************** default callbacks for console space ***************** */ @@ -169,7 +170,7 @@ static void console_cursor(wmWindow *win, ScrArea *sa, ARegion *ar) /* ************* dropboxes ************* */ -static int id_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool id_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) { // SpaceConsole *sc = CTX_wm_space_console(C); if (drag->type == WM_DRAG_ID) @@ -188,7 +189,7 @@ static void id_drop_copy(wmDrag *drag, wmDropBox *drop) MEM_freeN(text); } -static int path_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool path_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) { // SpaceConsole *sc = CTX_wm_space_console(C); if (drag->type == WM_DRAG_PATH) @@ -227,7 +228,7 @@ static void console_main_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); /* worlks best with no view2d matrix set */ UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 360009d3ea4..4d4845c41b9 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -74,6 +74,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" +#include "GPU_state.h" #include "filelist.h" @@ -377,14 +378,14 @@ static void file_draw_preview( xco = sx + (int)dx; yco = sy - layout->prv_h + (int)dy; - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); /* shadow */ if (use_dropshadow) { UI_draw_box_shadow(220, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey)); } - glEnable(GL_BLEND); + GPU_blend(true); /* the image */ if (!is_icon && typeflags & FILE_TYPE_FTFONT) { @@ -419,7 +420,7 @@ static void file_draw_preview( UI_but_drag_set_image(but, BLI_strdup(path), icon, imb, scale, true); } - glDisable(GL_BLEND); + GPU_blend(false); } static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname) diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index 742715039cf..6eaf2dda084 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -130,4 +130,3 @@ void file_panels_register(struct ARegionType *art); void file_tile_boundbox(const ARegion *ar, FileLayout *layout, const int file, rcti *r_bounds); #endif /* __FILE_INTERN_H__ */ - diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 0cd31ce7ca5..7c080044aee 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -458,7 +458,7 @@ static int file_border_select_exec(bContext *C, wmOperator *op) void FILE_OT_select_border(wmOperatorType *ot) { /* identifiers */ - ot->name = "Activate/Select File"; + ot->name = "Border Select"; ot->description = "Activate/select the file(s) contained in the border"; ot->idname = "FILE_OT_select_border"; @@ -527,7 +527,7 @@ void FILE_OT_select(wmOperatorType *ot) PropertyRNA *prop; /* identifiers */ - ot->name = "Activate/Select File"; + ot->name = "Select"; ot->description = "Activate/select file"; ot->idname = "FILE_OT_select"; @@ -1179,9 +1179,9 @@ int file_cancel_exec(bContext *C, wmOperator *UNUSED(unused)) return OPERATOR_FINISHED; } -static int file_operator_poll(bContext *C) +static bool file_operator_poll(bContext *C) { - int poll = ED_operator_file_active(C); + bool poll = ED_operator_file_active(C); SpaceFile *sfile = CTX_wm_space_file(C); if (!sfile || !sfile->op) poll = 0; @@ -2202,7 +2202,7 @@ static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) } -static int file_rename_poll(bContext *C) +static bool file_rename_poll(bContext *C) { bool poll = ED_operator_file_active(C); SpaceFile *sfile = CTX_wm_space_file(C); @@ -2248,9 +2248,9 @@ void FILE_OT_rename(struct wmOperatorType *ot) } -static int file_delete_poll(bContext *C) +static bool file_delete_poll(bContext *C) { - int poll = ED_operator_file_active(C); + bool poll = ED_operator_file_active(C); SpaceFile *sfile = CTX_wm_space_file(C); if (sfile && sfile->params) { diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index 78bbe3aea58..812a671ff33 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -57,7 +57,7 @@ #include <string.h> -static int file_panel_operator_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool file_panel_operator_poll(const bContext *C, PanelType *UNUSED(pt)) { SpaceFile *sfile = CTX_wm_space_file(C); return (sfile && sfile->op); @@ -107,4 +107,3 @@ void file_panels_register(ARegionType *art) pt->draw = file_panel_operator; BLI_addtail(&art->paneltypes, pt); } - diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h index 4e9c1e0dd1d..76845c44226 100644 --- a/source/blender/editors/space_file/filelist.h +++ b/source/blender/editors/space_file/filelist.h @@ -127,4 +127,3 @@ bool filelist_cache_previews_running(struct FileList *filelist); #endif #endif - diff --git a/source/blender/editors/space_file/fsmenu.h b/source/blender/editors/space_file/fsmenu.h index 85804538e19..bb201a7a80c 100644 --- a/source/blender/editors/space_file/fsmenu.h +++ b/source/blender/editors/space_file/fsmenu.h @@ -80,4 +80,3 @@ void fsmenu_refresh_bookmarks_status(struct FSMenu *fsmenu); int fsmenu_get_active_indices(struct FSMenu *fsmenu, enum FSMenuCategory category, const char *dir); #endif - diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 7b045a42595..853d31edebf 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -65,6 +65,7 @@ #include "file_intern.h" // own include #include "fsmenu.h" #include "filelist.h" +#include "GPU_framebuffer.h" /* ******************** default callbacks for file space ***************** */ @@ -408,8 +409,8 @@ static void file_main_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear_color(col[0], col[1], col[2], 0.0); + GPU_clear(GPU_COLOR_BIT); /* Allow dynamically sliders to be set, saves notifiers etc. */ @@ -505,6 +506,7 @@ static void file_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", HKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.params.show_hidden"); WM_keymap_add_item(keymap, "FILE_OT_directory_new", IKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "FILE_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_delete", DELKEY, KM_PRESS, 0, 0); @@ -687,8 +689,8 @@ static void file_ui_region_draw(const bContext *C, ARegion *ar) float col[3]; /* clear */ UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear_color(col[0], col[1], col[2], 0.0); + GPU_clear(GPU_COLOR_BIT); /* scrolling here is just annoying, disable it */ ar->v2d.cur.ymax = BLI_rctf_size_y(&ar->v2d.cur); @@ -719,7 +721,7 @@ static void file_ui_region_listener( } } -static int filepath_drop_poll(bContext *C, wmDrag *drag, const wmEvent *UNUSED(event)) +static bool filepath_drop_poll(bContext *C, wmDrag *drag, const wmEvent *UNUSED(event)) { if (drag->type == WM_DRAG_PATH) { SpaceFile *sfile = CTX_wm_space_file(C); @@ -854,4 +856,3 @@ void ED_file_read_bookmarks(void) fsmenu_read_bookmarks(ED_fsmenu_get(), name); } } - diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 2a0d5baa5c3..4162e6dec92 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -103,7 +103,7 @@ static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve ** return 1; } -static int graph_panel_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool graph_panel_poll(const bContext *C, PanelType *UNUSED(pt)) { return graph_panel_context(C, NULL, NULL); } @@ -564,7 +564,7 @@ static void driver_update_flags_cb(bContext *UNUSED(C), void *fcu_v, void *UNUSE } /* drivers panel poll */ -static int graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt)) { SpaceIpo *sipo = CTX_wm_space_graph(C); @@ -1016,7 +1016,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) /* ----------------------------------------------------------------- */ /* poll to make this not show up in the graph editor, as this is only to be used as a popup elsewhere */ -static int graph_panel_drivers_popover_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool graph_panel_drivers_popover_poll(const bContext *C, PanelType *UNUSED(pt)) { return ED_operator_graphedit_active((bContext *)C) == false; } diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 7c6af0b4c62..b08ff8dcfa1 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -51,6 +51,7 @@ #include "GPU_draw.h" #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "ED_anim_api.h" @@ -87,15 +88,15 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - glLineWidth(1.0f); + GPU_line_width(1.0f); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); - immUniform1i("num_colors", 0); /* Simple dashes. */ + immUniform1i("colors_len", 0); /* Simple dashes. */ immUniformColor3f(0.0f, 0.0f, 0.0f); immUniform1f("dash_width", 10.0f); immUniform1f("dash_factor", 0.5f); @@ -114,7 +115,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) if (env->totvert > 0) { /* set size of vertices (non-adjustable for now) */ - glPointSize(2.0f); + GPU_point_size(2.0f); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -281,7 +282,7 @@ static void draw_fcurve_vertices(ARegion *ar, FCurve *fcu, bool do_handles, bool unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - glEnable(GL_BLEND); + GPU_blend(true); GPU_enable_program_point_size(); /* draw the two handles first (if they're shown, the curve doesn't have just a single keyframe, and the curve is being edited) */ @@ -293,7 +294,7 @@ static void draw_fcurve_vertices(ARegion *ar, FCurve *fcu, bool do_handles, bool draw_fcurve_keyframe_vertices(fcu, v2d, !(fcu->flag & FCURVE_PROTECTED), pos); GPU_disable_program_point_size(); - glDisable(GL_BLEND); + GPU_blend(false); } /* Handles ---------------- */ @@ -449,8 +450,8 @@ static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu) /* draw */ if (first && last) { /* anti-aliased lines for more consistent appearance */ - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) GPU_line_smooth(true); + GPU_blend(true); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -462,8 +463,8 @@ static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu) immUnbindProgram(); - glDisable(GL_BLEND); - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH); + GPU_blend(false); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) GPU_line_smooth(false); } } @@ -846,10 +847,10 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); - immUniform1i("num_colors", 0); /* Simple dashes. */ + immUniform1i("colors_len", 0); /* Simple dashes. */ /* No curve to modify/visualize the result? * => We still want to show the 1-1 default... @@ -862,7 +863,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) immUniform1f("dash_width", 40.0f); immUniform1f("dash_factor", 0.5f); - glLineWidth(2.0f); + GPU_line_width(2.0f); /* draw 1-1 line, stretching just past the screen limits * NOTE: we need to scale the y-values to be valid for the units @@ -925,7 +926,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) /* x marks the spot .................................................... */ /* -> outer frame */ immUniformColor3f(0.9f, 0.9f, 0.9f); - glPointSize(7.0); + GPU_point_size(7.0); immBegin(GWN_PRIM_POINTS, 1); immVertex2f(shdr_pos, x, y); @@ -933,7 +934,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) /* inner frame */ immUniformColor3f(0.9f, 0.0f, 0.0f); - glPointSize(3.0); + GPU_point_size(3.0); immBegin(GWN_PRIM_POINTS, 1); immVertex2f(shdr_pos, x, y); @@ -954,23 +955,23 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) FCurve *fcu; /* draw with thick dotted lines */ - glLineWidth(3.0f); + GPU_line_width(3.0f); /* anti-aliased lines for less jagged appearance */ if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) { - glEnable(GL_LINE_SMOOTH); + GPU_line_smooth(true); } - glEnable(GL_BLEND); + GPU_blend(true); const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); - immUniform1i("num_colors", 0); /* Simple dashes. */ + immUniform1i("colors_len", 0); /* Simple dashes. */ immUniform1f("dash_width", 20.0f); immUniform1f("dash_factor", 0.5f); @@ -989,9 +990,9 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) immUnbindProgram(); if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) { - glDisable(GL_LINE_SMOOTH); + GPU_line_smooth(false); } - glDisable(GL_BLEND); + GPU_blend(false); } /* This is called twice from space_graph.c -> graph_main_region_draw() @@ -1036,27 +1037,27 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid /* set color/drawing style for curve itself */ /* draw active F-Curve thicker than the rest to make it stand out */ if (fcu->flag & FCURVE_ACTIVE) { - glLineWidth(2.5); + GPU_line_width(2.5); } else { - glLineWidth(1.0); + GPU_line_width(1.0); } /* anti-aliased lines for less jagged appearance */ if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) { - glEnable(GL_LINE_SMOOTH); + GPU_line_smooth(true); } - glEnable(GL_BLEND); + GPU_blend(true); const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); - immUniform1i("num_colors", 0); /* Simple dashes. */ + immUniform1i("colors_len", 0); /* Simple dashes. */ if (BKE_fcurve_is_protected(fcu)) { /* protected curves (non editable) are drawn with dotted lines */ @@ -1104,9 +1105,9 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid immUnbindProgram(); if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) { - glDisable(GL_LINE_SMOOTH); + GPU_line_smooth(false); } - glDisable(GL_BLEND); + GPU_blend(false); } /* 2) draw handles and vertices as appropriate based on active @@ -1134,16 +1135,16 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid gpuTranslate2f(0.0f, offset); /* set this once and for all - all handles and handle-verts should use the same thickness */ - glLineWidth(1.0); + GPU_line_width(1.0); if (fcu->bezt) { bool do_handles = draw_fcurve_handles_check(sipo, fcu); if (do_handles) { /* only draw handles/vertices on keyframes */ - glEnable(GL_BLEND); + GPU_blend(true); draw_fcurve_handles(sipo, fcu); - glDisable(GL_BLEND); + GPU_blend(false); } draw_fcurve_vertices(ar, fcu, do_handles, (sipo->flag & SIPO_SELVHANDLESONLY)); @@ -1229,8 +1230,8 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) y = (float)ACHANNEL_FIRST(ac); /* set blending again, as may not be set in previous step */ - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) { const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); @@ -1252,7 +1253,7 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) UI_block_end(C, block); UI_block_draw(C, block); - glDisable(GL_BLEND); + GPU_blend(false); } /* free tempolary channels */ diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 26a6e93ba57..b10141929d5 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1973,7 +1973,7 @@ void GRAPH_OT_euler_filter(wmOperatorType *ot) /* ***************** Jump to Selected Frames Operator *********************** */ -static int graphkeys_framejump_poll(bContext *C) +static bool graphkeys_framejump_poll(bContext *C) { /* prevent changes during render */ if (G.is_rendering) @@ -2808,7 +2808,7 @@ static int graph_driver_delete_invalid_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int graph_driver_delete_invalid_poll(bContext *C) +static bool graph_driver_delete_invalid_poll(bContext *C) { bAnimContext ac; ScrArea *sa = CTX_wm_area(C); diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index da352d4ea06..c50e0497519 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -170,10 +170,10 @@ void graph_buttons_register(struct ARegionType *art); struct bAnimListElem *get_active_fcurve_channel(struct bAnimContext *ac); -int graphop_visible_keyframes_poll(struct bContext *C); -int graphop_editable_keyframes_poll(struct bContext *C); -int graphop_active_fcurve_poll(struct bContext *C); -int graphop_selected_fcurve_poll(struct bContext *C); +bool graphop_visible_keyframes_poll(struct bContext *C); +bool graphop_editable_keyframes_poll(struct bContext *C); +bool graphop_active_fcurve_poll(struct bContext *C); +bool graphop_selected_fcurve_poll(struct bContext *C); /* ***************************************** */ /* graph_ops.c */ diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index bae5798ca21..8ac2c61b8e9 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -67,7 +67,7 @@ * 2) Value Indicator (stored per Graph Editor instance) */ -static int graphview_cursor_poll(bContext *C) +static bool graphview_cursor_poll(bContext *C) { /* prevent changes during render */ if (G.is_rendering) diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index ed9bed19d20..9a6b733a5ff 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -1530,7 +1530,7 @@ void GRAPH_OT_clickselect(wmOperatorType *ot) PropertyRNA *prop; /* identifiers */ - ot->name = "Mouse Select Keys"; + ot->name = "Select Keyframes"; ot->idname = "GRAPH_OT_clickselect"; ot->description = "Select keyframes by clicking on them"; diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c index f55a5511e2d..4adb95677b0 100644 --- a/source/blender/editors/space_graph/graph_utils.c +++ b/source/blender/editors/space_graph/graph_utils.c @@ -44,17 +44,62 @@ #include "BKE_context.h" #include "BKE_fcurve.h" +#include "BKE_screen.h" #include "WM_api.h" #include "ED_anim_api.h" +#include "ED_screen.h" +#include "UI_interface.h" #include "graph_intern.h" // own include /* ************************************************************** */ +/* Set Up Drivers Editor */ + +/* Set up UI configuration for Drivers Editor */ +/* NOTE: Currently called from windowmanager (new drivers editor window) and RNA (mode switching) */ +void ED_drivers_editor_init(bContext *C, ScrArea *sa) +{ + SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first; + + /* Set mode */ + sipo->mode = SIPO_MODE_DRIVERS; + + /* Show Properties Region (or else the settings can't be edited) */ + ARegion *ar_props = BKE_area_find_region_type(sa, RGN_TYPE_UI); + if (ar_props) { + UI_panel_category_active_set(ar_props, "Drivers"); + + ar_props->flag &= ~RGN_FLAG_HIDDEN; + /* XXX: Adjust width of this too? */ + + ED_region_visibility_change_update(C, ar_props); + } + else { + printf("%s: Couldn't find properties region for Drivers Editor - %p\n", __func__, sa); + } + + /* Adjust framing in graph region */ + /* TODO: Have a way of not resetting this every time? + * (e.g. So that switching back and forth between editors doesn't keep jumping?) + */ + ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if (ar_main) { + /* XXX: Ideally we recenter based on the range instead... */ + ar_main->v2d.tot.xmin = -2.0f; + ar_main->v2d.tot.ymin = -2.0f; + ar_main->v2d.tot.xmax = 2.0f; + ar_main->v2d.tot.ymax = 2.0f; + + ar_main->v2d.cur = ar_main->v2d.tot; + } +} + +/* ************************************************************** */ /* Active F-Curve */ /* Find 'active' F-Curve. It must be editable, since that's the purpose of these buttons (subject to change). @@ -90,7 +135,7 @@ bAnimListElem *get_active_fcurve_channel(bAnimContext *ac) /* Operator Polling Callbacks */ /* Check if there are any visible keyframes (for selection tools) */ -int graphop_visible_keyframes_poll(bContext *C) +bool graphop_visible_keyframes_poll(bContext *C) { bAnimContext ac; bAnimListElem *ale; @@ -139,7 +184,7 @@ int graphop_visible_keyframes_poll(bContext *C) } /* Check if there are any visible + editable keyframes (for editing tools) */ -int graphop_editable_keyframes_poll(bContext *C) +bool graphop_editable_keyframes_poll(bContext *C) { bAnimContext ac; bAnimListElem *ale; @@ -189,7 +234,7 @@ int graphop_editable_keyframes_poll(bContext *C) } /* has active F-Curve that's editable */ -int graphop_active_fcurve_poll(bContext *C) +bool graphop_active_fcurve_poll(bContext *C) { bAnimContext ac; bAnimListElem *ale; @@ -229,7 +274,7 @@ int graphop_active_fcurve_poll(bContext *C) } /* has selected F-Curve that's editable */ -int graphop_selected_fcurve_poll(bContext *C) +bool graphop_selected_fcurve_poll(bContext *C) { bAnimContext ac; ListBase anim_data = {NULL, NULL}; diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index d208ead317b..878c4815f73 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -54,12 +54,16 @@ #include "ED_markers.h" #include "GPU_immediate.h" +#include "GPU_state.h" +#include "GPU_framebuffer.h" #include "WM_api.h" #include "WM_types.h" #include "WM_message.h" #include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" #include "UI_resources.h" #include "UI_view2d.h" @@ -238,8 +242,8 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear_color(col[0], col[1], col[2], 0.0); + GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); @@ -285,15 +289,15 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) /* Draw a green line to indicate the cursor value */ immUniformThemeColorShadeAlpha(TH_CFRAME, -10, -50); - glEnable(GL_BLEND); - glLineWidth(2.0); + GPU_blend(true); + GPU_line_width(2.0); immBegin(GWN_PRIM_LINES, 2); immVertex2f(pos, v2d->cur.xmin, y); immVertex2f(pos, v2d->cur.xmax, y); immEnd(); - glDisable(GL_BLEND); + GPU_blend(false); } /* current frame or vertical component of vertical component of the cursor */ @@ -303,15 +307,15 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) /* to help differentiate this from the current frame, draw slightly darker like the horizontal one */ immUniformThemeColorShadeAlpha(TH_CFRAME, -40, -50); - glEnable(GL_BLEND); - glLineWidth(2.0); + GPU_blend(true); + GPU_line_width(2.0); immBegin(GWN_PRIM_LINES, 2); immVertex2f(pos, x, v2d->cur.ymin); immVertex2f(pos, x, v2d->cur.ymax); immEnd(); - glDisable(GL_BLEND); + GPU_blend(false); } immUnbindProgram(); @@ -379,8 +383,8 @@ static void graph_channel_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear_color(col[0], col[1], col[2], 0.0); + GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); @@ -799,6 +803,24 @@ static void graph_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID } } +static int graph_space_subtype_get(ScrArea *sa) +{ + SpaceIpo *sgraph = sa->spacedata.first; + return sgraph->mode; +} + +static void graph_space_subtype_set(ScrArea *sa, int value) +{ + SpaceIpo *sgraph = sa->spacedata.first; + sgraph->mode = value; +} + +static void graph_space_subtype_item_extend( + bContext *UNUSED(C), EnumPropertyItem **item, int *totitem) +{ + RNA_enum_items_add(item, totitem, rna_enum_space_graph_mode_items); +} + /* only called once, from space/spacetypes.c */ void ED_spacetype_ipo(void) { @@ -817,6 +839,9 @@ void ED_spacetype_ipo(void) st->listener = graph_listener; st->refresh = graph_refresh; st->id_remap = graph_id_remap; + st->space_subtype_item_extend = graph_space_subtype_item_extend; + st->space_subtype_get = graph_space_subtype_get; + st->space_subtype_set = graph_space_subtype_set; /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); @@ -867,4 +892,3 @@ void ED_spacetype_ipo(void) BKE_spacetype_register(st); } - diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 7236a99ad80..191f57961c9 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -710,7 +710,7 @@ static void uiblock_layer_pass_buttons( if (render_slot) { char str[64]; RenderSlot *slot = BKE_image_get_renderslot(image, *render_slot); - if (slot->name[0] != '\0') { + if (slot && slot->name[0] != '\0') { BLI_strncpy(str, slot->name, sizeof(str)); } else { @@ -827,7 +827,7 @@ static void rna_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg)) RNA_property_update(C, &cb->ptr, cb->prop); } -void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *userptr, int compact, int multiview) +void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *userptr, bool compact, bool multiview) { PropertyRNA *prop; PointerRNA imaptr; @@ -1063,7 +1063,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char MEM_freeN(cb); } -void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_management) +void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, bool color_management) { ImageFormatData *imf = imfptr->data; ID *id = imfptr->id.data; @@ -1349,4 +1349,3 @@ void IMAGE_OT_toolshelf(wmOperatorType *ot) /* flags */ ot->flag = 0; } - diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 1e2d668018f..f70efa00244 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -65,6 +65,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "BLF_api.h" @@ -130,7 +131,7 @@ static void draw_render_info(const bContext *C, immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_FACE_SELECT); - glLineWidth(1.0f); + GPU_line_width(1.0f); rcti *tile = tiles; for (int i = 0; i < total_tiles; i++, tile++) { @@ -170,8 +171,8 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d float hue = 0, sat = 0, val = 0, lum = 0, u = 0, v = 0; float col[4], finalcol[4]; - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -182,7 +183,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); BLF_size(blf_mono_font, 11 * U.pixelsize, U.dpi); @@ -323,7 +324,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d copy_v4_v4(finalcol, col); } - glDisable(GL_BLEND); + GPU_blend(false); dx += 0.25f * UI_UNIT_X; BLI_rcti_init(&color_rect, dx, dx + (1.5f * UI_UNIT_X), 0.15f * UI_UNIT_Y, 0.85f * UI_UNIT_Y); @@ -354,10 +355,10 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d immRecti(pos, color_quater_x, color_quater_y, color_rect_half.xmax, color_rect_half.ymax); immRecti(pos, color_rect_half.xmin, color_rect_half.ymin, color_quater_x, color_quater_y); - glEnable(GL_BLEND); + GPU_blend(true); immUniformColor3fvAlpha(finalcol, fp ? fp[3] : (cp[3] / 255.0f)); immRecti(pos, color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax); - glDisable(GL_BLEND); + GPU_blend(false); } else { immUniformColor3fv(finalcol); @@ -503,8 +504,8 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar, if (sima->flag & SI_USE_ALPHA) { imm_draw_box_checker_2d(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); } /* If RGBA display with color management */ @@ -544,7 +545,7 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar, } if (sima->flag & SI_USE_ALPHA) - glDisable(GL_BLEND); + GPU_blend(false); } } @@ -578,10 +579,10 @@ void draw_image_sample_line(SpaceImage *sima) immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); - immUniform1i("num_colors", 2); /* Advanced dashes. */ + immUniform1i("colors_len", 2); /* Advanced dashes. */ immUniformArray4fv("colors", (float *)(float[][4]){{1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2); immUniform1f("dash_width", 2.0f); @@ -618,13 +619,13 @@ static void draw_image_paint_helpers(const bContext *C, ARegion *ar, Scene *scen return; } - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); immDrawPixelsTex(&state, x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer, zoomx, zoomy, col); - glDisable(GL_BLEND); + GPU_blend(false); BKE_image_release_ibuf(brush->clone.image, ibuf, NULL); IMB_display_buffer_release(cache_handle); @@ -758,8 +759,8 @@ void draw_image_cache(const bContext *C, ARegion *ar) mask = ED_space_image_get_mask(sima); } - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); /* Draw cache background. */ ED_region_cache_draw_background(ar); @@ -773,7 +774,7 @@ void draw_image_cache(const bContext *C, ARegion *ar) ED_region_cache_draw_cached_segments(ar, num_segments, points, sfra + sima->iuser.offset, efra + sima->iuser.offset); } - glDisable(GL_BLEND); + GPU_blend(false); /* Draw current frame. */ x = (cfra - sfra) / (efra - sfra + 1) * ar->winx; diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index f4ecd2e7d34..4388accc534 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -388,7 +388,7 @@ bool ED_space_image_check_show_maskedit(SpaceImage *sima, ViewLayer *view_layer) return (sima->mode == SI_MODE_MASK); } -int ED_space_image_maskedit_poll(bContext *C) +bool ED_space_image_maskedit_poll(bContext *C) { SpaceImage *sima = CTX_wm_space_image(C); @@ -415,7 +415,7 @@ bool ED_space_image_paint_curve(const bContext *C) } -int ED_space_image_maskedit_mask_poll(bContext *C) +bool ED_space_image_maskedit_mask_poll(bContext *C) { if (ED_space_image_maskedit_poll(C)) { SpaceImage *sima = CTX_wm_space_image(C); @@ -424,4 +424,3 @@ int ED_space_image_maskedit_mask_poll(bContext *C) return false; } - diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h index 49c2690daaf..5d9c496d584 100644 --- a/source/blender/editors/space_image/image_intern.h +++ b/source/blender/editors/space_image/image_intern.h @@ -54,7 +54,7 @@ void draw_image_grease_pencil(struct bContext *C, bool onlyv2d); void draw_image_sample_line(struct SpaceImage *sima); /* image_ops.c */ -int space_image_main_region_poll(struct bContext *C); +bool space_image_main_region_poll(struct bContext *C); void IMAGE_OT_view_all(struct wmOperatorType *ot); void IMAGE_OT_view_pan(struct wmOperatorType *ot); @@ -104,4 +104,3 @@ void IMAGE_OT_properties(struct wmOperatorType *ot); void IMAGE_OT_toolshelf(struct wmOperatorType *ot); #endif /* __IMAGE_INTERN_H__ */ - diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index b2116b1a770..3efdce3ea6d 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -57,7 +57,6 @@ #include "BKE_colortools.h" #include "BKE_context.h" -#include "BKE_DerivedMesh.h" #include "BKE_icons.h" #include "BKE_image.h" #include "BKE_global.h" @@ -180,13 +179,13 @@ static void sima_zoom_set_from_bounds(SpaceImage *sima, ARegion *ar, const rctf } #if 0 // currently unused -static int image_poll(bContext *C) +static bool image_poll(bContext *C) { return (CTX_data_edit_image(C) != NULL); } #endif -static int space_image_buffer_exists_poll(bContext *C) +static bool space_image_buffer_exists_poll(bContext *C) { SpaceImage *sima = CTX_wm_space_image(C); if (sima && ED_space_image_has_buffer(sima)) { @@ -195,7 +194,7 @@ static int space_image_buffer_exists_poll(bContext *C) return false; } -static int image_not_packed_poll(bContext *C) +static bool image_not_packed_poll(bContext *C) { SpaceImage *sima = CTX_wm_space_image(C); @@ -214,7 +213,7 @@ static bool imbuf_format_writeable(const ImBuf *ibuf) return (BKE_image_imtype_to_ftype(im_format.imtype, &options_dummy) == ibuf->ftype); } -static int space_image_file_exists_poll(bContext *C) +static bool space_image_file_exists_poll(bContext *C) { if (space_image_buffer_exists_poll(C)) { Main *bmain = CTX_data_main(C); @@ -250,7 +249,7 @@ static int space_image_file_exists_poll(bContext *C) } #if 0 /* UNUSED */ -static int space_image_poll(bContext *C) +static bool space_image_poll(bContext *C) { SpaceImage *sima = CTX_wm_space_image(C); if (sima && sima->image) { @@ -260,7 +259,7 @@ static int space_image_poll(bContext *C) } #endif -int space_image_main_region_poll(bContext *C) +bool space_image_main_region_poll(bContext *C) { SpaceImage *sima = CTX_wm_space_image(C); /* XXX ARegion *ar = CTX_wm_region(C); */ @@ -272,7 +271,7 @@ int space_image_main_region_poll(bContext *C) } /* For IMAGE_OT_curves_point_set to avoid sampling when in uv smooth mode or editmode */ -static int space_image_main_area_not_uv_brush_poll(bContext *C) +static bool space_image_main_area_not_uv_brush_poll(bContext *C) { SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); @@ -285,7 +284,7 @@ static int space_image_main_area_not_uv_brush_poll(bContext *C) return 0; } -static int image_sample_poll(bContext *C) +static bool image_sample_poll(bContext *C) { SpaceImage *sima = CTX_wm_space_image(C); if (sima) { @@ -423,7 +422,7 @@ static void image_view_pan_cancel(bContext *C, wmOperator *op) void IMAGE_OT_view_pan(wmOperatorType *ot) { /* identifiers */ - ot->name = "View Pan"; + ot->name = "Pan View"; ot->idname = "IMAGE_OT_view_pan"; ot->description = "Pan the view"; @@ -639,7 +638,7 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot) PropertyRNA *prop; /* identifiers */ - ot->name = "View Zoom"; + ot->name = "Zoom View"; ot->idname = "IMAGE_OT_view_zoom"; ot->description = "Zoom in/out the image"; @@ -834,7 +833,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static int image_view_selected_poll(bContext *C) +static bool image_view_selected_poll(bContext *C) { return (space_image_main_region_poll(C) && (ED_operator_uvedit(C) || ED_operator_mask(C))); } @@ -2158,7 +2157,7 @@ static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op) uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr); } -static int image_save_as_poll(bContext *C) +static bool image_save_as_poll(bContext *C) { if (space_image_buffer_exists_poll(C)) { if (G.is_rendering) { @@ -2601,7 +2600,7 @@ void IMAGE_OT_new(wmOperatorType *ot) /********************* invert operators *********************/ -static int image_invert_poll(bContext *C) +static bool image_invert_poll(bContext *C) { Image *ima = CTX_data_edit_image(C); @@ -3445,7 +3444,7 @@ void IMAGE_OT_record_composite(wmOperatorType *ot) /********************* cycle render slot operator *********************/ -static int image_cycle_render_slot_poll(bContext *C) +static bool image_cycle_render_slot_poll(bContext *C) { Image *ima = CTX_data_edit_image(C); @@ -3581,7 +3580,7 @@ void IMAGE_OT_remove_render_slot(wmOperatorType *ot) /********************** change frame operator *********************/ -static int change_frame_poll(bContext *C) +static bool change_frame_poll(bContext *C) { /* prevent changes during render */ if (G.is_rendering) diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index e84b596530e..907b7e51c42 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -79,6 +79,7 @@ #include "UI_view2d.h" #include "image_intern.h" +#include "GPU_framebuffer.h" /**************************** common state *****************************/ @@ -301,7 +302,7 @@ static void image_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "IMAGE_OT_reload", RKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "IMAGE_OT_read_viewlayers", RKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "IMAGE_OT_save", SKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "IMAGE_OT_save_as", F3KEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "IMAGE_OT_save_as", SKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "IMAGE_OT_properties", NKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_toolshelf", TKEY, KM_PRESS, 0, 0); @@ -386,7 +387,7 @@ static void image_keymap(struct wmKeyConfig *keyconf) } /* dropboxes */ -static int image_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool image_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) { if (drag->type == WM_DRAG_PATH) if (ELEM(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_MOVIE, ICON_FILE_BLANK)) /* rule might not work? */ @@ -722,8 +723,8 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear_color(col[0], col[1], col[2], 0.0); + GPU_clear(GPU_COLOR_BIT); image_user_refresh_scene(C, sima); diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c index 9421567b6ba..ecd0b082df6 100644 --- a/source/blender/editors/space_info/info_draw.c +++ b/source/blender/editors/space_info/info_draw.c @@ -51,6 +51,7 @@ #include "info_intern.h" #include "textview.h" +#include "GPU_framebuffer.h" /* complicates things a bit, so leaving in old simple code */ #define USE_INFO_NEWLINE @@ -130,7 +131,7 @@ static int report_textview_begin(TextViewContext *tvc) tvc->iter = reports->list.last; UI_ThemeClearColor(TH_BACK); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); #ifdef USE_INFO_NEWLINE tvc->iter_tmp = 0; diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index 481c9031a73..3830e6d2792 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -34,6 +34,7 @@ #include "DNA_curve_types.h" #include "DNA_group_types.h" #include "DNA_lattice_types.h" +#include "DNA_mesh_types.h" #include "DNA_meta_types.h" #include "DNA_scene_types.h" @@ -48,7 +49,6 @@ #include "BKE_blender_version.h" #include "BKE_curve.h" #include "BKE_displist.h" -#include "BKE_DerivedMesh.h" #include "BKE_key.h" #include "BKE_layer.h" #include "BKE_paint.h" @@ -92,15 +92,15 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) switch (ob->type) { case OB_MESH: { - /* we assume derivedmesh is already built, this strictly does stats now. */ - DerivedMesh *dm = ob->derivedFinal; + /* we assume evaluated mesh is already built, this strictly does stats now. */ + Mesh *me_eval = ob->runtime.mesh_eval; int totvert, totedge, totface, totloop; - if (dm) { - totvert = dm->getNumVerts(dm); - totedge = dm->getNumEdges(dm); - totface = dm->getNumPolys(dm); - totloop = dm->getNumLoops(dm); + if (me_eval) { + totvert = me_eval->totvert; + totedge = me_eval->totedge; + totface = me_eval->totpoly; + totloop = me_eval->totloop; stats->totvert += totvert * totob; stats->totedge += totedge * totob; @@ -387,7 +387,7 @@ static void stats_update(ViewLayer *view_layer) else { /* Objects */ for (base = view_layer->object_bases.first; base; base = base->next) - if (base->flag & BASE_VISIBLED) { + if (base->flag & BASE_VISIBLE) { stats_dupli_object(base, base->object, &stats); } } @@ -471,7 +471,9 @@ static void stats_string(ViewLayer *view_layer) s = stats->infostr; ofs = 0; - ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, "%s | ", versionstr); + if (ob) { + ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, "%s | ", ob->id.name + 2); + } if (obedit) { if (BKE_keyblock_from_object(obedit)) @@ -505,15 +507,13 @@ static void stats_string(ViewLayer *view_layer) } else { ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, - IFACE_("Verts:%s | Faces:%s | Tris:%s | Objects:%s/%s | Lamps:%s/%s%s%s"), + IFACE_("Verts:%s | Faces:%s | Tris:%s | Objects:%s/%s%s%s"), stats_fmt.totvert, stats_fmt.totface, stats_fmt.tottri, stats_fmt.totobjsel, - stats_fmt.totobj, stats_fmt.totlampsel, - stats_fmt.totlamp, memstr, gpumemstr); + stats_fmt.totobj, memstr, gpumemstr); } - if (ob) - BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, " | %s", ob->id.name + 2); + ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, " | %s", versionstr); #undef MAX_INFO_MEM_LEN } diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 65b3c7bb9fd..5f9de037409 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -60,6 +60,7 @@ #include "info_intern.h" /* own include */ #include "BLO_readfile.h" +#include "GPU_framebuffer.h" /* ******************** default callbacks for info space ***************** */ @@ -157,7 +158,7 @@ static void info_main_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); /* quick way to avoid drawing if not bug enough */ if (ar->winy < 16) @@ -220,8 +221,10 @@ static void info_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "INFO_OT_select_border", BKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "INFO_OT_report_replay", RKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "INFO_OT_report_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "INFO_OT_report_delete", DELKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "INFO_OT_report_copy", CKEY, KM_PRESS, KM_CTRL, 0); #ifdef __APPLE__ WM_keymap_add_item(keymap, "INFO_OT_report_copy", CKEY, KM_PRESS, KM_OSKEY, 0); @@ -263,7 +266,7 @@ static void info_header_listener( /* context changes */ switch (wmn->category) { case NC_SCREEN: - if (ELEM(wmn->data, ND_LAYER, ND_SCREENCAST, ND_ANIMPLAY)) { + if (ELEM(wmn->data, ND_LAYER, ND_ANIMPLAY)) { ED_region_tag_redraw(ar); } break; diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index 85de70c020f..a1e3842f887 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -40,6 +40,7 @@ #include "BLI_string_utf8.h" #include "GPU_immediate.h" +#include "GPU_state.h" #include "BIF_gl.h" @@ -81,8 +82,8 @@ static void console_draw_sel(const char *str, const int sel[2], const int xy[2], const int sta = txt_utf8_offset_to_column(str, max_ii(sel[0], 0)); const int end = txt_utf8_offset_to_column(str, min_ii(sel[1], str_len_draw)); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); @@ -93,7 +94,7 @@ static void console_draw_sel(const char *str, const int sel[2], const int xy[2], immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } } diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index cafb40626ee..57464cbf092 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -184,31 +184,31 @@ bool nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA *nlt_p } #if 0 -static int nla_panel_poll(const bContext *C, PanelType *pt) +static bool nla_panel_poll(const bContext *C, PanelType *pt) { return nla_panel_context(C, NULL, NULL); } #endif -static int nla_animdata_panel_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool nla_animdata_panel_poll(const bContext *C, PanelType *UNUSED(pt)) { PointerRNA ptr; return (nla_panel_context(C, &ptr, NULL, NULL) && (ptr.data != NULL)); } -static int nla_track_panel_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool nla_track_panel_poll(const bContext *C, PanelType *UNUSED(pt)) { PointerRNA ptr; return (nla_panel_context(C, NULL, &ptr, NULL) && (ptr.data != NULL)); } -static int nla_strip_panel_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool nla_strip_panel_poll(const bContext *C, PanelType *UNUSED(pt)) { PointerRNA ptr; return (nla_panel_context(C, NULL, NULL, &ptr) && (ptr.data != NULL)); } -static int nla_strip_actclip_panel_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool nla_strip_actclip_panel_poll(const bContext *C, PanelType *UNUSED(pt)) { PointerRNA ptr; NlaStrip *strip; @@ -222,7 +222,7 @@ static int nla_strip_actclip_panel_poll(const bContext *C, PanelType *UNUSED(pt) return (strip->type == NLASTRIP_TYPE_CLIP); } -static int nla_strip_eval_panel_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool nla_strip_eval_panel_poll(const bContext *C, PanelType *UNUSED(pt)) { PointerRNA ptr; NlaStrip *strip; diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index d782fe4d7ef..3368ad4fe8d 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -129,7 +129,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe Object *ob = base->object; AnimData *adt = ob->adt; - if (nlaedit_is_tweakmode_on(ac) == 0 && (base->flag & BASE_SELECTABLED)) { + if (nlaedit_is_tweakmode_on(ac) == 0 && (base->flag & BASE_SELECTABLE)) { /* set selection status */ if (selectmode == SELECT_INVERT) { /* swap select */ @@ -507,7 +507,7 @@ void NLA_OT_action_pushdown(wmOperatorType *ot) /* ******************** Action Unlink ******************************** */ -static int nla_action_unlink_poll(bContext *C) +static bool nla_action_unlink_poll(bContext *C) { if (ED_operator_nla_active(C)) { return nla_panel_context(C, NULL, NULL, NULL); diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 3f1ab059a91..a21a62dc8e8 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -58,6 +58,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_draw.h" +#include "GPU_state.h" #include "WM_types.h" @@ -181,10 +182,10 @@ static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymax immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); - immUniform1i("num_colors", 0); /* "simple" mode */ + immUniform1i("colors_len", 0); /* "simple" mode */ immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); } @@ -212,7 +213,7 @@ static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymax /* Markers inside a NLA-Strip */ static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc) { - glLineWidth(2.0f); + GPU_line_width(2.0f); if (strip->type == NLASTRIP_TYPE_CLIP) { /* try not to be too conspicuous, while being visible enough when transforming */ @@ -232,7 +233,7 @@ static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc) } } - glLineWidth(1.0f); + GPU_line_width(1.0f); } /* Strips (Proper) ---------------------- */ @@ -307,8 +308,8 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uns immUniformColor3f(0.7f, 0.7f, 0.7f); /* draw with AA'd line */ - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); + GPU_line_smooth(true); + GPU_blend(true); /* influence -------------------------- */ if (strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) { @@ -357,8 +358,8 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uns } /* turn off AA'd lines */ - glDisable(GL_LINE_SMOOTH); - glDisable(GL_BLEND); + GPU_line_smooth(false); + GPU_blend(false); } /* helper call to setup dashed-lines for strip outlines */ @@ -369,10 +370,10 @@ static uint nla_draw_use_dashed_outlines(float color[4], bool muted) immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); - immUniform1i("num_colors", 0); /* Simple dashes. */ + immUniform1i("colors_len", 0); /* Simple dashes. */ immUniformColor3fv(color); /* line style: dotted for muted */ @@ -380,12 +381,12 @@ static uint nla_draw_use_dashed_outlines(float color[4], bool muted) /* dotted - and slightly thicker for readability of the dashes */ immUniform1f("dash_width", 5.0f); immUniform1f("dash_factor", 0.4f); - glLineWidth(1.5f); + GPU_line_width(1.5f); } else { /* solid line */ immUniform1f("dash_factor", 2.0f); - glLineWidth(1.0f); + GPU_line_width(1.0f); } return shdr_pos; @@ -410,8 +411,8 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri */ if ((strip->extendmode != NLASTRIP_EXTEND_NOTHING) && (non_solo == 0)) { /* enable transparency... */ - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); switch (strip->extendmode) { /* since this does both sides, only do the 'before' side, and leave the rest to the next case */ @@ -442,7 +443,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri break; } - glDisable(GL_BLEND); + GPU_blend(false); } @@ -462,9 +463,9 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri /* strip is in disabled track - make less visible */ immUniformColor3fvAlpha(color, 0.1f); - glEnable(GL_BLEND); + GPU_blend(true); immRectf(shdr_pos, strip->start, yminc, strip->end, ymaxc); - glDisable(GL_BLEND); + GPU_blend(false); } @@ -711,8 +712,8 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* just draw a semi-shaded rect spanning the width of the viewable area if there's data, * and a second darker rect within which we draw keyframe indicator dots if there's data */ - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); /* get colors for drawing */ float color[4]; @@ -726,7 +727,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* draw 'embossed' lines above and below the strip for effect */ /* white base-lines */ - glLineWidth(2.0f); + GPU_line_width(2.0f); immUniformColor4f(1.0f, 1.0f, 1.0f, 0.3f); immBegin(GWN_PRIM_LINES, 4); immVertex2f(pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP); @@ -736,7 +737,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) immEnd(); /* black top-lines */ - glLineWidth(1.0f); + GPU_line_width(1.0f); immUniformColor3f(0.0f, 0.0f, 0.0f); immBegin(GWN_PRIM_LINES, 4); immVertex2f(pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP); @@ -752,7 +753,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* draw keyframes in the action */ nla_action_draw_keyframes(adt, ale->data, y, yminc + NLACHANNEL_SKIP, ymaxc - NLACHANNEL_SKIP); - glDisable(GL_BLEND); + GPU_blend(false); break; } } @@ -828,8 +829,8 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar) y = (float)(-NLACHANNEL_HEIGHT(snla)); /* set blending again, as may not be set in previous step */ - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); /* loop through channels, and set up drawing depending on their type */ for (ale = anim_data.first; ale; ale = ale->next) { @@ -852,7 +853,7 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar) UI_block_end(C, block); UI_block_draw(C, block); - glDisable(GL_BLEND); + GPU_blend(false); } /* free temporary channels */ diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index 2e73c82ebb6..a00e71a192d 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -148,8 +148,8 @@ void NLA_OT_selected_objects_add(wmOperatorType *ot); /* **************************************** */ /* nla_ops.c */ -int nlaop_poll_tweakmode_off(bContext *C); -int nlaop_poll_tweakmode_on(bContext *C); +bool nlaop_poll_tweakmode_off(bContext *C); +bool nlaop_poll_tweakmode_on(bContext *C); bool nlaedit_is_tweakmode_on(bAnimContext *ac); @@ -159,4 +159,3 @@ void nla_operatortypes(void); void nla_keymap(wmKeyConfig *keyconf); #endif /* __NLA_INTERN_H__ */ - diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index 0c087fa67b9..5bfd73b8163 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -52,7 +52,7 @@ /* ************************** poll callbacks for operators **********************************/ /* tweakmode is NOT enabled */ -int nlaop_poll_tweakmode_off(bContext *C) +bool nlaop_poll_tweakmode_off(bContext *C) { Scene *scene; @@ -74,7 +74,7 @@ int nlaop_poll_tweakmode_off(bContext *C) } /* tweakmode IS enabled */ -int nlaop_poll_tweakmode_on(bContext *C) +bool nlaop_poll_tweakmode_on(bContext *C) { Scene *scene; diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index 8c9372f0612..f22c211af64 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -653,7 +653,7 @@ void NLA_OT_click_select(wmOperatorType *ot) PropertyRNA *prop; /* identifiers */ - ot->name = "Mouse Select"; + ot->name = "Select"; ot->idname = "NLA_OT_click_select"; ot->description = "Handle clicks to select NLA Strips"; diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 745cea37ea3..62144db0577 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -63,6 +63,7 @@ #include "UI_view2d.h" #include "nla_intern.h" /* own include */ +#include "GPU_framebuffer.h" /* ******************** manage regions ********************* */ @@ -232,7 +233,7 @@ static void nla_channel_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); @@ -278,7 +279,7 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index a162a863038..12da5086c52 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -56,6 +56,7 @@ #include "GPU_batch.h" #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "RNA_access.h" #include "RNA_define.h" @@ -562,8 +563,8 @@ static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED( /* outline active and selected emphasis */ if (node->flag & SELECT) { - glEnable(GL_BLEND); - glEnable(GL_LINE_SMOOTH); + GPU_blend(true); + GPU_line_smooth(true); /* using different shades of TH_TEXT_HI for the empasis, like triangle */ if (node->flag & NODE_ACTIVE) { UI_GetThemeColorShadeAlpha4fv(TH_TEXT_HI, 0, -40, debug_color); @@ -573,8 +574,8 @@ static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED( } UI_draw_roundbox_4fv(false, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size, debug_color); - glDisable(GL_LINE_SMOOTH); - glDisable(GL_BLEND); + GPU_line_smooth(false); + GPU_blend(false); } #endif @@ -3214,12 +3215,12 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b GPU_shader_unbind(); } else if (snode->flag & SNODE_USE_ALPHA) { - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom); - glDisable(GL_BLEND); + GPU_blend(false); } else { glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom); @@ -3503,7 +3504,7 @@ static void nodelink_batch_draw(SpaceNode *snode) if (g_batch_link.count == 0) return; - glEnable(GL_BLEND); + GPU_blend(true); float colors[6][4] = {{0.0f}}; UI_GetThemeColor4fv(TH_WIRE_INNER, colors[nodelink_get_color_id(TH_WIRE_INNER)]); @@ -3523,7 +3524,7 @@ static void nodelink_batch_draw(SpaceNode *snode) nodelink_batch_reset(); - glDisable(GL_BLEND); + GPU_blend(false); } void nodelink_batch_start(SpaceNode *UNUSED(snode)) diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index 72b1a35973a..8f6a0f5c4e2 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -392,7 +392,7 @@ void NODE_OT_add_file(wmOperatorType *ot) /* ****************** Add Mask Node Operator ******************* */ -static int node_add_mask_poll(bContext *C) +static bool node_add_mask_poll(bContext *C) { SpaceNode *snode = CTX_wm_space_node(C); @@ -533,4 +533,3 @@ void NODE_OT_new_node_tree(wmOperatorType *ot) RNA_def_enum_funcs(prop, new_node_tree_type_itemf); RNA_def_string(ot->srna, "name", "NodeTree", MAX_ID_NAME - 2, "Name", ""); } - diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c index 38183637750..c2efc548c30 100644 --- a/source/blender/editors/space_node/node_buttons.c +++ b/source/blender/editors/space_node/node_buttons.c @@ -59,7 +59,7 @@ #if 0 /* poll for active nodetree */ -static int active_nodetree_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool active_nodetree_poll(const bContext *C, PanelType *UNUSED(pt)) { SpaceNode *snode = CTX_wm_space_node(C); @@ -67,7 +67,7 @@ static int active_nodetree_poll(const bContext *C, PanelType *UNUSED(pt)) } #endif -static int node_sockets_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool node_sockets_poll(const bContext *C, PanelType *UNUSED(pt)) { SpaceNode *snode = CTX_wm_space_node(C); @@ -95,7 +95,7 @@ static void node_sockets_panel(const bContext *C, Panel *pa) } } -static int node_tree_interface_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool node_tree_interface_poll(const bContext *C, PanelType *UNUSED(pt)) { SpaceNode *snode = CTX_wm_space_node(C); @@ -216,7 +216,7 @@ static int node_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op)) } /* non-standard poll operator which doesn't care if there are any nodes */ -static int node_properties_poll(bContext *C) +static bool node_properties_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); return (sa && (sa->spacetype == SPACE_NODE)); diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 8089f47bce4..01e22ec5245 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -58,6 +58,8 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" +#include "GPU_state.h" +#include "GPU_framebuffer.h" #include "WM_api.h" #include "WM_types.h" @@ -620,12 +622,12 @@ static void node_draw_mute_line(View2D *v2d, SpaceNode *snode, bNode *node) { bNodeLink *link; - glEnable(GL_BLEND); + GPU_blend(true); for (link = node->internal_links.first; link; link = link->next) node_draw_link_bezier(v2d, snode, link, TH_REDALERT, TH_REDALERT, -1); - glDisable(GL_BLEND); + GPU_blend(false); } static void node_socket_circle_draw(const bContext *C, bNodeTree *ntree, PointerRNA node_ptr, bNodeSocket *sock, unsigned pos, unsigned col) @@ -710,14 +712,14 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv) node_draw_preview_background(BLI_rctf_size_x(prv) / 10.0f, &draw_rect); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); /* premul graphics */ + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); /* premul graphics */ IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); immDrawPixelsTex(&state, draw_rect.xmin, draw_rect.ymin, preview->xsize, preview->ysize, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, preview->rect, scale, scale, NULL); - glDisable(GL_BLEND); + GPU_blend(false); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -773,7 +775,7 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode * unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); - glEnable(GL_BLEND); + GPU_blend(true); GPU_enable_program_point_size(); immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_VARYING_COLOR_OUTLINE_AA); @@ -864,7 +866,7 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode * immUnbindProgram(); GPU_disable_program_point_size(); - glDisable(GL_BLEND); + GPU_blend(false); } static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey key) @@ -903,7 +905,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN } } - glLineWidth(1.0f); + GPU_line_width(1.0f); UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); UI_draw_roundbox_aa(true, rct->xmin, rct->ymax - NODE_DY, rct->xmax, rct->ymax, BASIS_RAD, color); @@ -1048,13 +1050,13 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b /* custom color inline */ if (node->flag & NODE_CUSTOM_COLOR) { - glEnable(GL_BLEND); - glEnable(GL_LINE_SMOOTH); + GPU_blend(true); + GPU_line_smooth(true); UI_draw_roundbox_3fvAlpha(false, rct->xmin + 1, rct->ymin + 1, rct->xmax -1, rct->ymax - 1, hiddenrad, node->color, 1.0f); - glDisable(GL_LINE_SMOOTH); - glDisable(GL_BLEND); + GPU_line_smooth(false); + GPU_blend(false); } /* title */ @@ -1239,14 +1241,14 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT } /* node lines */ - glEnable(GL_BLEND); + GPU_blend(true); nodelink_batch_start(snode); for (link = ntree->links.first; link; link = link->next) { if (!nodeLinkIsHidden(link)) node_draw_link(&ar->v2d, snode, link); } nodelink_batch_end(snode); - glDisable(GL_BLEND); + GPU_blend(false); /* draw foreground nodes, last nodes in front */ for (a = 0, node = ntree->nodes.first; node; node = node->next, a++) { @@ -1303,12 +1305,12 @@ static void draw_group_overlay(const bContext *C, ARegion *ar) float color[4]; /* shade node groups to separate them visually */ - glEnable(GL_BLEND); + GPU_blend(true); UI_GetThemeColorShadeAlpha4fv(TH_NODE_GROUP, 0, -70, color); UI_draw_roundbox_corner_set(UI_CNR_NONE); UI_draw_roundbox_4fv(true, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 0, color); - glDisable(GL_BLEND); + GPU_blend(false); /* set the block bounds to clip mouse events from underlying nodes */ block = UI_block_begin(C, ar, "node tree bounds block", UI_EMBOSS); @@ -1325,7 +1327,7 @@ void drawnodespace(const bContext *C, ARegion *ar) View2D *v2d = &ar->v2d; UI_ThemeClearColor(TH_BACK); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); @@ -1338,7 +1340,7 @@ void drawnodespace(const bContext *C, ARegion *ar) ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); /* only set once */ - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); /* nodes */ snode_set_context(C); @@ -1418,14 +1420,14 @@ void drawnodespace(const bContext *C, ARegion *ar) } /* temporary links */ - glEnable(GL_BLEND); - glEnable(GL_LINE_SMOOTH); + GPU_blend(true); + GPU_line_smooth(true); for (nldrag = snode->linkdrag.first; nldrag; nldrag = nldrag->next) { for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) node_draw_link(v2d, snode, (bNodeLink *)linkdata->data); } - glDisable(GL_LINE_SMOOTH); - glDisable(GL_BLEND); + GPU_line_smooth(false); + GPU_blend(false); if (snode->flag & SNODE_SHOW_GPENCIL) { /* draw grease-pencil ('canvas' strokes) */ diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index ff87dcf409a..cc32e5ef499 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -303,7 +303,7 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene /* ***************************************** */ /* operator poll callback */ -int composite_node_active(bContext *C) +bool composite_node_active(bContext *C) { if (ED_operator_node_active(C)) { SpaceNode *snode = CTX_wm_space_node(C); @@ -314,7 +314,7 @@ int composite_node_active(bContext *C) } /* operator poll callback */ -int composite_node_editable(bContext *C) +bool composite_node_editable(bContext *C) { if (ED_operator_node_editable(C)) { SpaceNode *snode = CTX_wm_space_node(C); @@ -719,7 +719,7 @@ void ED_node_post_apply_transform(bContext *UNUSED(C), bNodeTree *UNUSED(ntree)) #if 0 /* UNUSED */ -static int edit_node_poll(bContext *C) +static bool edit_node_poll(bContext *C) { return ED_operator_node_active(C); } @@ -1617,7 +1617,7 @@ void NODE_OT_delete(wmOperatorType *ot) /* ****************** Switch View ******************* */ -static int node_switch_view_poll(bContext *C) +static bool node_switch_view_poll(bContext *C) { SpaceNode *snode = CTX_wm_space_node(C); @@ -2290,7 +2290,7 @@ void NODE_OT_tree_socket_move(wmOperatorType *ot) /* ********************** Shader Script Update ******************/ -static int node_shader_script_update_poll(bContext *C) +static bool node_shader_script_update_poll(bContext *C) { Scene *scene = CTX_data_scene(C); RenderEngineType *type = RE_engines_find(scene->r.engine); diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index 926fff7a3b6..a3294211ff9 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -65,7 +65,7 @@ #include "node_intern.h" /* own include */ #include "NOD_common.h" -static int node_group_operator_active(bContext *C) +static bool node_group_operator_active(bContext *C) { if (ED_operator_node_active(C)) { SpaceNode *snode = CTX_wm_space_node(C); @@ -84,7 +84,7 @@ static int node_group_operator_active(bContext *C) return false; } -static int node_group_operator_editable(bContext *C) +static bool node_group_operator_editable(bContext *C) { if (ED_operator_node_editable(C)) { SpaceNode *snode = CTX_wm_space_node(C); diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 2cc37a4e0fe..d7a43bda461 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -180,8 +180,8 @@ void snode_dag_update(struct bContext *C, struct SpaceNode *snode); void snode_set_context(const struct bContext *C); void snode_update(struct SpaceNode *snode, struct bNode *node); -int composite_node_active(struct bContext *C); -int composite_node_editable(struct bContext *C); +bool composite_node_active(struct bContext *C); +bool composite_node_editable(struct bContext *C); int node_has_hidden_sockets(bNode *node); void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set); diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index 3b6cc8a89cf..069d8a500ca 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -306,7 +306,9 @@ void node_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "NODE_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NODE_OT_delete", DELKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "NODE_OT_delete_reconnect", XKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "NODE_OT_delete_reconnect", DELKEY, KM_PRESS, KM_CTRL, 0); kmi = WM_keymap_add_item(keymap, "NODE_OT_select_all", AKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index e4c59bc9508..c4cd59b65f4 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -532,7 +532,7 @@ static void node_link_update_header(bContext *C, bNodeLinkDrag *UNUSED(nldrag)) char header[UI_MAX_DRAW_STR]; BLI_strncpy(header, IFACE_("LMB: drag node link, RMB: cancel"), sizeof(header)); - ED_area_headerprint(CTX_wm_area(C), header); + ED_workspace_status_text(C, header); } static int node_count_links(bNodeTree *ntree, bNodeSocket *sock) @@ -729,7 +729,7 @@ static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event->val == KM_RELEASE) { node_link_exit(C, op, true); - ED_area_headerprint(CTX_wm_area(C), NULL); + ED_workspace_status_text(C, NULL); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 3ae542c48db..636ed755cb1 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -1064,5 +1064,3 @@ void NODE_OT_find_node(wmOperatorType *ot) RNA_def_boolean(ot->srna, "prev", 0, "Previous", ""); } - - diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 23fd793cdd3..b884db1ced4 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -769,4 +769,3 @@ void uiTemplateNodeView(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode * else ui_node_draw_node(layout, C, ntree, node, 0); } - diff --git a/source/blender/editors/space_node/node_toolbar.c b/source/blender/editors/space_node/node_toolbar.c index 21278dd9fa5..b4e7e853330 100644 --- a/source/blender/editors/space_node/node_toolbar.c +++ b/source/blender/editors/space_node/node_toolbar.c @@ -63,7 +63,7 @@ static int node_toolbar_toggle_exec(bContext *C, wmOperator *UNUSED(op)) } /* non-standard poll operator which doesn't care if there are any nodes */ -static int node_toolbar_poll(bContext *C) +static bool node_toolbar_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); return (sa && (sa->spacetype == SPACE_NODE)); diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 441ab03cb28..fa6fa02cdc5 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -676,7 +676,7 @@ static void node_main_region_draw(const bContext *C, ARegion *ar) /* ************* dropboxes ************* */ -static int node_ima_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool node_ima_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) { if (drag->type == WM_DRAG_ID) { ID *id = drag->poin; @@ -690,7 +690,7 @@ static int node_ima_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent * return 0; } -static int node_mask_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool node_mask_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) { if (drag->type == WM_DRAG_ID) { ID *id = drag->poin; @@ -772,7 +772,6 @@ static void node_region_listener( WM_manipulatormap_tag_refresh(mmap); } switch (wmn->data) { - case ND_SCREENCAST: case ND_ANIMPLAY: case ND_LAYER: ED_region_tag_redraw(ar); @@ -1045,4 +1044,3 @@ void ED_spacetype_node(void) BKE_spacetype_register(st); } - diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c index a700f8e20e0..ad94615a0d2 100644 --- a/source/blender/editors/space_outliner/outliner_collections.c +++ b/source/blender/editors/space_outliner/outliner_collections.c @@ -102,7 +102,7 @@ Collection *outliner_collection_from_tree_element(const TreeElement *te) /* -------------------------------------------------------------------- */ /* Poll functions. */ -int ED_outliner_collections_editor_poll(bContext *C) +bool ED_outliner_collections_editor_poll(bContext *C) { SpaceOops *so = CTX_wm_space_outliner(C); return (so != NULL) && ELEM(so->outlinevis, SO_VIEW_LAYER, SO_SCENES, SO_LIBRARIES); @@ -164,8 +164,10 @@ static int collection_new_exec(bContext *C, wmOperator *op) data.collection, NULL); - outliner_cleanup_tree(soops); + DEG_id_tag_update(&data.collection->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); + + outliner_cleanup_tree(soops); WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); return OPERATOR_FINISHED; } @@ -236,18 +238,19 @@ static int collection_delete_exec(bContext *C, wmOperator *op) /* Effectively delete the collections. */ GSetIterator collections_to_edit_iter; GSET_ITER(collections_to_edit_iter, data.collections_to_edit) { - /* TODO: what if collection was child and got deleted in the meantime? */ Collection *collection = BLI_gsetIterator_getKey(&collections_to_edit_iter); - BKE_collection_delete(bmain, collection, hierarchy); + + /* Test in case collection got deleted as part of another one. */ + if (BLI_findindex(&bmain->collection, collection) != -1) { + BKE_collection_delete(bmain, collection, hierarchy); + } } BLI_gset_free(data.collections_to_edit, NULL); + DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); - /* TODO(sergey): Use proper flag for tagging here. */ - DEG_id_tag_update(&scene->id, 0); - WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); return OPERATOR_FINISHED; @@ -462,11 +465,9 @@ static int collection_link_exec(bContext *C, wmOperator *UNUSED(op)) BLI_gset_free(data.collections_to_edit, NULL); + DEG_id_tag_update(&active_collection->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); - /* TODO(sergey): Use proper flag for tagging here. */ - DEG_id_tag_update(&scene->id, 0); - WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); return OPERATOR_FINISHED; @@ -527,9 +528,6 @@ static int collection_instance_exec(bContext *C, wmOperator *UNUSED(op)) DEG_relations_tag_update(bmain); - /* TODO(sergey): Use proper flag for tagging here. */ - DEG_id_tag_update(&scene->id, 0); - WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); return OPERATOR_FINISHED; @@ -576,7 +574,7 @@ static TreeTraversalAction layer_collection_find_data_to_edit(TreeElement *te, v return TRAVERSE_CONTINUE; } -static int collections_view_layer_poll(bContext *C, bool include) +static bool collections_view_layer_poll(bContext *C, bool include) { /* Poll function so the right click menu show current state of selected collections. */ SpaceOops *soops = CTX_wm_space_outliner(C); @@ -607,12 +605,12 @@ static int collections_view_layer_poll(bContext *C, bool include) return result; } -static int collections_exclude_poll(bContext *C) +static bool collections_exclude_poll(bContext *C) { return collections_view_layer_poll(C, false); } -static int collections_include_poll(bContext *C) +static bool collections_include_poll(bContext *C) { return collections_view_layer_poll(C, true); } diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index a3f3acf1c32..75349ce99c5 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -51,6 +51,7 @@ #include "BKE_deform.h" #include "BKE_fcurve.h" #include "BKE_global.h" +#include "BKE_idcode.h" #include "BKE_layer.h" #include "BKE_library.h" #include "BKE_main.h" @@ -71,6 +72,7 @@ #include "WM_types.h" #include "GPU_immediate.h" +#include "GPU_state.h" #include "UI_interface.h" #include "UI_interface_icons.h" @@ -286,11 +288,11 @@ static void hidebutton_base_flag_cb(bContext *C, void *poin, void *poin2) bool extend = (CTX_wm_window(C)->eventstate->ctrl == 0); /* Undo button toggle, let function do it. */ - base->flag ^= BASE_HIDE; + base->flag ^= BASE_HIDDEN; BKE_base_set_visible(scene, view_layer, base, extend); - if (!extend && (base->flag & BASE_VISIBLED)) { + if (!extend && (base->flag & BASE_VISIBLE)) { /* Auto select solo-ed object. */ ED_object_base_select(base, BA_SELECT); view_layer->basact = base; @@ -515,7 +517,7 @@ static void outliner_draw_restrictbuts( if (base) { bt = uiDefIconButBitS( - block, UI_BTYPE_ICON_TOGGLE, BASE_HIDE, 0, ICON_HIDE_OFF, + block, UI_BTYPE_ICON_TOGGLE, BASE_HIDDEN, 0, ICON_HIDE_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_HIDEX), te->ys, UI_UNIT_X, UI_UNIT_Y, &base->flag, 0, 0, 0, 0, TIP_("Hide object in viewport (Ctrl to isolate)")); @@ -738,7 +740,7 @@ static void outliner_draw_rnacols(ARegion *ar, int sizex) float miny = v2d->cur.ymin; if (miny < v2d->tot.ymin) miny = v2d->tot.ymin; - glLineWidth(1.0f); + GPU_line_width(1.0f); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -854,9 +856,9 @@ static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon) { /* restrict column clip... it has been coded by simply overdrawing, doesnt work for buttons */ if (arg->x >= arg->xmax) { - glEnable(GL_BLEND); + GPU_blend(true); UI_icon_draw_alpha(arg->x, arg->y, icon, arg->alpha); - glDisable(GL_BLEND); + GPU_blend(false); } else { uiBut *but = uiDefIconBut( @@ -905,7 +907,7 @@ static void UNUSED_FUNCTION(tselem_draw_gp_icon_uibut)(struct DrawIconArg *arg, static void tselem_draw_icon( uiBlock *block, int xmax, float x, float y, TreeStoreElem *tselem, TreeElement *te, - float alpha) + float alpha, const bool is_clickable) { struct DrawIconArg arg; float aspect; @@ -926,6 +928,7 @@ static void tselem_draw_icon( arg.y = y; #define ICON_DRAW(_icon) UI_icon_draw_alpha(x, y, _icon, alpha) +#define ICON_CLICK_DRAW(_icon) if (!is_clickable) ICON_DRAW(_icon); else tselem_draw_icon_uibut(&arg, _icon) if (tselem->type) { switch (tselem->type) { @@ -1198,33 +1201,33 @@ static void tselem_draw_icon( Object *ob = (Object *)tselem->id; switch (ob->type) { case OB_LAMP: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_LAMP); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_LAMP); break; case OB_MESH: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_MESH); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_MESH); break; case OB_CAMERA: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_CAMERA); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_CAMERA); break; case OB_CURVE: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_CURVE); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_CURVE); break; case OB_MBALL: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_META); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_META); break; case OB_LATTICE: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_LATTICE); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_LATTICE); break; case OB_ARMATURE: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_ARMATURE); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_ARMATURE); break; case OB_FONT: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_FONT); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_FONT); break; case OB_SURF: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_SURFACE); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_SURFACE); break; case OB_SPEAKER: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_SPEAKER); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_SPEAKER); break; case OB_LIGHTPROBE: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_LIGHTPROBE); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_LIGHTPROBE); break; case OB_EMPTY: if (ob->dup_group) { - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_GROUP_INSTANCE); + ICON_CLICK_DRAW(ICON_OUTLINER_OB_GROUP_INSTANCE); } else { - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_EMPTY); + ICON_CLICK_DRAW(ICON_OUTLINER_OB_EMPTY); } break; } @@ -1332,13 +1335,137 @@ static void tselem_draw_icon( #undef ICON_DRAW } +/** + * For icon-only children of a collapsed tree, + * Draw small number over the icon to show how many items of this type are displayed. + */ +static void outliner_draw_iconrow_number( + const uiFontStyle *fstyle, + int offsx, int ys, + const eOLDrawState active, + const int num_elements) +{ + float color[4] = {0.4f, 0.4f, 0.4f, 0.9f}; + copy_v3_fl(color, 0.2f); + if (active != OL_DRAWSEL_NONE) { + copy_v3_fl(color, 0.65f); + color[3] = 1.0f; + } + + float ufac = 0.25f * UI_UNIT_X; + float offset_x = (float) offsx + UI_UNIT_X * 0.35f; + + UI_draw_roundbox_corner_set(UI_CNR_ALL); + UI_draw_roundbox_aa(true, + offset_x + ufac, + (float)ys - UI_UNIT_Y * 0.2f + ufac, + offset_x + UI_UNIT_X - ufac, + (float)ys - UI_UNIT_Y * 0.2f + UI_UNIT_Y - ufac, + (float)UI_UNIT_Y / 2.0f - ufac, + color); + + /* Now the numbers. */ + unsigned char text_col[4]; + + UI_GetThemeColor4ubv(TH_TEXT_HI, text_col); + text_col[3] = 255; + + uiFontStyle fstyle_small = *fstyle; + fstyle_small.points *= 0.8f; + + /* We treat +99 as 4 digits to make sure the (eyeballed) alignment looks nice. */ + int num_digits = 4; + char number_text[4] = "+99\0"; + if (num_elements < 100) { + BLI_snprintf(number_text, sizeof(number_text), "%d", num_elements); + num_digits = num_elements < 10 ? 1 : 2; + } + UI_fontstyle_draw_simple(&fstyle_small, + (offset_x + ufac + UI_UNIT_X * (2 - num_digits) * 0.12f), + (float)ys - UI_UNIT_Y * 0.095f + ufac, + number_text, text_col); + UI_fontstyle_set(fstyle); + GPU_blend(true); /* Roundbox and text drawing disables. */ +} + +static void outliner_draw_iconrow_doit( + uiBlock *block, TreeElement *te, + const uiFontStyle *fstyle, + int xmax, int *offsx, int ys, float alpha_fac, + const eOLDrawState active, + const int num_elements) +{ + TreeStoreElem *tselem = TREESTORE(te); + + if (active != OL_DRAWSEL_NONE) { + float ufac = UI_UNIT_X / 20.0f; + float color[4] = {1.0f, 1.0f, 1.0f, 0.4f}; + + UI_draw_roundbox_corner_set(UI_CNR_ALL); + color[3] *= alpha_fac; + + UI_draw_roundbox_aa(true, + (float) *offsx + 1.0f * ufac, + (float)ys + 1.0f * ufac, + (float)*offsx + UI_UNIT_X - 1.0f * ufac, + (float)ys + UI_UNIT_Y - ufac, + (float)UI_UNIT_Y / 2.0f - ufac, + color); + GPU_blend(true); /* Roundbox disables. */ + } + + /* No inlined icon should be clickable. */ + tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, 0.5f * alpha_fac, false); + te->xs = *offsx; + te->ys = ys; + te->xend = (short)*offsx + UI_UNIT_X; + + if (num_elements > 1) { + outliner_draw_iconrow_number(fstyle, *offsx, ys, active, num_elements); + } + (*offsx) += UI_UNIT_X; +} + +/** + * Return the index to use based on the TreeElement ID and object type + * + * We use a continuum of indeces until we get to the object datablocks + * and we then make room for the object types. + */ +static int tree_element_id_type_to_index(TreeElement *te) +{ + TreeStoreElem *tselem = TREESTORE(te); + + const int id_index = tselem->type == 0 ? BKE_idcode_to_index(te->idcode) : INDEX_ID_GR; + if (id_index < INDEX_ID_OB) { + return id_index; + } + else if (id_index == INDEX_ID_OB) { + const Object *ob = (Object *)tselem->id; + return INDEX_ID_OB + ob->type; + } + else { + return id_index + OB_TYPE_MAX; + } +} + static void outliner_draw_iconrow( - bContext *C, uiBlock *block, Scene *scene, ViewLayer *view_layer, SpaceOops *soops, + bContext *C, uiBlock *block, const uiFontStyle *fstyle, Scene *scene, ViewLayer *view_layer, SpaceOops *soops, ListBase *lb, int level, int xmax, int *offsx, int ys, float alpha_fac) { eOLDrawState active; const Object *obact = OBACT(view_layer); + struct { + eOLDrawState active[INDEX_ID_MAX + OB_TYPE_MAX]; + int num_elements[INDEX_ID_MAX + OB_TYPE_MAX]; + TreeElement *tree_element[INDEX_ID_MAX + OB_TYPE_MAX]; + } data = { + .active = {0}, + .num_elements = {0}, + .tree_element = {NULL}, + }; + for (TreeElement *te = lb->first; te; te = te->next) { /* exit drawing early */ if ((*offsx) - UI_UNIT_X > xmax) @@ -1364,41 +1491,48 @@ static void outliner_draw_iconrow( active = tree_element_type_active(C, scene, view_layer, soops, te, tselem, OL_SETSEL_NONE, false); } - if (active != OL_DRAWSEL_NONE) { - float ufac = UI_UNIT_X / 20.0f; - float color[4] = {1.0f, 1.0f, 1.0f, 0.4f}; - - UI_draw_roundbox_corner_set(UI_CNR_ALL); - color[3] *= alpha_fac; - - UI_draw_roundbox_aa( - true, - (float) *offsx + 1.0f * ufac, - (float)ys + 1.0f * ufac, - (float)*offsx + UI_UNIT_X - 1.0f * ufac, - (float)ys + UI_UNIT_Y - ufac, - (float)UI_UNIT_Y / 2.0f - ufac, - color); - glEnable(GL_BLEND); /* roundbox disables */ + if (!ELEM(tselem->type, 0, TSE_LAYER_COLLECTION)) { + outliner_draw_iconrow_doit(block, te, fstyle, xmax, offsx, ys, alpha_fac, active, 1); + } + else { + const int index = tree_element_id_type_to_index(te); + data.num_elements[index]++; + if ((data.tree_element[index] == NULL) || + (active > data.active[index])) + { + data.tree_element[index] = te; + } + data.active[index] = MAX2(active, data.active[index]); } - - tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, 0.5f * alpha_fac); - te->xs = *offsx; - te->ys = ys; - te->xend = (short)*offsx + UI_UNIT_X; - te->flag |= TE_ICONROW; // for click - - (*offsx) += UI_UNIT_X; } /* this tree element always has same amount of branches, so don't draw */ if (tselem->type != TSE_R_LAYER) { outliner_draw_iconrow( - C, block, scene, view_layer, soops, + C, block, fstyle, scene, view_layer, soops, &te->subtree, level + 1, xmax, offsx, ys, alpha_fac); } } + for (int i = 0; i < INDEX_ID_MAX; i++) { + const int num_subtypes = (i == INDEX_ID_OB) ? OB_TYPE_MAX : 1; + /* See tree_element_id_type_to_index for the index logic. */ + int index_base = i; + if (i > INDEX_ID_OB) { + index_base += OB_TYPE_MAX; + } + for (int j = 0; j < num_subtypes; j++) { + const int index = index_base + j; + if (data.num_elements[index] != 0) { + outliner_draw_iconrow_doit(block, + data.tree_element[index], + fstyle, + xmax, offsx, ys, alpha_fac, + data.active[index], + data.num_elements[index]); + } + } + } } /* closed tree element */ @@ -1447,7 +1581,7 @@ static void outliner_draw_tree_element( if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) xmax -= OL_TOGW + UI_UNIT_X; - glEnable(GL_BLEND); + GPU_blend(true); /* colors for active/selected data */ if (tselem->type == 0) { @@ -1510,7 +1644,7 @@ static void outliner_draw_tree_element( (float)startx + 2.0f * UI_UNIT_X - 1.0f * ufac, (float)*starty + UI_UNIT_Y - 1.0f * ufac, UI_UNIT_Y / 2.0f - 1.0f * ufac, color); - glEnable(GL_BLEND); /* roundbox disables it */ + GPU_blend(true); /* roundbox disables it */ te->flag |= TE_ACTIVE; // for lookup in display hierarchies } @@ -1539,7 +1673,7 @@ static void outliner_draw_tree_element( /* datatype icon */ if (!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM, TSE_ID_BASE))) { - tselem_draw_icon(block, xmax, (float)startx + offsx, (float)*starty, tselem, te, alpha_fac); + tselem_draw_icon(block, xmax, (float)startx + offsx, (float)*starty, tselem, te, alpha_fac, true); offsx += UI_UNIT_X + 2 * ufac; } else @@ -1569,7 +1703,7 @@ static void outliner_draw_tree_element( alpha_fac); offsx += UI_UNIT_X + 2 * ufac; } - glDisable(GL_BLEND); + GPU_blend(false); /* name */ if ((tselem->flag & TSE_TEXTBUT) == 0) { @@ -1602,7 +1736,7 @@ static void outliner_draw_tree_element( else if (tselem->type != TSE_R_LAYER) { int tempx = startx + offsx; - glEnable(GL_BLEND); + GPU_blend(true); /* divider */ { @@ -1623,10 +1757,10 @@ static void outliner_draw_tree_element( } outliner_draw_iconrow( - C, block, scene, view_layer, soops, &te->subtree, 0, xmax, &tempx, + C, block, fstyle, scene, view_layer, soops, &te->subtree, 0, xmax, &tempx, *starty, alpha_fac); - glDisable(GL_BLEND); + GPU_blend(false); } } } @@ -1676,14 +1810,14 @@ static void outliner_draw_tree_element_floating( UI_GetThemeColorShade4fv(TH_BACK, -40, col); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - glEnable(GL_BLEND); + GPU_blend(true); if (ELEM(te_floating->drag_data->insert_type, TE_INSERT_BEFORE, TE_INSERT_AFTER)) { if (te_floating->drag_data->insert_type == TE_INSERT_BEFORE) { coord_y += UI_UNIT_Y; } immUniformColor4fv(col); - glLineWidth(line_width); + GPU_line_width(line_width); immBegin(GWN_PRIM_LINE_STRIP, 2); immVertex2f(pos, coord_x, coord_y); @@ -1702,7 +1836,7 @@ static void outliner_draw_tree_element_floating( immEnd(); } - glDisable(GL_BLEND); + GPU_blend(false); immUnbindProgram(); } @@ -1776,9 +1910,9 @@ static void outliner_draw_hierarchy_lines(SpaceOops *soops, ListBase *lb, int st UI_GetThemeColorBlend3ubv(TH_BACK, TH_TEXT, 0.4f, col); col[3] = 255; - glEnable(GL_BLEND); + GPU_blend(true); outliner_draw_hierarchy_lines_recursive(pos, soops, lb, startx, col, false, starty); - glDisable(GL_BLEND); + GPU_blend(false); immUnbindProgram(); } @@ -1828,7 +1962,6 @@ static void outliner_draw_highlights_recursive( const bool is_searching = ( SEARCHING_OUTLINER(soops) || (soops->outlinevis == SO_DATA_API && - (soops->filter & SO_FILTER_SEARCH) && soops->search_string[0] != 0)); for (TreeElement *te = lb->first; te; te = te->next) { @@ -1874,7 +2007,7 @@ static void outliner_draw_highlights(ARegion *ar, SpaceOops *soops, int startx, UI_GetThemeColor4fv(TH_MATCH, col_searchmatch); col_searchmatch[3] = 0.5f; - glEnable(GL_BLEND); + GPU_blend(true); Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1882,7 +2015,7 @@ static void outliner_draw_highlights(ARegion *ar, SpaceOops *soops, int startx, pos, ar, soops, &soops->tree, col_selection, col_highlight, col_searchmatch, startx, starty); immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } static void outliner_draw_tree( @@ -1894,7 +2027,7 @@ static void outliner_draw_tree( TreeElement *te_floating = NULL; int starty, startx; - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // only once + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); // only once if (soops->outlinevis == SO_DATA_API) { /* struct marks */ @@ -1908,13 +2041,13 @@ static void outliner_draw_tree( outliner_draw_highlights(ar, soops, startx, &starty); /* set scissor so tree elements or lines can't overlap restriction icons */ - GLfloat scissor[4] = {0}; + float scissor[4] = {0}; if (has_restrict_icons) { int mask_x = BLI_rcti_size_x(&ar->v2d.mask) - (int)OL_TOGW + 1; CLAMP_MIN(mask_x, 0); - glGetFloatv(GL_SCISSOR_BOX, scissor); - glScissor(0, 0, mask_x, ar->winy); + GPU_scissor_get_f(scissor); + GPU_scissor(0, 0, mask_x, ar->winy); } // gray hierarchy lines @@ -1938,7 +2071,7 @@ static void outliner_draw_tree( if (has_restrict_icons) { /* reset scissor */ - glScissor(UNPACK4(scissor)); + GPU_scissor(UNPACK4(scissor)); } } @@ -1980,7 +2113,7 @@ static void outliner_back(ARegion *ar) static void outliner_draw_restrictcols(ARegion *ar) { - glLineWidth(1.0f); + GPU_line_width(1.0f); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -2097,13 +2230,13 @@ void draw_outliner(const bContext *C) outliner_draw_restrictbuts(block, scene, view_layer, ar, soops, &soops->tree); } + UI_block_emboss_set(block, UI_EMBOSS); + /* draw edit buttons if nessecery */ if (te_edit) { outliner_buttons(C, block, ar, te_edit); } - UI_block_emboss_set(block, UI_EMBOSS); - UI_block_end(C, block); UI_block_draw(C, block); } diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index a455f8c076a..1c78931b449 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -242,7 +242,7 @@ static int outliner_item_openclose(bContext *C, wmOperator *op, const wmEvent *e void OUTLINER_OT_item_openclose(wmOperatorType *ot) { - ot->name = "Open/Close Item"; + ot->name = "Open/Close"; ot->idname = "OUTLINER_OT_item_openclose"; ot->description = "Toggle whether item under cursor is enabled or closed"; @@ -399,7 +399,7 @@ static int outliner_item_rename(bContext *C, wmOperator *op, const wmEvent *even void OUTLINER_OT_item_rename(wmOperatorType *ot) { - ot->name = "Rename Item"; + ot->name = "Rename"; ot->idname = "OUTLINER_OT_item_rename"; ot->description = "Rename item under cursor"; @@ -542,7 +542,7 @@ static int outliner_id_remap_exec(bContext *C, wmOperator *op) DEG_relations_tag_update(bmain); /* free gpu materials, some materials depend on existing objects, such as lamps so freeing correctly refreshes */ - GPU_materials_free(); + GPU_materials_free(bmain); WM_event_add_notifier(C, NC_WINDOW, NULL); @@ -1385,7 +1385,7 @@ void OUTLINER_OT_show_hierarchy(wmOperatorType *ot) /* KeyingSet and Driver Creation - Helper functions */ /* specialized poll callback for these operators to work in Datablocks view only */ -static int ed_operator_outliner_datablocks_active(bContext *C) +static bool ed_operator_outliner_datablocks_active(bContext *C) { ScrArea *sa = CTX_wm_area(C); if ((sa) && (sa->spacetype == SPACE_OUTLINER)) { @@ -1873,7 +1873,7 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) /* ************************************************************** */ /* ORPHANED DATABLOCKS */ -static int ed_operator_outliner_id_orphans_active(bContext *C) +static bool ed_operator_outliner_id_orphans_active(bContext *C) { ScrArea *sa = CTX_wm_area(C); if ((sa) && (sa->spacetype == SPACE_OUTLINER)) { @@ -2110,7 +2110,7 @@ void OUTLINER_OT_parent_drop(wmOperatorType *ot) RNA_def_enum(ot->srna, "type", prop_make_parent_types, 0, "Type", ""); } -static int outliner_parenting_poll(bContext *C) +static bool outliner_parenting_poll(bContext *C) { SpaceOops *soops = CTX_wm_space_outliner(C); @@ -2366,6 +2366,7 @@ static int collection_drop_invoke(bContext *C, wmOperator *op, const wmEvent *ev Object *ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, childname); BKE_collection_object_add(bmain, collection, ob); + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 1f8320f73a0..0ab22208841 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -182,7 +182,7 @@ typedef enum { * - not searching into RNA items helps but isn't the complete solution */ -#define SEARCHING_OUTLINER(sov) ((sov->search_flags & SO_SEARCH_RECURSIVE) && (sov->filter & SO_FILTER_SEARCH)) +#define SEARCHING_OUTLINER(sov) (sov->search_flags & SO_SEARCH_RECURSIVE) /* is the currrent element open? if so we also show children */ #define TSELEM_OPEN(telm, sv) ( (telm->flag & TSE_CLOSED) == 0 || (SEARCHING_OUTLINER(sv) && (telm->flag & TSE_CHILDSEARCH)) ) diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 316caf0e239..4d8c0c5bd38 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -41,6 +41,7 @@ #include "BKE_main.h" #include "GPU_immediate.h" +#include "GPU_state.h" #include "RNA_access.h" @@ -64,7 +65,7 @@ enum { OUTLINER_ITEM_DRAG_CONFIRM, }; -static int outliner_item_drag_drop_poll(bContext *C) +static bool outliner_item_drag_drop_poll(bContext *C) { SpaceOops *soops = CTX_wm_space_outliner(C); return ED_operator_outliner_active(C) && @@ -346,9 +347,9 @@ static void outliner_drag_drop_tooltip_cb(const wmWindow *win, void *vdata) const float col_fg[4] = {1.0f, 1.0f, 1.0f, 1.0f}; const float col_bg[4] = {0.0f, 0.0f, 0.0f, 0.2f}; - glEnable(GL_BLEND); + GPU_blend(true); UI_fontstyle_draw_simple_backdrop(fstyle, x, y, tooltip, col_fg, col_bg); - glDisable(GL_BLEND); + GPU_blend(false); } static int outliner_item_drag_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -388,7 +389,7 @@ static int outliner_item_drag_drop_invoke(bContext *C, wmOperator *op, const wmE */ static void OUTLINER_OT_item_drag_drop(wmOperatorType *ot) { - ot->name = "Drag and Drop Item"; + ot->name = "Drag and Drop"; ot->idname = "OUTLINER_OT_item_drag_drop"; ot->description = "Change the hierarchical position of an item by repositioning it using drag and drop"; @@ -466,7 +467,7 @@ static wmKeyMap *outliner_item_drag_drop_modal_keymap(wmKeyConfig *keyconf) {OUTLINER_ITEM_DRAG_CONFIRM, "CONFIRM", 0, "Confirm/Drop", ""}, {0, NULL, 0, NULL, NULL} }; - const char *map_name = "Outliner Item Drap 'n Drop Modal Map"; + const char *map_name = "Outliner Item Drap & Drop Modal Map"; wmKeyMap *keymap = WM_modalkeymap_get(keyconf, map_name); @@ -555,7 +556,9 @@ void outliner_keymap(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "OUTLINER_OT_drivers_delete_selected", DKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "OUTLINER_OT_collection_new", CKEY, KM_PRESS, 0, 0); + WM_keymap_verify_item(keymap, "OUTLINER_OT_collection_delete", XKEY, KM_PRESS, 0, 0); + WM_keymap_verify_item(keymap, "OUTLINER_OT_collection_delete", DELKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_move_to_collection", MKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_link_to_collection", MKEY, KM_PRESS, KM_SHIFT, 0); @@ -569,4 +572,3 @@ void outliner_keymap(wmKeyConfig *keyconf) outliner_item_drag_drop_modal_keymap(keyconf); } - diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 38ae0683d4b..6668ea1faeb 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -206,7 +206,7 @@ static void do_outliner_object_select_recursive(ViewLayer *view_layer, Object *o for (base = FIRSTBASE(view_layer); base; base = base->next) { Object *ob = base->object; - if ((((base->flag & BASE_VISIBLED) == 0) && BKE_object_is_child_recursive(ob_parent, ob))) { + if ((((base->flag & BASE_VISIBLE) == 0) && BKE_object_is_child_recursive(ob_parent, ob))) { ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT); } } @@ -1000,7 +1000,7 @@ static void do_outliner_item_activate_tree_element( Object *ob = (Object *)outliner_search_back(soops, te, ID_OB); if ((ob != NULL) && (ob->data == tselem->id)) { Base *base = BKE_view_layer_base_find(view_layer, ob); - if ((base != NULL) && (base->flag & BASE_VISIBLED)) { + if ((base != NULL) && (base->flag & BASE_VISIBLE)) { do_outliner_activate_obdata(C, scene, view_layer, base); } } @@ -1142,9 +1142,9 @@ static int outliner_item_activate_invoke(bContext *C, wmOperator *op, const wmEv void OUTLINER_OT_item_activate(wmOperatorType *ot) { - ot->name = "Activate Item"; + ot->name = "Select"; ot->idname = "OUTLINER_OT_item_activate"; - ot->description = "Handle mouse clicks to activate/select items"; + ot->description = "Handle mouse clicks to select and activate items"; ot->invoke = outliner_item_activate_invoke; diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 32918806765..9952db5e652 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -63,6 +63,7 @@ #include "BKE_main.h" #include "BKE_report.h" #include "BKE_scene.h" +#include "BKE_screen.h" #include "BKE_sequencer.h" #include "DEG_depsgraph.h" @@ -229,18 +230,22 @@ static void unlink_collection_cb( if (GS(tsep->id->name) == ID_OB) { Object *ob = (Object *)tsep->id; ob->dup_group = NULL; + DEG_id_tag_update(&ob->id, OB_RECALC_OB); DEG_relations_tag_update(bmain); } else if (GS(tsep->id->name) == ID_GR) { Collection *parent = (Collection *)tsep->id; id_fake_user_set(&collection->id); BKE_collection_child_remove(bmain, parent, collection); + DEG_id_tag_update(&parent->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); } else if (GS(tsep->id->name) == ID_SCE) { - Collection *parent = BKE_collection_master((Scene *)tsep->id); + Scene *scene = (Scene *)tsep->id; + Collection *parent = BKE_collection_master(scene); id_fake_user_set(&collection->id); BKE_collection_child_remove(bmain, parent, collection); + DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); } } @@ -257,11 +262,14 @@ static void unlink_object_cb( if (GS(tsep->id->name) == ID_GR) { Collection *parent = (Collection *)tsep->id; BKE_collection_object_remove(bmain, parent, ob, true); + DEG_id_tag_update(&parent->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); } else if (GS(tsep->id->name) == ID_SCE) { - Collection *parent = BKE_collection_master((Scene *)tsep->id); + Scene *scene = (Scene *)tsep->id; + Collection *parent = BKE_collection_master(scene); BKE_collection_object_remove(bmain, parent, ob, true); + DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); } } @@ -394,7 +402,7 @@ static void object_select_cb( Object *ob = (Object *)tselem->id; Base *base = BKE_view_layer_base_find(view_layer, ob); - if (base && ((base->flag & BASE_VISIBLED) != 0)) { + if (base && ((base->flag & BASE_VISIBLE) != 0)) { base->flag |= BASE_SELECTED; } } @@ -1776,6 +1784,26 @@ void OUTLINER_OT_data_operation(wmOperatorType *ot) /* ******************** */ +static int outliner_operator_menu(bContext *C, const char *opname) +{ + wmOperatorType *ot = WM_operatortype_find(opname, false); + uiPopupMenu *pup = UI_popup_menu_begin(C, RNA_struct_ui_name(ot->srna), ICON_NONE); + uiLayout *layout = UI_popup_menu_layout(pup); + + /* set this so the default execution context is the same as submenus */ + uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN); + uiItemsEnumO(layout, ot->idname, RNA_property_identifier(ot->prop)); + + MenuType *mt = WM_menutype_find("OUTLINER_MT_context", false); + if (mt) { + uiItemS(layout); + UI_menutype_draw(C, mt, layout); + } + + UI_popup_menu_end(C, pup); + + return OPERATOR_INTERFACE; +} static int do_outliner_operation_event(bContext *C, ARegion *ar, SpaceOops *soops, TreeElement *te, const float mval[2]) @@ -1804,28 +1832,32 @@ static int do_outliner_operation_event(bContext *C, ARegion *ar, SpaceOops *soop if (scenelevel) { if (objectlevel || datalevel || idlevel) { BKE_report(reports, RPT_WARNING, "Mixed selection"); + return OPERATOR_CANCELLED; } else { - WM_operator_name_call(C, "OUTLINER_OT_scene_operation", WM_OP_INVOKE_REGION_WIN, NULL); + return outliner_operator_menu(C, "OUTLINER_OT_scene_operation"); } } else if (objectlevel) { WM_menu_name_call(C, "OUTLINER_MT_object", WM_OP_INVOKE_REGION_WIN); + return OPERATOR_FINISHED; } else if (idlevel) { if (idlevel == -1 || datalevel) { BKE_report(reports, RPT_WARNING, "Mixed selection"); + return OPERATOR_CANCELLED; } else { switch (idlevel) { case ID_GR: WM_menu_name_call(C, "OUTLINER_MT_collection", WM_OP_INVOKE_REGION_WIN); + return OPERATOR_FINISHED; break; case ID_LI: - WM_operator_name_call(C, "OUTLINER_OT_lib_operation", WM_OP_INVOKE_REGION_WIN, NULL); + return outliner_operator_menu(C, "OUTLINER_OT_lib_operation"); break; default: - WM_operator_name_call(C, "OUTLINER_OT_id_operation", WM_OP_INVOKE_REGION_WIN, NULL); + return outliner_operator_menu(C, "OUTLINER_OT_id_operation"); break; } } @@ -1833,41 +1865,49 @@ static int do_outliner_operation_event(bContext *C, ARegion *ar, SpaceOops *soop else if (datalevel) { if (datalevel == -1) { BKE_report(reports, RPT_WARNING, "Mixed selection"); + return OPERATOR_CANCELLED; } else { - if (datalevel == TSE_ANIM_DATA) - WM_operator_name_call(C, "OUTLINER_OT_animdata_operation", WM_OP_INVOKE_REGION_WIN, NULL); + if (datalevel == TSE_ANIM_DATA) { + return outliner_operator_menu(C, "OUTLINER_OT_animdata_operation"); + } else if (datalevel == TSE_DRIVER_BASE) { /* do nothing... no special ops needed yet */ + return OPERATOR_CANCELLED; } else if (datalevel == TSE_LAYER_COLLECTION) { WM_menu_name_call(C, "OUTLINER_MT_collection", WM_OP_INVOKE_REGION_WIN); + return OPERATOR_FINISHED; } else if (ELEM(datalevel, TSE_SCENE_COLLECTION_BASE, TSE_VIEW_COLLECTION_BASE)) { WM_menu_name_call(C, "OUTLINER_MT_collection_new", WM_OP_INVOKE_REGION_WIN); + return OPERATOR_FINISHED; } else if (datalevel == TSE_ID_BASE) { /* do nothing... there are no ops needed here yet */ } else if (datalevel == TSE_CONSTRAINT) { - WM_operator_name_call(C, "OUTLINER_OT_constraint_operation", WM_OP_INVOKE_REGION_WIN, NULL); + return outliner_operator_menu(C, "OUTLINER_OT_constraint_operation"); } else if (datalevel == TSE_MODIFIER) { - WM_operator_name_call(C, "OUTLINER_OT_modifier_operation", WM_OP_INVOKE_REGION_WIN, NULL); + return outliner_operator_menu(C, "OUTLINER_OT_modifier_operation"); } else { - WM_operator_name_call(C, "OUTLINER_OT_data_operation", WM_OP_INVOKE_REGION_WIN, NULL); + return outliner_operator_menu(C, "OUTLINER_OT_data_operation"); } } } - return 1; + return 0; } for (te = te->subtree.first; te; te = te->next) { - if (do_outliner_operation_event(C, ar, soops, te, mval)) - return 1; + int retval = do_outliner_operation_event(C, ar, soops, te, mval); + if (retval) { + return retval; + } } + return 0; } @@ -1879,7 +1919,6 @@ static int outliner_operation(bContext *C, wmOperator *UNUSED(op), const wmEvent uiBut *but = UI_context_active_but_get(C); TreeElement *te; float fmval[2]; - bool found = false; if (but) { UI_but_tooltip_timer_remove(C, but); @@ -1888,26 +1927,26 @@ static int outliner_operation(bContext *C, wmOperator *UNUSED(op), const wmEvent UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); for (te = soops->tree.first; te; te = te->next) { - if (do_outliner_operation_event(C, ar, soops, te, fmval)) { - found = true; - break; + int retval = do_outliner_operation_event(C, ar, soops, te, fmval); + if (retval) { + return retval; } } - if (!found) { - /* Menus for clicking in empty space. */ - if (soops->outlinevis == SO_VIEW_LAYER) { - WM_menu_name_call(C, "OUTLINER_MT_collection_new", WM_OP_INVOKE_REGION_WIN); - } + /* Menus for clicking in empty space. */ + if (soops->outlinevis == SO_VIEW_LAYER) { + WM_menu_name_call(C, "OUTLINER_MT_collection_new", WM_OP_INVOKE_REGION_WIN); + return OPERATOR_FINISHED; } + WM_menu_name_call(C, "OUTLINER_MT_context", WM_OP_INVOKE_REGION_WIN); return OPERATOR_FINISHED; } /* Menu only! Calls other operators */ void OUTLINER_OT_operation(wmOperatorType *ot) { - ot->name = "Execute Operation"; + ot->name = "Context Menu"; ot->idname = "OUTLINER_OT_operation"; ot->description = "Context menu for item operations"; diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 13b62b766f5..9f6c944c914 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -1470,7 +1470,7 @@ static void outliner_add_layer_collection_objects( TreeElement *te_object = outliner_add_element(soops, tree, base->object, ten, 0, 0); te_object->directdata = base; - if (!(base->flag & BASE_VISIBLED)) { + if (!(base->flag & BASE_VISIBLE)) { te_object->flag |= TE_DISABLED; } } @@ -1493,7 +1493,8 @@ static void outliner_add_layer_collections_recursive( const bool exclude = (lc->flag & LAYER_COLLECTION_EXCLUDE) != 0; if (exclude || ((layer->runtime_flag & VIEW_LAYER_HAS_HIDE) && - !(lc->runtime_flag & LAYER_COLLECTION_HAS_VISIBLE_OBJECTS))) { + !(lc->runtime_flag & LAYER_COLLECTION_HAS_VISIBLE_OBJECTS))) + { ten->flag |= TE_DISABLED; } @@ -1891,10 +1892,11 @@ static int outliner_exclude_filter_get(SpaceOops *soops) { int exclude_filter = soops->filter & ~SO_FILTER_OB_STATE; - if (soops->filter & SO_FILTER_SEARCH) { - if (soops->search_string[0] == 0) { - exclude_filter &= ~SO_FILTER_SEARCH; - } + if (soops->search_string[0] != 0) { + exclude_filter |= SO_FILTER_SEARCH; + } + else { + exclude_filter &= ~SO_FILTER_SEARCH; } /* Let's have this for the collection options at first. */ @@ -1982,7 +1984,7 @@ static bool outliner_element_visible_get(ViewLayer *view_layer, TreeElement *te, } if (exclude_filter & SO_FILTER_OB_STATE_VISIBLE) { - if ((base->flag & BASE_VISIBLED) == 0) { + if ((base->flag & BASE_VISIBLE) == 0) { return false; } } @@ -2268,5 +2270,3 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa BKE_main_id_clear_newpoins(mainvar); } - - diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 71ae7eeeb3d..e1baaf54163 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -63,6 +63,7 @@ #include "outliner_intern.h" +#include "GPU_framebuffer.h" static void outliner_main_region_init(wmWindowManager *wm, ARegion *ar) { @@ -92,7 +93,7 @@ static void outliner_main_region_init(wmWindowManager *wm, ARegion *ar) WM_event_add_dropbox_handler(&ar->handlers, lb); } -static int outliner_parent_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool outliner_parent_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); SpaceOops *soops = CTX_wm_space_outliner(C); @@ -150,7 +151,7 @@ static void outliner_parent_drop_copy(wmDrag *drag, wmDropBox *drop) RNA_string_set(drop->ptr, "child", id->name + 2); } -static int outliner_parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool outliner_parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); SpaceOops *soops = CTX_wm_space_outliner(C); @@ -196,7 +197,7 @@ static void outliner_parent_clear_copy(wmDrag *drag, wmDropBox *drop) RNA_enum_set(drop->ptr, "type", 0); } -static int outliner_scene_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool outliner_scene_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); SpaceOops *soops = CTX_wm_space_outliner(C); @@ -221,7 +222,7 @@ static void outliner_scene_drop_copy(wmDrag *drag, wmDropBox *drop) RNA_string_set(drop->ptr, "object", id->name + 2); } -static int outliner_material_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool outliner_material_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); SpaceOops *soops = CTX_wm_space_outliner(C); @@ -246,7 +247,7 @@ static void outliner_material_drop_copy(wmDrag *drag, wmDropBox *drop) RNA_string_set(drop->ptr, "material", id->name + 2); } -static int outliner_collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool outliner_collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); SpaceOops *soops = CTX_wm_space_outliner(C); @@ -289,7 +290,7 @@ static void outliner_main_region_draw(const bContext *C, ARegion *ar) /* clear */ UI_ThemeClearColor(TH_BACK); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); draw_outliner(C); @@ -610,4 +611,3 @@ void ED_spacetype_outliner(void) BKE_spacetype_register(st); } - diff --git a/source/blender/editors/space_script/script_intern.h b/source/blender/editors/space_script/script_intern.h index a3fcbb34e7e..0e0936cf082 100644 --- a/source/blender/editors/space_script/script_intern.h +++ b/source/blender/editors/space_script/script_intern.h @@ -43,4 +43,3 @@ void SCRIPT_OT_python_file_run(struct wmOperatorType *ot); void SCRIPT_OT_autoexec_warn_clear(struct wmOperatorType *ot); #endif /* __SCRIPT_INTERN_H__ */ - diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c index c8e5a4bdf87..8b6100cd9e0 100644 --- a/source/blender/editors/space_script/space_script.c +++ b/source/blender/editors/space_script/space_script.c @@ -55,6 +55,7 @@ #endif #include "script_intern.h" // own include +#include "GPU_framebuffer.h" //static script_run_python(char *funcname, ) @@ -144,7 +145,7 @@ static void script_main_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); @@ -225,4 +226,3 @@ void ED_spacetype_script(void) BKE_spacetype_register(st); } - diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c index 72f78d4f466..a4bca555490 100644 --- a/source/blender/editors/space_sequencer/sequencer_buttons.c +++ b/source/blender/editors/space_sequencer/sequencer_buttons.c @@ -52,7 +52,7 @@ /* **************************** buttons ********************************* */ #if 0 -static int sequencer_grease_pencil_panel_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool sequencer_grease_pencil_panel_poll(const bContext *C, PanelType *UNUSED(pt)) { SpaceSeq *sseq = CTX_wm_space_seq(C); @@ -102,4 +102,3 @@ void SEQUENCER_OT_properties(wmOperatorType *ot) /* flags */ ot->flag = 0; } - diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index ffcb4329726..7da20131069 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -61,6 +61,8 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" +#include "GPU_state.h" +#include "GPU_framebuffer.h" #include "ED_anim_api.h" #include "ED_gpencil.h" @@ -263,7 +265,7 @@ static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *s immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f); - glEnable(GL_BLEND); + GPU_blend(true); immBegin(GWN_PRIM_TRI_STRIP, length * 2); @@ -296,7 +298,7 @@ static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *s immEnd(); - glDisable(GL_BLEND); + GPU_blend(false); } } static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, float x2, float y2) @@ -328,8 +330,8 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, offset = 0; } - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); for (seq = seqbase->first; seq; seq = seq->next) { chan_min = min_ii(chan_min, seq->machine); @@ -379,7 +381,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } /* clamp handles to defined size in pixel space */ @@ -432,9 +434,9 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla if (!(seq->type & SEQ_TYPE_EFFECT) || BKE_sequence_effect_get_num_inputs(seq->type) == 0) { - glEnable(GL_BLEND); + GPU_blend(true); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); if (seq->flag & whichsel) { immUniformColor4ub(0, 0, 0, 80); @@ -461,7 +463,7 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla immVertex2fv(pos, v3); immEnd(); - glDisable(GL_BLEND); + GPU_blend(false); } if ((G.moving & G_TRANSFORM_SEQ) || (seq->flag & whichsel)) { @@ -618,8 +620,8 @@ static void draw_sequence_extensions(Scene *scene, ARegion *ar, Sequence *seq, u blendcol[0] = blendcol[1] = blendcol[2] = 120; if (seq->startofs || seq->endofs) { - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); color3ubv_from_seq(scene, seq, col); @@ -658,12 +660,12 @@ static void draw_sequence_extensions(Scene *scene, ARegion *ar, Sequence *seq, u } if (seq->startofs || seq->endofs) { - glDisable(GL_BLEND); + GPU_blend(false); } if (seq->startstill || seq->endstill) { - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); color3ubv_from_seq(scene, seq, col); UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5f, 60); @@ -691,7 +693,7 @@ static void draw_sequence_extensions(Scene *scene, ARegion *ar, Sequence *seq, u } if (seq->startstill || seq->endstill) { - glDisable(GL_BLEND); + GPU_blend(false); } } @@ -728,8 +730,8 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg if (seq->flag & SEQ_MUTE) { background_col[3] = 128; - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); } else { background_col[3] = 255; @@ -751,7 +753,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg } if (seq->flag & SEQ_MUTE) { - glDisable(GL_BLEND); + GPU_blend(false); } if (!is_single_image) { @@ -777,7 +779,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg /* draw lock */ if (seq->flag & SEQ_LOCK) { - glEnable(GL_BLEND); + GPU_blend(true); pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_DIAG_STRIPES); @@ -791,11 +793,11 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } if (!BKE_sequence_is_valid_check(seq)) { - glEnable(GL_BLEND); + GPU_blend(true); pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_DIAG_STRIPES); @@ -809,7 +811,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } color3ubv_from_seq(scene, seq, col); @@ -840,8 +842,8 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg if (seq->flag & SEQ_MUTE) { col[3] = 96; - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); immUniformColor4ubv(col); } @@ -1035,7 +1037,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons float x2 = v2d->tot.xmax; float y2 = v2d->tot.ymax; - glLineWidth(1.0f); + GPU_line_width(1.0f); /* border */ const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -1043,11 +1045,11 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); immUniformThemeColor(TH_BACK); - immUniform1i("num_colors", 0); /* Simple dashes. */ + immUniform1i("colors_len", 0); /* Simple dashes. */ immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); @@ -1124,8 +1126,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq if ((!draw_overlay || sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE) && !draw_backdrop) { UI_GetThemeColor3fv(TH_SEQ_PREVIEW, col); - glClearColor(col[0], col[1], col[2], 0.0); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear_color(col[0], col[1], col[2], 0.0); + GPU_clear(GPU_COLOR_BIT); } /* only initialize the preview if a render is in progress */ @@ -1221,8 +1223,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq } if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA) { - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); } /* Format needs to be created prior to any immBindProgram call. @@ -1418,7 +1420,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq } if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA) { - glDisable(GL_BLEND); + GPU_blend(false); } glDeleteTextures(1, &texid); @@ -1589,7 +1591,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) /* draw highlight when previewing a single strip */ if (special_seq_update) { const Sequence *seq = special_seq_update; - glEnable(GL_BLEND); + GPU_blend(true); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1599,7 +1601,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } } @@ -1609,7 +1611,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) const int frame_sta = PSFRA; const int frame_end = PEFRA + 1; - glEnable(GL_BLEND); + GPU_blend(true); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1660,7 +1662,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } /* Draw Timeline/Strip Editor Mode for Sequencer */ @@ -1677,10 +1679,10 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); if (ed && ed->metastack.first) - glClearColor(col[0], col[1], col[2] - 0.1f, 0.0f); + GPU_clear_color(col[0], col[1], col[2] - 0.1f, 0.0f); else - glClearColor(col[0], col[1], col[2], 0.0f); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear_color(col[0], col[1], col[2], 0.0f); + GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); @@ -1764,5 +1766,3 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) ANIM_draw_cfra_number(C, v2d, cfra_flag); } } - - diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index a78b3ee79c1..cefc6cdd814 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -476,7 +476,7 @@ void recurs_sel_seq(Sequence *seqm) } } -int ED_space_sequencer_maskedit_mask_poll(bContext *C) +bool ED_space_sequencer_maskedit_mask_poll(bContext *C) { /* in this case both funcs are the same, for clip editor not */ return ED_space_sequencer_maskedit_poll(C); @@ -491,7 +491,7 @@ bool ED_space_sequencer_check_show_maskedit(SpaceSeq *sseq, Scene *scene) return false; } -int ED_space_sequencer_maskedit_poll(bContext *C) +bool ED_space_sequencer_maskedit_poll(bContext *C) { SpaceSeq *sseq = CTX_wm_space_seq(C); @@ -1149,27 +1149,27 @@ static int seq_get_snaplimit(View2D *v2d) #endif /* Operator functions */ -int sequencer_edit_poll(bContext *C) +bool sequencer_edit_poll(bContext *C) { return (BKE_sequencer_editing_get(CTX_data_scene(C), false) != NULL); } #if 0 /* UNUSED */ -int sequencer_strip_poll(bContext *C) +bool sequencer_strip_poll(bContext *C) { Editing *ed; return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), false)) != NULL) && (ed->act_seq != NULL)); } #endif -int sequencer_strip_has_path_poll(bContext *C) +bool sequencer_strip_has_path_poll(bContext *C) { Editing *ed; Sequence *seq; return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), false)) != NULL) && ((seq = ed->act_seq) != NULL) && (SEQ_HAS_PATH(seq))); } -int sequencer_view_preview_poll(bContext *C) +bool sequencer_view_preview_poll(bContext *C) { SpaceSeq *sseq = CTX_wm_space_seq(C); Editing *ed = BKE_sequencer_editing_get(CTX_data_scene(C), false); @@ -1179,7 +1179,7 @@ int sequencer_view_preview_poll(bContext *C) return 0; } -int sequencer_view_strips_poll(bContext *C) +bool sequencer_view_strips_poll(bContext *C) { SpaceSeq *sseq = CTX_wm_space_seq(C); if (sseq && ED_space_sequencer_check_show_strip(sseq)) @@ -1534,7 +1534,7 @@ static void sequencer_slip_update_header(Scene *scene, ScrArea *sa, SlipData *da } } - ED_area_headerprint(sa, msg); + ED_area_status_text(sa, msg); } static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *event) @@ -1605,7 +1605,7 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even MEM_freeN(data); op->customdata = NULL; if (sa) { - ED_area_headerprint(sa, NULL); + ED_area_status_text(sa, NULL); } WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -1638,7 +1638,7 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even BKE_sequencer_free_imbuf(scene, &ed->seqbase, false); if (sa) { - ED_area_headerprint(sa, NULL); + ED_area_status_text(sa, NULL); } return OPERATOR_CANCELLED; @@ -1914,7 +1914,7 @@ void SEQUENCER_OT_reload(struct wmOperatorType *ot) } /* reload operator */ -static int sequencer_refresh_all_poll(bContext *C) +static bool sequencer_refresh_all_poll(bContext *C) { if (G.is_rendering) { return 0; @@ -1976,7 +1976,7 @@ static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int sequencer_effect_poll(bContext *C) +static bool sequencer_effect_poll(bContext *C) { Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); @@ -2970,7 +2970,7 @@ static bool strip_jump_internal(Scene *scene, return changed; } -static int sequencer_strip_jump_poll(bContext *C) +static bool sequencer_strip_jump_poll(bContext *C) { /* prevent changes during render */ if (G.is_rendering) @@ -3953,7 +3953,7 @@ static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int sequencer_strip_is_text_poll(bContext *C) +static bool sequencer_strip_is_text_poll(bContext *C) { Editing *ed; Sequence *seq; diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 41fc98fbe4e..ef1559ca940 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -75,12 +75,12 @@ void recurs_sel_seq(struct Sequence *seqm); int seq_effect_find_selected(struct Scene *scene, struct Sequence *activeseq, int type, struct Sequence **selseq1, struct Sequence **selseq2, struct Sequence **selseq3, const char **error_str); /* operator helpers */ -int sequencer_edit_poll(struct bContext *C); +bool sequencer_edit_poll(struct bContext *C); /* UNUSED */ -//int sequencer_strip_poll(struct bContext *C); -int sequencer_strip_has_path_poll(struct bContext *C); -int sequencer_view_preview_poll(struct bContext *C); -int sequencer_view_strips_poll(struct bContext *C); +//bool sequencer_strip_poll(struct bContext *C); +bool sequencer_strip_has_path_poll(struct bContext *C); +bool sequencer_view_preview_poll(struct bContext *C); +bool sequencer_view_strips_poll(struct bContext *C); /* externs */ extern EnumPropertyItem sequencer_prop_effect_types[]; @@ -212,4 +212,3 @@ int sequencer_image_seq_get_minmax_frame(struct wmOperator *op, int sfra, int *r void sequencer_image_seq_reserve_frames(struct wmOperator *op, struct StripElem *se, int len, int minframe, int numdigits); #endif /* __SEQUENCER_INTERN_H__ */ - diff --git a/source/blender/editors/space_sequencer/sequencer_modifier.c b/source/blender/editors/space_sequencer/sequencer_modifier.c index 7ab9308f9a6..3c4481b32cb 100644 --- a/source/blender/editors/space_sequencer/sequencer_modifier.c +++ b/source/blender/editors/space_sequencer/sequencer_modifier.c @@ -50,7 +50,7 @@ /*********************** Add modifier operator *************************/ -static int strip_modifier_active_poll(bContext *C) +static bool strip_modifier_active_poll(bContext *C) { Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); @@ -281,4 +281,3 @@ void SEQUENCER_OT_strip_modifier_copy(wmOperatorType *ot) /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", type_items, SEQ_MODIFIER_COPY_REPLACE, "Type", ""); } - diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index d7206a6da4e..1ec9ea53e33 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -557,7 +557,7 @@ void SEQUENCER_OT_select(wmOperatorType *ot) }; /* identifiers */ - ot->name = "Activate/Select"; + ot->name = "Select"; ot->idname = "SEQUENCER_OT_select"; ot->description = "Select a strip (last selected becomes the \"active strip\")"; @@ -1282,4 +1282,3 @@ void SEQUENCER_OT_select_grouped(wmOperatorType *ot) RNA_def_boolean(ot->srna, "use_active_channel", false, "Same Channel", "Only consider strips on the same channel as the active one"); } - diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c index 88dcc3a8821..fb4ef3e51ab 100644 --- a/source/blender/editors/space_sequencer/sequencer_view.c +++ b/source/blender/editors/space_sequencer/sequencer_view.c @@ -220,7 +220,7 @@ static void sample_cancel(bContext *C, wmOperator *op) sample_exit(C, op); } -static int sample_poll(bContext *C) +static bool sample_poll(bContext *C) { SpaceSeq *sseq = CTX_wm_space_seq(C); return sseq && BKE_sequencer_editing_get(CTX_data_scene(C), false) != NULL; diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index fc47934bc1e..04be1f82a60 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -367,7 +367,7 @@ static void sequencer_listener( /* ************* dropboxes ************* */ -static int image_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool image_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); @@ -381,7 +381,7 @@ static int image_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) return 0; } -static int movie_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool movie_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); @@ -394,7 +394,7 @@ static int movie_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) return 0; } -static int sound_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool sound_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); @@ -529,7 +529,7 @@ static void sequencer_main_region_listener( ED_region_tag_redraw(ar); break; case NC_SCREEN: - if (ELEM(wmn->data, ND_SCREENCAST, ND_ANIMPLAY)) + if (ELEM(wmn->data, ND_ANIMPLAY)) ED_region_tag_redraw(ar); break; } diff --git a/source/blender/editors/space_statusbar/space_statusbar.c b/source/blender/editors/space_statusbar/space_statusbar.c index 4c6a2eea469..5ff32b98f90 100644 --- a/source/blender/editors/space_statusbar/space_statusbar.c +++ b/source/blender/editors/space_statusbar/space_statusbar.c @@ -56,21 +56,8 @@ static SpaceLink *statusbar_new(const ScrArea *UNUSED(area), const Scene *UNUSED sstatusbar = MEM_callocN(sizeof(*sstatusbar), "init statusbar"); sstatusbar->spacetype = SPACE_STATUSBAR; - /* header regions */ - /* *** NOTE: *** - * Python layout code (space_statusbar.py) depends on the list order of - * these! Not nice at all, but the only way to identify the correct header - * to draw to is using alignment + list position. It can't use alignment - * only since code below has to set two right aligned regions - XXX. */ - ar = MEM_callocN(sizeof(*ar), "right aligned header for statusbar"); - BLI_addtail(&sstatusbar->regionbase, ar); - ar->regiontype = RGN_TYPE_HEADER; - ar->alignment = RGN_ALIGN_RIGHT; - ar = MEM_callocN(sizeof(*ar), "center header for statusbar"); - BLI_addtail(&sstatusbar->regionbase, ar); - ar->regiontype = RGN_TYPE_HEADER; - ar->alignment = RGN_ALIGN_RIGHT; /* Right aligned too, so region layout code scales it correctly. */ - ar = MEM_callocN(sizeof(*ar), "left aligned header for statusbar"); + /* header region */ + ar = MEM_callocN(sizeof(*ar), "header for statusbar"); BLI_addtail(&sstatusbar->regionbase, ar); ar->regiontype = RGN_TYPE_HEADER; ar->alignment = RGN_ALIGN_NONE; @@ -128,7 +115,7 @@ static void statusbar_header_region_listener( /* context changes */ switch (wmn->category) { case NC_SCREEN: - if (ELEM(wmn->data, ND_LAYER, ND_SCREENCAST, ND_ANIMPLAY)) { + if (ELEM(wmn->data, ND_LAYER, ND_ANIMPLAY)) { ED_region_tag_redraw(ar); } break; @@ -186,7 +173,7 @@ void ED_spacetype_statusbar(void) /* regions: header window */ art = MEM_callocN(sizeof(*art), "spacetype statusbar header region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey = HEADERY; + art->prefsizey = 0.8f * HEADERY; art->prefsizex = UI_UNIT_X * 5; /* Mainly to avoid glitches */ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; art->init = statusbar_header_region_init; diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index e827f4f0149..c3e2945f3ff 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -59,6 +59,7 @@ #include "text_format.h" #include "text_intern.h" /* own include */ +#include "GPU_framebuffer.h" /* ******************** default callbacks for text space ***************** */ @@ -299,7 +300,11 @@ static void text_keymap(struct wmKeyConfig *keyconf) RNA_string_set(kmi->ptr, "data_path", "space_data.font_size"); RNA_boolean_set(kmi->ptr, "reverse", true); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "TEXT_OT_new", NKEY, KM_PRESS, KM_CTRL, 0); +#else + WM_keymap_add_item(keymap, "TEXT_OT_new", NKEY, KM_PRESS, KM_ALT, 0); +#endif WM_keymap_add_item(keymap, "TEXT_OT_open", OKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_reload", RKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_save", SKEY, KM_PRESS, KM_ALT, 0); @@ -441,7 +446,7 @@ static void text_main_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); // UI_view2d_view_ortho(v2d); @@ -470,7 +475,7 @@ static void text_cursor(wmWindow *win, ScrArea *sa, ARegion *ar) /* ************* dropboxes ************* */ -static int text_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool text_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) { if (drag->type == WM_DRAG_PATH) { /* rule might not work? */ @@ -487,7 +492,7 @@ static void text_drop_copy(wmDrag *drag, wmDropBox *drop) RNA_string_set(drop->ptr, "filepath", drag->path); } -static int text_drop_paste_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool text_drop_paste_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) { if (drag->type == WM_DRAG_ID) return true; @@ -640,4 +645,3 @@ void ED_spacetype_text(void) ED_text_format_register_pov(); ED_text_format_register_pov_ini(); } - diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c index 9163831c333..4f6a3bc82ba 100644 --- a/source/blender/editors/space_text/text_autocomplete.c +++ b/source/blender/editors/space_text/text_autocomplete.c @@ -40,7 +40,10 @@ #include "WM_api.h" #include "WM_types.h" +#include "ED_text.h" +#include "ED_undo.h" #include "ED_screen.h" + #include "UI_interface.h" #include "text_format.h" @@ -284,10 +287,11 @@ static int text_autocomplete_invoke(bContext *C, wmOperator *op, const wmEvent * ED_area_tag_redraw(CTX_wm_area(C)); if (texttool_suggest_first() == texttool_suggest_last()) { - TextUndoBuf *utxt = NULL; // FIXME + TextUndoBuf *utxt = ED_text_undo_push_init(C); confirm_suggestion(st->text, utxt); text_update_line_edited(st->text->curl); text_autocomplete_free(C, op); + ED_undo_push(C, op->type->name); return OPERATOR_FINISHED; } else { @@ -315,8 +319,6 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e (void)text; - TextUndoBuf *utxt = NULL; // FIXME - if (st->doplugins && texttool_text_is_active(st->text)) { if (texttool_suggest_first()) tools |= TOOL_SUGG_LIST; if (texttool_docs_get()) tools |= TOOL_DOCUMENT; @@ -343,8 +345,10 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e case MIDDLEMOUSE: if (event->val == KM_PRESS) { if (text_do_suggest_select(st, ar)) { + TextUndoBuf *utxt = ED_text_undo_push_init(C); confirm_suggestion(st->text, utxt); text_update_line_edited(st->text->curl); + ED_undo_push(C, op->type->name); swallow = 1; } else { @@ -378,8 +382,10 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e case PADENTER: if (event->val == KM_PRESS) { if (tools & TOOL_SUGG_LIST) { + TextUndoBuf *utxt = ED_text_undo_push_init(C); confirm_suggestion(st->text, utxt); text_update_line_edited(st->text->curl); + ED_undo_push(C, op->type->name); swallow = 1; draw = 1; } @@ -591,5 +597,6 @@ void TEXT_OT_autocomplete(wmOperatorType *ot) ot->poll = text_space_edit_poll; /* flags */ + /* Undo is handled conditionally by this operator. */ ot->flag = OPTYPE_BLOCKING; } diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index c1b49fbd32a..21cd24cf84c 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -50,6 +50,7 @@ #include "BIF_glutil.h" #include "GPU_immediate.h" +#include "GPU_state.h" #include "UI_interface.h" #include "UI_resources.h" @@ -1207,10 +1208,10 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar) immUniformColor4ub(255, 255, 255, 32); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); immRecti(pos, x1 - 4, y1, x2, y2); - glDisable(GL_BLEND); + GPU_blend(false); } } @@ -1506,10 +1507,10 @@ void draw_text_main(SpaceText *st, ARegion *ar) immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); - immUniform1i("num_colors", 0); /* "simple" mode */ + immUniform1i("colors_len", 0); /* "simple" mode */ immUniformThemeColor(TH_GRID); /* same color as line number background */ immUniform1f("dash_width", 2.0f); immUniform1f("dash_factor", 0.5f); diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c index 3d964d07908..896b5444a85 100644 --- a/source/blender/editors/space_text/text_header.c +++ b/source/blender/editors/space_text/text_header.c @@ -72,7 +72,7 @@ static ARegion *text_has_properties_region(ScrArea *sa) return arnew; } -static int text_properties_poll(bContext *C) +static bool text_properties_poll(bContext *C) { return (CTX_wm_space_text(C) != NULL); } @@ -212,4 +212,3 @@ void TEXT_OT_start_find(wmOperatorType *ot) UI_popup_menu_end(C, pup); } #endif - diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h index bc902135b50..02948d35623 100644 --- a/source/blender/editors/space_text/text_intern.h +++ b/source/blender/editors/space_text/text_intern.h @@ -142,7 +142,7 @@ void TEXT_OT_to_3d_object(struct wmOperatorType *ot); void TEXT_OT_resolve_conflict(struct wmOperatorType *ot); -int text_space_edit_poll(struct bContext *C); +bool text_space_edit_poll(struct bContext *C); /* text_autocomplete.c */ void TEXT_OT_autocomplete(struct wmOperatorType *ot); @@ -151,4 +151,3 @@ void TEXT_OT_autocomplete(struct wmOperatorType *ot); extern const char *text_context_dir[]; /* doc access */ #endif /* __TEXT_INTERN_H__ */ - diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index e34edc8908f..a8c14a3d4c1 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -80,12 +80,12 @@ BLI_INLINE int text_pixel_x_to_column(SpaceText *st, const int x) return (x + (st->cwidth / 2)) / st->cwidth; } -static int text_new_poll(bContext *UNUSED(C)) +static bool text_new_poll(bContext *UNUSED(C)) { return 1; } -static int text_edit_poll(bContext *C) +static bool text_edit_poll(bContext *C) { Text *text = CTX_data_edit_text(C); @@ -100,7 +100,7 @@ static int text_edit_poll(bContext *C) return 1; } -int text_space_edit_poll(bContext *C) +bool text_space_edit_poll(bContext *C) { SpaceText *st = CTX_wm_space_text(C); Text *text = CTX_data_edit_text(C); @@ -116,7 +116,7 @@ int text_space_edit_poll(bContext *C) return 1; } -static int text_region_edit_poll(bContext *C) +static bool text_region_edit_poll(bContext *C) { SpaceText *st = CTX_wm_space_text(C); Text *text = CTX_data_edit_text(C); @@ -361,7 +361,7 @@ void TEXT_OT_reload(wmOperatorType *ot) /******************* delete operator *********************/ -static int text_unlink_poll(bContext *C) +static bool text_unlink_poll(bContext *C) { /* it should be possible to unlink texts if they're lib-linked in... */ return CTX_data_edit_text(C) != NULL; @@ -447,7 +447,7 @@ void TEXT_OT_make_internal(wmOperatorType *ot) /******************* save operator *********************/ -static int text_save_poll(bContext *C) +static bool text_save_poll(bContext *C) { Text *text = CTX_data_edit_text(C); @@ -590,7 +590,7 @@ void TEXT_OT_save_as(wmOperatorType *ot) /******************* run script operator *********************/ -static int text_run_script_poll(bContext *C) +static bool text_run_script_poll(bContext *C) { return (CTX_data_edit_text(C) != NULL); } @@ -2142,7 +2142,7 @@ typedef struct TextScroll { int zone; } TextScroll; -static int text_scroll_poll(bContext *C) +static bool text_scroll_poll(bContext *C) { /* it should be possible to still scroll linked texts to read them, even if they can't be edited... */ return CTX_data_edit_text(C) != NULL; @@ -2325,7 +2325,7 @@ void TEXT_OT_scroll(wmOperatorType *ot) /******************** scroll bar operator *******************/ -static int text_region_scroll_poll(bContext *C) +static bool text_region_scroll_poll(bContext *C) { /* same as text_region_edit_poll except it works on libdata too */ SpaceText *st = CTX_wm_space_text(C); diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c index 1d3c24c518a..fc5182fcb4f 100644 --- a/source/blender/editors/space_userpref/space_userpref.c +++ b/source/blender/editors/space_userpref/space_userpref.c @@ -196,4 +196,3 @@ void ED_spacetype_userpref(void) BKE_spacetype_register(st); } - diff --git a/source/blender/editors/space_userpref/userpref_intern.h b/source/blender/editors/space_userpref/userpref_intern.h index d67ba32f68b..720b4da0f71 100644 --- a/source/blender/editors/space_userpref/userpref_intern.h +++ b/source/blender/editors/space_userpref/userpref_intern.h @@ -34,4 +34,3 @@ /* internal exports only */ #endif /* __USERPREF_INTERN_H__ */ - diff --git a/source/blender/editors/space_userpref/userpref_ops.c b/source/blender/editors/space_userpref/userpref_ops.c index c5a62f46c36..6666a6cfc16 100644 --- a/source/blender/editors/space_userpref/userpref_ops.c +++ b/source/blender/editors/space_userpref/userpref_ops.c @@ -31,5 +31,3 @@ #include <string.h> #include <stdio.h> - - diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 1224c284d5f..bca5faa314a 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -100,6 +100,8 @@ #include "GPU_immediate_util.h" #include "GPU_batch.h" #include "GPU_matrix.h" +#include "GPU_state.h" +#include "GPU_framebuffer.h" #include "ED_mesh.h" #include "ED_particle.h" @@ -289,7 +291,7 @@ static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *dm, int offset) immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32); - glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); + GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE)); immBeginAtMost(GWN_PRIM_POINTS, imm_len); dm->foreachMappedVert(dm, bbs_obmode_mesh_verts__mapFunc, &data, DM_FOREACH_NOP); @@ -332,7 +334,7 @@ static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *dm, int offset) immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32); - glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); + GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE)); immBeginAtMost(GWN_PRIM_POINTS, em->bm->totvert); dm->foreachMappedVert(dm, bbs_mesh_verts__mapFunc, &data, DM_FOREACH_NOP); @@ -343,7 +345,7 @@ static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *dm, int offset) #else static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *UNUSED(dm), int offset) { - glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); + GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE)); Mesh *me = em->ob->data; Gwn_Batch *batch = DRW_mesh_batch_cache_get_verts_with_select_id(me, offset); @@ -384,7 +386,7 @@ static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset) immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32); - glLineWidth(1.0f); + GPU_line_width(1.0f); immBeginAtMost(GWN_PRIM_LINES, imm_len); dm->foreachMappedEdge(dm, bbs_mesh_wire__mapFunc, &data); @@ -395,7 +397,7 @@ static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset) #else static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *UNUSED(dm), int offset) { - glLineWidth(1.0f); + GPU_line_width(1.0f); Mesh *me = em->ob->data; Gwn_Batch *batch = DRW_mesh_batch_cache_get_edges_with_select_id(me, offset); @@ -503,7 +505,7 @@ static void bbs_mesh_face_dot(BMEditMesh *em, DerivedMesh *dm) immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32); - glPointSize(UI_GetThemeValuef(TH_FACEDOT_SIZE)); + GPU_point_size(UI_GetThemeValuef(TH_FACEDOT_SIZE)); immBeginAtMost(GWN_PRIM_POINTS, em->bm->totface); dm->foreachMappedFaceCenter(dm, bbs_mesh_solid__drawCenter, &data, DM_FOREACH_NOP); @@ -621,8 +623,8 @@ void draw_object_backbufsel( gpuMultMatrix(ob->obmat); - glClearDepth(1.0); glClear(GL_DEPTH_BUFFER_BIT); - glEnable(GL_DEPTH_TEST); + glClearDepth(1.0); GPU_clear(GPU_DEPTH_BIT); + GPU_depth_test(true); switch (ob->type) { case OB_MESH: @@ -722,7 +724,7 @@ void ED_draw_object_facemap( glColor4fv(col); gpuPushAttrib(GL_ENABLE_BIT); - glEnable(GL_BLEND); + GPU_blend(true); glDisable(GL_LIGHTING); /* always draw using backface culling */ @@ -752,8 +754,8 @@ void ED_draw_object_facemap( immUniformColor4fv(col); /* XXX, alpha isn't working yet, not sure why. */ - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); MVert *mvert; @@ -810,10 +812,9 @@ void ED_draw_object_facemap( immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } #endif dm->release(dm); } - diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 3b648e3b13a..c6874a663a5 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -1,4 +1,4 @@ -/* +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -40,8 +40,8 @@ #include "BLI_utildefines.h" #include "BLI_math.h" -#include "BKE_DerivedMesh.h" #include "BKE_colorband.h" +#include "BKE_deform.h" #include "BKE_particle.h" #include "smoke_API.h" @@ -50,6 +50,7 @@ #include "GPU_shader.h" #include "GPU_texture.h" +#include "GPU_state.h" #include "view3d_intern.h" // own include @@ -632,11 +633,11 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob, glGetBooleanv(GL_DEPTH_TEST, (GLboolean *)&gl_depth); glGetBooleanv(GL_DEPTH_WRITEMASK, (GLboolean *)&gl_depth_write); - glEnable(GL_DEPTH_TEST); + GPU_depth_test(true); glDepthMask(GL_FALSE); - glEnable(GL_BLEND); + GPU_blend(true); - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); draw_buffer(sds, shader, &slicer, ob_sizei, invsize, num_points, false); /* Draw fire separately (T47639). */ @@ -655,11 +656,11 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob, glDepthMask(gl_depth_write); if (!gl_blend) { - glDisable(GL_BLEND); + GPU_blend(false); } if (gl_depth) { - glEnable(GL_DEPTH_TEST); + GPU_depth_test(true); } } @@ -684,7 +685,7 @@ static void add_needle(float (*verts)[3], float (*colors)[3], float center[3], float len = len_v3(dir); float rgb[3]; - weight_to_rgb(rgb, len); + BKE_defvert_weight_to_rgb(rgb, len); if (len != 0.0f) { mul_v3_fl(dir, 1.0f / len); @@ -724,7 +725,7 @@ static void add_streamline(float (*verts)[3], float(*colors)[3], float center[3] const float len = len_v3(dir); float rgb[3]; - weight_to_rgb(rgb, len); + BKE_defvert_weight_to_rgb(rgb, len); copy_v3_v3(colors[(*offset)], rgb); copy_v3_v3(verts[(*offset)++], center); @@ -831,7 +832,7 @@ void draw_smoke_velocity(SmokeDomainSettings *domain, float viewnormal[3]) } } - glLineWidth(1.0f); + GPU_line_width(1.0f); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, verts); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index d77b13630e3..4660255cc6c 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -335,6 +335,9 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) v3d->overlay.flag = V3D_OVERLAY_LOOK_DEV; v3d->overlay.wireframe_threshold = 0.5f; v3d->overlay.bone_selection_alpha = 0.5f; + v3d->overlay.texture_paint_mode_opacity = 0.8; + v3d->overlay.weight_paint_mode_opacity = 0.8; + v3d->overlay.vertex_paint_mode_opacity = 0.8; v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR; @@ -549,7 +552,7 @@ static void view3d_main_region_exit(wmWindowManager *wm, ARegion *ar) } } -static int view3d_ob_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool view3d_ob_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) { if (drag->type == WM_DRAG_ID) { ID *id = drag->poin; @@ -559,7 +562,7 @@ static int view3d_ob_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent return 0; } -static int view3d_collection_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool view3d_collection_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) { if (drag->type == WM_DRAG_ID) { ID *id = drag->poin; @@ -569,7 +572,7 @@ static int view3d_collection_drop_poll(bContext *UNUSED(C), wmDrag *drag, const return 0; } -static int view3d_mat_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool view3d_mat_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) { if (drag->type == WM_DRAG_ID) { ID *id = drag->poin; @@ -579,7 +582,7 @@ static int view3d_mat_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent return 0; } -static int view3d_ima_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +static bool view3d_ima_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) { if (drag->type == WM_DRAG_ID) { ID *id = drag->poin; @@ -593,7 +596,7 @@ static int view3d_ima_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent return 0; } -static int view3d_ima_bg_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool view3d_ima_bg_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) { if (event->ctrl) return false; @@ -604,7 +607,7 @@ static int view3d_ima_bg_drop_poll(bContext *C, wmDrag *drag, const wmEvent *eve return 0; } -static int view3d_ima_empty_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool view3d_ima_empty_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) { Base *base = ED_view3d_give_base_under_cursor(C, event->mval); @@ -618,7 +621,7 @@ static int view3d_ima_empty_drop_poll(bContext *C, wmDrag *drag, const wmEvent * return 0; } -static int view3d_ima_mesh_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +static bool view3d_ima_mesh_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) { Base *base = ED_view3d_give_base_under_cursor(C, event->mval); @@ -1407,7 +1410,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes if (view_layer->basact) { Object *ob = view_layer->basact->object; /* if hidden but in edit mode, we still display, can happen with animation */ - if ((view_layer->basact->flag & BASE_VISIBLED) != 0 || (ob->mode & OB_MODE_EDIT)) { + if ((view_layer->basact->flag & BASE_VISIBLE) != 0 || (ob->mode & OB_MODE_EDIT)) { CTX_data_pointer_set(result, &scene->id, &RNA_ObjectBase, view_layer->basact); } } @@ -1419,7 +1422,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes if (view_layer->basact) { Object *ob = view_layer->basact->object; /* if hidden but in edit mode, we still display, can happen with animation */ - if ((view_layer->basact->flag & BASE_VISIBLED) != 0 || (ob->mode & OB_MODE_EDIT) != 0) { + if ((view_layer->basact->flag & BASE_VISIBLE) != 0 || (ob->mode & OB_MODE_EDIT) != 0) { CTX_data_id_pointer_set(result, &ob->id); } } @@ -1538,11 +1541,6 @@ void ED_spacetype_view3d(void) art->draw = view3d_tools_region_draw; BLI_addhead(&st->regiontypes, art); -#if 0 - /* unfinished still */ - view3d_toolshelf_register(art); -#endif - /* regions: header */ art = MEM_callocN(sizeof(ARegionType), "spacetype view3d header region"); art->regionid = RGN_TYPE_HEADER; diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 6ebed88728e..f5e8bf10817 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -786,7 +786,7 @@ static void do_view3d_vgroup_buttons(bContext *C, void *UNUSED(arg), int event) } } -static int view3d_panel_vgroup_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool view3d_panel_vgroup_poll(const bContext *C, PanelType *UNUSED(pt)) { ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); @@ -1120,7 +1120,7 @@ static void do_view3d_region_buttons(bContext *C, void *UNUSED(index), int event WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); } -static int view3d_panel_transform_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool view3d_panel_transform_poll(const bContext *C, PanelType *UNUSED(pt)) { ViewLayer *view_layer = CTX_data_view_layer(C); return (view_layer->basact != NULL); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index fd2f604651b..0d5240d8e86 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -44,6 +44,7 @@ #include "BKE_context.h" #include "BKE_global.h" #include "BKE_key.h" +#include "BKE_main.h" #include "BKE_scene.h" #include "BKE_object.h" #include "BKE_paint.h" @@ -79,6 +80,8 @@ #include "GPU_immediate_util.h" #include "GPU_material.h" #include "GPU_viewport.h" +#include "GPU_state.h" +#include "GPU_framebuffer.h" #include "MEM_guardedalloc.h" @@ -449,7 +452,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View x2 = viewborder.xmax; y2 = viewborder.ymax; - glLineWidth(1.0f); + GPU_line_width(1.0f); /* apply offsets so the real 3D camera shows through */ @@ -477,8 +480,8 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View float alpha = 1.0f; if (ca->passepartalpha != 1.0f) { - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); alpha = ca->passepartalpha; } @@ -493,7 +496,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View if (y2i > 0.0f) immRectf(shdr_pos, x1i, y1i, x2i, 0.0f); - glDisable(GL_BLEND); + GPU_blend(false); } immUniformThemeColor(TH_BACK); @@ -515,10 +518,10 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View { float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); - immUniform1i("num_colors", 0); /* "simple" mode */ + immUniform1i("colors_len", 0); /* "simple" mode */ immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); @@ -672,15 +675,15 @@ static void drawrenderborder(ARegion *ar, View3D *v3d) /* use the same program for everything */ uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - glLineWidth(1.0f); + GPU_line_width(1.0f); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); - immUniform1i("num_colors", 0); /* "simple" mode */ + immUniform1i("colors_len", 0); /* "simple" mode */ immUniform4f("color", 1.0f, 0.25f, 0.25f, 1.0f); immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); @@ -716,7 +719,7 @@ void ED_view3d_draw_depth( ED_view3d_draw_setup_view(NULL, depsgraph, scene, ar, v3d, NULL, NULL, NULL); - glClear(GL_DEPTH_BUFFER_BIT); + GPU_clear(GPU_DEPTH_BIT); if (rv3d->rflag & RV3D_CLIPPING) { ED_view3d_clipping_set(rv3d); @@ -725,7 +728,7 @@ void ED_view3d_draw_depth( rv3d->rflag |= RV3D_ZOFFSET_DISABLED; v3d->zbuf = true; - glEnable(GL_DEPTH_TEST); + GPU_depth_test(true); DRW_draw_depth_loop(depsgraph, ar, v3d); @@ -735,7 +738,7 @@ void ED_view3d_draw_depth( rv3d->rflag &= ~RV3D_ZOFFSET_DISABLED; v3d->zbuf = zbuf; - if (!v3d->zbuf) glDisable(GL_DEPTH_TEST); + if (!v3d->zbuf) GPU_depth_test(false); U.glalphaclip = glalphaclip; v3d->flag = flag; @@ -807,10 +810,10 @@ static void draw_view_axis(RegionView3D *rv3d, const rcti *rect) } /* draw axis lines */ - glLineWidth(2.0f); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_line_width(2.0f); + GPU_line_smooth(true); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -830,7 +833,7 @@ static void draw_view_axis(RegionView3D *rv3d, const rcti *rect) immEnd(); immUnbindProgram(); - glDisable(GL_LINE_SMOOTH); + GPU_line_smooth(false); /* draw axis names */ for (int axis_i = 0; axis_i < 3; axis_i++) { @@ -853,8 +856,8 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d) negate_v3_v3(o, rv3d->ofs); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); glDepthMask(GL_FALSE); /* don't overwrite zbuf */ Gwn_VertFormat *format = immVertexFormat(); @@ -937,7 +940,7 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d) /* -- draw rotation center -- */ immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR); - glPointSize(5.0f); + GPU_point_size(5.0f); immBegin(GWN_PRIM_POINTS, 1); immAttrib4ubv(col, color); immVertex3fv(pos, o); @@ -951,7 +954,7 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d) /* ^^ just playing around, does not work */ #endif - glDisable(GL_BLEND); + GPU_blend(false); glDepthMask(GL_TRUE); } #endif /* WITH_INPUT_NDOF */ @@ -1182,7 +1185,7 @@ static void draw_selected_name(Scene *scene, Object *ob, rcti *rect) /** * Information drawn on top of the solid plates and composed data */ -void view3d_draw_region_info(const bContext *C, ARegion *ar, const int offset) +void view3d_draw_region_info(const bContext *C, ARegion *ar, const int UNUSED(offset)) { RegionView3D *rv3d = ar->regiondata; View3D *v3d = CTX_wm_view3d(C); @@ -1196,8 +1199,6 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int offset) rcti rect; ED_region_visible_rect(ar, &rect); - /* Leave room for previously drawn info. */ - rect.ymax -= offset; view3d_draw_border(C, ar); view3d_draw_grease_pencil(C); @@ -1271,11 +1272,12 @@ RenderEngineType *ED_view3d_engine_type(Scene *scene, int drawtype) void view3d_main_region_draw(const bContext *C, ARegion *ar) { + Main *bmain = CTX_data_main(C); View3D *v3d = CTX_wm_view3d(C); view3d_draw_view(C, ar); - GPU_free_images_old(); + GPU_free_images_old(bmain); GPU_pass_cache_garbage_collect(); /* XXX This is in order to draw UI batches with the DRW @@ -1283,7 +1285,7 @@ void view3d_main_region_draw(const bContext *C, ARegion *ar) gpu_batch_presets_reset(); /* No depth test for drawing action zones afterwards. */ - glDisable(GL_DEPTH_TEST); + GPU_depth_test(false); v3d->flag |= V3D_INVALID_BACKBUF; } @@ -1348,7 +1350,7 @@ void ED_view3d_draw_offscreen( if ((v3d->flag2 & V3D_RENDER_SHADOW) == 0) { /* free images which can have changed on frame-change * warning! can be slow so only free animated images - campbell */ - GPU_free_images_anim(); + GPU_free_images_anim(G.main); /* XXX :((( */ } gpuPushProjectionMatrix(); diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index 3a89c910ea8..06cdba3f537 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -57,7 +57,6 @@ #include "BKE_camera.h" #include "BKE_context.h" #include "BKE_customdata.h" -#include "BKE_DerivedMesh.h" #include "BKE_image.h" #include "BKE_key.h" #include "BKE_layer.h" @@ -105,6 +104,7 @@ #include "GPU_immediate_util.h" #include "GPU_select.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "RE_engine.h" @@ -246,16 +246,16 @@ static void backdrawview3d( if (rv3d->gpuoffscreen) GPU_offscreen_bind(rv3d->gpuoffscreen, true); else - glScissor(ar->winrct.xmin, ar->winrct.ymin, BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct)); + GPU_scissor(ar->winrct.xmin, ar->winrct.ymin, BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct)); - glClearColor(0.0, 0.0, 0.0, 0.0); + GPU_clear_color(0.0, 0.0, 0.0, 0.0); if (v3d->zbuf) { - glEnable(GL_DEPTH_TEST); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GPU_depth_test(true); + GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT); } else { - glClear(GL_COLOR_BUFFER_BIT); - glDisable(GL_DEPTH_TEST); + GPU_clear(GPU_COLOR_BIT); + GPU_depth_test(false); } if (rv3d->rflag & RV3D_CLIPPING) @@ -263,7 +263,7 @@ static void backdrawview3d( G.f |= G_BACKBUFSEL; - if (obact_eval && ((obact_eval->base_flag & BASE_VISIBLED) != 0)) { + if (obact_eval && ((obact_eval->base_flag & BASE_VISIBLE) != 0)) { draw_object_backbufsel(depsgraph, scene_eval, v3d, rv3d, obact_eval, select_mode); } @@ -274,7 +274,7 @@ static void backdrawview3d( G.f &= ~G_BACKBUFSEL; v3d->zbuf = false; - glDisable(GL_DEPTH_TEST); + GPU_depth_test(false); glEnable(GL_DITHER); if (rv3d->rflag & RV3D_CLIPPING) @@ -684,11 +684,11 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph, ibuf = ibuf->mipmap[mip - 1]; } - if (v3d->zbuf) glDisable(GL_DEPTH_TEST); + if (v3d->zbuf) GPU_depth_test(false); glDepthMask(GL_FALSE); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); gpuPushProjectionMatrix(); gpuPushMatrix(); @@ -715,10 +715,10 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph, gpuPopProjectionMatrix(); gpuPopMatrix(); - glDisable(GL_BLEND); + GPU_blend(false); glDepthMask(GL_TRUE); - if (v3d->zbuf) glEnable(GL_DEPTH_TEST); + if (v3d->zbuf) GPU_depth_test(true); if (freeibuf) IMB_freeImBuf(freeibuf); @@ -883,17 +883,17 @@ void ED_view3d_draw_depth_gpencil( /* Setup view matrix. */ ED_view3d_draw_setup_view(NULL, depsgraph, scene, ar, v3d, NULL, NULL, NULL); - glClear(GL_DEPTH_BUFFER_BIT); + GPU_clear(GPU_DEPTH_BIT); v3d->zbuf = true; - glEnable(GL_DEPTH_TEST); + GPU_depth_test(true); if (v3d->flag2 & V3D_SHOW_GPENCIL) { ED_gpencil_draw_view3d(NULL, scene, view_layer, depsgraph, v3d, ar, true); } v3d->zbuf = zbuf; - if (!zbuf) glDisable(GL_DEPTH_TEST); + if (!zbuf) GPU_depth_test(false); } /* *********************** customdata **************** */ diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index bae186097a8..cc30375255d 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -940,7 +940,7 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, const wmEvent *event) } /* test for unlocked camera view in quad view */ -static int view3d_camera_user_poll(bContext *C) +static bool view3d_camera_user_poll(bContext *C) { View3D *v3d; ARegion *ar; @@ -955,7 +955,7 @@ static int view3d_camera_user_poll(bContext *C) return 0; } -static int view3d_lock_poll(bContext *C) +static bool view3d_lock_poll(bContext *C) { View3D *v3d = CTX_wm_view3d(C); if (v3d) { @@ -1554,7 +1554,7 @@ static int ndof_all_invoke(bContext *C, wmOperator *op, const wmEvent *event) void VIEW3D_OT_ndof_all(struct wmOperatorType *ot) { /* identifiers */ - ot->name = "NDOF Move View"; + ot->name = "NDOF Pan View"; ot->description = "Pan and rotate the view with the 3D mouse"; ot->idname = "VIEW3D_OT_ndof_all"; @@ -1744,7 +1744,7 @@ void VIEW3D_OT_move(wmOperatorType *ot) { /* identifiers */ - ot->name = "Move View"; + ot->name = "Pan View"; ot->description = "Move the view"; ot->idname = "VIEW3D_OT_move"; @@ -4255,8 +4255,8 @@ static int viewpan_invoke(bContext *C, wmOperator *op, const wmEvent *event) void VIEW3D_OT_view_pan(wmOperatorType *ot) { /* identifiers */ - ot->name = "View Pan"; - ot->description = "Pan the view"; + ot->name = "Pan View Direction"; + ot->description = "Pan the view in a given direction"; ot->idname = "VIEW3D_OT_view_pan"; /* api callbacks */ @@ -4553,7 +4553,7 @@ void VIEW3D_OT_clip_border(wmOperatorType *ot) /* cursor position in vec, result in vec, mval in region coords */ /* note: cannot use event->mval here (called by object_add() */ -void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2]) +void ED_view3d_cursor3d_position(bContext *C, const int mval[2], bool use_depth, float cursor_co[3]) { ARegion *ar = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); @@ -4566,32 +4566,35 @@ void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2]) if (rv3d == NULL) return; - ED_view3d_calc_zfac(rv3d, fp, &flip); + ED_view3d_calc_zfac(rv3d, cursor_co, &flip); /* reset the depth based on the view offset (we _know_ the offset is infront of us) */ if (flip) { - negate_v3_v3(fp, rv3d->ofs); + negate_v3_v3(cursor_co, rv3d->ofs); /* re initialize, no need to check flip again */ - ED_view3d_calc_zfac(rv3d, fp, NULL /* &flip */ ); + ED_view3d_calc_zfac(rv3d, cursor_co, NULL /* &flip */ ); } - if (U.uiflag & USER_DEPTH_CURSOR) { /* maybe this should be accessed some other way */ + if (use_depth) { /* maybe this should be accessed some other way */ struct Depsgraph *depsgraph = CTX_data_depsgraph(C); view3d_operator_needs_opengl(C); - if (ED_view3d_autodist(depsgraph, ar, v3d, mval, fp, true, NULL)) { + if (ED_view3d_autodist(depsgraph, ar, v3d, mval, cursor_co, true, NULL)) { depth_used = true; } } if (depth_used == false) { float depth_pt[3]; - copy_v3_v3(depth_pt, fp); - ED_view3d_win_to_3d_int(v3d, ar, depth_pt, mval, fp); + copy_v3_v3(depth_pt, cursor_co); + ED_view3d_win_to_3d_int(v3d, ar, depth_pt, mval, cursor_co); } } -void ED_view3d_cursor3d_update(bContext *C, const int mval[2]) +void ED_view3d_cursor3d_position_rotation( + bContext *C, const int mval[2], + const bool use_depth, enum eV3DCursorOrient orientation, + float cursor_co[3], float cursor_quat[4]) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); @@ -4599,16 +4602,26 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2]) ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ar->regiondata; - View3DCursor *cursor_curr = ED_view3d_cursor3d_get(scene, v3d); - View3DCursor cursor_prev = *cursor_curr; + /* XXX, caller should check. */ + if (rv3d == NULL) + return; - ED_view3d_cursor3d_position(C, cursor_curr->location, mval); - copy_qt_qt(cursor_curr->rotation, rv3d->viewquat); - cursor_curr->rotation[0] *= -1.0f; + ED_view3d_cursor3d_position(C, mval, use_depth, cursor_co); + + if (orientation == V3D_CURSOR_ORIENT_NONE) { + /* pass */ + } + else if (orientation == V3D_CURSOR_ORIENT_VIEW) { + copy_qt_qt(cursor_quat, rv3d->viewquat); + cursor_quat[0] *= -1.0f; + } + else if (orientation == V3D_CURSOR_ORIENT_GEOM) { + copy_qt_qt(cursor_quat, rv3d->viewquat); + cursor_quat[0] *= -1.0f; - { const float mval_fl[2] = {UNPACK2(mval)}; float ray_no[3]; + float ray_co[3]; struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d( bmain, scene, CTX_data_depsgraph(C), 0, ar, v3d); @@ -4624,16 +4637,21 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2]) .use_object_edit_cage = false, }, mval_fl, &dist_px, - cursor_curr->location, ray_no, NULL, + ray_co, ray_no, NULL, &ob_dummy, obmat)) { + if (use_depth) { + copy_v3_v3(cursor_co, ray_co); + } + float tquat[4]; + /* Math normal (Z). */ { float z_src[3] = {0, 0, 1}; - mul_qt_v3(cursor_curr->rotation, z_src); + mul_qt_v3(cursor_quat, z_src); rotation_between_vecs_to_quat(tquat, z_src, ray_no); - mul_qt_qtqt(cursor_curr->rotation, tquat, cursor_curr->rotation); + mul_qt_qtqt(cursor_quat, tquat, cursor_quat); } /* Match object matrix (X). */ @@ -4646,27 +4664,47 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2]) const int ortho_axis = axis_dominant_v3_ortho_single(ortho_axis_dot); float x_src[3] = {1, 0, 0}; float x_dst[3]; - mul_qt_v3(cursor_curr->rotation, x_src); + mul_qt_v3(cursor_quat, x_src); project_plane_v3_v3v3(x_dst, obmat[ortho_axis], ray_no); normalize_v3(x_dst); rotation_between_vecs_to_quat(tquat, x_src, x_dst); - mul_qt_qtqt(cursor_curr->rotation, tquat, cursor_curr->rotation); + mul_qt_qtqt(cursor_quat, tquat, cursor_quat); } } ED_transform_snap_object_context_destroy(snap_context); } +} + +void ED_view3d_cursor3d_update( + bContext *C, const int mval[2], + const bool use_depth, enum eV3DCursorOrient orientation) +{ + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); + ARegion *ar = CTX_wm_region(C); + RegionView3D *rv3d = ar->regiondata; + + View3DCursor *cursor_curr = ED_view3d_cursor3d_get(scene, v3d); + View3DCursor cursor_prev = *cursor_curr; + + ED_view3d_cursor3d_position_rotation( + C, mval, + use_depth, orientation, + cursor_curr->location, cursor_curr->rotation); /* offset the cursor lock to avoid jumping to new offset */ if (v3d->ob_centre_cursor) { if (U.uiflag & USER_LOCK_CURSOR_ADJUST) { - float co_curr[2], co_prev[2]; + float co_2d_curr[2], co_2d_prev[2]; - if ((ED_view3d_project_float_global(ar, cursor_prev.location, co_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && - (ED_view3d_project_float_global(ar, cursor_curr->location, co_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) + if ((ED_view3d_project_float_global( + ar, cursor_prev.location, co_2d_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && + (ED_view3d_project_float_global( + ar, cursor_curr->location, co_2d_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) { - rv3d->ofs_lock[0] += (co_curr[0] - co_prev[0]) / (ar->winx * 0.5f); - rv3d->ofs_lock[1] += (co_curr[1] - co_prev[1]) / (ar->winy * 0.5f); + rv3d->ofs_lock[0] += (co_2d_curr[0] - co_2d_prev[0]) / (ar->winx * 0.5f); + rv3d->ofs_lock[1] += (co_2d_curr[1] - co_2d_prev[1]) / (ar->winy * 0.5f); } } else { @@ -4689,9 +4727,20 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2]) DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE); } -static int view3d_cursor3d_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) +static int view3d_cursor3d_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - ED_view3d_cursor3d_update(C, event->mval); + bool use_depth = (U.uiflag & USER_DEPTH_CURSOR); + { + PropertyRNA *prop = RNA_struct_find_property(op->ptr, "use_depth"); + if (RNA_property_is_set(op->ptr, prop)) { + use_depth = RNA_property_boolean_get(op->ptr, prop); + } + else { + RNA_property_boolean_set(op->ptr, prop, use_depth); + } + } + const enum eV3DCursorOrient orientation = RNA_enum_get(op->ptr, "orientation"); + ED_view3d_cursor3d_update(C, event->mval, use_depth, orientation); return OPERATOR_FINISHED; } @@ -4711,6 +4760,24 @@ void VIEW3D_OT_cursor3d(wmOperatorType *ot) /* flags */ // ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + + PropertyRNA *prop; + static const EnumPropertyItem orientation_items[] = { + {V3D_CURSOR_ORIENT_NONE, "NONE", 0, "None", "Leave orientation unchanged"}, + {V3D_CURSOR_ORIENT_VIEW, "VIEW", 0, "View", "Orient to the viewport"}, + {V3D_CURSOR_ORIENT_GEOM, "GEOM", 0, "Geometry", "Match the surface normal"}, + {0, NULL, 0, NULL, NULL} + }; + + prop = RNA_def_boolean( + ot->srna, "use_depth", true, "Surface Project", + "Project onto the surface"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + + prop = RNA_def_enum( + ot->srna, "orientation", orientation_items, V3D_CURSOR_ORIENT_VIEW, + "Orientation", "Preset viewpoint to use"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /** \} */ diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index d8cc9ab9828..f9fdf8c2cc0 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -333,7 +333,7 @@ static void fly_update_header(bContext *C, wmOperator *op, FlyInfo *fly) #undef WM_MODALKEY - ED_area_headerprint(CTX_wm_area(C), header); + ED_workspace_status_text(C, header); } /* FlyInfo->state */ @@ -1082,7 +1082,7 @@ static int fly_modal(bContext *C, wmOperator *op, const wmEvent *event) } if (ELEM(exit_code, OPERATOR_FINISHED, OPERATOR_CANCELLED)) - ED_area_headerprint(CTX_wm_area(C), NULL); + ED_workspace_status_text(C, NULL); return exit_code; } diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 4f81fa7585c..eeddacee808 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -196,7 +196,7 @@ static int view3d_layers_invoke(bContext *C, wmOperator *op, const wmEvent *even return OPERATOR_FINISHED; } -static int view3d_layers_poll(bContext *C) +static bool view3d_layers_poll(bContext *C) { return (ED_operator_view3d_active(C) && CTX_wm_view3d(C)->localvd == NULL); } @@ -234,7 +234,7 @@ static int toggle_show_xray(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static int toggle_show_xray_poll(bContext *C) +static bool toggle_show_xray_poll(bContext *C) { bool result = (ED_operator_view3d_active(C) && !ED_operator_posemode(C) && !ED_operator_editmesh(C)); if (result) { diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 017b31a0bf2..8263d1d892c 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -41,7 +41,6 @@ struct Base; struct BoundBox; struct Gwn_Batch; struct Depsgraph; -struct DerivedMesh; struct Object; struct SmokeDomainSettings; struct bAnimVizSettings; @@ -235,7 +234,6 @@ struct Object *ED_view3d_cameracontrol_object_get( /* view3d_toolbar.c */ void VIEW3D_OT_toolshelf(struct wmOperatorType *ot); -void view3d_toolshelf_register(struct ARegionType *art); /* view3d_snap.c */ bool ED_view3d_minmax_verts(struct Object *obedit, float min[3], float max[3]); diff --git a/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c b/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c index 305085be370..b42f49e6d1c 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c @@ -120,4 +120,3 @@ void VIEW3D_WGT_force_field(wmManipulatorGroupType *wgt) } /** \} */ - diff --git a/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c b/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c index b232be35462..996da2a1475 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c @@ -43,6 +43,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "RNA_access.h" #include "RNA_define.h" @@ -64,7 +65,7 @@ static void axis_geom_draw( const wmManipulator *mpr, const float color[4], const bool UNUSED(select)) { - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); Gwn_VertFormat *format = immVertexFormat(); const uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -128,15 +129,15 @@ static void axis_geom_draw( zero_v3(center); copy_v3_fl(size, HANDLE_SIZE); - glEnable(GL_DEPTH_TEST); + GPU_depth_test(true); glDepthMask(GL_TRUE); glDepthFunc(GL_LEQUAL); - glBlendFunc(GL_ONE, GL_ZERO); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func(GPU_ONE, GPU_ZERO); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); - glLineWidth(1.0f); + GPU_line_smooth(true); + GPU_blend(true); + GPU_line_width(1.0f); /* Just draw depth values. */ immUniformColor4fv(axis_nop); imm_draw_cube_fill_3d(pos_id, center, size); @@ -150,9 +151,9 @@ static void axis_geom_draw( }, 0.08f); imm_draw_cube_wire_3d(pos_id, center, size); - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); - glDisable(GL_DEPTH_TEST); + GPU_blend(false); + GPU_line_smooth(false); + GPU_depth_test(false); } draw_center_done = true; @@ -216,9 +217,9 @@ static void axis3d_draw_intern( gpuPushMatrix(); gpuMultMatrix(matrix_final); - glEnable(GL_BLEND); + GPU_blend(true); axis_geom_draw(mpr, color, select); - glDisable(GL_BLEND); + GPU_blend(false); gpuPopMatrix(); } @@ -229,9 +230,9 @@ static void manipulator_axis_draw(const bContext *C, wmManipulator *mpr) (void)is_modal; - glEnable(GL_BLEND); + GPU_blend(true); axis3d_draw_intern(C, mpr, false, is_highlight); - glDisable(GL_BLEND); + GPU_blend(false); } static int manipulator_axis_test_select( diff --git a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c index 8178c2f5be9..c33f15c0493 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c @@ -63,6 +63,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_select.h" +#include "GPU_state.h" #include "BLF_api.h" @@ -526,7 +527,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr) float color_back[4] = {1.0f, 1.0f, 1.0f, 0.5f}; /* anti-aliased lines for more consistent appearance */ - glEnable(GL_LINE_SMOOTH); + GPU_line_smooth(true); BLF_enable(blf_mono_font, BLF_ROTATION); BLF_size(blf_mono_font, 14 * U.pixelsize, U.dpi); @@ -545,7 +546,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr) ED_view3d_project_float_global(ar, ruler_item->co[j], co_ss[j], V3D_PROJ_TEST_NOP); } - glEnable(GL_BLEND); + GPU_blend(true); const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -553,10 +554,10 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr) immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); - immUniform1i("num_colors", 2); /* "advanced" mode */ + immUniform1i("colors_len", 2); /* "advanced" mode */ const float *col = is_act ? color_act : color_base; immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2); immUniform1f("dash_width", 6.0f); @@ -632,7 +633,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr) rot_90_vec_b[1] = dir_ruler[0]; normalize_v2(rot_90_vec_b); - glEnable(GL_BLEND); + GPU_blend(true); immUniformColor3ubv(color_wire); @@ -656,7 +657,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr) immEnd(); - glDisable(GL_BLEND); + GPU_blend(false); } immUnbindProgram(); @@ -693,10 +694,10 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr) immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); - immUniform1i("num_colors", 2); /* "advanced" mode */ + immUniform1i("colors_len", 2); /* "advanced" mode */ const float *col = is_act ? color_act : color_base; immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2); immUniform1f("dash_width", 6.0f); @@ -721,7 +722,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr) normalize_v2(rot_90_vec); - glEnable(GL_BLEND); + GPU_blend(true); immUniformColor3ubv(color_wire); @@ -739,7 +740,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr) immEnd(); - glDisable(GL_BLEND); + GPU_blend(false); } immUnbindProgram(); @@ -775,7 +776,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr) } } - glDisable(GL_LINE_SMOOTH); + GPU_line_smooth(false); BLF_disable(blf_mono_font, BLF_ROTATION); @@ -1031,7 +1032,7 @@ void VIEW3D_WGT_ruler(wmManipulatorGroupType *wgt) /** \name Add Ruler Operator * \{ */ -static int view3d_ruler_poll(bContext *C) +static bool view3d_ruler_poll(bContext *C) { bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); if ((tref_rt == NULL) || diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 267712b3339..b16327d2a4a 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -254,10 +254,12 @@ void view3d_keymap(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "use_all_regions", false); +#ifdef USE_WM_KEYMAP_27X WM_keymap_verify_item(keymap, "VIEW3D_OT_view_lock_to_active", PADPERIOD, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_view_lock_clear", PADPERIOD, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_navigate", FKEY, KM_PRESS, KM_SHIFT, 0); +#endif WM_keymap_verify_item(keymap, "VIEW3D_OT_smoothview", TIMER1, KM_ANY, KM_ANY, 0); @@ -286,21 +288,27 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_dolly", EQUALKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_dolly", MINUSKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "delta", -1); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "VIEW3D_OT_zoom_camera_1_to_1", PADENTER, KM_PRESS, KM_SHIFT, 0); +#endif WM_keymap_add_item(keymap, "VIEW3D_OT_view_center_camera", HOMEKEY, KM_PRESS, 0, 0); /* only with camera view */ WM_keymap_add_item(keymap, "VIEW3D_OT_view_center_lock", HOMEKEY, KM_PRESS, 0, 0); /* only with lock view */ +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "VIEW3D_OT_view_center_cursor", HOMEKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_view_center_pick", FKEY, KM_PRESS, KM_ALT, 0); +#endif kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "center", false); /* only without camera view */ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_all", HOMEKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "use_all_regions", true); RNA_boolean_set(kmi->ptr, "center", false); /* only without camera view */ +#ifdef USE_WM_KEYMAP_27X kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_all", CKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "center", true); +#endif WM_keymap_add_menu_pie(keymap, "VIEW3D_MT_view_pie", ACCENTGRAVEKEY, KM_CLICK_DRAG, 0, 0); @@ -328,6 +336,7 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_enum_set(kmi->ptr, "type", V3D_VIEW_STEPRIGHT); RNA_float_set(kmi->ptr, "angle", (float)M_PI); +#ifdef USE_WM_KEYMAP_27X RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELUPMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANRIGHT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANLEFT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELUPMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "type", V3D_VIEW_PANUP); @@ -340,6 +349,7 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", WHEELUPMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "type", V3D_VIEW_STEPLEFT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "type", V3D_VIEW_STEPRIGHT); +#endif /* active aligned, replaces '*' key in 2.4x */ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT, 0); @@ -530,4 +540,3 @@ void view3d_keymap(wmKeyConfig *keyconf) viewzoom_modal_keymap(keyconf); viewdolly_modal_keymap(keyconf); } - diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index e001ed9112b..5911c8224be 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -46,6 +46,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" +#include "GPU_state.h" #include "WM_api.h" #include "WM_types.h" @@ -438,7 +439,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a float color_back[4] = {1.0f, 1.0f, 1.0f, 0.5f}; /* anti-aliased lines for more consistent appearance */ - glEnable(GL_LINE_SMOOTH); + GPU_line_smooth(true); BLF_enable(blf_mono_font, BLF_ROTATION); BLF_size(blf_mono_font, 14 * U.pixelsize, U.dpi); @@ -458,7 +459,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a ED_view3d_project_float_global(ar, ruler_item->co[j], co_ss[j], V3D_PROJ_TEST_NOP); } - glEnable(GL_BLEND); + GPU_blend(true); const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -466,10 +467,10 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); - immUniform1i("num_colors", 2); /* "advanced" mode */ + immUniform1i("colors_len", 2); /* "advanced" mode */ const float *col = is_act ? color_act : color_base; immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2); immUniform1f("dash_width", 6.0f); @@ -545,7 +546,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a rot_90_vec_b[1] = dir_ruler[0]; normalize_v2(rot_90_vec_b); - glEnable(GL_BLEND); + GPU_blend(true); immUniformColor3ubv(color_wire); @@ -569,7 +570,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a immEnd(); - glDisable(GL_BLEND); + GPU_blend(false); } immUnbindProgram(); @@ -605,10 +606,10 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); - immUniform1i("num_colors", 2); /* "advanced" mode */ + immUniform1i("colors_len", 2); /* "advanced" mode */ const float *col = is_act ? color_act : color_base; immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2); immUniform1f("dash_width", 6.0f); @@ -633,7 +634,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a normalize_v2(rot_90_vec); - glEnable(GL_BLEND); + GPU_blend(true); immUniformColor3ubv(color_wire); @@ -651,7 +652,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a immEnd(); - glDisable(GL_BLEND); + GPU_blend(false); } immUnbindProgram(); @@ -687,7 +688,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a } } - glDisable(GL_LINE_SMOOTH); + GPU_line_smooth(false); BLF_disable(blf_mono_font, BLF_ROTATION); @@ -811,7 +812,7 @@ static bool view3d_ruler_item_mousemove( } } -static void view3d_ruler_header_update(ScrArea *sa) +static void view3d_ruler_header_update(bContext *C) { const char *text = IFACE_("Ctrl+LMB: Add, " "Del: Remove, " @@ -821,7 +822,7 @@ static void view3d_ruler_header_update(ScrArea *sa) "Enter: Store, " "Esc: Cancel"); - ED_area_headerprint(sa, text); + ED_workspace_status_text(C, text); } /* -------------------------------------------------------------------- */ @@ -847,7 +848,7 @@ static int view3d_ruler_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE ruler_info->draw_handle_pixel = ED_region_draw_cb_activate(ar->type, ruler_info_draw_pixel, ruler_info, REGION_DRAW_POST_PIXEL); - view3d_ruler_header_update(sa); + view3d_ruler_header_update(C); op->flag |= OP_IS_MODAL_CURSOR_REGION; @@ -1079,7 +1080,7 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event) } if (do_draw) { - view3d_ruler_header_update(sa); + view3d_ruler_header_update(C); /* all 3d views draw rulers */ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); @@ -1093,7 +1094,7 @@ exit: view3d_ruler_free(ruler_info); op->customdata = NULL; - ED_area_headerprint(sa, NULL); + ED_workspace_status_text(C, NULL); } return exit_code; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index b4f3be178aa..b7dbb09e1a4 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -265,7 +265,7 @@ static void view3d_userdata_lassoselect_init( r_data->is_changed = false; } -static int view3d_selectable_data(bContext *C) +static bool view3d_selectable_data(bContext *C) { Object *ob = CTX_data_active_object(C); @@ -1326,7 +1326,7 @@ static Base *mouse_select_eval_buffer( while (base) { /* skip objects with select restriction, to prevent prematurely ending this loop * with an un-selectable choice */ - if ((base->flag & BASE_SELECTABLED) == 0) { + if ((base->flag & BASE_SELECTABLE) == 0) { base = base->next; if (base == NULL) base = FIRSTBASE(view_layer); if (base == startbase) break; @@ -2518,8 +2518,8 @@ void VIEW3D_OT_select(wmOperatorType *ot) PropertyRNA *prop; /* identifiers */ - ot->name = "Activate/Select"; - ot->description = "Activate/select item(s)"; + ot->name = "Select"; + ot->description = "Select and activate item(s)"; ot->idname = "VIEW3D_OT_select"; /* api callbacks */ diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index acceb40beaa..707e0e7a394 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -28,153 +28,24 @@ * \ingroup spview3d */ - #include <string.h> #include <stdio.h> #include <math.h> #include <float.h> -#include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "MEM_guardedalloc.h" - -#include "BLI_blenlib.h" #include "BLI_utildefines.h" -#include "BLI_ghash.h" - -#include "BLT_translation.h" #include "BKE_context.h" -#include "BKE_screen.h" - #include "WM_api.h" #include "WM_types.h" -#include "RNA_access.h" - #include "ED_screen.h" -#include "ED_undo.h" - -#include "UI_interface.h" -#include "UI_resources.h" #include "view3d_intern.h" /* own include */ -/* ******************* */ - -typedef struct CustomTool { - struct CustomTool *next, *prev; - char opname[OP_MAX_TYPENAME]; - char context[OP_MAX_TYPENAME]; -} CustomTool; - -static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2) -{ - wmOperatorType *ot = arg2; - - if (ot) { - CustomTool *ct = MEM_callocN(sizeof(CustomTool), "CustomTool"); - - BLI_addtail(arg_listbase, ct); - BLI_strncpy(ct->opname, ot->idname, OP_MAX_TYPENAME); - BLI_strncpy(ct->context, CTX_data_mode_string(C), OP_MAX_TYPENAME); - } - -} - -static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items) -{ - GHashIterator iter; - - for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) { - wmOperatorType *ot = BLI_ghashIterator_getValue(&iter); - - if (BLI_strcasestr(ot->name, str)) { - if (WM_operator_poll((bContext *)C, ot)) { - - if (false == UI_search_item_add(items, ot->name, ot, 0)) - break; - } - } - } -} - - -/* ID Search browse menu, open */ -static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase) -{ - static char search[OP_MAX_TYPENAME]; - wmEvent event; - wmWindow *win = CTX_wm_window(C); - uiBlock *block; - uiBut *but; - - /* clear initial search string, then all items show */ - search[0] = 0; - - block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); - UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_SEARCH_MENU); - - /* fake button, it holds space for search items */ - uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 15, UI_searchbox_size_x(), UI_searchbox_size_y(), NULL, 0, 0, 0, 0, NULL); - - but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, 19, 0, 0, ""); - UI_but_func_search_set(but, NULL, operator_search_cb, arg_listbase, operator_call_cb, NULL); - - UI_block_bounds_set_normal(block, 6); - UI_block_direction_set(block, UI_DIR_DOWN); - UI_block_end(C, block); - - wm_event_init_from_window(win, &event); - event.type = EVT_BUT_OPEN; - event.val = KM_PRESS; - event.customdata = but; - event.customdatafree = false; - wm_event_add(win, &event); - - return block; -} - - -static void view3d_panel_tool_shelf(const bContext *C, Panel *pa) -{ - SpaceLink *sl = CTX_wm_space_data(C); - SpaceType *st = NULL; - uiLayout *col; - const char *context = CTX_data_mode_string(C); - - if (sl) - st = BKE_spacetype_from_id(sl->spacetype); - - if (st && st->toolshelf.first) { - CustomTool *ct; - - for (ct = st->toolshelf.first; ct; ct = ct->next) { - if (STREQLEN(context, ct->context, OP_MAX_TYPENAME)) { - col = uiLayoutColumn(pa->layout, true); - uiItemFullO(col, ct->opname, NULL, ICON_NONE, NULL, WM_OP_INVOKE_REGION_WIN, 0, NULL); - } - } - } - col = uiLayoutColumn(pa->layout, true); - uiDefBlockBut(uiLayoutGetBlock(pa->layout), tool_search_menu, &st->toolshelf, "Add Tool", 0, 0, UI_UNIT_X, UI_UNIT_Y, "Add Tool in shelf, gets saved in files"); -} - - -void view3d_toolshelf_register(ARegionType *art) -{ - PanelType *pt; - - pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel tools"); - strcpy(pt->idname, "VIEW3D_PT_tool_shelf"); - strcpy(pt->label, N_("Tool Shelf")); - strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); - pt->draw = view3d_panel_tool_shelf; - BLI_addtail(&art->paneltypes, pt); -} - /* ********** operator to open/close toolshelf region */ static int view3d_toolshelf_toggle_exec(bContext *C, wmOperator *UNUSED(op)) @@ -200,4 +71,3 @@ void VIEW3D_OT_toolshelf(wmOperatorType *ot) /* flags */ ot->flag = 0; } - diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index abb8c688e05..aad2ac7284f 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -55,6 +55,7 @@ #include "GPU_glew.h" #include "GPU_select.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "WM_api.h" #include "WM_types.h" @@ -463,7 +464,7 @@ static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op)) } -static int view3d_camera_to_view_poll(bContext *C) +static bool view3d_camera_to_view_poll(bContext *C) { View3D *v3d; ARegion *ar; @@ -509,7 +510,6 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op) { Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); /* can be NULL */ Object *camera_ob = v3d ? v3d->camera : scene->camera; Object *camera_ob_eval = DEG_get_evaluated_object(depsgraph, camera_ob); @@ -523,7 +523,7 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op) } /* this function does all the important stuff */ - if (BKE_camera_view_frame_fit_to_scene(depsgraph, scene, view_layer, camera_ob_eval, r_co, &r_scale)) { + if (BKE_camera_view_frame_fit_to_scene(depsgraph, scene, camera_ob_eval, r_co, &r_scale)) { ObjectTfmProtectedChannels obtfm; float obmat_new[4][4]; @@ -663,7 +663,7 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -int ED_operator_rv3d_user_region_poll(bContext *C) +bool ED_operator_rv3d_user_region_poll(bContext *C) { View3D *v3d_dummy; ARegion *ar_dummy; @@ -1005,7 +1005,7 @@ int view3d_opengl_select( if (v3d->drawtype > OB_WIRE) { v3d->zbuf = true; - glEnable(GL_DEPTH_TEST); + GPU_depth_test(true); } if (vc->rv3d->rflag & RV3D_CLIPPING) @@ -1051,7 +1051,7 @@ int view3d_opengl_select( if (v3d->drawtype > OB_WIRE) { v3d->zbuf = 0; - glDisable(GL_DEPTH_TEST); + GPU_depth_test(false); } if (vc->rv3d->rflag & RV3D_CLIPPING) @@ -1076,7 +1076,7 @@ finally: /** \name View Layer Utilities * \{ */ -int ED_view3d_view_layer_set(int lay, const int *values, int *active) +int ED_view3d_view_layer_set(int lay, const bool *values, int *active) { int i, tot = 0; diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index 352e85703bc..e3e82e8b9c2 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -404,7 +404,7 @@ static void walk_update_header(bContext *C, wmOperator *op, WalkInfo *walk) #undef WM_MODALKEY - ED_area_headerprint(CTX_wm_area(C), header); + ED_workspace_status_text(C, header); } static void walk_navigation_mode_set(bContext *C, wmOperator *op, WalkInfo *walk, eWalkMethod mode) @@ -1436,7 +1436,7 @@ static int walk_modal(bContext *C, wmOperator *op, const wmEvent *event) } if (ELEM(exit_code, OPERATOR_FINISHED, OPERATOR_CANCELLED)) - ED_area_headerprint(CTX_wm_area(C), NULL); + ED_workspace_status_text(C, NULL); return exit_code; } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index acb92b1606c..ba9430c46f7 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -76,6 +76,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "ED_image.h" #include "ED_keyframing.h" @@ -658,7 +659,7 @@ static void viewRedrawForce(const bContext *C, TransInfo *t) static void viewRedrawPost(bContext *C, TransInfo *t) { - ED_area_headerprint(t->sa, NULL); + ED_area_status_text(t->sa, NULL); if (t->spacetype == SPACE_VIEW3D) { /* if autokeying is enabled, send notifiers that keyframes were added */ @@ -1723,7 +1724,7 @@ static void drawArc(float size, float angle_start, float angle_end, int segments immEnd(); } -static int helpline_poll(bContext *C) +static bool helpline_poll(bContext *C) { ARegion *ar = CTX_wm_region(C); @@ -1770,15 +1771,15 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) UNUSED_VARS_NDEBUG(shdr_pos); /* silence warning */ BLI_assert(shdr_pos == POS_INDEX); - glLineWidth(1.0f); + GPU_line_width(1.0f); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); - immUniform1i("num_colors", 0); /* "simple" mode */ + immUniform1i("colors_len", 0); /* "simple" mode */ immUniformThemeColor(TH_VIEW_OVERLAY); immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); @@ -1804,7 +1805,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) gpuTranslate3fv(mval); gpuRotateAxis(-RAD2DEGF(atan2f(cent[0] - tmval[0], cent[1] - tmval[1])), 'Z'); - glLineWidth(3.0f); + GPU_line_width(3.0f); drawArrow(UP, 5, 10, 5); drawArrow(DOWN, 5, 10, 5); break; @@ -1812,7 +1813,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) immUniformThemeColor(TH_VIEW_OVERLAY); gpuTranslate3fv(mval); - glLineWidth(3.0f); + GPU_line_width(3.0f); drawArrow(RIGHT, 5, 10, 5); drawArrow(LEFT, 5, 10, 5); break; @@ -1821,7 +1822,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) gpuTranslate3fv(mval); - glLineWidth(3.0f); + GPU_line_width(3.0f); drawArrow(UP, 5, 10, 5); drawArrow(DOWN, 5, 10, 5); break; @@ -1837,7 +1838,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) gpuTranslate3f(cent[0] - tmval[0] + mval[0], cent[1] - tmval[1] + mval[1], 0); - glLineWidth(3.0f); + GPU_line_width(3.0f); drawArc(dist, angle - delta_angle, angle - spacing_angle, 10); drawArc(dist, angle + spacing_angle, angle + delta_angle, 10); @@ -1863,16 +1864,16 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) gpuTranslate3fv(mval); - glLineWidth(3.0f); + GPU_line_width(3.0f); UI_make_axis_color(col, col2, 'X'); - immUniformColor3ubv((GLubyte *)col2); + immUniformColor3ubv(col2); drawArrow(RIGHT, 5, 10, 5); drawArrow(LEFT, 5, 10, 5); UI_make_axis_color(col, col2, 'Y'); - immUniformColor3ubv((GLubyte *)col2); + immUniformColor3ubv(col2); drawArrow(UP, 5, 10, 5); drawArrow(DOWN, 5, 10, 5); @@ -1889,7 +1890,7 @@ static void drawTransformView(const struct bContext *C, ARegion *UNUSED(ar), voi { TransInfo *t = arg; - glLineWidth(1.0f); + GPU_line_width(1.0f); drawConstraint(t); drawPropCircle(C, t); @@ -1929,15 +1930,15 @@ static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *ar) #endif /* autokey recording icon... */ - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); xco -= U.widget_unit; yco -= (int)printable_size[1] / 2; UI_icon_draw(xco, yco, ICON_REC); - glDisable(GL_BLEND); + GPU_blend(false); } static void drawTransformPixel(const struct bContext *UNUSED(C), ARegion *ar, void *arg) @@ -1969,7 +1970,7 @@ static void drawTransformPixel(const struct bContext *UNUSED(C), ARegion *ar, vo void saveTransform(bContext *C, TransInfo *t, wmOperator *op) { ToolSettings *ts = CTX_data_tool_settings(C); - int constraint_axis[3] = {0, 0, 0}; + bool constraint_axis[3] = {false, false, false}; int proportional = 0; PropertyRNA *prop; @@ -2091,13 +2092,13 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) if (t->con.mode & CON_APPLY) { if (t->con.mode & CON_AXIS0) { - constraint_axis[0] = 1; + constraint_axis[0] = true; } if (t->con.mode & CON_AXIS1) { - constraint_axis[1] = 1; + constraint_axis[1] = true; } if (t->con.mode & CON_AXIS2) { - constraint_axis[2] = 1; + constraint_axis[2] = true; } } @@ -2287,7 +2288,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve /* Constraint init from operator */ if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis")) && RNA_property_is_set(op->ptr, prop)) { - int constraint_axis[3]; + bool constraint_axis[3]; RNA_property_boolean_get_array(op->ptr, prop, constraint_axis); @@ -3189,7 +3190,7 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -3343,7 +3344,7 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -3622,7 +3623,7 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -3725,7 +3726,7 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -3823,7 +3824,7 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -4190,7 +4191,7 @@ static void applyRotation(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -4307,7 +4308,7 @@ static void applyTrackball(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -4757,7 +4758,7 @@ static void applyTranslation(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -4859,7 +4860,7 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -4938,7 +4939,7 @@ static void applyTilt(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -5019,7 +5020,7 @@ static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -5125,7 +5126,7 @@ static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -5206,7 +5207,7 @@ static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -5301,7 +5302,7 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -5383,7 +5384,7 @@ static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -5468,7 +5469,7 @@ static void applyCrease(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -5591,7 +5592,7 @@ static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -5668,7 +5669,7 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -7165,10 +7166,10 @@ static void drawEdgeSlide(TransInfo *t) const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f; if (v3d && v3d->zbuf) - glDisable(GL_DEPTH_TEST); + GPU_depth_test(false); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); gpuPushMatrix(); gpuMultMatrix(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); @@ -7188,7 +7189,7 @@ static void drawEdgeSlide(TransInfo *t) add_v3_v3v3(co_a, curr_sv->v_co_orig, curr_sv->dir_side[0]); add_v3_v3v3(co_b, curr_sv->v_co_orig, curr_sv->dir_side[1]); - glLineWidth(line_size); + GPU_line_width(line_size); immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); immBeginAtMost(GWN_PRIM_LINES, 4); if (curr_sv->v_side[0]) { @@ -7202,7 +7203,7 @@ static void drawEdgeSlide(TransInfo *t) immEnd(); immUniformThemeColorShadeAlpha(TH_SELECT, -30, alpha_shade); - glPointSize(ctrl_size); + GPU_point_size(ctrl_size); immBegin(GWN_PRIM_POINTS, 1); if (slp->flipped) { if (curr_sv->v_side[1]) immVertex3fv(pos, curr_sv->v_side[1]->co); @@ -7213,7 +7214,7 @@ static void drawEdgeSlide(TransInfo *t) immEnd(); immUniformThemeColorShadeAlpha(TH_SELECT, 255, alpha_shade); - glPointSize(guide_size); + GPU_point_size(guide_size); immBegin(GWN_PRIM_POINTS, 1); interp_line_v3_v3v3v3(co_mark, co_b, curr_sv->v_co_orig, co_a, fac); immVertex3fv(pos, co_mark); @@ -7226,7 +7227,7 @@ static void drawEdgeSlide(TransInfo *t) int i; const int alpha_shade = -160; - glLineWidth(line_size); + GPU_line_width(line_size); immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); immBegin(GWN_PRIM_LINES, sld->totsv * 2); @@ -7261,10 +7262,10 @@ static void drawEdgeSlide(TransInfo *t) gpuPopMatrix(); - glDisable(GL_BLEND); + GPU_blend(false); if (v3d && v3d->zbuf) - glEnable(GL_DEPTH_TEST); + GPU_depth_test(true); } } } @@ -7394,7 +7395,7 @@ static void applyEdgeSlide(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -7801,15 +7802,15 @@ static void drawVertSlide(TransInfo *t) int i; if (v3d && v3d->zbuf) - glDisable(GL_DEPTH_TEST); + GPU_depth_test(false); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); gpuPushMatrix(); gpuMultMatrix(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); - glLineWidth(line_size); + GPU_line_width(line_size); const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -7840,7 +7841,7 @@ static void drawVertSlide(TransInfo *t) } immEnd(); - glPointSize(ctrl_size); + GPU_point_size(ctrl_size); immBegin(GWN_PRIM_POINTS, 1); immVertex3fv(shdr_pos, (slp->flipped && slp->use_even) ? @@ -7872,15 +7873,15 @@ static void drawVertSlide(TransInfo *t) add_v3_v3(co_dest_3d, curr_sv->co_orig_3d); - glLineWidth(1.0f); + GPU_line_width(1.0f); immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); - immUniform1i("num_colors", 0); /* "simple" mode */ + immUniform1i("colors_len", 0); /* "simple" mode */ immUniformColor4f(1.0f, 1.0f, 1.0f, 1.0f); immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); @@ -7896,7 +7897,7 @@ static void drawVertSlide(TransInfo *t) gpuPopMatrix(); if (v3d && v3d->zbuf) - glEnable(GL_DEPTH_TEST); + GPU_depth_test(true); } } } @@ -7993,7 +7994,7 @@ static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -8067,7 +8068,7 @@ static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -8158,7 +8159,7 @@ static void applyBakeTime(TransInfo *t, const int mval[2]) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -8219,7 +8220,7 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } else { size[0] = size[1] = size[2] = 1; @@ -8242,9 +8243,9 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); if (t->flag & T_2D_EDIT) - ED_area_headerprint(t->sa, IFACE_("Select a mirror axis (X, Y)")); + ED_area_status_text(t->sa, IFACE_("Select a mirror axis (X, Y)")); else - ED_area_headerprint(t->sa, IFACE_("Select a mirror axis (X, Y, Z)")); + ED_area_status_text(t->sa, IFACE_("Select a mirror axis (X, Y, Z)")); } } /** \} */ @@ -8306,7 +8307,7 @@ static void applyAlign(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, IFACE_("Align")); + ED_area_status_text(t->sa, IFACE_("Align")); } /** \} */ @@ -8405,7 +8406,7 @@ static void applySeqSlide(TransInfo *t, const int mval[2]) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -8689,7 +8690,7 @@ static void applyTimeTranslate(TransInfo *t, const int mval[2]) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -8879,7 +8880,7 @@ static void applyTimeSlide(TransInfo *t, const int mval[2]) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ @@ -9000,12 +9001,12 @@ static void applyTimeScale(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - ED_area_headerprint(t->sa, str); + ED_area_status_text(t->sa, str); } /** \} */ -/* TODO, move to: transform_queries.c */ +/* TODO, move to: transform_query.c */ bool checkUseAxisMatrix(TransInfo *t) { /* currently only checks for editmode */ diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index d72d311e0f6..b9fbb37722c 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -890,7 +890,7 @@ void freeVertSlideVerts(TransInfo *t, TransDataContainer *tc, TransCustomData *c void projectVertSlideData(TransInfo *t, bool is_final); -/* TODO. transform_queries.c */ +/* TODO. transform_query.c */ bool checkUseAxisMatrix(TransInfo *t); #define TRANSFORM_SNAP_MAX_PX 100.0f diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 3c70eaae2d3..9df8264cc76 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -44,6 +44,7 @@ #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "BLI_math.h" #include "BLI_utildefines.h" @@ -559,7 +560,7 @@ static void applyObjectConstraintRot( /* on setup call, use first object */ if (td == NULL) { - td = tc->data; + td = TRANS_DATA_CONTAINER_FIRST_OK(t)->data; } if (t->flag & T_EDIT) { @@ -742,19 +743,19 @@ void drawConstraint(TransInfo *t) drawLine(t, t->center_global, tc->mtx[1], 'Y', 0); drawLine(t, t->center_global, tc->mtx[2], 'Z', 0); - depth_test_enabled = glIsEnabled(GL_DEPTH_TEST); + depth_test_enabled = GPU_depth_test_enabled(); if (depth_test_enabled) - glDisable(GL_DEPTH_TEST); + GPU_depth_test(false); const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); - immUniform1i("num_colors", 0); /* "simple" mode */ + immUniform1i("colors_len", 0); /* "simple" mode */ immUniformColor4f(1.0f, 1.0f, 1.0f, 1.0f); immUniform1f("dash_width", 2.0f); immUniform1f("dash_factor", 0.5f); @@ -767,7 +768,7 @@ void drawConstraint(TransInfo *t) immUnbindProgram(); if (depth_test_enabled) - glEnable(GL_DEPTH_TEST); + GPU_depth_test(true); } if (tc->mode & CON_AXIS0) { @@ -818,9 +819,9 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) gpuScale2f(1.0f, (ysize / xsize) * (xmask / ymask)); } - depth_test_enabled = glIsEnabled(GL_DEPTH_TEST); + depth_test_enabled = GPU_depth_test_enabled(); if (depth_test_enabled) - glDisable(GL_DEPTH_TEST); + GPU_depth_test(false); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -834,7 +835,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) immUnbindProgram(); if (depth_test_enabled) - glEnable(GL_DEPTH_TEST); + GPU_depth_test(true); gpuPopMatrix(); } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 8462004c549..c622a50ff11 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -61,7 +61,6 @@ #include "BLI_bitmap.h" #include "BLI_rect.h" -#include "BKE_DerivedMesh.h" #include "BKE_action.h" #include "BKE_armature.h" #include "BKE_constraint.h" diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 053647cbfea..db8bbe05c69 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -2336,4 +2336,3 @@ void transform_data_ext_rotate(TransData *td, float mat[3][3], bool use_drot) copy_v3_v3(td->ext->rot, eul); } } - diff --git a/source/blender/editors/transform/transform_manipulator_2d.c b/source/blender/editors/transform/transform_manipulator_2d.c index d2743f47000..fd6e7ed5442 100644 --- a/source/blender/editors/transform/transform_manipulator_2d.c +++ b/source/blender/editors/transform/transform_manipulator_2d.c @@ -223,7 +223,7 @@ void ED_widgetgroup_manipulator2d_setup(const bContext *UNUSED(C), wmManipulator /* assign operator */ PointerRNA *ptr = WM_manipulator_operator_set(axis, 0, ot_translate, NULL); - int constraint[3] = {0}; + bool constraint[3] = {0}; constraint[(axis_idx + 1) % 2] = 1; if (RNA_struct_find_property(ptr, "constraint_axis")) RNA_boolean_set_array(ptr, "constraint_axis", constraint); @@ -240,8 +240,8 @@ void ED_widgetgroup_manipulator2d_setup(const bContext *UNUSED(C), wmManipulator ptr = WM_manipulator_operator_set(man->cage, 0, ot_translate, NULL); RNA_boolean_set(ptr, "release_confirm", 1); - int constraint_x[3] = {1, 0, 0}; - int constraint_y[3] = {0, 1, 0}; + bool constraint_x[3] = {1, 0, 0}; + bool constraint_y[3] = {0, 1, 0}; ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X, ot_resize, NULL); PropertyRNA *prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm"); diff --git a/source/blender/editors/transform/transform_manipulator_3d.c b/source/blender/editors/transform/transform_manipulator_3d.c index 75da0fc2d23..8f547fb7451 100644 --- a/source/blender/editors/transform/transform_manipulator_3d.c +++ b/source/blender/editors/transform/transform_manipulator_3d.c @@ -159,18 +159,15 @@ enum { MAN_AXES_SCALE, }; -/* naming from old blender we may combine. */ -enum { - V3D_MANIP_TRANSLATE = 1, - V3D_MANIP_ROTATE = 2, - V3D_MANIP_SCALE = 4, -}; - - typedef struct ManipulatorGroup { bool all_hidden; int twtype; + /* Users may change the twtype, detect changes to re-setup manipulator options. */ + int twtype_init; + int twtype_prev; + int use_twtype_refresh; + struct wmManipulator *manipulators[MAN_AXIS_LAST]; } ManipulatorGroup; @@ -269,9 +266,9 @@ static bool manipulator_is_axis_visible( } } - if ((axis_type == MAN_AXES_TRANSLATE && !(twtype & V3D_MANIP_TRANSLATE)) || - (axis_type == MAN_AXES_ROTATE && !(twtype & V3D_MANIP_ROTATE)) || - (axis_type == MAN_AXES_SCALE && !(twtype & V3D_MANIP_SCALE))) + if ((axis_type == MAN_AXES_TRANSLATE && !(twtype & SCE_MANIP_TRANSLATE)) || + (axis_type == MAN_AXES_ROTATE && !(twtype & SCE_MANIP_ROTATE)) || + (axis_type == MAN_AXES_SCALE && !(twtype & SCE_MANIP_SCALE))) { return false; } @@ -301,34 +298,34 @@ static bool manipulator_is_axis_visible( case MAN_AXIS_SCALE_Z: return (rv3d->twdrawflag & MAN_SCALE_Z); case MAN_AXIS_SCALE_C: - return (rv3d->twdrawflag & MAN_SCALE_C && (twtype & V3D_MANIP_TRANSLATE) == 0); + return (rv3d->twdrawflag & MAN_SCALE_C && (twtype & SCE_MANIP_TRANSLATE) == 0); case MAN_AXIS_TRANS_XY: return (rv3d->twdrawflag & MAN_TRANS_X && rv3d->twdrawflag & MAN_TRANS_Y && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_ROTATE) == 0); case MAN_AXIS_TRANS_YZ: return (rv3d->twdrawflag & MAN_TRANS_Y && rv3d->twdrawflag & MAN_TRANS_Z && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_ROTATE) == 0); case MAN_AXIS_TRANS_ZX: return (rv3d->twdrawflag & MAN_TRANS_Z && rv3d->twdrawflag & MAN_TRANS_X && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_ROTATE) == 0); case MAN_AXIS_SCALE_XY: return (rv3d->twdrawflag & MAN_SCALE_X && rv3d->twdrawflag & MAN_SCALE_Y && - (twtype & V3D_MANIP_TRANSLATE) == 0 && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_TRANSLATE) == 0 && + (twtype & SCE_MANIP_ROTATE) == 0); case MAN_AXIS_SCALE_YZ: return (rv3d->twdrawflag & MAN_SCALE_Y && rv3d->twdrawflag & MAN_SCALE_Z && - (twtype & V3D_MANIP_TRANSLATE) == 0 && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_TRANSLATE) == 0 && + (twtype & SCE_MANIP_ROTATE) == 0); case MAN_AXIS_SCALE_ZX: return (rv3d->twdrawflag & MAN_SCALE_Z && rv3d->twdrawflag & MAN_SCALE_X && - (twtype & V3D_MANIP_TRANSLATE) == 0 && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_TRANSLATE) == 0 && + (twtype & SCE_MANIP_ROTATE) == 0); } return false; } @@ -404,9 +401,9 @@ static void manipulator_get_axis_color( r_col_hi[3] = alpha_hi * alpha_fac; } -static void manipulator_get_axis_constraint(const int axis_idx, int r_axis[3]) +static void manipulator_get_axis_constraint(const int axis_idx, bool r_axis[3]) { - zero_v3_int(r_axis); + ARRAY_SET_ITEMS(r_axis, 0, 0, 0); switch (axis_idx) { case MAN_AXIS_TRANS_X: @@ -1122,15 +1119,15 @@ static void manipulator_line_range(const int twtype, const short axis_type, floa switch (axis_type) { case MAN_AXES_TRANSLATE: - if (twtype & V3D_MANIP_SCALE) { + if (twtype & SCE_MANIP_SCALE) { *r_start = *r_len - ofs + 0.075f; } - if (twtype & V3D_MANIP_ROTATE) { + if (twtype & SCE_MANIP_ROTATE) { *r_len += ofs; } break; case MAN_AXES_SCALE: - if (twtype & (V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE)) { + if (twtype & (SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE)) { *r_len -= ofs + 0.025f; } break; @@ -1172,8 +1169,10 @@ static void manipulator_xform_message_subscribe( if (type_fn == TRANSFORM_WGT_manipulator) { extern PropertyRNA rna_ToolSettings_transform_pivot_point; + extern PropertyRNA rna_ToolSettings_use_manipulator_mode; const PropertyRNA *props[] = { - &rna_ToolSettings_transform_pivot_point + &rna_ToolSettings_transform_pivot_point, + &rna_ToolSettings_use_manipulator_mode, }; for (int i = 0; i < ARRAY_SIZE(props); i++) { WM_msg_subscribe_rna(mbus, &toolsettings_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); @@ -1285,45 +1284,16 @@ static int manipulator_modal( return OPERATOR_RUNNING_MODAL; } -static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup *mgroup) +static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgroup) { - ManipulatorGroup *man = manipulatorgroup_init(mgroup); struct { wmOperatorType *translate, *rotate, *trackball, *resize; } ot_store = {NULL}; - - mgroup->customdata = man; - - { - /* TODO: support mixing modes again? - it's supported but tool system makes it unobvious. */ - man->twtype = 0; - ScrArea *sa = CTX_wm_area(C); - bToolRef_Runtime *tref_rt = sa->runtime.tool ? sa->runtime.tool->runtime : NULL; - wmKeyMap *km = tref_rt ? WM_keymap_find_all(C, tref_rt->keymap, sa->spacetype, RGN_TYPE_WINDOW) : NULL; - /* Weak, check first event */ - wmKeyMapItem *kmi = km ? km->items.first : NULL; - - if (kmi == NULL) { - man->twtype |= V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE | V3D_MANIP_SCALE; - } - else if (STREQ(kmi->idname, "TRANSFORM_OT_translate")) { - man->twtype |= V3D_MANIP_TRANSLATE; - } - else if (STREQ(kmi->idname, "TRANSFORM_OT_rotate")) { - man->twtype |= V3D_MANIP_ROTATE; - } - else if (STREQ(kmi->idname, "TRANSFORM_OT_resize")) { - man->twtype |= V3D_MANIP_SCALE; - } - BLI_assert(man->twtype != 0); - } - - /* *** set properties for axes *** */ - + ManipulatorGroup *man = mgroup->customdata; MAN_ITER_AXES_BEGIN(axis, axis_idx) { const short axis_type = manipulator_get_axis_type(axis_idx); - int constraint_axis[3] = {1, 0, 0}; + bool constraint_axis[3] = {1, 0, 0}; PointerRNA *ptr; manipulator_get_axis_constraint(axis_idx, constraint_axis); @@ -1340,7 +1310,7 @@ static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup case MAN_AXIS_SCALE_Z: if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { int draw_options = 0; - if ((man->twtype & (V3D_MANIP_ROTATE | V3D_MANIP_SCALE)) == 0) { + if ((man->twtype & (SCE_MANIP_ROTATE | SCE_MANIP_SCALE)) == 0) { draw_options |= ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM; } RNA_enum_set(axis->ptr, "draw_options", draw_options); @@ -1434,6 +1404,39 @@ static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup MAN_ITER_AXES_END; } +static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup *mgroup) +{ + ManipulatorGroup *man = manipulatorgroup_init(mgroup); + + mgroup->customdata = man; + + { + man->twtype = 0; + ScrArea *sa = CTX_wm_area(C); + const bToolRef *tref = sa->runtime.tool; + + if (tref == NULL || STREQ(tref->idname, "Transform")) { + /* Setup all manipulators, they can be toggled via 'ToolSettings.manipulator_flag' */ + man->twtype = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; + man->use_twtype_refresh = true; + } + else if (STREQ(tref->idname, "Move")) { + man->twtype |= SCE_MANIP_TRANSLATE; + } + else if (STREQ(tref->idname, "Rotate")) { + man->twtype |= SCE_MANIP_ROTATE; + } + else if (STREQ(tref->idname, "Scale")) { + man->twtype |= SCE_MANIP_SCALE; + } + BLI_assert(man->twtype != 0); + man->twtype_init = man->twtype; + } + + /* *** set properties for axes *** */ + manipulatorgroup_init_properties_from_twtype(mgroup); +} + static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGroup *mgroup) { ManipulatorGroup *man = mgroup->customdata; @@ -1443,6 +1446,15 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou RegionView3D *rv3d = ar->regiondata; struct TransformBounds tbounds; + if (man->use_twtype_refresh) { + Scene *scene = CTX_data_scene(C); + man->twtype = scene->toolsettings->manipulator_flag & man->twtype_init; + if (man->twtype != man->twtype_prev) { + man->twtype_prev = man->twtype; + manipulatorgroup_init_properties_from_twtype(mgroup); + } + } + /* skip, we don't draw anything anyway */ if ((man->all_hidden = (ED_transform_calc_manipulator_stats( @@ -1481,7 +1493,7 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou RNA_float_set(axis->ptr, "length", len); if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { - if (man->twtype & V3D_MANIP_ROTATE) { + if (man->twtype & SCE_MANIP_ROTATE) { /* Avoid rotate and translate arrows overlap. */ start_co[2] += 0.215f; } @@ -1653,7 +1665,7 @@ static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmManipulato for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { for (int z = 0; z < 3; z++) { - int constraint[3] = {x != 1, y != 1, z != 1}; + bool constraint[3] = {x != 1, y != 1, z != 1}; ptr = WM_manipulator_operator_set(mpr, i, ot_resize, NULL); if (prop_release_confirm == NULL) { prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm"); diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index d98e3e3261a..cfac908f976 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -226,7 +226,7 @@ static int delete_orientation_invoke(bContext *C, wmOperator *op, const wmEvent return delete_orientation_exec(C, op); } -static int delete_orientation_poll(bContext *C) +static bool delete_orientation_poll(bContext *C) { Scene *scene = CTX_data_scene(C); @@ -307,7 +307,7 @@ static void transformops_loopsel_hack(bContext *C, wmOperator *op) if (op->opm && op->opm->opm && op->opm->opm->prev) { wmOperator *op_prev = op->opm->opm->prev; Scene *scene = CTX_data_scene(C); - int mesh_select_mode[3]; + bool mesh_select_mode[3]; PropertyRNA *prop = RNA_struct_find_property(op_prev->ptr, "mesh_select_mode_init"); if (prop && RNA_property_is_set(op_prev->ptr, prop)) { @@ -652,7 +652,7 @@ static void TRANSFORM_OT_resize(struct wmOperatorType *ot) ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_OPTIONS | P_GPENCIL_EDIT | P_CENTER); } -static int skin_resize_poll(bContext *C) +static bool skin_resize_poll(bContext *C) { struct Object *obedit = CTX_data_edit_object(C); if (obedit && obedit->type == OB_MESH) { @@ -1148,11 +1148,13 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac /* Will fall-through to texture-space transform. */ kmi = WM_keymap_add_item(keymap, "OBJECT_OT_transform_axis_target", TKEY, KM_PRESS, KM_SHIFT, 0); +#ifdef USE_WM_KEYMAP_27X kmi = WM_keymap_add_item(keymap, OP_TRANSLATION, TKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "texture_space", true); kmi = WM_keymap_add_item(keymap, OP_RESIZE, TKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0); RNA_boolean_set(kmi->ptr, "texture_space", true); +#endif WM_keymap_add_item(keymap, OP_SKIN_RESIZE, AKEY, KM_PRESS, KM_CTRL, 0); @@ -1264,4 +1266,3 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac break; } } - diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 704582deaca..48ec664d634 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -50,8 +50,8 @@ #include "BLI_utildefines.h" #include "GPU_immediate.h" +#include "GPU_state.h" -#include "BKE_DerivedMesh.h" #include "BKE_global.h" #include "BKE_object.h" #include "BKE_anim.h" /* for duplis */ @@ -160,7 +160,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) float imat[4][4]; float size; - glDisable(GL_DEPTH_TEST); + GPU_depth_test(false); size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE); @@ -202,7 +202,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) immUnbindProgram(); if (v3d->zbuf) - glEnable(GL_DEPTH_TEST); + GPU_depth_test(true); } } else if (t->spacetype == SPACE_IMAGE) { @@ -219,7 +219,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE); - glEnable(GL_BLEND); + GPU_blend(true); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -244,7 +244,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } } } diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c index 478e004743d..c090414bc22 100644 --- a/source/blender/editors/undo/ed_undo.c +++ b/source/blender/editors/undo/ed_undo.c @@ -242,7 +242,7 @@ static int ed_undo_redo_exec(bContext *C, wmOperator *UNUSED(op)) return ret ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } -static int ed_undo_redo_poll(bContext *C) +static bool ed_undo_redo_poll(bContext *C) { wmOperator *last_op = WM_operator_last_redo(C); return last_op && ED_operator_screenactive(C) && diff --git a/source/blender/editors/util/ed_transverts.c b/source/blender/editors/util/ed_transverts.c index 494ae769cf3..3cd74f1266f 100644 --- a/source/blender/editors/util/ed_transverts.c +++ b/source/blender/editors/util/ed_transverts.c @@ -497,7 +497,7 @@ void ED_transverts_free(TransVertStore *tvs) tvs->transverts_tot = 0; } -int ED_transverts_poll(bContext *C) +bool ED_transverts_poll(bContext *C) { Object *obedit = CTX_data_edit_object(C); if (obedit) { diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 549b9b7de77..65147d53b5d 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -76,6 +76,7 @@ #include "ED_util.h" #include "GPU_immediate.h" +#include "GPU_state.h" #include "UI_interface.h" #include "UI_resources.h" @@ -346,10 +347,10 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); - immUniform1i("num_colors", 0); /* "simple" mode */ + immUniform1i("colors_len", 0); /* "simple" mode */ immUniformThemeColor(TH_VIEW_OVERLAY); immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c index 5e867afd58e..60500f0211a 100644 --- a/source/blender/editors/uvedit/uvedit_buttons.c +++ b/source/blender/editors/uvedit/uvedit_buttons.c @@ -208,7 +208,7 @@ static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event) /* Panels */ -static int image_panel_uv_poll(const bContext *C, PanelType *UNUSED(pt)) +static bool image_panel_uv_poll(const bContext *C, PanelType *UNUSED(pt)) { Object *obedit = CTX_data_edit_object(C); return ED_uvedit_test(obedit); @@ -235,4 +235,3 @@ void ED_uvedit_buttons_register(ARegionType *art) pt->poll = image_panel_uv_poll; BLI_addtail(&art->paneltypes, pt); } - diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 4473922841f..411c4838252 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -48,7 +48,7 @@ #include "BLI_buffer.h" #include "BLI_bitmap.h" -#include "BKE_DerivedMesh.h" +#include "BKE_deform.h" #include "BKE_editmesh.h" #include "BKE_material.h" #include "BKE_layer.h" @@ -64,6 +64,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "ED_image.h" #include "ED_mesh.h" @@ -87,7 +88,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2]) x_fac = zoom[0]; y_fac = zoom[1]; - glLineWidth(1.0f); + GPU_line_width(1.0f); gpuTranslate2fv(cursor); @@ -96,10 +97,10 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2]) immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); - immUniform1i("num_colors", 2); /* "advanced" mode */ + immUniform1i("colors_len", 2); /* "advanced" mode */ immUniformArray4fv("colors", (float *)(float[][4]){{1.0f, 0.0f, 0.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2); immUniform1f("dash_width", 8.0f); @@ -276,7 +277,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME else areadiff = 1.0f - (area / uvarea); - weight_to_rgb(col, areadiff); + BKE_defvert_weight_to_rgb(col, areadiff); immUniformColor3fv(col); /* TODO: use editmesh tessface */ @@ -356,7 +357,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); a = fabsf(uvang[i] - ang[i]) / (float)M_PI; - weight_to_rgb(col, 1.0f - pow2f(1.0f - a)); + BKE_defvert_weight_to_rgb(col, 1.0f - pow2f(1.0f - a)); immAttrib3fv(color, col); immVertex2fv(pos, luv->uv); } @@ -502,7 +503,7 @@ static void draw_uvs_other(ViewLayer *view_layer, Object *obedit, const Image *c for (Base *base = view_layer->object_bases.first; base; base = base->next) { if (((base->flag & BASE_SELECTED) != 0) && - ((base->flag & BASE_VISIBLED) != 0)) + ((base->flag & BASE_VISIBLE) != 0)) { Object *ob = base->object; if ((ob->type == OB_MESH) && (ob != obedit) && ((Mesh *)ob->data)->mloopuv) { @@ -654,8 +655,8 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje /* draw transparent faces */ UI_GetThemeColor4fv(TH_FACE, col1); UI_GetThemeColor4fv(TH_FACE_SELECT, col2); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); Gwn_VertFormat *format = immVertexFormat(); pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -691,7 +692,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } else { if (efa_act && !uvedit_face_visible_test(scene, obedit, ima, efa_act)) { @@ -706,9 +707,9 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje /* 4. draw edges */ if (sima->flag & SI_SMOOTH_UV) { - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_line_smooth(true); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); } pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -719,13 +720,13 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_get_f(viewport_size); immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); - immUniform1i("num_colors", 2); /* "advanced" mode */ + immUniform1i("colors_len", 2); /* "advanced" mode */ immUniformArray4fv("colors", (float *)(float[][4]){{0.56f, 0.56f, 0.56f, 1.0f}, {0.07f, 0.07f, 0.07f, 1.0f}}, 2); immUniform1f("dash_width", 4.0f); - glLineWidth(1.0f); + GPU_line_width(1.0f); break; } @@ -738,13 +739,13 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje else { immUniformColor3f(0.0f, 0.0f, 0.0f); } - glLineWidth(1.0f); + GPU_line_width(1.0f); break; case SI_UVDT_OUTLINE: immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); imm_cpack(0x0); - glLineWidth(3.0f); + GPU_line_width(3.0f); break; } @@ -780,7 +781,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje if (sima->dt_uv == SI_UVDT_OUTLINE) { - glLineWidth(1.0f); + GPU_line_width(1.0f); UI_GetThemeColor4fv(TH_WIRE_EDIT, col2); if (me->drawflag & ME_DRAWEDGES) { @@ -883,8 +884,8 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje GWN_batch_discard(loop_batch); if (sima->flag & SI_SMOOTH_UV) { - glDisable(GL_LINE_SMOOTH); - glDisable(GL_BLEND); + GPU_line_smooth(false); + GPU_blend(false); } /* 5. draw face centers */ @@ -900,7 +901,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); pointsize = UI_GetThemeValuef(TH_FACEDOT_SIZE); - glPointSize(pointsize); + GPU_point_size(pointsize); immBeginAtMost(GWN_PRIM_POINTS, bm->totface); @@ -961,7 +962,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje /* unselected uvs */ immUniformThemeColor(TH_VERTEX); pointsize = UI_GetThemeValuef(TH_VERTEX_SIZE); - glPointSize(pointsize); + GPU_point_size(pointsize); immBeginAtMost(GWN_PRIM_POINTS, bm->totloop); @@ -980,7 +981,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje /* pinned uvs */ /* give odd pointsizes odd pin pointsizes */ - glPointSize(pointsize * 2 + (((int)pointsize % 2) ? (-1) : 0)); + GPU_point_size(pointsize * 2 + (((int)pointsize % 2) ? (-1) : 0)); imm_cpack(0xFF); immBeginAtMost(GWN_PRIM_POINTS, bm->totloop); @@ -1001,7 +1002,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje /* selected uvs */ immUniformThemeColor(TH_VERTEX_SELECT); - glPointSize(pointsize); + GPU_point_size(pointsize); immBeginAtMost(GWN_PRIM_POINTS, bm->totloop); @@ -1073,4 +1074,3 @@ void ED_uvedit_draw_main( ED_image_draw_cursor(ar, sima->cursor); } } - diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index e3d2537c040..8a00b542eed 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -118,7 +118,7 @@ bool ED_uvedit_test(Object *obedit) return ret; } -static int ED_operator_uvedit_can_uv_sculpt(struct bContext *C) +static bool ED_operator_uvedit_can_uv_sculpt(struct bContext *C) { SpaceImage *sima = CTX_wm_space_image(C); ToolSettings *toolsettings = CTX_data_tool_settings(C); @@ -4060,7 +4060,7 @@ static void UV_OT_reveal(wmOperatorType *ot) /** \name Set 2D Cursor Operator * \{ */ -static int uv_set_2d_cursor_poll(bContext *C) +static bool uv_set_2d_cursor_poll(bContext *C) { return ED_operator_uvedit_space_image(C) || ED_space_image_maskedit_poll(C) || @@ -4397,9 +4397,11 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf) keymap = WM_keymap_find(keyconf, "UV Editor", 0, 0); keymap->poll = ED_operator_uvedit_can_uv_sculpt; +#ifdef USE_WM_KEYMAP_27X /* Uv sculpt toggle */ kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", QKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_uv_sculpt"); +#endif /* Mark edge seam */ WM_keymap_add_item(keymap, "UV_OT_mark_seam", EKEY, KM_PRESS, KM_CTRL, 0); @@ -4460,9 +4462,11 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf) /* unwrap */ WM_keymap_add_item(keymap, "UV_OT_unwrap", EKEY, KM_PRESS, 0, 0); +#ifdef USE_WM_KEYMAP_27X WM_keymap_add_item(keymap, "UV_OT_minimize_stretch", VKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "UV_OT_pack_islands", PKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "UV_OT_average_islands_scale", AKEY, KM_PRESS, KM_CTRL, 0); +#endif /* hide */ kmi = WM_keymap_add_item(keymap, "UV_OT_hide", HKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 1d2583cf9d4..79e804725e5 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -4702,4 +4702,3 @@ void param_flush_restore(ParamHandle *handle) p_face_restore_uvs(f); } } - diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.h b/source/blender/editors/uvedit/uvedit_parametrizer.h index 50b4ee66644..2714bc33769 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.h +++ b/source/blender/editors/uvedit/uvedit_parametrizer.h @@ -120,4 +120,3 @@ void param_flush_restore(ParamHandle *handle); #endif #endif /*__UVEDIT_PARAMETRIZER_H__*/ - diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index f39498b08f3..9091f3eff0b 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -65,6 +65,7 @@ #include "ED_space_api.h" #include "GPU_batch.h" +#include "GPU_state.h" #include "RNA_access.h" #include "RNA_define.h" @@ -291,7 +292,7 @@ static void stitch_update_header(StitchState *state, bContext *C) state->limit_dist, WM_bool_as_string(state->use_limit)); - ED_area_headerprint(sa, msg); + ED_workspace_status_text(C, msg); } } @@ -1570,7 +1571,7 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } - glEnable(GL_BLEND); + GPU_blend(true); /* Static Tris */ UI_GetThemeColor4fv(TH_STITCH_PREVIEW_ACTIVE, col); @@ -1623,12 +1624,12 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar UI_GetThemeColor4fv(TH_STITCH_PREVIEW_EDGE, col); stitch_draw_vbo(vbo_line, GWN_PRIM_LINES, col); - glDisable(GL_BLEND); + GPU_blend(false); /* draw stitch vert/lines preview */ if (state->mode == STITCH_VERT) { - glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE) * 2.0f); + GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE) * 2.0f); UI_GetThemeColor4fv(TH_STITCH_PREVIEW_STITCHABLE, col); vbo = GWN_vertbuf_create_with_format(&format); @@ -2089,7 +2090,7 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished) } if (sa) - ED_area_headerprint(sa, NULL); + ED_workspace_status_text(C, NULL); ED_region_draw_cb_exit(CTX_wm_region(C)->type, state->draw_handle); diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 78b412579e6..52409dc2a1f 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -496,7 +496,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B smd.subdivType = smd_real->subdivType; initialDerived = CDDM_from_editbmesh(em, false, false); - derivedMesh = subsurf_make_derived_from_derived(initialDerived, &smd, + derivedMesh = subsurf_make_derived_from_derived(initialDerived, &smd, scene, NULL, SUBSURF_IN_EDIT_MODE); initialDerived->release(initialDerived); @@ -656,9 +656,9 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, bool interac param_flush(ms->handle); if (sa) { - BLI_snprintf(str, sizeof(str), - IFACE_("Minimize Stretch. Blend %.2f (Press + and -, or scroll wheel to set)"), ms->blend); - ED_area_headerprint(sa, str); + BLI_snprintf(str, sizeof(str), IFACE_("Minimize Stretch. Blend %.2f"), ms->blend); + ED_area_status_text(sa, str); + ED_workspace_status_text(C, IFACE_("Press + and -, or scroll wheel to set blending")); } ms->lasttime = PIL_check_seconds_timer(); @@ -673,8 +673,9 @@ static void minimize_stretch_exit(bContext *C, wmOperator *op, bool cancel) MinStretch *ms = op->customdata; ScrArea *sa = CTX_wm_area(C); - if (sa) - ED_area_headerprint(sa, NULL); + ED_area_status_text(sa, NULL); + ED_workspace_status_text(C, NULL); + if (ms->timer) WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), ms->timer); @@ -1578,7 +1579,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) } } -static int uv_from_view_poll(bContext *C) +static bool uv_from_view_poll(bContext *C) { RegionView3D *rv3d = CTX_wm_region_view3d(C); |