diff options
author | YimingWu <xp8110@outlook.com> | 2019-05-06 05:09:12 +0300 |
---|---|---|
committer | YimingWu <xp8110@outlook.com> | 2019-05-06 05:09:12 +0300 |
commit | 2753611c4e2482885021416f1b2af46250fd09dd (patch) | |
tree | 47df66cf547affa1d388c3b154d5f5817af59819 /source/blender/editors | |
parent | fbb5edf974f87894baa2cfd1a36878d5dce5be01 (diff) | |
parent | 90f8f5cb06efc3255257b1fcb0811dfab76cc146 (diff) |
Merge branch 'master' into soc-2018-npr
Diffstat (limited to 'source/blender/editors')
239 files changed, 3251 insertions, 3036 deletions
diff --git a/source/blender/editors/animation/CMakeLists.txt b/source/blender/editors/animation/CMakeLists.txt index b67298a6df6..978bd772b6f 100644 --- a/source/blender/editors/animation/CMakeLists.txt +++ b/source/blender/editors/animation/CMakeLists.txt @@ -26,8 +26,8 @@ set(INC ../../makesrna ../../windowmanager ../../../../intern/clog - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index bab76911449..6d1ee08d5e9 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -222,7 +222,8 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa rgb_uchar_to_float(r_color, cp); } else { - // FIXME: what happens when the indention is 1 greater than what it should be (due to grouping)? + /* FIXME: what happens when the indention is 1 greater than what it should be + * (due to grouping)? */ int colOfs = 10 - 10 * indent; UI_GetThemeColorShade3fv(TH_SHADE2, colOfs, r_color); } @@ -360,7 +361,7 @@ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale) offset += (short)(0.7f * U.widget_unit); /* If not in Action Editor mode, action-groups (and their children) - * must carry some offset too. */ + * must carry some offset too. */ } else if (ac->datatype != ANIMCONT_ACTION) { offset += (short)(0.7f * U.widget_unit); @@ -4525,7 +4526,7 @@ static void draw_setting_widget(bAnimContext *ac, /* get the base icon for the setting */ switch (setting) { case ACHANNEL_SETTING_VISIBLE: /* visibility eyes */ - //icon = ((enabled) ? ICON_VISIBLE_IPO_ON : ICON_VISIBLE_IPO_OFF); + // icon = ((enabled) ? ICON_VISIBLE_IPO_ON : ICON_VISIBLE_IPO_OFF); icon = ICON_VISIBLE_IPO_OFF; if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { @@ -4550,13 +4551,13 @@ static void draw_setting_widget(bAnimContext *ac, break; case ACHANNEL_SETTING_EXPAND: /* expanded triangle */ - //icon = ((enabled) ? ICON_TRIA_DOWN : ICON_TRIA_RIGHT); + // icon = ((enabled) ? ICON_TRIA_DOWN : ICON_TRIA_RIGHT); icon = ICON_TRIA_RIGHT; tooltip = TIP_("Make channels grouped under this channel visible"); break; case ACHANNEL_SETTING_SOLO: /* NLA Tracks only */ - //icon = ((enabled) ? ICON_SOLO_OFF : ICON_SOLO_ON); + // icon = ((enabled) ? ICON_SOLO_OFF : ICON_SOLO_ON); icon = ICON_SOLO_OFF; tooltip = TIP_( "NLA Track is the only one evaluated in this animation data-block, with all others " @@ -4567,7 +4568,7 @@ static void draw_setting_widget(bAnimContext *ac, case ACHANNEL_SETTING_PROTECT: /* protected lock */ // TODO: what about when there's no protect needed? - //icon = ((enabled) ? ICON_LOCKED : ICON_UNLOCKED); + // icon = ((enabled) ? ICON_LOCKED : ICON_UNLOCKED); icon = ICON_UNLOCKED; if (ale->datatype != ALE_NLASTRIP) { @@ -4598,7 +4599,7 @@ static void draw_setting_widget(bAnimContext *ac, break; case ACHANNEL_SETTING_PINNED: /* pin icon */ - //icon = ((enabled) ? ICON_PINNED : ICON_UNPINNED); + // icon = ((enabled) ? ICON_PINNED : ICON_UNPINNED); icon = ICON_UNPINNED; if (ale->type == ANIMTYPE_NLAACTION) { diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index d0eb2d187fd..adc6ec3f6be 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -474,7 +474,8 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, for (ale = anim_data->first; ale; ale = ale->next) { /* compare data, and type as main way of identifying the channel */ if ((ale->data == ale_setting->data) && (ale->type == ale_setting->type)) { - /* we also have to check the ID, this is assigned to, since a block may have multiple users */ + /* We also have to check the ID, this is assigned to, + * since a block may have multiple users. */ /* TODO: is the owner-data more revealing? */ if (ale->id == ale_setting->id) { match = ale; @@ -549,8 +550,8 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, if (prevLevel == 0) { break; /* otherwise, this level weaves into another sibling hierarchy to the previous one just - * finished, so skip until we get to the parent of this level - */ + * finished, so skip until we get to the parent of this level + */ } else { continue; @@ -582,9 +583,10 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, if (level > matchLevel) { ANIM_channel_setting_set(ac, ale, setting, mode); /* however, if the level is 'less than or equal to' the channel that was changed, - * (i.e. the current channel is as important if not more important than the changed channel) - * then we should stop, since we've found the last one of the children we should flush - */ + * (i.e. the current channel is as important if not more important than the changed + * channel) then we should stop, since we've found the last one of the children we should + * flush + */ } else { break; @@ -647,14 +649,28 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f * channel list that are empty, and linger around long after the data they * are for has disappeared (and probably won't come back). */ + ANIM_remove_empty_action_from_animdata(adt); + } + + /* free the F-Curve itself */ + free_fcurve(fcu); +} + +/* If the action has no F-Curves, unlink it from AnimData if it did not + * come from a NLA Strip being tweaked. */ +bool ANIM_remove_empty_action_from_animdata(struct AnimData *adt) +{ + if (adt->action != NULL) { + bAction *act = adt->action; + if (BLI_listbase_is_empty(&act->curves) && (adt->flag & ADT_NLA_EDIT_ON) == 0) { id_us_min(&act->id); adt->action = NULL; + return true; } } - /* free the F-Curve itself */ - free_fcurve(fcu); + return false; } /* ************************************************************************** */ @@ -1233,9 +1249,10 @@ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrange /* Filter visible data. */ rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_GROUP); - /* rearrange groups first - * - the group's channels will only get considered if nothing happened when rearranging the groups - * i.e. the rearrange function returned 0 + /* Rearrange groups first: + * - The group's channels will only get considered + * if nothing happened when rearranging the groups + * i.e. the rearrange function returned 0. */ do_channels = (rearrange_animchannel_islands( &act->groups, rearrange_func, mode, ANIMTYPE_GROUP, &anim_data_visible) == 0); @@ -2514,17 +2531,6 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm SpaceNla *snla = (SpaceNla *)ac->sl; View2D *v2d = &ac->ar->v2d; rctf rectf; - float ymin, ymax; - - /* set initial y extents */ - if (ac->datatype == ANIMCONT_NLA) { - ymin = (float)(-NLACHANNEL_HEIGHT(snla)); - ymax = 0.0f; - } - else { - ymin = 0.0f; - ymax = (float)(-ACHANNEL_HEIGHT(ac)); - } /* convert border-region to view coordinates */ UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin + 2, &rectf.xmin, &rectf.ymin); @@ -2534,8 +2540,17 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + float ymax; + if (ac->datatype == ANIMCONT_NLA) { + ymax = NLACHANNEL_FIRST_TOP(snla); + } + else { + ymax = ACHANNEL_FIRST_TOP(ac); + } + /* loop over data, doing box select */ for (ale = anim_data.first; ale; ale = ale->next) { + float ymin; if (ac->datatype == ANIMCONT_NLA) { ymin = ymax - NLACHANNEL_STEP(snla); } @@ -2712,32 +2727,25 @@ static int animchannels_channel_get(bAnimContext *ac, const int mval[2]) ar = ac->ar; v2d = &ar->v2d; - /* Figure out which channel user clicked in. - * - * Note: although channels technically start at (y = ACHANNEL_FIRST), - * we need to adjust by half a channel's height so that the tops of channels get caught ok. - * Since ACHANNEL_FIRST is really ACHANNEL_HEIGHT, we simply use ACHANNEL_HEIGHT_HALF. - */ + /* Figure out which channel user clicked in. */ UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); if (ac->datatype == ANIMCONT_NLA) { SpaceNla *snla = (SpaceNla *)ac->sl; - UI_view2d_listview_view_to_cell(v2d, - NLACHANNEL_NAMEWIDTH, + UI_view2d_listview_view_to_cell(NLACHANNEL_NAMEWIDTH, NLACHANNEL_STEP(snla), 0, - (float)NLACHANNEL_HEIGHT_HALF(snla), + NLACHANNEL_FIRST_TOP(snla), x, y, NULL, &channel_index); } else { - UI_view2d_listview_view_to_cell(v2d, - ACHANNEL_NAMEWIDTH, + UI_view2d_listview_view_to_cell(ACHANNEL_NAMEWIDTH, ACHANNEL_STEP(ac), 0, - (float)ACHANNEL_HEIGHT_HALF(ac), + ACHANNEL_FIRST_TOP(ac), x, y, NULL, @@ -2858,7 +2866,6 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, if (selectmode == SELECT_INVERT) { /* swap select */ ED_object_base_select(base, BA_INVERT); - BKE_scene_object_base_flag_sync_from_base(base); if (adt) { adt->flag ^= ADT_UI_SELECTED; @@ -2871,7 +2878,6 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, /* TODO: should this deselect all other types of channels too? */ for (b = view_layer->object_bases.first; b; b = b->next) { ED_object_base_select(b, BA_DESELECT); - BKE_scene_object_base_flag_sync_from_base(b); if (b->object->adt) { b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE); } @@ -2879,7 +2885,6 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, /* select object now */ ED_object_base_select(base, BA_SELECT); - BKE_scene_object_base_flag_sync_from_base(base); if (adt) { adt->flag |= ADT_UI_SELECTED; } @@ -3192,19 +3197,12 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmE selectmode = SELECT_REPLACE; } - /* figure out which channel user clicked in - * - * Note: - * although channels technically start at (y = ACHANNEL_FIRST), - * we need to adjust by half a channel's height so that the tops of channels get caught ok. - * Since ACHANNEL_FIRST is really ACHANNEL_HEIGHT, we simply use ACHANNEL_HEIGHT_HALF. - */ + /* figure out which channel user clicked in */ UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y); - UI_view2d_listview_view_to_cell(v2d, - ACHANNEL_NAMEWIDTH, + UI_view2d_listview_view_to_cell(ACHANNEL_NAMEWIDTH, ACHANNEL_STEP(&ac), 0, - (float)ACHANNEL_HEIGHT_HALF(&ac), + ACHANNEL_FIRST_TOP(&ac), x, y, NULL, diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index d7fe326f2ee..5c9f0707aa9 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -377,7 +377,7 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data) if (ale->update & ANIM_UPDATE_ORDER) { ale->update &= ~ANIM_UPDATE_ORDER; if (gpl) { - //gpencil_sort_frames(gpl); + // gpencil_sort_frames(gpl); } } diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index d5116858970..61bf7f95340 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -169,7 +169,7 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width) immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_ANIM_PREVIEW_RANGE, -25, -30); /* XXX: Fix this hardcoded color (anim_active) */ - //immUniformColor4f(0.8f, 0.44f, 0.1f, 0.2f); + // immUniformColor4f(0.8f, 0.44f, 0.1f, 0.2f); /* only draw two separate 'curtains' if there's no overlap between them */ if (PSFRA < PEFRA + end_frame_width) { diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 674f530894d..b94d0e3ada7 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -117,7 +117,7 @@ static void animedit_get_yscale_factor(bAnimContext *ac) if (ac->yscale_fac < 0.1f) { ac->yscale_fac = 1.0f; } - //printf("yscale_fac = %f\n", ac->yscale_fac); + // printf("yscale_fac = %f\n", ac->yscale_fac); } /* ----------- Private Stuff - Action Editor ------------- */ @@ -136,7 +136,7 @@ static Key *actedit_get_shapekeys(bAnimContext *ac) } /* XXX pinning is not available in 'ShapeKey' mode... */ - //if (saction->pin) return NULL; + // if (saction->pin) return NULL; /* shapekey data is stored with geometry data */ key = BKE_key_from_object(ob); @@ -218,7 +218,7 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction) { /* TODO, other methods to get the mask */ // Sequence *seq = BKE_sequencer_active_get(ac->scene); - //MovieClip *clip = ac->scene->clip; + // MovieClip *clip = ac->scene->clip; // struct Mask *mask = seq ? seq->mask : NULL; /* update scene-pointer (no need to check for pinning yet, as not implemented) */ @@ -425,7 +425,8 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) animedit_get_yscale_factor(ac); /* get data context info */ - // XXX: if the below fails, try to grab this info from context instead... (to allow for scripting) + /* XXX: if the below fails, try to grab this info from context instead... + * (to allow for scripting). */ return ANIM_animdata_context_getdata(ac); } @@ -486,7 +487,8 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) * Quick macro to test for all three above usability tests, performing the appropriate provided * action for each when the AnimData context is appropriate. * - * Priority order for this goes (most important, to least): AnimData blocks, NLA, Drivers, Keyframes. + * Priority order for this goes (most important, to least): + * AnimData blocks, NLA, Drivers, Keyframes. * * For this to work correctly, * a standard set of data needs to be available within the scope that this @@ -582,7 +584,8 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) #define ANIMCHANNEL_ACTIVEOK(ale) \ (!(filter_mode & ANIMFILTER_ACTIVE) || !(ale->adt) || (ale->adt->flag & ADT_UI_ACTIVE)) -/* quick macro to test if an anim-channel (F-Curve, Group, etc.) is selected in an acceptable way */ +/* Quick macro to test if an anim-channel (F-Curve, Group, etc.) + * is selected in an acceptable way. */ #define ANIMCHANNEL_SELOK(test_func) \ (!(filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL)) || \ ((filter_mode & ANIMFILTER_SEL) && test_func) || \ @@ -1210,12 +1213,13 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads, */ for (fcu = first; ((fcu) && (fcu->grp == grp)); fcu = fcu->next) { /* special exception for Pose-Channel/Sequence-Strip/Node Based F-Curves: - * - the 'Only Selected' and 'Include Hidden' data filters should be applied to sub-ID data which - * can be independently selected/hidden, such as Pose-Channels, Sequence Strips, and Nodes. - * Since these checks were traditionally done as first check for objects, we do the same here - * - we currently use an 'approximate' method for getting these F-Curves that doesn't require - * carefully checking the entire path - * - this will also affect things like Drivers, and also works for Bone Constraints + * - The 'Only Selected' and 'Include Hidden' data filters should be applied to sub-ID data + * which can be independently selected/hidden, such as Pose-Channels, Sequence Strips, + * and Nodes. Since these checks were traditionally done as first check for objects, + * we do the same here. + * - We currently use an 'approximate' method for getting these F-Curves that doesn't require + * carefully checking the entire path. + * - This will also affect things like Drivers, and also works for Bone Constraints. */ if (ads && owner_id) { if ((filter_mode & ANIMFILTER_TMP_IGNORE_ONLYSEL) == 0) { @@ -1320,7 +1324,7 @@ static size_t animfilter_act_group(bAnimContext *ac, ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; size_t items = 0; - //int ofilter = filter_mode; + // int ofilter = filter_mode; /* if we care about the selection status of the channels, * but the group isn't expanded (1)... @@ -1380,7 +1384,7 @@ static size_t animfilter_act_group(bAnimContext *ac, /* add this group as a channel first */ if (filter_mode & ANIMFILTER_LIST_CHANNELS) { /* restore original filter mode so that this next step works ok... */ - //filter_mode = ofilter; + // filter_mode = ofilter; /* filter selection of channel specially here again, * since may be open and not subject to previous test */ @@ -1498,7 +1502,8 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac), next = nlt->next; } - /* if we're in NLA-tweakmode, don't show this track if it was disabled (due to tweaking) for now + /* if we're in NLA-tweakmode, don't show this track if it was disabled + * (due to tweaking) for now: * - active track should still get shown though (even though it has disabled flag set) */ // FIXME: the channels after should still get drawn, just 'differently', @@ -1811,7 +1816,8 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, */ 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 */ + /* Layer visibility - we check both object and base, + * since these may not be in sync yet. */ if ((base->flag & BASE_VISIBLE) == 0) { continue; } @@ -2223,7 +2229,8 @@ static size_t animdata_filter_ds_textures( } } - /* firstly check that we actuallly have some textures, by gathering all textures in a temp list */ + /* Firstly check that we actuallly have some textures, + * by gathering all textures in a temp list. */ for (a = 0; a < MAX_MTEX; a++) { Tex *tex = (mtex[a]) ? mtex[a]->tex : NULL; @@ -2393,7 +2400,8 @@ static size_t animdata_filter_ds_modifiers( /* 1) create a temporary "context" containing all the info we have here to pass to the callback * use to walk through the dependencies of the modifiers * - * ! Assumes that all other unspecified values (i.e. accumulation buffers) are zero'd out properly + * Assumes that all other unspecified values (i.e. accumulation buffers) + * are zero'd out properly! */ afm.ac = ac; afm.ads = ads; @@ -2915,7 +2923,8 @@ static size_t animdata_filter_dopesheet_scene( tmp_items += animdata_filter_ds_gpencil(ac, &tmp_data, ads, gpd, filter_mode); } - /* TODO: one day, when sequencer becomes its own datatype, perhaps it should be included here */ + /* TODO: one day, when sequencer becomes its own datatype, + * perhaps it should be included here. */ } END_ANIMFILTER_SUBCHANNELS; @@ -3148,7 +3157,8 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac, /* If filtering for channel drawing, we want the objects in alphabetical order, * to make it easier to predict where items are in the hierarchy - * - This order only really matters if we need to show all channels in the list (e.g. for drawing) + * - This order only really matters + * if we need to show all channels in the list (e.g. for drawing). * (XXX: What about lingering "active" flags? The order may now become unpredictable) * - Don't do this if this behavior has been turned off (i.e. due to it being too slow) * - Don't do this if there's just a single object @@ -3320,7 +3330,8 @@ static size_t animdata_filter_remove_duplis(ListBase *anim_data) /* check if hash has any record of an entry like this * - just use ale->data for now, though it would be nicer to involve - * ale->type in combination too to capture corner cases (where same data performs differently) + * ale->type in combination too to capture corner cases + * (where same data performs differently) */ if (BLI_gset_add(gs, ale->data)) { /* this entry is 'unique' and can be kept */ @@ -3439,7 +3450,8 @@ size_t ANIM_animdata_filter(bAnimContext *ac, break; } - /* Timeline Mode - Basically the same as dopesheet, except we only have the summary for now */ + /* Timeline Mode - Basically the same as dopesheet, + * except we only have the summary for now */ case ANIMCONT_TIMELINE: { /* the DopeSheet editor is the primary place where the DopeSheet summaries are useful */ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) { diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index e90599b05c8..66cdae07a36 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -203,7 +203,7 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la float min, max; /* sanity check */ - //printf("markers = %p - %p, %p\n", markers, markers->first, markers->last); + // printf("markers = %p - %p, %p\n", markers, markers->first, markers->last); if (ELEM(NULL, markers, markers->first, markers->last)) { *first = 0.0f; *last = 0.0f; @@ -361,45 +361,38 @@ void debug_markers_print_list(ListBase *markers) /* ************* Marker Drawing ************ */ -static void draw_marker_name(const uiFontStyle *fstyle, - TimeMarker *marker, - const char *name, - int cfra, - const float xpos, - const float ypixels) +static void marker_color_get(TimeMarker *marker, unsigned char *color) { - unsigned char text_col[4]; - float x, y; - - /* minimal y coordinate which wouldn't be occluded by scroll */ - int min_y = 17.0f * UI_DPI_FAC; - if (marker->flag & SELECT) { - UI_GetThemeColor4ubv(TH_TEXT_HI, text_col); - x = xpos + 4.0f * UI_DPI_FAC; - y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC; - y = max_ii(y, min_y); + UI_GetThemeColor4ubv(TH_TEXT_HI, color); } else { - UI_GetThemeColor4ubv(TH_TEXT, text_col); - if ((marker->frame <= cfra) && (marker->frame + 5 > cfra)) { - x = xpos + 8.0f * UI_DPI_FAC; - y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC; - y = max_ii(y, min_y); - } - else { - x = xpos + 8.0f * UI_DPI_FAC; - y = 17.0f * UI_DPI_FAC; - } + UI_GetThemeColor4ubv(TH_TEXT, color); } +} + +static void draw_marker_name(const uiFontStyle *fstyle, + TimeMarker *marker, + float marker_x, + float text_y) +{ + unsigned char text_color[4]; + marker_color_get(marker, text_color); + + const char *name = marker->name; #ifdef DURIAN_CAMERA_SWITCH - if (marker->camera && (marker->camera->restrictflag & OB_RESTRICT_RENDER)) { - text_col[3] = 100; + if (marker->camera) { + Object *camera = marker->camera; + name = camera->id.name + 2; + if (camera->restrictflag & OB_RESTRICT_RENDER) { + text_color[3] = 100; + } } #endif - UI_fontstyle_draw_simple(fstyle, x, y, name, text_col); + int name_x = marker_x + UI_DPI_ICON_SIZE * 0.6; + UI_fontstyle_draw_simple(fstyle, name_x, text_y, name, text_color); } static void draw_marker_line(const float color[4], float x, float ymin, float ymax) @@ -426,29 +419,24 @@ static void draw_marker_line(const float color[4], float x, float ymin, float ym immUnbindProgram(); } -/* function to draw markers */ -static void draw_marker(const uiFontStyle *fstyle, - TimeMarker *marker, - int cfra, - int flag, - /* avoid re-calculating each time */ - const float ypixels, - const float xscale, - int height) +static int marker_get_icon_id(TimeMarker *marker, int flag) { - const float xpos = marker->frame * xscale; + if (flag & DRAW_MARKERS_LOCAL) { + return (marker->flag & ACTIVE) ? ICON_PMARKER_ACT : + (marker->flag & SELECT) ? ICON_PMARKER_SEL : ICON_PMARKER; + } #ifdef DURIAN_CAMERA_SWITCH - const float yoffs = (marker->camera) ? 0.2f * UI_DPI_ICON_SIZE : 0.0f; -#else - const float yoffs = 0.0f; + else if (marker->camera) { + return (marker->flag & SELECT) ? ICON_OUTLINER_OB_CAMERA : ICON_CAMERA_DATA; + } #endif - int icon_id; - - GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + else { + return (marker->flag & SELECT) ? ICON_MARKER_HLT : ICON_MARKER; + } +} - /* vertical line - dotted */ +static void draw_marker_line_if_necessary(TimeMarker *marker, int flag, int xpos, int height) +{ #ifdef DURIAN_CAMERA_SWITCH if ((marker->camera) || (flag & DRAW_MARKERS_LINES)) #else @@ -463,103 +451,114 @@ static void draw_marker(const uiFontStyle *fstyle, copy_v4_fl4(color, 0.0f, 0.0f, 0.0f, 0.38f); } - draw_marker_line(color, xpos, yoffs + 1.5f * UI_DPI_ICON_SIZE, height); + draw_marker_line(color, xpos, UI_DPI_FAC * 20, height); } +} - /* 5 px to offset icon to align properly, space / pixels corrects for zoom */ - if (flag & DRAW_MARKERS_LOCAL) { - icon_id = (marker->flag & ACTIVE) ? ICON_PMARKER_ACT : - (marker->flag & SELECT) ? ICON_PMARKER_SEL : ICON_PMARKER; - } -#ifdef DURIAN_CAMERA_SWITCH - else if (marker->camera) { - icon_id = (marker->flag & SELECT) ? ICON_OUTLINER_OB_CAMERA : ICON_CAMERA_DATA; - } -#endif - else { - icon_id = (marker->flag & SELECT) ? ICON_MARKER_HLT : ICON_MARKER; - } +static void draw_marker( + const uiFontStyle *fstyle, TimeMarker *marker, int xpos, int flag, int region_height) +{ + GPU_blend(true); + GPU_blend_set_func_separate( + GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + + draw_marker_line_if_necessary(marker, flag, xpos, region_height); - UI_icon_draw(xpos - 0.55f * UI_DPI_ICON_SIZE, yoffs + UI_DPI_ICON_SIZE, icon_id); + int icon_id = marker_get_icon_id(marker, flag); + UI_icon_draw(xpos - 0.55f * UI_DPI_ICON_SIZE, UI_DPI_FAC * 18, icon_id); GPU_blend(false); - /* and the marker name too, shifted slightly to the top-right */ -#ifdef DURIAN_CAMERA_SWITCH - if (marker->camera) { - draw_marker_name(fstyle, marker, marker->camera->id.name + 2, cfra, xpos, ypixels); + float name_y = UI_DPI_FAC * 18; + if (marker->flag & SELECT) { + name_y += UI_DPI_FAC * 10; } - else if (marker->name[0]) { - draw_marker_name(fstyle, marker, marker->name, cfra, xpos, ypixels); + draw_marker_name(fstyle, marker, xpos, name_y); +} + +static void draw_markers_background(rctf *rect) +{ + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + + const unsigned char shade[4] = {0, 0, 0, 16}; + immUniformColor4ubv(shade); + + 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, rect->xmin, rect->ymin, rect->xmax, rect->ymax); + + GPU_blend(false); + + immUnbindProgram(); +} + +static bool marker_is_in_frame_range(TimeMarker *marker, int frame_range[2]) +{ + if (marker->frame < frame_range[0]) { + return false; } -#else - if (marker->name[0]) { - draw_marker_name(fstyle, marker, marker->name, cfra, xpos, ypixels); + if (marker->frame > frame_range[1]) { + return false; } -#endif + return true; +} + +static void get_marker_region_rect(View2D *v2d, rctf *rect) +{ + rect->xmin = v2d->cur.xmin; + rect->xmax = v2d->cur.xmax; + rect->ymin = 0; + rect->ymax = UI_MARKER_MARGIN_Y; +} + +static void get_marker_clip_frame_range(View2D *v2d, float xscale, int r_range[2]) +{ + float font_width_max = (10 * UI_DPI_FAC) / xscale; + r_range[0] = v2d->cur.xmin - sizeof(((TimeMarker *)NULL)->name) * font_width_max; + r_range[1] = v2d->cur.xmax + font_width_max; } /* Draw Scene-Markers in time window */ void ED_markers_draw(const bContext *C, int flag) { - const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; ListBase *markers = ED_context_get_markers(C); - View2D *v2d; - TimeMarker *marker; - Scene *scene; - int select_pass; - int v2d_clip_range_x[2]; - float font_width_max; - - /* cache values */ - float ypixels, xscale, yscale; - if (markers == NULL || BLI_listbase_is_empty(markers)) { return; } - scene = CTX_data_scene(C); - v2d = UI_view2d_fromcontext(C); - int height = v2d->mask.ymax - v2d->mask.ymin; - - if (flag & DRAW_MARKERS_MARGIN) { - uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - - const unsigned char shade[4] = {0, 0, 0, 16}; - immUniformColor4ubv(shade); - - GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + ARegion *ar = CTX_wm_region(C); + View2D *v2d = UI_view2d_fromcontext(C); - immRectf(pos, v2d->cur.xmin, 0, v2d->cur.xmax, UI_MARKER_MARGIN_Y); + rctf markers_region_rect; + get_marker_region_rect(v2d, &markers_region_rect); - GPU_blend(false); - - immUnbindProgram(); - } + draw_markers_background(&markers_region_rect); /* no time correction for framelen! space is drawn with old values */ - ypixels = BLI_rcti_size_y(&v2d->mask); - UI_view2d_scale_get(v2d, &xscale, &yscale); + float xscale, dummy; + UI_view2d_scale_get(v2d, &xscale, &dummy); GPU_matrix_push(); GPU_matrix_scale_2f(1.0f / xscale, 1.0f); - /* x-bounds with offset for text (adjust for long string, avoid checking string width) */ - font_width_max = (10 * UI_DPI_FAC) / xscale; - v2d_clip_range_x[0] = v2d->cur.xmin - (sizeof(marker->name) * font_width_max); - v2d_clip_range_x[1] = v2d->cur.xmax + font_width_max; + int clip_frame_range[2]; + get_marker_clip_frame_range(v2d, xscale, clip_frame_range); - /* loop [unselected, selected] */ - for (select_pass = 0; select_pass <= SELECT; select_pass += SELECT) { - /* unselected markers are drawn at the first time */ - for (marker = markers->first; marker; marker = marker->next) { - if ((marker->flag & SELECT) == select_pass) { - /* bounds check */ - if ((marker->frame >= v2d_clip_range_x[0]) && (marker->frame <= v2d_clip_range_x[1])) { - draw_marker(fstyle, marker, scene->r.cfra, flag, ypixels, xscale, height); - } + const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; + + for (TimeMarker *marker = markers->first; marker; marker = marker->next) { + if ((marker->flag & SELECT) == 0) { + if (marker_is_in_frame_range(marker, clip_frame_range)) { + draw_marker(fstyle, marker, marker->frame * xscale, flag, ar->winy); + } + } + } + for (TimeMarker *marker = markers->first; marker; marker = marker->next) { + if (marker->flag & SELECT) { + if (marker_is_in_frame_range(marker, clip_frame_range)) { + draw_marker(fstyle, marker, marker->frame * xscale, flag, ar->winy); } } } diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 45bb8f3b11e..97ba7132c3d 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -52,6 +52,9 @@ #include "ED_sequencer.h" #include "ED_util.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" + #include "anim_intern.h" /* ********************** frame change operator ***************************/ @@ -88,7 +91,6 @@ static bool change_frame_poll(bContext *C) /* Set the new frame number */ static void change_frame_apply(bContext *C, wmOperator *op) { - Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); float frame = RNA_float_get(op->ptr, "frame"); bool do_snap = RNA_boolean_get(op->ptr, "snap"); @@ -114,7 +116,7 @@ static void change_frame_apply(bContext *C, wmOperator *op) FRAMENUMBER_MIN_CLAMP(CFRA); /* do updates */ - BKE_sound_seek_scene(bmain, scene); + BKE_sound_update_and_seek(CTX_data_main(C), CTX_data_depsgraph(C)); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 34d7fac041f..2a8702802aa 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -1140,7 +1140,7 @@ void ANIM_OT_driver_button_remove(wmOperatorType *ot) /* callbacks */ ot->exec = remove_driver_button_exec; - //op->poll = ??? // TODO: need to have some driver to be able to do this... + // op->poll = ??? // TODO: need to have some driver to be able to do this... /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; @@ -1177,7 +1177,7 @@ void ANIM_OT_driver_button_edit(wmOperatorType *ot) /* callbacks */ ot->exec = edit_driver_button_exec; - //op->poll = ??? // TODO: need to have some driver to be able to do this... + // op->poll = ??? // TODO: need to have some driver to be able to do this... /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; @@ -1221,7 +1221,7 @@ void ANIM_OT_copy_driver_button(wmOperatorType *ot) /* callbacks */ ot->exec = copy_driver_button_exec; - //op->poll = ??? // TODO: need to have some driver to be able to do this... + // op->poll = ??? // TODO: need to have some driver to be able to do this... /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; @@ -1270,7 +1270,7 @@ void ANIM_OT_paste_driver_button(wmOperatorType *ot) /* callbacks */ ot->exec = paste_driver_button_exec; - //op->poll = ??? // TODO: need to have some driver to be able to do this... + // op->poll = ??? // TODO: need to have some driver to be able to do this... /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 22350f997f3..678afef5773 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -715,7 +715,7 @@ static void draw_keylist(View2D *v2d, float sel_mhcol[4], unsel_mhcol[4]; float ipo_color[4], ipo_color_mix[4]; - /* cache colours first */ + /* cache colors first */ UI_GetThemeColor4fv(TH_STRIP_SELECT, sel_color); UI_GetThemeColor4fv(TH_STRIP, unsel_color); UI_GetThemeColor4fv(TH_DOPESHEET_IPOLINE, ipo_color); diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 815d4c5f3af..884a8c20b19 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -240,7 +240,8 @@ static short ob_keyframes_loop(KeyframeEditData *ked, filter = ANIMFILTER_DATA_VISIBLE; // curves only ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - /* loop through each F-Curve, applying the operation as required, but stopping on the first one */ + /* Loop through each F-Curve, applying the operation as required, + * but stopping on the first one. */ for (ale = anim_data.first; ale; ale = ale->next) { if (ANIM_fcurve_keyframes_loop(ked, (FCurve *)ale->data, key_ok, key_cb, fcu_cb)) { ret = 1; @@ -288,7 +289,8 @@ static short scene_keyframes_loop(KeyframeEditData *ked, filter = ANIMFILTER_DATA_VISIBLE; // curves only ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - /* loop through each F-Curve, applying the operation as required, but stopping on the first one */ + /* Loop through each F-Curve, applying the operation as required, + * but stopping on the first one. */ for (ale = anim_data.first; ale; ale = ale->next) { if (ANIM_fcurve_keyframes_loop(ked, (FCurve *)ale->data, key_ok, key_cb, fcu_cb)) { ret = 1; diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 4851665c9f3..a0433b49b16 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1071,7 +1071,10 @@ static float *visualkey_get_values(Depsgraph *depsgraph, /* ------------------------- Insert Key API ------------------------- */ -/* Retrieve current property values to keyframe, possibly applying NLA correction when necessary. */ +/** + * Retrieve current property values to keyframe, + * possibly applying NLA correction when necessary. + */ static float *get_keyframe_values(Depsgraph *depsgraph, ReportList *reports, PointerRNA ptr, @@ -2206,6 +2209,11 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op)) changed = true; } } + + /* Delete the action itself if it is empty. */ + if (ANIM_remove_empty_action_from_animdata(adt)) { + changed = true; + } } } CTX_DATA_END; @@ -2787,8 +2795,10 @@ bool fcurve_is_changed(PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float fra return !compare_ff_relative(fcurve_val, cur_val, FLT_EPSILON, 64); } -/* Checks whether an Action has a keyframe for a given frame - * Since we're only concerned whether a keyframe exists, we can simply loop until a match is found... +/** + * Checks whether an Action has a keyframe for a given frame + * Since we're only concerned whether a keyframe exists, + * we can simply loop until a match is found. */ static bool action_frame_has_keyframe(bAction *act, float frame, short filter) { diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 7362a7e04a1..ab5e3186c47 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -377,7 +377,7 @@ void ANIM_OT_keyingset_button_add(wmOperatorType *ot) /* callbacks */ ot->exec = add_keyingset_button_exec; - //op->poll = ??? + // op->poll = ??? /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -459,7 +459,7 @@ void ANIM_OT_keyingset_button_remove(wmOperatorType *ot) /* callbacks */ ot->exec = remove_keyingset_button_exec; - //op->poll = ??? + // op->poll = ??? /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1021,8 +1021,10 @@ static short keyingset_apply_keying_flags(const short base_flags, return result; } -/* Given a KeyingSet and context info (if required), modify keyframes for the channels specified - * by the KeyingSet. This takes into account many of the different combinations of using KeyingSets. +/** + * Given a KeyingSet and context info (if required), + * modify keyframes for the channels specified by the KeyingSet. + * This takes into account many of the different combinations of using KeyingSets. * Returns the number of channels that keyframes were added to */ int ANIM_apply_keyingset( diff --git a/source/blender/editors/armature/CMakeLists.txt b/source/blender/editors/armature/CMakeLists.txt index 274fa86184d..71c7febe192 100644 --- a/source/blender/editors/armature/CMakeLists.txt +++ b/source/blender/editors/armature/CMakeLists.txt @@ -26,9 +26,9 @@ set(INC ../../makesrna ../../windowmanager ../../../../intern/clog - ../../../../intern/guardedalloc ../../../../intern/eigen ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 4aed4217b6d..6c2d9fe8f42 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -217,8 +217,9 @@ void POSE_OT_propagate(struct wmOperatorType *ot); /* ******************************************************* */ /* Various Armature Edit/Pose Editing API's */ -/* Ideally, many of these defines would not be needed as everything would be strictly self-contained - * within each file, but some tools still have a bit of overlap which makes things messy -- Feb 2013 +/* Ideally, many of these defines would not be needed as everything would be strictly + * self-contained within each file, + * but some tools still have a bit of overlap which makes things messy -- Feb 2013 */ EditBone *make_boneList(struct ListBase *edbo, struct ListBase *bones, struct Bone *actBone); diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index 6d25fac79f6..083967d5d41 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -328,9 +328,10 @@ void ED_armature_bone_rename(Main *bmain, /* Fix all animdata that may refer to this bone - * we can't just do the ones attached to objects, - * since other ID-blocks may have drivers referring to this bone T29822. - */ - // XXX: the ID here is for armatures, but most bone drivers are actually on the object instead... + * since other ID-blocks may have drivers referring to this bone T29822. */ + + /* XXX: the ID here is for armatures, + * but most bone drivers are actually on the object instead. */ { BKE_animdata_fix_paths_rename_all(&arm->id, "pose.bones", oldname, newname); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 3401c6ed157..b53ae813f10 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -161,7 +161,7 @@ void ED_operatormacros_armature(void) OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_move", "Extrude", @@ -170,7 +170,7 @@ void ED_operatormacros_armature(void) otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); RNA_boolean_set(otmacro->ptr, "forked", false); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); /* XXX would it be nicer to just be able to have standard extrude_move, * but set the forked property separate? @@ -182,7 +182,7 @@ void ED_operatormacros_armature(void) otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); RNA_boolean_set(otmacro->ptr, "forked", true); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); } void ED_keymap_armature(wmKeyConfig *keyconf) diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index 037703c50bf..b2ca1d84520 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -296,7 +296,7 @@ int join_armature_exec(bContext *C, wmOperator *op) /* Get Pose of current armature */ opose = ob_iter->pose; ob_iter->mode &= ~OB_MODE_POSE; - //BASACT->flag &= ~OB_MODE_POSE; + // BASACT->flag &= ~OB_MODE_POSE; /* Find the difference matrix */ invert_m4_m4(oimat, ob_active->obmat); @@ -432,9 +432,10 @@ static void separated_armature_fix_links(Main *bmain, Object *origArm, Object *n cti->get_constraint_targets(con, &targets); for (ct = targets.first; ct; ct = ct->next) { - /* any targets which point to original armature are redirected to the new one only if: - * - the target isn't origArm/newArm itself - * - the target is one that can be found in newArm/origArm + /* Any targets which point to original armature + * are redirected to the new one only if: + * - The target isn't origArm/newArm itself. + * - The target is one that can be found in newArm/origArm. */ if (ct->subtarget[0] != 0) { if (ct->tar == origArm) { @@ -611,7 +612,7 @@ static int separate_armature_exec(bContext *C, wmOperator *op) oldob = obedit; oldbase = base_iter; oldob->mode &= ~OB_MODE_POSE; - //oldbase->flag &= ~OB_POSEMODE; + // oldbase->flag &= ~OB_POSEMODE; ED_armature_from_edit(bmain, obedit->data); ED_armature_edit_free(obedit->data); @@ -763,11 +764,11 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else if (arm->flag & ARM_MIRROR_EDIT) { - /* For X-Axis Mirror Editing option, we may need a mirror copy of actbone - * - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone + /* For X-Axis Mirror Editing option, we may need a mirror copy of actbone: + * - If there's a mirrored copy of selbone, try to find a mirrored copy of actbone * (i.e. selbone="child.L" and actbone="parent.L", find "child.R" and "parent.R"). - * This is useful for arm-chains, for example parenting lower arm to upper arm - * - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent") + * This is useful for arm-chains, for example parenting lower arm to upper arm. + * - If there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent") * then just use actbone. Useful when doing upper arm to spine. */ actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone); @@ -776,10 +777,22 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) } } - /* if there is only 1 selected bone, we assume that that is the active bone, - * since a user will need to have clicked on a bone (thus selecting it) to make it active - */ - if (CTX_DATA_COUNT(C, selected_editable_bones) <= 1) { + /* If there is only 1 selected bone, we assume that that is the active bone, + * since a user will need to have clicked on a bone (thus selecting it) to make it active. */ + bool is_active_only_selected = false; + if (actbone->flag & BONE_SELECTED) { + is_active_only_selected = true; + for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) { + if (ebone != actbone) { + is_active_only_selected = false; + break; + } + } + } + } + + if (is_active_only_selected) { /* When only the active bone is selected, and it has a parent, * connect it to the parent, as that is the only possible outcome. */ @@ -792,26 +805,31 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) } } else { - /* Parent 'selected' bones to the active one - * - the context iterator contains both selected bones and their mirrored copies, - * so we assume that unselected bones are mirrored copies of some selected bone - * - since the active one (and/or its mirror) will also be selected, we also need + /* Parent 'selected' bones to the active one: + * - The context iterator contains both selected bones and their mirrored copies, + * so we assume that unselected bones are mirrored copies of some selected bone. + * - Since the active one (and/or its mirror) will also be selected, we also need * to check that we are not trying to operate on them, since such an operation - * would cause errors + * would cause errors. */ - /* parent selected bones to the active one */ - CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) { - if (ELEM(ebone, actbone, actmirb) == 0) { - if (ebone->flag & BONE_SELECTED) { + /* Parent selected bones to the active one. */ + for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) { + if (ebone != actbone) { bone_connect_to_new_parent(arm->edbo, ebone, actbone, val); } - else { - bone_connect_to_new_parent(arm->edbo, ebone, actmirb, val); + + if (arm->flag & ARM_MIRROR_EDIT) { + EditBone *ebone_mirror = ED_armature_ebone_get_mirrored(arm->edbo, ebone); + if (ebone_mirror && (ebone_mirror->flag & BONE_SELECTED) == 0) { + if (ebone_mirror != actmirb) { + bone_connect_to_new_parent(arm->edbo, ebone_mirror, actmirb, val); + } + } } } } - CTX_DATA_END; } /* note, notifier might evolve */ @@ -824,25 +842,29 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) { - EditBone *actbone = CTX_data_active_bone(C); - uiPopupMenu *pup = UI_popup_menu_begin( - C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Make Parent"), ICON_NONE); - uiLayout *layout = UI_popup_menu_layout(pup); - int allchildbones = 0; - - CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) { - if (ebone != actbone) { - if (ebone->parent != actbone) { - allchildbones = 1; + bool all_childbones = false; + { + Object *ob = CTX_data_edit_object(C); + bArmature *arm = ob->data; + EditBone *actbone = arm->act_edbone; + for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { + if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) { + if (ebone != actbone) { + if (ebone->parent != actbone) { + all_childbones = true; + break; + } + } } } } - CTX_DATA_END; + uiPopupMenu *pup = UI_popup_menu_begin( + C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Make Parent"), ICON_NONE); + uiLayout *layout = UI_popup_menu_layout(pup); uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_CONNECT); - - /* ob becomes parent, make the associated menus */ - if (allchildbones) { + if (all_childbones) { + /* Object becomes parent, make the associated menus. */ uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_OFFSET); } diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 95c10b79678..fbbb68d2003 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -867,8 +867,8 @@ static bool armature_edit_select_op_apply(bArmature *arm, } /** - * Perform a selection operation on elements which have been 'touched', use for lasso & border select - * but can be used elsewhere too. + * Perform a selection operation on elements which have been 'touched', + * use for lasso & border select but can be used elsewhere too. * * Tagging is done via #EditBone.temp.i using: #BONESEL_ROOT, #BONESEL_TIP, #BONESEL_BONE * And optionally ignoring end-points using the #BONESEL_ROOT, #BONESEL_TIP right shifted 16 bits. diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index fb3fb310b9d..b23081cd6fa 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -466,8 +466,8 @@ static EditBone *make_boneList_rec(ListBase *edbo, eBone->parent->flag |= BONE_TIPSEL; } - /* For connected bones, take care when changing the selection when we have a connected parent, - * this flag is a copy of '(eBone->parent->flag & BONE_TIPSEL)'. */ + /* For connected bones, take care when changing the selection when we have a + * connected parent, this flag is a copy of '(eBone->parent->flag & BONE_TIPSEL)'. */ eBone->flag |= BONE_ROOTSEL; } else { diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index b194650060a..81030c7f199 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -365,7 +365,7 @@ int laplacian_system_solve(LaplacianSystem *sys) { sys->variablesdone = false; - //EIG_linear_solver_print_matrix(sys->context, ); + // EIG_linear_solver_print_matrix(sys->context, ); return EIG_linear_solver_solve(sys->context); } @@ -451,7 +451,7 @@ static void heat_ray_tree_create(LaplacianSystem *sys) BLI_bvhtree_insert(sys->heat.bvhtree, a, bb, 2); - //Setup inverse pointers to use on isect.orig + // Setup inverse pointers to use on isect.orig sys->heat.vltree[vtri[0]] = lt; sys->heat.vltree[vtri[1]] = lt; sys->heat.vltree[vtri[2]] = lt; diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index cf64210ebdb..954beda7777 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -65,7 +65,7 @@ #include "armature_intern.h" -#define DEBUG_TIME +#undef DEBUG_TIME #include "PIL_time.h" #ifdef DEBUG_TIME @@ -197,38 +197,6 @@ void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob, bool curre ListBase targets = {NULL, NULL}; bool free_depsgraph = false; - /* Override depsgraph with a filtered, simpler copy */ - if (!current_frame_only && G.debug_value != -1) { - DEG_FilterQuery query = {{0}}; - - DEG_FilterTarget *dft_ob = MEM_callocN(sizeof(DEG_FilterTarget), "DEG_FilterTarget"); - dft_ob->id = &ob->id; - BLI_addtail(&query.targets, dft_ob); - -#ifdef DEBUG_TIME - TIMEIT_START(filter_pose_depsgraph); -#endif - - depsgraph = DEG_graph_filter(depsgraph, bmain, &query); - -#ifdef DEBUG_TIME - TIMEIT_END(filter_pose_depsgraph); -#endif - - free_depsgraph = true; - MEM_freeN(dft_ob); - -#ifdef DEBUG_TIME - TIMEIT_START(filter_pose_update); -#endif - - BKE_scene_graph_update_tagged(depsgraph, bmain); - -#ifdef DEBUG_TIME - TIMEIT_END(filter_pose_update); -#endif - } - /* set flag to force recalc, then grab the relevant bones to target */ ob->pose->avs.recalc |= ANIMVIZ_RECALC_PATHS; animviz_get_object_motionpaths(ob, &targets); diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index 010f1c0e654..7b31897766d 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -77,7 +77,9 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUS } /* ************************************************************* */ -/* == POSE-LIBRARY TOOL FOR BLENDER == +/** + * Pose-Library Tool for Blender + * ============================= * * Overview: * This tool allows animators to store a set of frequently used poses to dump into @@ -85,13 +87,13 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUS * It acts as a kind of "glorified clipboard for poses", allowing for naming of poses. * * Features: - * - PoseLibs are simply normal Actions - * - Each "pose" is simply a set of keyframes that occur on a particular frame - * -> a set of TimeMarkers that belong to each Action, help 'label' where a 'pose' can be - * found in the Action + * - PoseLibs are simply normal Actions. + * - Each "pose" is simply a set of keyframes that occur on a particular frame. + * - A set of TimeMarkers that belong to each Action, help 'label' where a 'pose' can be + * found in the Action. * - The Scrollwheel or PageUp/Down buttons when used in a special mode or after pressing/holding - * [a modifier] key, cycles through the poses available for the active pose's poselib, allowing the - * animator to preview what action best suits that pose + * [a modifier] key, cycles through the poses available for the active pose's poselib, + * allowing the animator to preview what action best suits that pose. */ /* ************************************************************* */ @@ -1453,7 +1455,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con case PADMINUS: case MIDDLEMOUSE: case MOUSEMOVE: - //pld->redraw = PL_PREVIEW_REDRAWHEADER; + // pld->redraw = PL_PREVIEW_REDRAWHEADER; ret = OPERATOR_PASS_THROUGH; break; @@ -1585,7 +1587,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con */ case MIDDLEMOUSE: case MOUSEMOVE: - //pld->redraw = PL_PREVIEW_REDRAWHEADER; + // pld->redraw = PL_PREVIEW_REDRAWHEADER; ret = OPERATOR_PASS_THROUGH; break; @@ -1608,7 +1610,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con } else { /* view manipulation (see above) */ - //pld->redraw = PL_PREVIEW_REDRAWHEADER; + // pld->redraw = PL_PREVIEW_REDRAWHEADER; ret = OPERATOR_PASS_THROUGH; } break; @@ -1746,7 +1748,7 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op) /* updates */ if (IS_AUTOKEY_MODE(scene, NORMAL)) { - //remake_action_ipos(ob->action); + // remake_action_ipos(ob->action); } else { BKE_pose_where_is(CTX_data_depsgraph(C), scene, ob); diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index 79182a89096..d683c599f7b 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -335,12 +335,6 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, Object *ob, flo /* next/end */ eVal = evaluate_fcurve(fcu, nextFrameF); - /* if both values are equal, don't do anything */ - if (IS_EQF(sVal, eVal)) { - (*val) = sVal; - return; - } - /* calculate the relative weights of the endpoints */ if (pso->mode == POSESLIDE_BREAKDOWN) { /* get weights from the percentage control */ @@ -362,9 +356,10 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, Object *ob, flo w2 = (w2 / wtot); } - /* depending on the mode, calculate the new value - * - in all of these, the start+end values are multiplied by w2 and w1 (respectively), - * since multiplication in another order would decrease the value the current frame is closer to + /* Depending on the mode, calculate the new value: + * - In all of these, the start+end values are multiplied by w2 and w1 (respectively), + * since multiplication in another order would decrease + * the value the current frame is closer to. */ switch (pso->mode) { case POSESLIDE_PUSH: /* make the current pose more pronounced */ @@ -509,7 +504,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, default: /* cannot handle */ - //printf("Cannot Pose Slide non-numerical property\n"); + // printf("Cannot Pose Slide non-numerical property\n"); break; } } @@ -698,9 +693,8 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso) } if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_PROPS) && (pfl->oldprops)) { - /* not strictly a transform, but custom properties contribute to the pose produced in many rigs - * (e.g. the facial rigs used in Sintel) - */ + /* Not strictly a transform, but custom properties contribute + * to the pose produced in many rigs (e.g. the facial rigs used in Sintel). */ pose_slide_apply_props(pso, pfl, "[\""); /* dummy " for texteditor bugs */ } } @@ -982,35 +976,41 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) case LEFTMOUSE: /* confirm */ case RETKEY: case PADENTER: { - /* return to normal cursor and header status */ - ED_area_status_text(pso->sa, NULL); - WM_cursor_modal_restore(win); + if (event->val == KM_PRESS) { + /* return to normal cursor and header status */ + ED_area_status_text(pso->sa, NULL); + WM_cursor_modal_restore(win); - /* insert keyframes as required... */ - pose_slide_autoKeyframe(C, pso); - pose_slide_exit(op); + /* insert keyframes as required... */ + pose_slide_autoKeyframe(C, pso); + pose_slide_exit(op); - /* done! */ - return OPERATOR_FINISHED; + /* done! */ + return OPERATOR_FINISHED; + } + break; } case ESCKEY: /* cancel */ case RIGHTMOUSE: { - /* return to normal cursor and header status */ - ED_area_status_text(pso->sa, NULL); - WM_cursor_modal_restore(win); + if (event->val == KM_PRESS) { + /* return to normal cursor and header status */ + ED_area_status_text(pso->sa, NULL); + WM_cursor_modal_restore(win); - /* reset transforms back to original state */ - pose_slide_reset(pso); + /* reset transforms back to original state */ + pose_slide_reset(pso); - /* depsgraph updates + redraws */ - pose_slide_refresh(C, pso); + /* depsgraph updates + redraws */ + pose_slide_refresh(C, pso); - /* clean up temp data */ - pose_slide_exit(op); + /* clean up temp data */ + pose_slide_exit(op); - /* canceled! */ - return OPERATOR_CANCELLED; + /* canceled! */ + return OPERATOR_CANCELLED; + } + break; } /* Percentage Chane... */ @@ -1162,8 +1162,8 @@ static void pose_slide_opdef_properties(wmOperatorType *ot) 1.0f, "Percentage", "Weighting factor for which keyframe is favored more", - 0.3, - 0.7); + 0.0, + 1.0); RNA_def_int(ot->srna, "prev_frame", @@ -1254,7 +1254,7 @@ void POSE_OT_push(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA; /* Properties */ pose_slide_opdef_properties(ot); @@ -1316,7 +1316,7 @@ void POSE_OT_relax(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA; /* Properties */ pose_slide_opdef_properties(ot); @@ -1378,7 +1378,7 @@ void POSE_OT_breakdown(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA; /* Properties */ pose_slide_opdef_properties(ot); @@ -1783,7 +1783,7 @@ void POSE_OT_propagate(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* XXX: needs selected bones! */ /* flag */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; /* properties */ /* TODO: add "fade out" control for tapering off amount of propagation as time goes by? */ diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c index 45c51897cbf..a1f763ac57d 100644 --- a/source/blender/editors/armature/pose_utils.c +++ b/source/blender/editors/armature/pose_utils.c @@ -220,24 +220,9 @@ void poseAnim_mapping_free(ListBase *pfLinks) /* ------------------------- */ /* helper for apply() / reset() - refresh the data */ -void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob) +void poseAnim_mapping_refresh(bContext *C, Scene *UNUSED(scene), Object *ob) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); - bArmature *arm = (bArmature *)ob->data; - - /* old optimize trick... this enforces to bypass the depgraph - * - note: code copied from transform_generics.c -> recalcData() - */ - /* FIXME: shouldn't this use the builtin stuff? */ - if ((arm->flag & ARM_DELAYDEFORM) == 0) { - DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); /* sets recalc flags */ - } - else { - BKE_pose_where_is(depsgraph, scene, ob); - } - - /* otherwise animation doesn't get updated */ - DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); + DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); } @@ -342,7 +327,7 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, ListBase *pfLinks, FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob) { if (ob->id.tag & LIB_TAG_DOIT) { if (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) { - //ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear + // ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear ED_pose_recalculate_paths(C, scene, ob, false); } } diff --git a/source/blender/editors/curve/CMakeLists.txt b/source/blender/editors/curve/CMakeLists.txt index 3df6f3c97d4..8c9309055c8 100644 --- a/source/blender/editors/curve/CMakeLists.txt +++ b/source/blender/editors/curve/CMakeLists.txt @@ -26,8 +26,8 @@ set(INC ../../makesrna ../../windowmanager ../../../../intern/clog - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ../../../../extern/curve_fit_nd ) diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 782b093fab4..3d2ac009072 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -147,7 +147,7 @@ void ED_operatormacros_curve(void) OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "CURVE_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); RNA_boolean_set(otmacro->ptr, "mirror", false); ot = WM_operatortype_append_macro("CURVE_OT_extrude_move", @@ -156,7 +156,7 @@ void ED_operatormacros_curve(void) OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "CURVE_OT_extrude"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); RNA_boolean_set(otmacro->ptr, "mirror", false); } diff --git a/source/blender/editors/gizmo_library/CMakeLists.txt b/source/blender/editors/gizmo_library/CMakeLists.txt index 8b035d3207d..d9503c4e759 100644 --- a/source/blender/editors/gizmo_library/CMakeLists.txt +++ b/source/blender/editors/gizmo_library/CMakeLists.txt @@ -27,9 +27,9 @@ set(INC ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/eigen ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/gpencil/CMakeLists.txt b/source/blender/editors/gpencil/CMakeLists.txt index 5573c88c710..21f1801f7eb 100644 --- a/source/blender/editors/gpencil/CMakeLists.txt +++ b/source/blender/editors/gpencil/CMakeLists.txt @@ -22,13 +22,13 @@ set(INC ../../blenlib ../../blentranslation ../../depsgraph - ../../imbuf ../../gpu + ../../imbuf ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c index 84dc29afab3..f325422fec7 100644 --- a/source/blender/editors/gpencil/annotate_draw.c +++ b/source/blender/editors/gpencil/annotate_draw.c @@ -91,12 +91,12 @@ typedef enum eDrawStrokeFlags { /* ----- Tool Buffer Drawing ------ */ /* draw stroke defined in buffer (simple ogl lines/points for now, as dotted lines) */ -static void gp_draw_stroke_buffer(const tGPspoint *points, - int totpoints, - short thickness, - short dflag, - short sflag, - float ink[4]) +static void annotation_draw_stroke_buffer(const tGPspoint *points, + int totpoints, + short thickness, + short dflag, + short sflag, + float ink[4]) { int draw_points = 0; @@ -181,7 +181,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, /* --------- 2D Stroke Drawing Helpers --------- */ /* change in parameter list */ -static void gp_calc_2d_stroke_fxy( +static void annotation_calc_2d_stroke_fxy( const float pt[3], short sflag, int offsx, int offsy, int winx, int winy, float r_co[2]) { if (sflag & GP_STROKE_2DSPACE) { @@ -207,15 +207,15 @@ static void gp_calc_2d_stroke_fxy( /* ----- Existing Strokes Drawing (3D and Point) ------ */ /* draw a given stroke - just a single dot (only one point) */ -static void gp_draw_stroke_point(const bGPDspoint *points, - short thickness, - short UNUSED(dflag), - short sflag, - int offsx, - int offsy, - int winx, - int winy, - const float ink[4]) +static void annotation_draw_stroke_point(const bGPDspoint *points, + short thickness, + short UNUSED(dflag), + short sflag, + int offsx, + int offsy, + int winx, + int winy, + const float ink[4]) { const bGPDspoint *pt = points; @@ -234,7 +234,7 @@ static void gp_draw_stroke_point(const bGPDspoint *points, /* get 2D coordinates of point */ float co[3] = {0.0f}; - gp_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, co); + annotation_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, co); copy_v3_v3(fpt, co); } @@ -252,12 +252,12 @@ static void gp_draw_stroke_point(const bGPDspoint *points, } /* draw a given stroke in 3d (i.e. in 3d-space), using simple ogl lines */ -static void gp_draw_stroke_3d(const bGPDspoint *points, - int totpoints, - short thickness, - short UNUSED(sflag), - const float ink[4], - bool cyclic) +static void annotation_draw_stroke_3d(const bGPDspoint *points, + int totpoints, + short thickness, + short UNUSED(sflag), + const float ink[4], + bool cyclic) { float curpressure = points[0].pressure; float cyclic_fpt[3]; @@ -336,16 +336,16 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, /* ----- Fancy 2D-Stroke Drawing ------ */ /* draw a given stroke in 2d */ -static void gp_draw_stroke_2d(const bGPDspoint *points, - int totpoints, - short thickness_s, - short dflag, - short sflag, - int offsx, - int offsy, - int winx, - int winy, - const float ink[4]) +static void annotation_draw_stroke_2d(const bGPDspoint *points, + int totpoints, + short thickness_s, + short dflag, + short sflag, + int offsx, + int offsy, + int winx, + int winy, + const float ink[4]) { /* otherwise thickness is twice that of the 3D view */ float thickness = (float)thickness_s * 0.5f; @@ -374,7 +374,7 @@ static void gp_draw_stroke_2d(const bGPDspoint *points, immBegin(GPU_PRIM_TRI_STRIP, totpoints * 2 + 4); /* get x and y coordinates from first point */ - gp_calc_2d_stroke_fxy(&points->x, sflag, offsx, offsy, winx, winy, s0); + annotation_calc_2d_stroke_fxy(&points->x, sflag, offsx, offsy, winx, winy, s0); for (i = 0, pt1 = points, pt2 = points + 1; i < (totpoints - 1); i++, pt1++, pt2++) { float t0[2], t1[2]; /* tessellated coordinates */ @@ -384,7 +384,7 @@ static void gp_draw_stroke_2d(const bGPDspoint *points, /* Get x and y coordinates from point2 * (point1 has already been computed in previous iteration). */ - gp_calc_2d_stroke_fxy(&pt2->x, sflag, offsx, offsy, winx, winy, s1); + annotation_calc_2d_stroke_fxy(&pt2->x, sflag, offsx, offsy, winx, winy, s1); /* calculate gradient and normal - 'angle'=(ny/nx) */ m1[1] = s1[1] - s0[1]; @@ -513,7 +513,7 @@ static void gp_draw_stroke_2d(const bGPDspoint *points, /* ----- Strokes Drawing ------ */ /* Helper for doing all the checks on whether a stroke can be drawn */ -static bool gp_can_draw_stroke(const bGPDstroke *gps, const int dflag) +static bool annotation_can_draw_stroke(const bGPDstroke *gps, const int dflag) { /* skip stroke if it isn't in the right display space for this drawing context */ /* 1) 3D Strokes */ @@ -550,22 +550,22 @@ static bool gp_can_draw_stroke(const bGPDstroke *gps, const int dflag) } /* draw a set of strokes */ -static void gp_draw_strokes(bGPdata *UNUSED(gpd), - bGPDlayer *UNUSED(gpl), - const bGPDframe *gpf, - int offsx, - int offsy, - int winx, - int winy, - int dflag, - short lthick, - const float color[4]) +static void annotation_draw_strokes(bGPdata *UNUSED(gpd), + bGPDlayer *UNUSED(gpl), + const bGPDframe *gpf, + int offsx, + int offsy, + int winx, + int winy, + int dflag, + short lthick, + const float color[4]) { GPU_enable_program_point_size(); for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { /* check if stroke can be drawn */ - if (gp_can_draw_stroke(gps, dflag) == false) { + if (annotation_can_draw_stroke(gps, dflag) == false) { continue; } @@ -586,11 +586,11 @@ static void gp_draw_strokes(bGPdata *UNUSED(gpd), /* 3D Lines - OpenGL primitives-based */ if (gps->totpoints == 1) { - gp_draw_stroke_point( + annotation_draw_stroke_point( gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy, color); } else { - gp_draw_stroke_3d( + annotation_draw_stroke_3d( gps->points, gps->totpoints, lthick, gps->flag, color, gps->flag & GP_STROKE_CYCLIC); } @@ -604,20 +604,20 @@ static void gp_draw_strokes(bGPdata *UNUSED(gpd), else { /* 2D Strokes... */ if (gps->totpoints == 1) { - gp_draw_stroke_point( + annotation_draw_stroke_point( gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy, color); } else { - gp_draw_stroke_2d(gps->points, - gps->totpoints, - lthick, - dflag, - gps->flag, - offsx, - offsy, - winx, - winy, - color); + annotation_draw_stroke_2d(gps->points, + gps->totpoints, + lthick, + dflag, + gps->flag, + offsx, + offsy, + winx, + winy, + color); } } } @@ -626,16 +626,16 @@ static void gp_draw_strokes(bGPdata *UNUSED(gpd), } /* Draw selected verts for strokes being edited */ -static void gp_draw_strokes_edit(bGPdata *gpd, - bGPDlayer *gpl, - const bGPDframe *gpf, - int offsx, - int offsy, - int winx, - int winy, - short dflag, - short UNUSED(lflag), - float alpha) +static void annotation_draw_strokes_edit(bGPdata *gpd, + bGPDlayer *gpl, + const bGPDframe *gpf, + int offsx, + int offsy, + int winx, + int winy, + short dflag, + short UNUSED(lflag), + float alpha) { /* if alpha 0 do not draw */ if (alpha == 0.0f) { @@ -663,7 +663,7 @@ static void gp_draw_strokes_edit(bGPdata *gpd, /* draw stroke verts */ for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { /* check if stroke can be drawn */ - if (gp_can_draw_stroke(gps, dflag) == false) { + if (annotation_can_draw_stroke(gps, dflag) == false) { continue; } @@ -742,7 +742,7 @@ static void gp_draw_strokes_edit(bGPdata *gpd, } else { float co[2]; - gp_calc_2d_stroke_fxy(&pt->x, gps->flag, offsx, offsy, winx, winy, co); + annotation_calc_2d_stroke_fxy(&pt->x, gps->flag, offsx, offsy, winx, winy, co); immVertex2fv(pos, co); } } @@ -770,15 +770,15 @@ static void gp_draw_strokes_edit(bGPdata *gpd, /* ----- General Drawing ------ */ /* draw onion-skinning for a layer */ -static void gp_draw_onionskins(bGPdata *gpd, - bGPDlayer *gpl, - bGPDframe *gpf, - int offsx, - int offsy, - int winx, - int winy, - int UNUSED(cfra), - int dflag) +static void annotation_draw_onionskins(bGPdata *gpd, + bGPDlayer *gpl, + bGPDframe *gpf, + int offsx, + int offsy, + int winx, + int winy, + int UNUSED(cfra), + int dflag) { const float alpha = 1.0f; float color[4]; @@ -797,7 +797,8 @@ static void gp_draw_onionskins(bGPdata *gpd, /* alpha decreases with distance from curframe index */ fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1)); color[3] = alpha * fac * 0.66f; - gp_draw_strokes(gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color); + annotation_draw_strokes( + gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color); } else { break; @@ -808,7 +809,8 @@ static void gp_draw_onionskins(bGPdata *gpd, /* draw the strokes for the ghost frames (at half of the alpha set by user) */ if (gpf->prev) { color[3] = (alpha / 7); - gp_draw_strokes(gpd, gpl, gpf->prev, offsx, offsy, winx, winy, dflag, gpl->thickness, color); + annotation_draw_strokes( + gpd, gpl, gpf->prev, offsx, offsy, winx, winy, dflag, gpl->thickness, color); } } else { @@ -829,7 +831,8 @@ static void gp_draw_onionskins(bGPdata *gpd, /* alpha decreases with distance from curframe index */ fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep_next + 1)); color[3] = alpha * fac * 0.66f; - gp_draw_strokes(gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color); + annotation_draw_strokes( + gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color); } else { break; @@ -840,7 +843,8 @@ static void gp_draw_onionskins(bGPdata *gpd, /* draw the strokes for the ghost frames (at half of the alpha set by user) */ if (gpf->next) { color[3] = (alpha / 4); - gp_draw_strokes(gpd, gpl, gpf->next, offsx, offsy, winx, winy, dflag, gpl->thickness, color); + annotation_draw_strokes( + gpd, gpl, gpf->next, offsx, offsy, winx, winy, dflag, gpl->thickness, color); } } else { @@ -849,7 +853,7 @@ static void gp_draw_onionskins(bGPdata *gpd, } /* loop over gpencil data layers, drawing them */ -static void gp_draw_data_layers( +static void annotation_draw_data_layers( bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag, float alpha) { float ink[4]; @@ -887,23 +891,25 @@ static void gp_draw_data_layers( /* Draw 'onionskins' (frame left + right) */ if (gpl->onion_flag & GP_LAYER_ONIONSKIN) { - gp_draw_onionskins(gpd, gpl, gpf, offsx, offsy, winx, winy, cfra, dflag); + annotation_draw_onionskins(gpd, gpl, gpf, offsx, offsy, winx, winy, cfra, dflag); } /* draw the strokes already in active frame */ - gp_draw_strokes(gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, lthick, ink); + annotation_draw_strokes(gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, lthick, ink); - /* Draw verts of selected strokes + /* Draw verts of selected strokes: * - when doing OpenGL renders, we don't want to be showing these, as that ends up flickering * - locked layers can't be edited, so there's no point showing these verts * as they will have no bearings on what gets edited * - only show when in editmode, since operators shouldn't work otherwise - * (NOTE: doing it this way means that the toggling editmode shows visible change immediately) + * (NOTE: doing it this way means that the toggling editmode + * shows visible change immediately). */ /* XXX: perhaps we don't want to show these when users are drawing... */ if ((G.f & G_FLAG_RENDER_VIEWPORT) == 0 && (gpl->flag & GP_LAYER_LOCKED) == 0 && (gpd->flag & GP_DATA_STROKE_EDITMODE)) { - gp_draw_strokes_edit(gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, gpl->flag, alpha); + annotation_draw_strokes_edit( + gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, gpl->flag, alpha); } /* Check if may need to draw the active stroke cache, only if this layer is the active layer @@ -917,18 +923,18 @@ static void gp_draw_data_layers( * It should also be noted that sbuffer contains temporary point types * i.e. tGPspoints NOT bGPDspoints */ - gp_draw_stroke_buffer(gpd->runtime.sbuffer, - gpd->runtime.sbuffer_size, - lthick, - dflag, - gpd->runtime.sbuffer_sflag, - ink); + annotation_draw_stroke_buffer(gpd->runtime.sbuffer, + gpd->runtime.sbuffer_size, + lthick, + dflag, + gpd->runtime.sbuffer_sflag, + ink); } } } /* draw a short status message in the top-right corner */ -static void gp_draw_status_text(const bGPdata *gpd, ARegion *ar) +static void annotation_draw_status_text(const bGPdata *gpd, ARegion *ar) { rcti rect; @@ -977,7 +983,7 @@ static void gp_draw_status_text(const bGPdata *gpd, ARegion *ar) } /* draw grease-pencil datablock */ -static void gp_draw_data( +static void annotation_draw_data( bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag, float alpha) { /* turn on smooth lines (i.e. anti-aliasing) */ @@ -989,7 +995,7 @@ static void gp_draw_data( GPU_blend(true); /* draw! */ - gp_draw_data_layers(gpd, offsx, offsy, winx, winy, cfra, dflag, alpha); + annotation_draw_data_layers(gpd, offsx, offsy, winx, winy, cfra, dflag, alpha); /* turn off alpha blending, then smooth lines */ GPU_blend(false); // alpha blending @@ -998,15 +1004,15 @@ static void gp_draw_data( /* if we have strokes for scenes (3d view)/clips (movie clip editor) * and objects/tracks, multiple data blocks have to be drawn */ -static void gp_draw_data_all(Scene *scene, - bGPdata *gpd, - int offsx, - int offsy, - int winx, - int winy, - int cfra, - int dflag, - const char spacetype) +static void annotation_draw_data_all(Scene *scene, + bGPdata *gpd, + int offsx, + int offsy, + int winx, + int winy, + int cfra, + int dflag, + const char spacetype) { bGPdata *gpd_source = NULL; float alpha = 1.0f; @@ -1022,14 +1028,14 @@ static void gp_draw_data_all(Scene *scene, } if (gpd_source) { - gp_draw_data(gpd_source, offsx, offsy, winx, winy, cfra, dflag, alpha); + annotation_draw_data(gpd_source, offsx, offsy, winx, winy, cfra, dflag, alpha); } } /* scene/clip data has already been drawn, only object/track data is drawn here * if gpd_source == gpd, we don't have any object/track data and we can skip */ if (gpd_source == NULL || (gpd_source && gpd_source != gpd)) { - gp_draw_data(gpd, offsx, offsy, winx, winy, cfra, dflag, alpha); + annotation_draw_data(gpd, offsx, offsy, winx, winy, cfra, dflag, alpha); } } @@ -1106,12 +1112,16 @@ void ED_annotation_draw_2dimage(const bContext *C) } /* draw it! */ - gp_draw_data_all(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag, sa->spacetype); + annotation_draw_data_all(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag, sa->spacetype); } -/* draw grease-pencil sketches to specified 2d-view assuming that matrices are already set correctly - * Note: this gets called twice - first time with onlyv2d=true to draw 'canvas' strokes, - * second time with onlyv2d=false for screen-aligned strokes */ +/** + * Draw grease-pencil sketches to specified 2d-view + * assuming that matrices are already set correctly. + * + * \note This gets called twice - first time with onlyv2d=true to draw 'canvas' strokes, + * second time with onlyv2d=false for screen-aligned strokes. + */ void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d) { wmWindowManager *wm = CTX_wm_manager(C); @@ -1130,7 +1140,8 @@ void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d) } /* special hack for Image Editor */ - /* FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled */ + /* FIXME: the opengl poly-strokes don't draw at right thickness when done this way, + * so disabled. */ if (ELEM(sa->spacetype, SPACE_IMAGE, SPACE_CLIP)) { dflag |= GP_DRAWDATA_IEDITHACK; } @@ -1143,11 +1154,11 @@ void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d) dflag |= GP_DRAWDATA_NO_ONIONS; } - gp_draw_data_all(scene, gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag, sa->spacetype); + annotation_draw_data_all(scene, gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag, sa->spacetype); /* draw status text (if in screen/pixel-space) */ if (!onlyv2d) { - gp_draw_status_text(gpd, ar); + annotation_draw_status_text(gpd, ar); } } @@ -1201,7 +1212,7 @@ void ED_annotation_draw_view3d( } /* draw it! */ - gp_draw_data_all(scene, gpd, offsx, offsy, winx, winy, CFRA, dflag, v3d->spacetype); + annotation_draw_data_all(scene, gpd, offsx, offsy, winx, winy, CFRA, dflag, v3d->spacetype); } void ED_annotation_draw_ex( @@ -1209,7 +1220,7 @@ void ED_annotation_draw_ex( { int dflag = GP_DRAWDATA_NOSTATUS | GP_DRAWDATA_ONLYV2D; - gp_draw_data_all(scene, gpd, 0, 0, winx, winy, cfra, dflag, spacetype); + annotation_draw_data_all(scene, gpd, 0, 0, winx, winy, cfra, dflag, spacetype); } /* ************************************************** */ diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index 0363fd6c754..73230e5fb0e 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -285,17 +285,17 @@ static bool gp_stroke_filtermval(tGPsdata *p, const float mval[2], float pmval[2 return true; /* check if mouse moved at least certain distance on both axes (best case) - * - aims to eliminate some jitter-noise from input when trying to draw straight lines freehand - */ + * - aims to eliminate some jitter-noise from input when trying to draw straight lines freehand + */ } else if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX)) { return true; /* Check if the distance since the last point is significant enough: - * - Prevents points being added too densely - * - Distance here doesn't use sqrt to prevent slowness. - * We should still be safe from overflows though. - */ + * - Prevents points being added too densely + * - Distance here doesn't use sqrt to prevent slowness. + * We should still be safe from overflows though. + */ } else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX) { return true; @@ -1361,7 +1361,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps if (has_layer_to_erase == false) { p->status = GP_STATUS_CAPTURE; - //if (G.debug & G_DEBUG) + // if (G.debug & G_DEBUG) printf("Error: Eraser will not be affecting anything (gpencil_paint_init)\n"); return; } @@ -1544,14 +1544,13 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr) immUniform1f("dash_width", 12.0f); immUniform1f("dash_factor", 0.5f); - imm_draw_circle_wire_2d( - shdr_pos, - x, - y, - p->radius, - /* XXX Dashed shader gives bad results with sets of small segments currently, - * temp hack around the issue. :( */ - max_ii(8, p->radius / 2)); /* was fixed 40 */ + imm_draw_circle_wire_2d(shdr_pos, + x, + y, + p->radius, + /* XXX Dashed shader gives bad results with sets of small segments + * currently, temp hack around the issue. :( */ + max_ii(8, p->radius / 2)); /* was fixed 40 */ immUnbindProgram(); @@ -2205,7 +2204,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) p->ar = ar; } - /* we don't pass on key events, GP is used with key-modifiers - prevents Dkey to insert drivers */ + /* We don't pass on key events, GP is used with key-modifiers - + * prevents Dkey to insert drivers. */ if (ISKEYBOARD(event->type)) { if (ELEM(event->type, LEFTARROWKEY, DOWNARROWKEY, RIGHTARROWKEY, UPARROWKEY, ZKEY)) { /* allow some keys: @@ -2233,10 +2233,12 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) } } - //printf("\tGP - handle modal event...\n"); + // printf("\tGP - handle modal event...\n"); - /* exit painting mode (and/or end current stroke) - * NOTE: cannot do RIGHTMOUSE (as is standard for canceling) as that would break polyline [#32647] + /* Exit painting mode (and/or end current stroke) + * + * NOTE: cannot do RIGHTMOUSE (as is standard for canceling) + * as that would break polyline T32647. */ if (ELEM(event->type, RETKEY, PADENTER, ESCKEY, SPACEKEY, EKEY)) { /* exit() ends the current stroke before cleaning up */ diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index c54598fd549..ef74aa28b63 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -121,9 +121,15 @@ static void gp_set_point_uniform_color(const bGPDspoint *pt, const float ink[4]) immUniformColor3fvAlpha(ink, alpha); } -static void gp_set_point_varying_color(const bGPDspoint *pt, const float ink[4], uint attr_id) +static void gp_set_point_varying_color(const bGPDspoint *pt, + const float ink[4], + uint attr_id, + bool fix_strength) { float alpha = ink[3] * pt->strength; + if ((fix_strength) && (alpha >= 0.1f)) { + alpha = 1.0f; + } CLAMP(alpha, GPENCIL_STRENGTH_MIN, 1.0f); immAttr4ub(attr_id, F2UB(ink[0]), F2UB(ink[1]), F2UB(ink[2]), F2UB(alpha)); } @@ -186,7 +192,7 @@ static void gp_draw_stroke_volumetric_2d(const bGPDspoint *points, mul_v3_m4v3(fpt, diff_mat, &pt->x); gp_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, co); - gp_set_point_varying_color(pt, ink, color); + gp_set_point_varying_color(pt, ink, color, false); immAttr1f(size, pt->pressure * thickness); /* TODO: scale based on view transform */ immVertex2f(pos, co[0], co[1]); } @@ -214,7 +220,7 @@ static void gp_draw_stroke_volumetric_3d(const bGPDspoint *points, const bGPDspoint *pt = points; for (int i = 0; i < totpoints && pt; i++, pt++) { - gp_set_point_varying_color(pt, ink, color); + gp_set_point_varying_color(pt, ink, color, false); /* TODO: scale based on view transform */ immAttr1f(size, pt->pressure * thickness); /* we can adjust size in vertex shader based on view/projection! */ @@ -576,7 +582,7 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4 for (int i = 0; i < totpoints; i++, pt++) { /* first point for adjacency (not drawn) */ if (i == 0) { - gp_set_point_varying_color(points, ink, attr_id.color); + gp_set_point_varying_color(points, ink, attr_id.color, (bool)tgpw->is_fill_stroke); if ((cyclic) && (totpoints > 2)) { immAttr1f(attr_id.thickness, max_ff((points + totpoints - 1)->pressure * thickness, 1.0f)); @@ -589,7 +595,7 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4 immVertex3fv(attr_id.pos, fpt); } /* set point */ - gp_set_point_varying_color(pt, ink, attr_id.color); + gp_set_point_varying_color(pt, ink, attr_id.color, (bool)tgpw->is_fill_stroke); immAttr1f(attr_id.thickness, max_ff(pt->pressure * thickness, 1.0f)); mul_v3_m4v3(fpt, tgpw->diff_mat, &pt->x); immVertex3fv(attr_id.pos, fpt); @@ -608,7 +614,9 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4 } /* last adjacency point (not drawn) */ else { - gp_set_point_varying_color(points + totpoints - 2, ink, attr_id.color); + gp_set_point_varying_color( + points + totpoints - 2, ink, attr_id.color, (bool)tgpw->is_fill_stroke); + immAttr1f(attr_id.thickness, max_ff((points + totpoints - 2)->pressure * thickness, 1.0f)); mul_v3_m4v3(fpt, tgpw->diff_mat, &(points + totpoints - 2)->x); immVertex3fv(attr_id.pos, fpt); @@ -693,7 +701,7 @@ static void gp_draw_stroke_2d(const bGPDspoint *points, pthick = (pt1->pressure * thickness * scalefac); /* color of point */ - gp_set_point_varying_color(pt1, ink, attr_id.color); + gp_set_point_varying_color(pt1, ink, attr_id.color, false); /* if the first segment, start of segment is segment's normal */ if (i == 0) { @@ -768,7 +776,7 @@ static void gp_draw_stroke_2d(const bGPDspoint *points, pthick = (pt2->pressure * thickness * scalefac); /* color of point */ - gp_set_point_varying_color(pt2, ink, attr_id.color); + gp_set_point_varying_color(pt2, ink, attr_id.color, false); /* calculate points for end of segment */ mt[0] = m2[0] * pthick; @@ -861,7 +869,9 @@ static void gp_draw_strokes(tGPDdraw *tgpw) GPU_enable_program_point_size(); - for (bGPDstroke *gps = tgpw->t_gpf->strokes.first; gps; gps = gps->next) { + bGPDstroke *gps_init = (tgpw->gps) ? tgpw->gps : tgpw->t_gpf->strokes.first; + + for (bGPDstroke *gps = gps_init; gps; gps = gps->next) { /* check if stroke can be drawn */ if (gp_can_draw_stroke(gps, tgpw->dflag) == false) { continue; @@ -909,7 +919,7 @@ static void gp_draw_strokes(tGPDdraw *tgpw) } /* 3D Fill */ - //if ((dflag & GP_DRAWDATA_FILL) && (gps->totpoints >= 3)) { + // if ((dflag & GP_DRAWDATA_FILL) && (gps->totpoints >= 3)) { if ((gps->totpoints >= 3) && (tgpw->disable_fill != 1)) { /* set color using material, tint color and opacity */ interp_v3_v3v3(tfill, gp_style->fill_rgba, tgpw->tintcolor, tgpw->tintcolor[3]); @@ -955,6 +965,14 @@ static void gp_draw_strokes(tGPDdraw *tgpw) copy_v4_v4(ink, tcolor); } } + + /* if used for fill, set opacity to 1 */ + if (tgpw->is_fill_stroke) { + if (ink[3] >= GPENCIL_ALPHA_OPACITY_THRESH) { + ink[3] = 1.0f; + } + } + if (gp_style->mode == GP_STYLE_MODE_DOTS) { /* volumetric stroke drawing */ if (tgpw->disable_fill != 1) { @@ -1080,6 +1098,10 @@ static void gp_draw_strokes(tGPDdraw *tgpw) } } } + /* if only one stroke, exit from loop */ + if (tgpw->gps) { + break; + } } GPU_disable_program_point_size(); @@ -1126,6 +1148,7 @@ void ED_gp_draw_interpolation(const bContext *C, tGPDinterpolate *tgpi, const in tgpw.gpl = tgpil->gpl; tgpw.gpf = tgpil->interFrame; tgpw.t_gpf = tgpil->interFrame; + tgpw.gps = NULL; tgpw.lthick = tgpil->gpl->line_change; tgpw.opacity = 1.0; diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c index c433b374d4c..6ad89d2e38d 100644 --- a/source/blender/editors/gpencil/gpencil_armature.c +++ b/source/blender/editors/gpencil/gpencil_armature.c @@ -480,6 +480,8 @@ static void gpencil_object_vgroup_calc_from_armature(const bContext *C, */ gpencil_add_verts_to_dgroups(C, ob, ob_arm, ratio, decay); } + + DEG_relations_tag_update(CTX_data_main(C)); } bool ED_gpencil_add_armature_weights( diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index f9a5ff3a0cf..9777a8190c1 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -88,6 +88,7 @@ typedef struct tGP_BrushEditData { /* Current editor/region/etc. */ /* NOTE: This stuff is mainly needed to handle 3D view projection stuff... */ Depsgraph *depsgraph; + struct Main *bmain; Scene *scene; Object *object; @@ -907,6 +908,7 @@ static bool gp_brush_weight_apply( if (gso->vrgroup == -1) { if (gso->object) { BKE_object_defgroup_add(gso->object); + DEG_relations_tag_update(gso->bmain); gso->vrgroup = 0; } } @@ -969,7 +971,7 @@ typedef struct tGPSB_CloneBrushData { /* for "stamp" mode, the currently pasted brushes */ bGPDstroke **new_strokes; - /* mapping from colors referenced per stroke, to the new colours in the "pasted" strokes */ + /** Mapping from colors referenced per stroke, to the new colors in the "pasted" strokes. */ GHash *new_colors; } tGPSB_CloneBrushData; @@ -1017,7 +1019,7 @@ static void gp_brush_clone_init(bContext *C, tGP_BrushEditData *gso) } /* Init colormap for mapping between the pasted stroke's source color (names) - * and the final colours that will be used here instead. + * and the final colors that will be used here instead. */ data->new_colors = gp_copybuf_validate_colormap(C); } @@ -1167,7 +1169,8 @@ static bool gpsculpt_brush_apply_clone(bContext *C, tGP_BrushEditData *gso) } else { /* Continuous - Just keep pasting everytime we move */ - /* TODO: The spacing of repeat should be controlled using a "stepsize" or similar property? */ + /* TODO: The spacing of repeat should be controlled using a + * "stepsize" or similar property? */ gp_brush_clone_add(C, gso); } } @@ -1219,6 +1222,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op) op->customdata = gso; gso->depsgraph = CTX_data_depsgraph(C); + gso->bmain = CTX_data_main(C); /* store state */ gso->settings = gpsculpt_get_settings(scene); gso->gp_brush = gpsculpt_get_brush(scene, is_weight_mode); @@ -1322,7 +1326,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op) gpsculpt_brush_header_set(C, gso); /* setup cursor drawing */ - //WM_cursor_modal_set(CTX_wm_window(C), BC_CROSSCURSOR); + // WM_cursor_modal_set(CTX_wm_window(C), BC_CROSSCURSOR); if (gso->sa->spacetype != SPACE_VIEW3D) { ED_gpencil_toggle_brush_cursor(C, true, NULL); } @@ -1406,9 +1410,10 @@ static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso) if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) { bGPDframe *gpf = gpl->actframe; - /* Make a new frame to work on if the layer's frame and the current scene frame don't match up + /* Make a new frame to work on if the layer's frame + * and the current scene frame don't match up: * - This is useful when animating as it saves that "uh-oh" moment when you realize you've - * spent too much time editing the wrong frame... + * spent too much time editing the wrong frame. */ // XXX: should this be allowed when framelock is enabled? if (gpf->framenum != cfra_eval) { @@ -2002,7 +2007,7 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even /* Painting mbut release = Stop painting (back to idle) */ case LEFTMOUSE: - //BLI_assert(event->val == KM_RELEASE); + // BLI_assert(event->val == KM_RELEASE); if (is_modal) { /* go back to idling... */ gso->is_painting = false; diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c index ded663276a4..5afa379e04f 100644 --- a/source/blender/editors/gpencil/gpencil_convert.c +++ b/source/blender/editors/gpencil/gpencil_convert.c @@ -79,6 +79,7 @@ #include "ED_view3d.h" #include "ED_clip.h" #include "ED_keyframing.h" +#include "ED_object.h" #include "gpencil_intern.h" @@ -328,9 +329,9 @@ static int gp_find_end_of_stroke_idx(tGpTimingData *gtd, else { float delta, min, max; - /* This code ensures that if the first gaps have been shorter than average gap_duration, - * next gaps will tend to be longer (i.e. try to recover the lateness), and vice-versa! - */ + /* This code ensures that if the first gaps + * have been shorter than average gap_duration, next gaps + * will tend to be longer (i.e. try to recover the lateness), and vice-versa! */ delta = delta_time - (gtd->gap_duration * (*nbr_done_gaps)); /* Clamp min between [-gap_randomness, 0.0], with lower delta giving higher min */ @@ -963,10 +964,10 @@ static void gp_stroke_to_bezier(bContext *C, /* Create "link points" */ /* About "zero-radius" point interpolations: - * - If we have at least two points in current curve (most common case), we linearly extrapolate - * the last segment to get the first point (p1) position and timing. - * - If we do not have those (quite odd, but may happen), we linearly interpolate the last point - * with the first point of the current stroke. + * - If we have at least two points in current curve (most common case), + * we linearly extrapolate the last segment to get the first point (p1) position and timing. + * - If we do not have those (quite odd, but may happen), + * we linearly interpolate the last point with the first point of the current stroke. * * The same goes for the second point, * first segment of the current stroke is "negatively" extrapolated @@ -1395,9 +1396,7 @@ static void gp_layer_to_curve(bContext *C, } } - /* set the layer and select */ - base_new->flag |= SELECT; - BKE_scene_object_base_flag_sync_from_base(base_new); + ED_object_base_select(base_new, BA_SELECT); } /* --- */ diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 5ac8cc1761f..463c2144276 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -619,7 +619,7 @@ static void gp_duplicate_points(const bGPDstroke *gps, else if (i == gps->totpoints - 1) { len = i - start_idx + 1; } - //printf("copying from %d to %d = %d\n", start_idx, i, len); + // printf("copying from %d to %d = %d\n", start_idx, i, len); /* make copies of the relevant data */ if (len) { @@ -1069,7 +1069,8 @@ void ED_gpencil_strokes_copybuf_free(void) gp_strokes_copypastebuf.first = gp_strokes_copypastebuf.last = NULL; } -/* Ensure that destination datablock has all the colours the pasted strokes need +/** + * Ensure that destination datablock has all the colors the pasted strokes need. * Helper function for copy-pasting strokes */ GHash *gp_copybuf_validate_colormap(bContext *C) @@ -1211,7 +1212,7 @@ void GPENCIL_OT_copy(wmOperatorType *ot) ot->poll = gp_stroke_edit_poll; /* flags */ - //ot->flag = OPTYPE_REGISTER; + // ot->flag = OPTYPE_REGISTER; } /* --------------------- */ @@ -2211,7 +2212,8 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, /* Watch out for special case where No islands = All points selected = Delete Stroke only */ if (num_islands) { - /* there are islands, so create a series of new strokes, adding them before the "next" stroke */ + /* There are islands, so create a series of new strokes, + * adding them before the "next" stroke. */ int idx; bGPDstroke *new_stroke = NULL; diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index 616db4b73f7..96f405fab2f 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -455,7 +455,7 @@ static void get_pixel(const ImBuf *ibuf, const int idx, float r_col[4]) /* set pixel data (rgba) at index */ static void set_pixel(ImBuf *ibuf, int idx, const float col[4]) { - //BLI_assert(idx <= ibuf->x * ibuf->y); + // BLI_assert(idx <= ibuf->x * ibuf->y); if (ibuf->rect) { uint *rrect = &ibuf->rect[idx]; uchar ccol[4]; diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c index fce8fa79217..db4c601709c 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil/gpencil_ops.c @@ -362,7 +362,7 @@ void ED_operatormacros_gpencil(void) WM_operatortype_macro_define(ot, "GPENCIL_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_boolean_set(otmacro->ptr, "gpencil_strokes", true); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); RNA_boolean_set(otmacro->ptr, "mirror", false); /* Extrude + Move = Interactively add new points */ @@ -373,7 +373,7 @@ void ED_operatormacros_gpencil(void) WM_operatortype_macro_define(ot, "GPENCIL_OT_extrude"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_boolean_set(otmacro->ptr, "gpencil_strokes", true); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); RNA_boolean_set(otmacro->ptr, "mirror", false); } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index f985ade9c7e..b1b29356060 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -372,10 +372,10 @@ static bool gp_stroke_filtermval(tGPsdata *p, const float mval[2], float mvalo[2 return true; /* Check if the distance since the last point is significant enough: - * - Prevents points being added too densely - * - Distance here doesn't use sqrt to prevent slowness. - * We should still be safe from overflows though. - */ + * - Prevents points being added too densely + * - Distance here doesn't use sqrt to prevent slowness. + * We should still be safe from overflows though. + */ } else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX) { return true; @@ -1205,10 +1205,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) gp_randomize_stroke(gps, brush, p->rng); } - /* smooth stroke after subdiv - only if there's something to do - * for each iteration, the factor is reduced to get a better smoothing without changing too much - * the original stroke - */ + /* Smooth stroke after subdiv - only if there's something to do for each iteration, + * the factor is reduced to get a better smoothing + * without changing too much the original stroke. */ if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) && (brush->gpencil_settings->draw_smoothfac > 0.0f)) { float reduce = 0.0f; @@ -2320,14 +2319,13 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr) immUniform1f("dash_width", 12.0f); immUniform1f("dash_factor", 0.5f); - imm_draw_circle_wire_2d( - shdr_pos, - x, - y, - p->radius, - /* XXX Dashed shader gives bad results with sets of small segments currently, - * temp hack around the issue. :( */ - max_ii(8, p->radius / 2)); /* was fixed 40 */ + imm_draw_circle_wire_2d(shdr_pos, + x, + y, + p->radius, + /* XXX Dashed shader gives bad results with sets of small segments + * currently, temp hack around the issue. :( */ + max_ii(8, p->radius / 2)); /* was fixed 40 */ immUnbindProgram(); @@ -2718,6 +2716,8 @@ static void gpencil_draw_apply_event( PointerRNA itemptr; float mousef[2]; int tablet = 0; + bool is_speed_guide = ((guide->use_guide) && + (p->brush && (p->brush->gpencil_tool == GPAINT_TOOL_DRAW))); /* convert from window-space to area-space mouse coordinates * add any x,y override position for fake events @@ -2727,7 +2727,7 @@ static void gpencil_draw_apply_event( p->shift = event->shift; /* verify direction for straight lines */ - if ((guide->use_guide) || + if ((is_speed_guide) || ((event->alt > 0) && (RNA_boolean_get(op->ptr, "disable_straight") == false))) { if (p->straight == 0) { int dx = (int)fabsf(p->mval[0] - p->mvali[0]); @@ -2825,7 +2825,7 @@ static void gpencil_draw_apply_event( /* special exception for grid snapping * it requires direction which needs at least two points */ - if (!ELEM(p->paintmode, GP_PAINTMODE_ERASER, GP_PAINTMODE_SET_CP) && guide->use_guide && + if (!ELEM(p->paintmode, GP_PAINTMODE_ERASER, GP_PAINTMODE_SET_CP) && is_speed_guide && guide->use_snapping && (guide->type == GP_GUIDE_GRID)) { p->flags |= GP_PAINTFLAG_REQ_VECTOR; } @@ -2853,9 +2853,9 @@ static void gpencil_draw_apply_event( } /* check if stroke is straight or guided */ - if ((p->paintmode != GP_PAINTMODE_ERASER) && ((p->straight) || (guide->use_guide))) { + if ((p->paintmode != GP_PAINTMODE_ERASER) && ((p->straight) || (is_speed_guide))) { /* guided stroke */ - if (guide->use_guide) { + if (is_speed_guide) { switch (guide->type) { default: case GP_GUIDE_CIRCULAR: { @@ -3474,7 +3474,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) } } - /* we don't pass on key events, GP is used with key-modifiers - prevents Dkey to insert drivers */ + /* We don't pass on key events, GP is used with key-modifiers - + * prevents Dkey to insert drivers. */ if (ISKEYBOARD(event->type)) { if (ELEM(event->type, LEFTARROWKEY, DOWNARROWKEY, RIGHTARROWKEY, UPARROWKEY, ZKEY)) { /* allow some keys: @@ -3506,10 +3507,12 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) } } - //printf("\tGP - handle modal event...\n"); + // printf("\tGP - handle modal event...\n"); - /* exit painting mode (and/or end current stroke) - * NOTE: cannot do RIGHTMOUSE (as is standard for canceling) as that would break polyline [#32647] + /* Exit painting mode (and/or end current stroke). + * + * NOTE: cannot do RIGHTMOUSE (as is standard for canceling) + * as that would break polyline T32647. */ /* if polyline and release shift must cancel */ if ((ELEM(event->type, RETKEY, PADENTER, ESCKEY, SPACEKEY, EKEY)) || diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 365fb319b3b..ba806022d3e 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -294,7 +294,7 @@ typedef enum eGP_SelectGrouped { /* TODO: All with same prefix - * Useful for isolating all layers for a particular character for instance. */ - /* TODO: All with same appearance - colour/opacity/volumetric/fills ? */ + /* TODO: All with same appearance - color/opacity/volumetric/fills ? */ } eGP_SelectGrouped; /* ----------------------------------- */ @@ -1298,6 +1298,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) bool deselect = RNA_boolean_get(op->ptr, "deselect"); bool toggle = RNA_boolean_get(op->ptr, "toggle"); bool whole = RNA_boolean_get(op->ptr, "entire_strokes"); + const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all"); int mval[2] = {0}; @@ -1360,15 +1361,18 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) /* Abort if nothing hit... */ if (ELEM(NULL, hit_stroke, hit_point)) { + if (deselect_all) { + /* since left mouse select change, deselect all if click outside any hit */ + deselect_all_selected(C); - /* since left mouse select change, deselect all if click outside any hit */ - deselect_all_selected(C); + /* copy on write tag is needed, or else no refresh happens */ + DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY); + DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE); + WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); - /* copy on write tag is needed, or else no refresh happens */ - DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY); - DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE); - WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL); - WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); + return OPERATOR_FINISHED; + } return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c index bf077d528dd..7b57dacd3e4 100644 --- a/source/blender/editors/gpencil/gpencil_undo.c +++ b/source/blender/editors/gpencil/gpencil_undo.c @@ -68,7 +68,7 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name) gpd_ptr = ED_gpencil_data_get_pointers(C, NULL); if (step == 1) { /* undo */ - //printf("\t\tGP - undo step\n"); + // printf("\t\tGP - undo step\n"); if (cur_node->prev) { if (!name || STREQ(cur_node->name, name)) { cur_node = cur_node->prev; @@ -77,7 +77,7 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name) } } else if (step == -1) { - //printf("\t\tGP - redo step\n"); + // printf("\t\tGP - redo step\n"); if (cur_node->next) { if (!name || STREQ(cur_node->name, name)) { cur_node = cur_node->next; @@ -134,7 +134,7 @@ void gpencil_undo_push(bGPdata *gpd) { bGPundonode *undo_node; - //printf("\t\tGP - undo push\n"); + // printf("\t\tGP - undo push\n"); if (cur_node) { /* remove all un-done nodes from stack */ diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 0d920641c5d..129bd01574c 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -1689,14 +1689,13 @@ void ED_gpencil_brush_draw_eraser(Brush *brush, int x, int y) immUniform1f("dash_width", 12.0f); immUniform1f("dash_factor", 0.5f); - imm_draw_circle_wire_2d( - shdr_pos, - x, - y, - radius, - /* XXX Dashed shader gives bad results with sets of small segments currently, - * temp hack around the issue. :( */ - max_ii(8, radius / 2)); /* was fixed 40 */ + imm_draw_circle_wire_2d(shdr_pos, + x, + y, + radius, + /* XXX Dashed shader gives bad results with sets of small segments + * currently, temp hack around the issue. :( */ + max_ii(8, radius / 2)); /* was fixed 40 */ immUnbindProgram(); @@ -2514,7 +2513,7 @@ void ED_gpencil_select_toggle_all(bContext *C, int action) case SEL_SELECT: pt->flag |= GP_SPOINT_SELECT; break; - //case SEL_DESELECT: + // case SEL_DESELECT: // pt->flag &= ~GP_SPOINT_SELECT; // break; case SEL_INVERT: diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index c88277c2ea5..7d4b6dbeea2 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -121,8 +121,8 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state, /* Image buffer drawing functions, with display transform * - * The view and display settings can either be specified manually, or retrived - * from the context with the _ctx variations. + * The view and display settings can either be specified manually, + * or retrieved from the context with the '_ctx' variations. * * For better performance clipping coordinates can be specified so parts of the * image outside the view are skipped. */ diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 3a9539ee52c..6342a8b26d9 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -276,7 +276,8 @@ typedef enum eAnim_Update_Flags { typedef enum eAnimFilter_Flags { /** data which channel represents is fits the dopesheet filters * (i.e. scene visibility criteria) */ - // XXX: it's hard to think of any examples where this *ISN'T* the case... perhaps becomes implicit? + /* XXX: it's hard to think of any examples where this *ISN'T* the case... + * perhaps becomes implicit?. */ ANIMFILTER_DATA_VISIBLE = (1 << 0), /** channel is visible within the channel-list hierarchy * (i.e. F-Curves within Groups in ActEdit) */ @@ -402,11 +403,13 @@ typedef enum eAnimFilter_Flags { /* -------------- Channel Defines -------------- */ /* channel heights */ -#define ACHANNEL_FIRST(ac) (-0.8f * (ac)->yscale_fac * U.widget_unit) +#define ACHANNEL_FIRST_TOP(ac) (-0.4f * (ac)->yscale_fac * U.widget_unit) #define ACHANNEL_HEIGHT(ac) (0.8f * (ac)->yscale_fac * U.widget_unit) -#define ACHANNEL_HEIGHT_HALF(ac) (0.4f * (ac)->yscale_fac * U.widget_unit) #define ACHANNEL_SKIP (0.1f * U.widget_unit) #define ACHANNEL_STEP(ac) (ACHANNEL_HEIGHT(ac) + ACHANNEL_SKIP) +/* Additional offset to give some room at the end. */ +#define ACHANNEL_TOT_HEIGHT(ac, item_amount) \ + (-ACHANNEL_FIRST_TOP(ac) + ACHANNEL_STEP(ac) * (item_amount + 1)) /* channel widths */ #define ACHANNEL_NAMEWIDTH (10 * U.widget_unit) @@ -417,13 +420,14 @@ typedef enum eAnimFilter_Flags { /* -------------- NLA Channel Defines -------------- */ /* NLA channel heights */ -#define NLACHANNEL_FIRST (-0.8f * U.widget_unit) +#define NLACHANNEL_FIRST_TOP(snla) (-0.4f * U.widget_unit) #define NLACHANNEL_HEIGHT(snla) \ ((snla && (snla->flag & SNLA_NOSTRIPCURVES)) ? (0.8f * U.widget_unit) : (1.2f * U.widget_unit)) -#define NLACHANNEL_HEIGHT_HALF(snla) \ - ((snla && (snla->flag & SNLA_NOSTRIPCURVES)) ? (0.4f * U.widget_unit) : (0.6f * U.widget_unit)) #define NLACHANNEL_SKIP (0.1f * U.widget_unit) #define NLACHANNEL_STEP(snla) (NLACHANNEL_HEIGHT(snla) + NLACHANNEL_SKIP) +/* Additional offset to give some room at the end. */ +#define NLACHANNEL_TOT_HEIGHT(snla, item_amount) \ + (-NLACHANNEL_FIRST_TOP(snla) + NLACHANNEL_STEP(snla) * (item_amount + 1)) /* channel widths */ #define NLACHANNEL_NAMEWIDTH (10 * U.widget_unit) @@ -611,6 +615,9 @@ void ANIM_set_active_channel(bAnimContext *ac, * as appropriate according to animation context */ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, struct AnimData *adt, struct FCurve *fcu); +/* Unlink the action from animdata if it's empty. */ +bool ANIM_remove_empty_action_from_animdata(struct AnimData *adt); + /* ************************************************ */ /* DRAWING API */ /* anim_draw.c */ diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h index ba5a6a8a339..5bd806b3dbf 100644 --- a/source/blender/editors/include/ED_image.h +++ b/source/blender/editors/include/ED_image.h @@ -71,9 +71,6 @@ void ED_space_image_scopes_update(const struct bContext *C, void ED_space_image_paint_update(struct Main *bmain, struct wmWindowManager *wm, struct Scene *scene); -void ED_space_image_uv_sculpt_update(struct Main *bmain, - struct wmWindowManager *wm, - struct Scene *scene); void ED_image_get_uv_aspect(struct Image *ima, struct ImageUser *iuser, float *aspx, float *aspy); void ED_image_mouse_pos(struct SpaceImage *sima, diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 543b2a5781f..264eb6abdf1 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -142,6 +142,13 @@ void ED_area_do_mgs_subscribe_for_tool_header(const struct bContext *C, struct ScrArea *sa, struct ARegion *ar, struct wmMsgBus *mbus); +void ED_area_do_mgs_subscribe_for_tool_ui(const struct bContext *C, + struct WorkSpace *workspace, + struct Scene *scene, + struct bScreen *screen, + struct ScrArea *sa, + struct ARegion *ar, + struct wmMsgBus *mbus); /* message bus */ void ED_region_message_subscribe(struct bContext *C, diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h index 3cbeab247ef..c515d501a8d 100644 --- a/source/blender/editors/include/ED_screen_types.h +++ b/source/blender/editors/include/ED_screen_types.h @@ -108,15 +108,29 @@ typedef struct AZone { float alpha; } AZone; -/* actionzone type */ +/** Action-Zone Type: #AZone.type */ enum { - /* corner widgets for splitting areas */ + /** + * Corner widgets for: + * - Splitting areas. + * - Swapping areas (Ctrl). + * - Copying the area into a new window (Shift). + */ AZONE_AREA = 1, - /* when a region is collapsed, draw a handle to expose */ + /** + * Use for region show/hide state: + * - When a region is collapsed, draw a handle to expose. + * - When a region is expanded, use the action zone to resize the region. + */ AZONE_REGION, - /* when in editor fullscreen draw a corner to go to normal mode */ + /** + * Used when in editor fullscreen draw a corner to return to normal mode. + */ AZONE_FULLSCREEN, - /* Hotspot azone around scrollbars to show/hide them. */ + /** + * Hotspot azone around scroll-bars to show/hide them. + * Only show the scroll-bars when the cursor is close. + */ AZONE_REGION_SCROLL, }; diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index 9259afd1d5f..8dd2dab5209 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -178,7 +178,6 @@ void ED_uvedit_add_simple_uvs(struct Main *bmain, struct Scene *scene, struct Ob /* uvedit_draw.c */ void ED_image_draw_cursor(struct ARegion *ar, const float cursor[2]); void ED_uvedit_draw_main(struct SpaceImage *sima, - struct ARegion *ar, struct Scene *scene, struct ViewLayer *view_layer, struct Object *obedit, diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index caa202c46a8..fd51419a3ee 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -54,6 +54,7 @@ struct RenderEngineType; struct Scene; struct ScrArea; struct View3D; +struct View3DShading; struct ViewContext; struct ViewLayer; struct WorkSpace; @@ -584,16 +585,6 @@ void ED_view3d_draw_setup_view(struct wmWindow *win, float winmat[4][4], const struct rcti *rect); -enum { - V3D_OFSDRAW_NONE = (0), - - V3D_OFSDRAW_USE_FULL_SAMPLE = (1 << 0), - - /* Only works with ED_view3d_draw_offscreen_imbuf_simple(). */ - V3D_OFSDRAW_USE_GPENCIL = (1 << 1), - V3D_OFSDRAW_USE_CAMERA_DOF = (1 << 2), -}; - struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Depsgraph *depsgraph, struct Scene *scene, int drawtype, @@ -610,6 +601,7 @@ struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Depsgraph *depsgraph, char err_out[256]); struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(struct Depsgraph *depsgraph, struct Scene *scene, + struct View3DShading *shading_override, int drawtype, struct Object *camera, int width, diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index 2f624007c98..b4d345a3344 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -139,12 +139,12 @@ DEF_ICON_BLANK(145) DEF_ICON_BLANK(146) DEF_ICON(SCRIPT) DEF_ICON_MODIFIER(PARTICLES) -DEF_ICON(PHYSICS) -DEF_ICON(SPEAKER) +DEF_ICON_MODIFIER(PHYSICS) +DEF_ICON_OBJECT_DATA(SPEAKER) DEF_ICON_BLANK(151) DEF_ICON(TOOL_SETTINGS) -DEF_ICON(SHADERFX) -DEF_ICON(MODIFIER) +DEF_ICON_MODIFIER(SHADERFX) +DEF_ICON_MODIFIER(MODIFIER) DEF_ICON_BLANK(155) DEF_ICON_BLANK(156) DEF_ICON_BLANK(157) @@ -163,7 +163,7 @@ DEF_ICON(FILEBROWSER) DEF_ICON(IMAGE) DEF_ICON(INFO) DEF_ICON(SEQUENCE) -DEF_ICON(TEXT) +DEF_ICON_OBJECT_DATA(TEXT) DEF_ICON_BLANK(174) DEF_ICON(SOUND) DEF_ICON(ACTION) @@ -214,24 +214,24 @@ DEF_ICON_BLANK(77b) DEF_ICON(SCENE_DATA) DEF_ICON(RENDERLAYERS) DEF_ICON_SHADING(WORLD_DATA) -DEF_ICON(OBJECT_DATA) -DEF_ICON(MESH_DATA) -DEF_ICON(CURVE_DATA) -DEF_ICON(META_DATA) -DEF_ICON(LATTICE_DATA) -DEF_ICON_SHADING(LIGHT_DATA) +DEF_ICON_OBJECT(OBJECT_DATA) +DEF_ICON_OBJECT_DATA(MESH_DATA) +DEF_ICON_OBJECT_DATA(CURVE_DATA) +DEF_ICON_OBJECT_DATA(META_DATA) +DEF_ICON_OBJECT_DATA(LATTICE_DATA) +DEF_ICON_OBJECT_DATA(LIGHT_DATA) DEF_ICON_SHADING(MATERIAL_DATA) DEF_ICON_SHADING(TEXTURE_DATA) DEF_ICON(ANIM_DATA) -DEF_ICON(CAMERA_DATA) -DEF_ICON(PARTICLE_DATA) +DEF_ICON_OBJECT_DATA(CAMERA_DATA) +DEF_ICON_OBJECT_DATA(PARTICLE_DATA) DEF_ICON(LIBRARY_DATA_DIRECT) DEF_ICON_COLLECTION(GROUP) -DEF_ICON(ARMATURE_DATA) +DEF_ICON_OBJECT_DATA(ARMATURE_DATA) DEF_ICON(COMMUNITY) -DEF_ICON(BONE_DATA) +DEF_ICON_OBJECT_DATA(BONE_DATA) DEF_ICON_MODIFIER(CONSTRAINT) -DEF_ICON(SHAPEKEY_DATA) +DEF_ICON_OBJECT_DATA(SHAPEKEY_DATA) DEF_ICON_MODIFIER(CONSTRAINT_BONE) DEF_ICON(CAMERA_STEREO) DEF_ICON(PACKAGE) @@ -245,8 +245,8 @@ DEF_ICON(FILE) DEF_ICON(FCURVE) DEF_ICON(FONT_DATA) DEF_ICON(RENDER_RESULT) -DEF_ICON(SURFACE_DATA) -DEF_ICON(EMPTY_DATA) +DEF_ICON_OBJECT_DATA(SURFACE_DATA) +DEF_ICON_OBJECT_DATA(EMPTY_DATA) DEF_ICON(PRESET) DEF_ICON(RENDER_ANIMATION) DEF_ICON(RENDER_STILL) @@ -254,7 +254,7 @@ DEF_ICON(LIBRARY_DATA_BROKEN) DEF_ICON(BOIDS) DEF_ICON(STRANDS) DEF_ICON(LIBRARY_DATA_INDIRECT) -DEF_ICON(GREASEPENCIL) +DEF_ICON_OBJECT_DATA(GREASEPENCIL) DEF_ICON_SHADING(LINE_DATA) DEF_ICON(LIBRARY_DATA_OVERRIDE) DEF_ICON(GROUP_BONE) @@ -363,11 +363,11 @@ DEF_ICON(MESH_TORUS) DEF_ICON(MESH_CONE) DEF_ICON(MESH_CAPSULE) DEF_ICON(EMPTY_SINGLE_ARROW) -DEF_ICON_SHADING(LIGHT_POINT) -DEF_ICON_SHADING(LIGHT_SUN) -DEF_ICON_SHADING(LIGHT_SPOT) -DEF_ICON_SHADING(LIGHT_HEMI) -DEF_ICON_SHADING(LIGHT_AREA) +DEF_ICON_OBJECT_DATA(LIGHT_POINT) +DEF_ICON_OBJECT_DATA(LIGHT_SUN) +DEF_ICON_OBJECT_DATA(LIGHT_SPOT) +DEF_ICON_OBJECT_DATA(LIGHT_HEMI) +DEF_ICON_OBJECT_DATA(LIGHT_AREA) DEF_ICON(CUBE) DEF_ICON(SPHERE) DEF_ICON(CONE) @@ -393,9 +393,9 @@ DEF_ICON(CURVE_BEZCIRCLE) DEF_ICON(CURVE_NCURVE) DEF_ICON(CURVE_NCIRCLE) DEF_ICON(CURVE_PATH) -DEF_ICON_SHADING(LIGHTPROBE_CUBEMAP) -DEF_ICON_SHADING(LIGHTPROBE_PLANAR) -DEF_ICON_SHADING(LIGHTPROBE_GRID) +DEF_ICON_OBJECT_DATA(LIGHTPROBE_CUBEMAP) +DEF_ICON_OBJECT_DATA(LIGHTPROBE_PLANAR) +DEF_ICON_OBJECT_DATA(LIGHTPROBE_GRID) DEF_ICON_BLANK(406) DEF_ICON_BLANK(407) DEF_ICON(COLOR_RED) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index d6cfe7aea1f..18960853011 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -520,6 +520,7 @@ 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); +bool UI_block_can_add_separator(const uiBlock *block); /* interface_region_menu_popup.c */ /** diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 18962f9d9da..af94889a1bb 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -92,6 +92,7 @@ typedef enum ThemeColorID { TH_VERTEX_UNREFERENCED, TH_VERTEX_SIZE, TH_OUTLINE_WIDTH, + TH_OBCENTER_DIA, TH_EDGE, TH_EDGE_SELECT, TH_EDGE_SEAM, @@ -356,7 +357,7 @@ void UI_GetThemeColorType4fv(int colorid, int spacetype, float col[4]); void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4]); void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4]); -// get four colour values ranged between 0 and 255; includes the alpha channel +// get four color values ranged between 0 and 255; includes the alpha channel void UI_GetThemeColorShadeAlpha4ubv(int colorid, int coloffset, int alphaoffset, diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index a16c1efd6cf..064951d40ed 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -56,40 +56,7 @@ enum eView2D_CommonViewTypes { V2D_COMMONVIEW_PANELS_UI, }; -/* ---- Defines for Scroller/Grid Arguments ----- */ - -/* 'dummy' argument to pass when argument is irrelevant */ -#define V2D_ARG_DUMMY -1 - -/* Grid units */ -enum eView2D_Units { - /* for drawing time */ - V2D_UNIT_SECONDS = 0, - V2D_UNIT_FRAMES, - V2D_UNIT_FRAMESCALE, - - /* for drawing values */ - V2D_UNIT_VALUES, -}; - -/* clamping of grid values to whole numbers */ -enum eView2D_Clamp { - V2D_GRID_NOCLAMP = 0, - V2D_GRID_CLAMP, -}; - -/* flags for grid-lines to draw */ -enum eView2D_Gridlines { - V2D_HORIZONTAL_LINES = (1 << 0), - V2D_VERTICAL_LINES = (1 << 1), - V2D_HORIZONTAL_AXIS = (1 << 2), - V2D_VERTICAL_AXIS = (1 << 3), - V2D_HORIZONTAL_FINELINES = (1 << 4), - - V2D_GRIDLINES_MAJOR = (V2D_VERTICAL_LINES | V2D_VERTICAL_AXIS | V2D_HORIZONTAL_LINES | - V2D_HORIZONTAL_AXIS), - V2D_GRIDLINES_ALL = (V2D_GRIDLINES_MAJOR | V2D_HORIZONTAL_FINELINES), -}; +/* ---- Defines for Scroller Arguments ----- */ /* ------ Defines for Scrollers ----- */ @@ -124,7 +91,6 @@ enum eView2D_Gridlines { /* Type definitions: */ struct View2D; -struct View2DGrid; struct View2DScrollers; struct ARegion; @@ -135,7 +101,6 @@ struct bScreen; struct rctf; struct wmKeyConfig; -typedef struct View2DGrid View2DGrid; typedef struct View2DScrollers View2DScrollers; /* ----------------------------------------- */ @@ -159,62 +124,60 @@ bool UI_view2d_tab_set(struct View2D *v2d, int tab); void UI_view2d_zoom_cache_reset(void); /* view matrix operations */ -void UI_view2d_view_ortho(struct View2D *v2d); +void UI_view2d_view_ortho(const struct View2D *v2d); void UI_view2d_view_orthoSpecial(struct ARegion *ar, struct View2D *v2d, const bool xaxis); void UI_view2d_view_restore(const struct bContext *C); /* grid drawing */ -View2DGrid *UI_view2d_grid_calc(struct Scene *scene, - struct View2D *v2d, - short xunits, - short xclamp, - short yunits, - short yclamp, - int winx, - int winy); -void UI_view2d_grid_draw(struct View2D *v2d, View2DGrid *grid, int flag); void UI_view2d_constant_grid_draw(struct View2D *v2d, float step); void UI_view2d_multi_grid_draw( struct View2D *v2d, int colorid, float step, int level_size, int totlevels); -void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy); -void UI_view2d_grid_draw_numbers_horizontal(const struct Scene *scene, - const struct View2D *v2d, - const View2DGrid *grid, - const struct rcti *rect, - int unit, - bool whole_numbers_only); -void UI_view2d_grid_draw_numbers_vertical(const struct Scene *scene, - const struct View2D *v2d, - const View2DGrid *grid, - const struct rcti *rect, - int unit, - float text_offset); -void UI_view2d_grid_free(View2DGrid *grid); + +void UI_view2d_draw_lines_y__values(const struct View2D *v2d); +void UI_view2d_draw_lines_x__values(const struct View2D *v2d); +void UI_view2d_draw_lines_x__discrete_values(const struct View2D *v2d); +void UI_view2d_draw_lines_x__discrete_time(const struct View2D *v2d, const struct Scene *scene); +void UI_view2d_draw_lines_x__discrete_frames_or_seconds(const struct View2D *v2d, + const struct Scene *scene, + bool display_seconds); +void UI_view2d_draw_lines_x__frames_or_seconds(const struct View2D *v2d, + const struct Scene *scene, + bool display_seconds); + +float UI_view2d_grid_resolution_x__frames_or_seconds(const struct View2D *v2d, + const struct Scene *scene, + bool display_seconds); +float UI_view2d_grid_resolution_y__values(const struct View2D *v2d); + +/* scale indicator text drawing */ +void UI_view2d_draw_scale_y__values(const struct ARegion *ar, + const struct View2D *v2d, + const struct rcti *rect, + int colorid); +void UI_view2d_draw_scale_y__block(const struct ARegion *ar, + const struct View2D *v2d, + const struct rcti *rect, + int colorid); +void UI_view2d_draw_scale_x__discrete_frames_or_seconds(const struct ARegion *ar, + const struct View2D *v2d, + const struct rcti *rect, + const struct Scene *scene, + bool display_seconds, + int colorid); +void UI_view2d_draw_scale_x__frames_or_seconds(const struct ARegion *ar, + const struct View2D *v2d, + const struct rcti *rect, + const struct Scene *scene, + bool display_seconds, + int colorid); /* scrollbar drawing */ -View2DScrollers *UI_view2d_scrollers_calc(const struct bContext *C, - struct View2D *v2d, - const struct rcti *mask_custom, - short xunits, - short xclamp, - short yunits, - short yclamp); -void UI_view2d_scrollers_draw(const struct bContext *C, - struct View2D *v2d, - View2DScrollers *scrollers); +View2DScrollers *UI_view2d_scrollers_calc(struct View2D *v2d, const struct rcti *mask_custom); +void UI_view2d_scrollers_draw(struct View2D *v2d, View2DScrollers *scrollers); void UI_view2d_scrollers_free(View2DScrollers *scrollers); /* list view tools */ -void UI_view2d_listview_cell_to_view(struct View2D *v2d, - float columnwidth, - float rowheight, - float startx, - float starty, - int column, - int row, - struct rctf *rect); -void UI_view2d_listview_view_to_cell(struct View2D *v2d, - float columnwidth, +void UI_view2d_listview_view_to_cell(float columnwidth, float rowheight, float startx, float starty, @@ -222,15 +185,6 @@ void UI_view2d_listview_view_to_cell(struct View2D *v2d, float viewy, int *column, int *row); -void UI_view2d_listview_visible_cells(struct View2D *v2d, - float columnwidth, - float rowheight, - float startx, - float starty, - int *column_min, - int *column_max, - int *row_min, - int *row_max); /* coordinate conversion */ float UI_view2d_region_to_view_x(const struct View2D *v2d, float x); diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt index 622f89b1f87..6ab1761e7f8 100644 --- a/source/blender/editors/interface/CMakeLists.txt +++ b/source/blender/editors/interface/CMakeLists.txt @@ -30,8 +30,8 @@ set(INC ../../makesrna ../../python ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS @@ -72,6 +72,7 @@ set(SRC interface_widgets.c resources.c view2d.c + view2d_draw.c view2d_ops.c interface_eyedropper_intern.h diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index a5abbb2b86f..42f4b4495c3 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1299,10 +1299,10 @@ static bool ui_but_event_property_operator_string(const bContext *C, } } else { - //puts("other id"); + // puts("other id"); } - //printf("prop shortcut: '%s' (%s)\n", RNA_property_identifier(prop), data_path); + // printf("prop shortcut: '%s' (%s)\n", RNA_property_identifier(prop), data_path); } /* we have a datapath! */ @@ -1615,7 +1615,7 @@ void ui_fontscale(short *points, float aspect) /* for some reason scaling fonts goes too fast compared to widget size */ /* XXX not true anymore? (ton) */ - //aspect = sqrt(aspect); + // aspect = sqrt(aspect); pointsf /= aspect; if (aspect > 1.0f) { diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c index b6d9863f9b5..748d6e6c183 100644 --- a/source/blender/editors/interface/interface_context_menu.c +++ b/source/blender/editors/interface/interface_context_menu.c @@ -148,7 +148,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg) if (prop) { prop = IDP_CopyProperty(prop); } - WM_keymap_properties_reset(kmi, prop); + WM_keymap_item_properties_reset(kmi, prop); /* update and get pointers again */ WM_keyconfig_update(wm); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 671a004f9fe..640d5127446 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1610,16 +1610,10 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const immBindBuiltinProgram(GPU_SHADER_2D_CHECKER); /* Drawing the checkerboard. */ - immUniform4f("color1", - UI_ALPHA_CHECKER_DARK / 255.0f, - UI_ALPHA_CHECKER_DARK / 255.0f, - UI_ALPHA_CHECKER_DARK / 255.0f, - 1.0f); - immUniform4f("color2", - UI_ALPHA_CHECKER_LIGHT / 255.0f, - UI_ALPHA_CHECKER_LIGHT / 255.0f, - UI_ALPHA_CHECKER_LIGHT / 255.0f, - 1.0f); + const float checker_dark = UI_ALPHA_CHECKER_DARK / 255.0f; + const float checker_light = UI_ALPHA_CHECKER_LIGHT / 255.0f; + immUniform4f("color1", checker_dark, checker_dark, checker_dark, 1.0f); + immUniform4f("color2", checker_light, checker_light, checker_light, 1.0f); immUniform1i("size", 8); immRectf(pos_id, x1, y1, x1 + sizex, rect->ymax); immUnbindProgram(); @@ -1804,12 +1798,12 @@ static void ui_draw_but_curve_grid( 1.0f); immBegin(GPU_PRIM_LINES, (int)line_count * 2); - while (fx < rect->xmax) { + while (fx <= rect->xmax) { immVertex2f(pos, fx, rect->ymin); immVertex2f(pos, fx, rect->ymax); fx += dx; } - while (fy < rect->ymax) { + while (fy <= rect->ymax) { immVertex2f(pos, rect->xmin, fy); immVertex2f(pos, rect->xmax, fy); fy += dy; @@ -1849,6 +1843,17 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons cumap = (CurveMapping *)but->poin; } + /* calculate offset and zoom */ + float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / BLI_rctf_size_x(&cumap->curr); + float zoomy = (BLI_rcti_size_y(rect) - 2.0f) / BLI_rctf_size_y(&cumap->curr); + float offsx = cumap->curr.xmin - (1.0f / zoomx); + float offsy = cumap->curr.ymin - (1.0f / zoomy); + + /* exit early if too narrow */ + if (zoomx == 0.0f) { + return; + } + CurveMap *cuma = &cumap->cm[cumap->cur]; /* need scissor test, curve can draw outside of boundary */ @@ -1867,12 +1872,6 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons 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); - float zoomy = (BLI_rcti_size_y(rect) - 2.0f) / BLI_rctf_size_y(&cumap->curr); - float offsx = cumap->curr.xmin - (1.0f / zoomx); - float offsy = cumap->curr.ymin - (1.0f / zoomy); - /* Do this first to not mess imm context */ if (but->a1 == UI_GRAD_H) { /* magic trigger for curve backgrounds */ diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 608ef69c4cc..111dfe01319 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3797,7 +3797,7 @@ static void ui_block_open_begin(bContext *C, uiBut *but, uiHandleButtonData *dat #endif /* this makes adjacent blocks auto open from now on */ - //if (but->block->auto_open == 0) { + // if (but->block->auto_open == 0) { // but->block->auto_open = 1; //} } @@ -3949,6 +3949,9 @@ static int ui_do_but_HOTKEYEVT(bContext *C, if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { return WM_UI_HANDLER_CONTINUE; } + else if (event->type == UNKNOWNKEY) { + return WM_UI_HANDLER_CONTINUE; + } if (event->type == LEFTMOUSE && event->val == KM_PRESS) { /* only cancel if click outside the button */ diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 4b66461e186..7e295f83390 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -1826,15 +1826,14 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id) ui_id_icon_render(C, id, true); } else { - WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = CTX_data_active_object(C); const EnumPropertyItem *items = NULL; ePaintMode paint_mode = PAINT_MODE_INVALID; ScrArea *sa = CTX_wm_area(C); char space_type = sa->spacetype; - /* When in an unsupported space. */ - if (!ELEM(space_type, SPACE_VIEW3D, SPACE_IMAGE)) { - space_type = workspace->tools_space_type; + /* Fallback to 3D view. */ + if (space_type == SPACE_PROPERTIES) { + space_type = SPACE_VIEW3D; } /* XXX: this is not nice, should probably make brushes @@ -1856,17 +1855,11 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id) } } else if (space_type == SPACE_IMAGE) { - int sima_mode; if (sa->spacetype == space_type) { - SpaceImage *sima = sa->spacedata.first; - sima_mode = sima->mode; - } - else { - sima_mode = workspace->tools_mode; - } - - if (sima_mode == SI_MODE_PAINT) { - paint_mode = PAINT_MODE_TEXTURE_2D; + const SpaceImage *sima = sa->spacedata.first; + if (sima->mode == SI_MODE_PAINT) { + paint_mode = PAINT_MODE_TEXTURE_2D; + } } } diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index cfedd40bfd1..15e507483ad 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -304,10 +304,14 @@ static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, bool layout->item.flag |= UI_ITEM_MIN; } const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; - /* it may seem odd that the icon only adds (unit_x / 4) - * but taking margins into account its fine */ - return (UI_fontstyle_string_width(fstyle, name) + - (unit_x * ((compact ? 1.25f : 1.50f) + (icon ? 0.25f : 0.0f)))); + float margin = compact ? 1.25 : 1.50; + if (icon) { + /* It may seem odd that the icon only adds (unit_x / 4) + * but taking margins into account its fine, except + * in compact mode a bit more margin is required. */ + margin += compact ? 0.35 : 0.25; + } + return UI_fontstyle_string_width(fstyle, name) + (unit_x * margin); } else { return unit_x * 10; @@ -840,7 +844,7 @@ static void ui_item_enum_expand_exec(uiLayout *layout, /* Separate items, potentially with a label. */ if (next_item->identifier) { /* Item without identifier but with name: - * Add group label for the following items. */ + * Add group label for the following items. */ if (item->name) { if (!is_first) { uiItemS(block->curlayout); @@ -2968,6 +2972,9 @@ void uiItemS_ex(uiLayout *layout, float factor) { uiBlock *block = layout->root->block; bool is_menu = ui_block_is_menu(block); + if (is_menu && !UI_block_can_add_separator(block)) { + return; + } int space = (is_menu) ? 0.45f * UI_UNIT_X : 0.3f * UI_UNIT_X; space *= factor; diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index ae28c09b7e2..87e58a4b3b5 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -701,11 +701,10 @@ void ui_draw_aligned_panel(uiStyle *style, const bool is_closed_x = (panel->flag & PNL_CLOSEDX) ? true : false; const bool is_closed_y = (panel->flag & PNL_CLOSEDY) ? true : false; const bool is_subpanel = (panel->type && panel->type->parent); - const bool show_drag = - (!is_subpanel && - /* FIXME(campbell): currently no background means floating panel which can't be dragged. - * This may be changed in future. */ - show_background); + const bool show_drag = (!is_subpanel && + /* FIXME(campbell): currently no background means floating panel which + * can't be dragged. This may be changed in future. */ + show_background); if (panel->paneltab) { return; @@ -1672,7 +1671,7 @@ static void ui_handle_panel_header( if (mx <= block->rect.xmax - 8 - PNL_ICON) { button = 2; } - //else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) { + // else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) { // button = 1; //} } @@ -2064,7 +2063,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) BLF_enable(fontid, BLF_ROTATION); BLF_rotation(fontid, M_PI_2); - //UI_fontstyle_set(&style->widget); + // UI_fontstyle_set(&style->widget); ui_fontscale(&fstyle_points, aspect / (U.pixelsize * 1.1f)); BLF_size(fontid, fstyle_points, U.dpi); @@ -2569,7 +2568,7 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat * is very hard to control and use, and has no real benefit." - BillRey * Aligorith, 2009Sep */ - //test_add_new_tabs(ar); // also copies locations of tabs in dragged panel + // test_add_new_tabs(ar); // also copies locations of tabs in dragged panel check_panel_overlap(ar, NULL); /* clears */ } diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c index e1f91be1631..b0fd0cdc35f 100644 --- a/source/blender/editors/interface/interface_query.c +++ b/source/blender/editors/interface/interface_query.c @@ -473,6 +473,15 @@ bool UI_block_is_empty(const uiBlock *block) return true; } +bool UI_block_can_add_separator(const uiBlock *block) +{ + if (ui_block_is_menu(block) && !ui_block_is_pie_menu(block)) { + const uiBut *but = block->buttons.last; + return (but && !ELEM(but->type, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR)); + } + return true; +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c index 110c8827849..f149ccd626c 100644 --- a/source/blender/editors/interface/interface_region_popover.c +++ b/source/blender/editors/interface/interface_region_popover.c @@ -257,6 +257,8 @@ static void ui_block_free_func_POPOVER(uiPopupBlockHandle *UNUSED(handle), void uiPopupBlockHandle *ui_popover_panel_create( bContext *C, ARegion *butregion, uiBut *but, uiMenuCreateFunc menu_func, void *arg) { + wmWindow *window = CTX_wm_window(C); + /* Create popover, buttons are created from callback. */ uiPopover *pup = MEM_callocN(sizeof(uiPopover), __func__); pup->but = but; @@ -271,7 +273,11 @@ uiPopupBlockHandle *ui_popover_panel_create( pup->menu_arg = arg; #ifdef USE_UI_POPOVER_ONCE - pup->is_once = true; + { + /* Ideally this would be passed in. */ + const wmEvent *event = window->eventstate; + pup->is_once = (event->type == LEFTMOUSE) && (event->val == KM_PRESS); + } #endif /* Create popup block. */ @@ -283,7 +289,6 @@ uiPopupBlockHandle *ui_popover_panel_create( /* Add handlers. If attached to a button, the button will already * add a modal handler and pass on events. */ if (!but) { - wmWindow *window = CTX_wm_window(C); UI_popup_handlers_add(C, &window->modalhandlers, handle, 0); WM_event_add_mousemove(C); handle->popup = true; diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c index 11b2e069d6c..c4bcd7074d8 100644 --- a/source/blender/editors/interface/interface_region_popup.c +++ b/source/blender/editors/interface/interface_region_popup.c @@ -236,10 +236,13 @@ static void ui_popup_block_position(wmWindow *window, } /* Compute offset based on direction. */ - int offset_x = 0, offset_y = 0; + float offset_x = 0, offset_y = 0; + + /* Ensure buttons don't come between the parent button and the popup, see: T63566. */ + const float offset_overlap = max_ff(U.pixelsize, 1.0f); if (dir1 == UI_DIR_LEFT) { - offset_x = butrct.xmin - block->rect.xmax; + offset_x = (butrct.xmin - block->rect.xmax) + offset_overlap; if (dir2 == UI_DIR_UP) { offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING; } @@ -248,7 +251,7 @@ static void ui_popup_block_position(wmWindow *window, } } else if (dir1 == UI_DIR_RIGHT) { - offset_x = butrct.xmax - block->rect.xmin; + offset_x = (butrct.xmax - block->rect.xmin) - offset_overlap; if (dir2 == UI_DIR_UP) { offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING; } @@ -257,7 +260,7 @@ static void ui_popup_block_position(wmWindow *window, } } else if (dir1 == UI_DIR_UP) { - offset_y = butrct.ymax - block->rect.ymin; + offset_y = (butrct.ymax - block->rect.ymin) - offset_overlap; if (dir2 == UI_DIR_RIGHT) { offset_x = butrct.xmax - block->rect.xmax + center_x; } @@ -271,7 +274,7 @@ static void ui_popup_block_position(wmWindow *window, } } else if (dir1 == UI_DIR_DOWN) { - offset_y = butrct.ymin - block->rect.ymax; + offset_y = (butrct.ymin - block->rect.ymax) + offset_overlap; if (dir2 == UI_DIR_RIGHT) { offset_x = butrct.xmax - block->rect.xmax + center_x; } diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c index 930f9e3fe1f..251bc86a3f5 100644 --- a/source/blender/editors/interface/interface_region_search.c +++ b/source/blender/editors/interface/interface_region_search.c @@ -598,7 +598,7 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiBut *but winx = WM_window_pixels_x(win); // winy = WM_window_pixels_y(win); /* UNUSED */ - //wm_window_get_size(win, &winx, &winy); + // wm_window_get_size(win, &winx, &winy); if (rect_i.xmax > winx) { /* super size */ diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index 017b7dea352..4a9c7b689c1 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -1063,7 +1063,7 @@ static ARegion *ui_tooltip_create_with_data(bContext *C, field->geom.x_pos = x_pos; } - //fontw *= aspect; + // fontw *= aspect; BLF_disable(data->fstyle.uifont_id, font_flag); BLF_disable(blf_mono_font, font_flag); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index bbff2c16636..e96141eaa05 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -798,7 +798,7 @@ static void template_ID(bContext *C, char name[UI_MAX_NAME_STR]; const bool user_alert = (id->us <= 0); - //text_idbutton(id, name); + // text_idbutton(id, name); name[0] = '\0'; but = uiDefButR(block, UI_BTYPE_TEXT, @@ -4282,7 +4282,7 @@ static void curvemap_buttons_layout(uiLayout *layout, UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), NULL); /* curve itself */ - size = uiLayoutGetWidth(layout); + size = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X); row = uiLayoutRow(layout, false); uiDefBut( block, UI_BTYPE_CURVE, 0, "", 0, 0, size, 8.0f * UI_UNIT_X, cumap, 0.0f, 1.0f, bg, 0, ""); @@ -4997,7 +4997,7 @@ static void uilist_filter_items_default(struct uiList *ui_list, dyn_data->items_shown++; do_order = order_by_name; } - //printf("%s: '%s' matches '%s'\n", __func__, name, filter); + // printf("%s: '%s' matches '%s'\n", __func__, name, filter); } else if (filter_exclude) { dyn_data->items_shown++; @@ -5321,16 +5321,16 @@ void uiTemplateList(uiLayout *layout, dyn_data->items_len = dyn_data->items_shown = RNA_property_collection_length(dataptr, prop); } else { - //printf("%s: filtering...\n", __func__); + // printf("%s: filtering...\n", __func__); filter_items(ui_list, C, dataptr, propname); - //printf("%s: filtering done.\n", __func__); + // printf("%s: filtering done.\n", __func__); } items_shown = dyn_data->items_shown; if (items_shown >= 0) { bool activei_mapping_pending = true; items_ptr = MEM_mallocN(sizeof(_uilist_item) * items_shown, __func__); - //printf("%s: items shown: %d.\n", __func__, items_shown); + // printf("%s: items shown: %d.\n", __func__, items_shown); RNA_PROP_BEGIN (dataptr, itemptr, prop) { if (!dyn_data->items_filter_flags || ((dyn_data->items_filter_flags[i] & UILST_FLT_ITEM) ^ filter_exclude)) { @@ -5342,7 +5342,7 @@ void uiTemplateList(uiLayout *layout, else { ii = order_reverse ? items_shown - ++idx : idx++; } - //printf("%s: ii: %d\n", __func__, ii); + // printf("%s: ii: %d\n", __func__, ii); items_ptr[ii].item = itemptr; items_ptr[ii].org_idx = i; items_ptr[ii].flt_flag = dyn_data->items_filter_flags ? dyn_data->items_filter_flags[i] : @@ -6711,17 +6711,18 @@ void uiTemplateCacheFile(uiLayout *layout, bContext *C, PointerRNA *ptr, const c uiItemR(row, &fileptr, "override_frame", 0, "Override Frame", ICON_NONE); row = uiLayoutRow(layout, false); - uiLayoutSetEnabled(row, RNA_boolean_get(&fileptr, "override_frame")); + uiLayoutSetActive(row, RNA_boolean_get(&fileptr, "override_frame")); uiItemR(row, &fileptr, "frame", 0, "Frame", ICON_NONE); row = uiLayoutRow(layout, false); uiItemR(row, &fileptr, "frame_offset", 0, "Frame Offset", ICON_NONE); + uiLayoutSetActive(row, !RNA_boolean_get(&fileptr, "is_sequence")); row = uiLayoutRow(layout, false); uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE); row = uiLayoutRow(layout, false); - uiLayoutSetEnabled(row, (sbuts->mainb == BCONTEXT_CONSTRAINT)); + uiLayoutSetActive(row, (sbuts->mainb == BCONTEXT_CONSTRAINT)); uiItemR(row, &fileptr, "scale", 0, "Scale", ICON_NONE); /* TODO: unused for now, so no need to expose. */ diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 32ec7910b36..a9cd2f9cee1 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2787,8 +2787,8 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir /* menu is 2nd level or deeper */ if (flag & UI_BLOCK_POPUP) { - //rect->ymin -= 4.0; - //rect->ymax += 4.0; + // rect->ymin -= 4.0; + // rect->ymax += 4.0; } else if (direction == UI_DIR_DOWN) { roundboxalign = (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT); @@ -4686,7 +4686,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct } if (wt) { - //rcti disablerect = *rect; /* rect gets clipped smaller for text */ + // rcti disablerect = *rect; /* rect gets clipped smaller for text */ int roundboxalign, state, drawflag; bool disabled = false; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index fa56dc04143..8ed7dd87e9f 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -366,6 +366,10 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) case TH_OUTLINE_WIDTH: cp = &ts->outline_width; break; + case TH_OBCENTER_DIA: + cp = &ts->obcenter_dia; + break; + break; case TH_EDGE: cp = ts->edge; break; @@ -1352,7 +1356,9 @@ bool UI_GetIconThemeColor4fv(int colorid, float col[4]) /* Only colored icons in outliner and popups, overall UI is intended * to stay monochrome and out of the way except a few places where it * is important to communicate different data types. */ - if (!((theme_spacetype == SPACE_OUTLINER) || (theme_regionid == RGN_TYPE_TEMPORARY))) { + if (!((theme_spacetype == SPACE_OUTLINER && theme_regionid == RGN_TYPE_WINDOW) || + (theme_spacetype == SPACE_PROPERTIES && theme_regionid == RGN_TYPE_NAV_BAR) || + (theme_regionid == RGN_TYPE_TEMPORARY))) { return false; } diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 952778cfc6d..9de7a33b757 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -31,12 +31,14 @@ #include "DNA_scene_types.h" #include "DNA_userdef_types.h" +#include "BLI_array.h" #include "BLI_utildefines.h" #include "BLI_link_utils.h" #include "BLI_rect.h" #include "BLI_math.h" #include "BLI_memarena.h" #include "BLI_timecode.h" +#include "BLI_string.h" #include "BKE_context.h" #include "BKE_screen.h" @@ -1117,7 +1119,7 @@ void UI_view2d_zoom_cache_reset(void) /* View Matrix Setup */ /* mapping function to ensure 'cur' draws extended over the area where sliders are */ -static void view2d_map_cur_using_mask(View2D *v2d, rctf *r_curmasked) +static void view2d_map_cur_using_mask(const View2D *v2d, rctf *r_curmasked) { *r_curmasked = v2d->cur; @@ -1149,7 +1151,7 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *r_curmasked) } /* Set view matrices to use 'cur' rect as viewing frame for View2D drawing */ -void UI_view2d_view_ortho(View2D *v2d) +void UI_view2d_view_ortho(const View2D *v2d) { rctf curmasked; const int sizex = BLI_rcti_size_x(&v2d->mask); @@ -1238,338 +1240,6 @@ void UI_view2d_view_restore(const bContext *C) /* *********************************************************************** */ /* Gridlines */ -/* View2DGrid is typedef'd in UI_view2d.h */ -struct View2DGrid { - float dx, dy; /* stepsize (in pixels) between gridlines */ - float startx, starty; /* initial coordinates to start drawing grid from */ - int powerx, powery; /* step as power of 10 */ -}; - -/* --------------- */ - -/* try to write step as a power of 10 */ -static void step_to_grid(float *step, const int unit, int *r_power) -{ - const float loga = (float)log10(*step); - float rem; - - int power = (int)(loga); - - rem = loga - power; - rem = (float)pow(10.0, rem); - - if (loga < 0.0f) { - if (rem < 0.2f) { - rem = 0.2f; - } - else if (rem < 0.5f) { - rem = 0.5f; - } - else { - rem = 1.0f; - } - - *step = rem * (float)pow(10.0, power); - - /* for frames, we want 1.0 frame intervals only */ - if (unit == V2D_UNIT_FRAMES) { - rem = 1.0f; - /* use 2 since there are grid lines drawn in between, - * this way to get 1 line per frame */ - *step = 2.0f; - } - - /* prevents printing 1.0 2.0 3.0 etc */ - if (rem == 1.0f) { - power++; - } - } - else { - if (rem < 2.0f) { - rem = 2.0f; - } - else if (rem < 5.0f) { - rem = 5.0f; - } - else { - rem = 10.0f; - } - - *step = rem * (float)pow(10.0, power); - - power++; - /* prevents printing 1.0, 2.0, 3.0, etc. */ - if (rem == 10.0f) { - power++; - } - } - - *r_power = power; -} - -/** - * Initialize settings necessary for drawing gridlines in a 2d-view - * - * - Currently, will return pointer to View2DGrid struct that needs to - * be freed with UI_view2d_grid_free() - * - Is used for scrollbar drawing too (for units drawing) - * - Units + clamping args will be checked, to make sure they are valid values that can be used - * so it is very possible that we won't return grid at all! - * - * - xunits,yunits = V2D_UNIT_* grid steps in seconds or frames - * - xclamp,yclamp = V2D_CLAMP_* only show whole-number intervals - * - winx = width of region we're drawing to, note: not used but keeping for completeness. - * - winy = height of region we're drawing into - */ -View2DGrid *UI_view2d_grid_calc(Scene *scene, - View2D *v2d, - short xunits, - short xclamp, - short yunits, - short yclamp, - int UNUSED(winx), - int winy) -{ - - View2DGrid *grid; - float space, seconddiv; - - /* check that there are at least some workable args */ - if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) && ELEM(V2D_ARG_DUMMY, yunits, yclamp)) { - return NULL; - } - - /* grid here is allocated... */ - grid = MEM_callocN(sizeof(View2DGrid), "View2DGrid"); - - /* rule: gridstep is minimal GRIDSTEP pixels */ - if (xunits == V2D_UNIT_SECONDS) { - seconddiv = (float)(0.01 * FPS); - } - else { - seconddiv = 1.0f; - } - - /* calculate x-axis grid scale (only if both args are valid) */ - if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) { - space = BLI_rctf_size_x(&v2d->cur); - - if (space != 0.0f) { - const float pixels = (float)BLI_rcti_size_x(&v2d->mask); - if (pixels != 0.0f) { - grid->dx = (U.v2d_min_gridsize * UI_DPI_FAC * space) / (seconddiv * pixels); - step_to_grid(&grid->dx, xunits, &grid->powerx); - grid->dx *= seconddiv; - } - } - - if (xclamp == V2D_GRID_CLAMP) { - CLAMP_MIN(grid->dx, 0.1f); - CLAMP_MIN(grid->powerx, 0); - grid->powerx -= 2; - } - } - - /* calculate y-axis grid scale (only if both args are valid) */ - if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) { - space = BLI_rctf_size_y(&v2d->cur); - if (space != 0.0f) { - const float pixels = (float)winy; - if (pixels != 0.0f) { - grid->dy = U.v2d_min_gridsize * UI_DPI_FAC * space / pixels; - step_to_grid(&grid->dy, yunits, &grid->powery); - } - } - - if (yclamp == V2D_GRID_CLAMP) { - CLAMP_MIN(grid->dy, 1.0f); - CLAMP_MIN(grid->powery, 1); - } - } - - /* calculate start position */ - if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) { - grid->startx = seconddiv * (v2d->cur.xmin / seconddiv - - (float)fmod(v2d->cur.xmin / seconddiv, grid->dx / seconddiv)); - if (v2d->cur.xmin < 0.0f) { - grid->startx -= grid->dx; - } - } - else { - grid->startx = v2d->cur.xmin; - } - - if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) { - grid->starty = (v2d->cur.ymin - (float)fmod(v2d->cur.ymin, grid->dy)); - if (v2d->cur.ymin < 0.0f) { - grid->starty -= grid->dy; - } - } - else { - grid->starty = v2d->cur.ymin; - } - - return grid; -} - -/* Draw gridlines in the given 2d-region */ -void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) -{ - float vec1[2], vec2[2]; - int a, step; - int vertical_minor_step = (BLI_rcti_size_x(&v2d->mask) + 1) / (U.v2d_min_gridsize * UI_DPI_FAC); - int horizontal_major_step = (BLI_rcti_size_y(&v2d->mask) + 1) / - (U.v2d_min_gridsize * UI_DPI_FAC); - uchar grid_line_color[3]; - - /* check for grid first, as it may not exist */ - if (grid == NULL) { - return; - } - - /* Count the needed vertices for the gridlines */ - unsigned vertex_count = 0; - if (flag & V2D_VERTICAL_LINES) { - /* vertical lines */ - vertex_count += 2 * vertical_minor_step; /* minor gridlines */ - vertex_count += 2 * (vertical_minor_step + 2); /* major gridlines */ - } - if (flag & V2D_HORIZONTAL_LINES) { - /* horizontal lines */ - vertex_count += 2 * (horizontal_major_step + 1); /* major gridlines */ - - /* fine lines */ - if (flag & V2D_HORIZONTAL_FINELINES) { - vertex_count += 2 * (horizontal_major_step + 1); - } - } - /* axes */ - if (flag & V2D_HORIZONTAL_AXIS) { - vertex_count += 2; - } - if (flag & V2D_VERTICAL_AXIS) { - vertex_count += 2; - } - - /* If there is nothing to render, exit early */ - if (vertex_count == 0) { - return; - } - - GPUVertFormat *format = immVertexFormat(); - uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - uint color = GPU_vertformat_attr_add( - format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); - - immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GPU_PRIM_LINES, vertex_count); - - /* vertical lines */ - if (flag & V2D_VERTICAL_LINES) { - /* initialize initial settings */ - vec1[0] = vec2[0] = grid->startx; - vec1[1] = grid->starty; - vec2[1] = v2d->cur.ymax; - - /* minor gridlines */ - step = vertical_minor_step; - if (step != 0) { - UI_GetThemeColor3ubv(TH_GRID, grid_line_color); - - for (a = 0; a < step; a++) { - immAttrSkip(color); - immVertex2fv(pos, vec1); - immAttr3ubv(color, grid_line_color); - immVertex2fv(pos, vec2); - - vec2[0] = vec1[0] += grid->dx; - } - } - - /* major gridlines */ - vec2[0] = vec1[0] -= 0.5f * grid->dx; - - UI_GetThemeColorShade3ubv(TH_GRID, 16, grid_line_color); - - step++; - for (a = 0; a <= step; a++) { - immAttrSkip(color); - immVertex2fv(pos, vec1); - immAttr3ubv(color, grid_line_color); - immVertex2fv(pos, vec2); - - vec2[0] = vec1[0] -= grid->dx; - } - } - - /* horizontal lines */ - if (flag & V2D_HORIZONTAL_LINES) { - /* only major gridlines */ - vec1[1] = vec2[1] = grid->starty; - vec1[0] = grid->startx; - vec2[0] = v2d->cur.xmax; - - step = horizontal_major_step; - - UI_GetThemeColor3ubv(TH_GRID, grid_line_color); - - for (a = 0; a <= step; a++) { - immAttrSkip(color); - immVertex2fv(pos, vec1); - immAttr3ubv(color, grid_line_color); - immVertex2fv(pos, vec2); - - vec2[1] = vec1[1] += grid->dy; - } - - /* fine grid lines */ - vec2[1] = vec1[1] -= 0.5f * grid->dy; - step++; - - if (flag & V2D_HORIZONTAL_FINELINES) { - UI_GetThemeColorShade3ubv(TH_GRID, 16, grid_line_color); - for (a = 0; a < step; a++) { - immAttrSkip(color); - immVertex2fv(pos, vec1); - immAttr3ubv(color, grid_line_color); - immVertex2fv(pos, vec2); - - vec2[1] = vec1[1] -= grid->dy; - } - } - } - - /* Axes are drawn as darker lines */ - UI_GetThemeColorShade3ubv(TH_GRID, -50, grid_line_color); - - /* horizontal axis */ - if (flag & V2D_HORIZONTAL_AXIS) { - vec1[0] = v2d->cur.xmin; - vec2[0] = v2d->cur.xmax; - vec1[1] = vec2[1] = 0.0f; - - immAttrSkip(color); - immVertex2fv(pos, vec1); - immAttr3ubv(color, grid_line_color); - immVertex2fv(pos, vec2); - } - - /* vertical axis */ - if (flag & V2D_VERTICAL_AXIS) { - vec1[1] = v2d->cur.ymin; - vec2[1] = v2d->cur.ymax; - vec1[0] = vec2[0] = 0.0f; - - immAttrSkip(color); - immVertex2fv(pos, vec1); - immAttr3ubv(color, grid_line_color); - immVertex2fv(pos, vec2); - } - - immEnd(); - immUnbindProgram(); -} - /* Draw a constant grid in given 2d-region */ void UI_view2d_constant_grid_draw(View2D *v2d, float step) { @@ -1727,135 +1397,6 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s immUnbindProgram(); } -static void get_scale_indicator_text( - const Scene *scene, float value, int brevity_level, short unit, uint max_length, char *r_str) -{ - if (unit == V2D_UNIT_SECONDS) { - BLI_timecode_string_from_time( - r_str, max_length, brevity_level, value / (float)FPS, FPS, U.timecode_style); - } - else { - BLI_timecode_string_from_time_seconds(r_str, max_length, brevity_level, value); - } -} - -void UI_view2d_grid_draw_numbers_horizontal(const Scene *scene, - const View2D *v2d, - const View2DGrid *grid, - const rcti *rect, - int unit, - bool whole_numbers_only) -{ - BLI_assert(grid); - float xstep = grid->dx * UI_view2d_scale_get_x(v2d); - if (xstep <= 0.0f) { - return; - } - - float initial_xpos = UI_view2d_view_to_region_x(v2d, grid->startx); - float ypos = (float)rect->ymin + 2 * UI_DPI_FAC; - float initial_value = grid->startx; - float value_step = grid->dx; - int brevity_level = grid->powerx; - - /* Make sure that the value_step is >= 1 when only whole numbers are displayed. - * Otherwise the same number could be displayed more than once. */ - if (whole_numbers_only) { - while (value_step < 0.9999f) { - xstep *= 2.0f; - value_step *= 2.0f; - } - } - - /* Skip first few steps if they don't intersect - * the rectangle that will contain the numbers. */ - while (initial_xpos < rect->xmin) { - initial_xpos += xstep; - initial_value += value_step; - } - - if (unit == V2D_UNIT_FRAMES) { - brevity_level = 1; - } - - const int font_id = BLF_default(); - UI_FontThemeColor(font_id, TH_TEXT); - - BLF_batch_draw_begin(); - - for (float xpos = initial_xpos, value = initial_value; xpos < rect->xmax; - xpos += xstep, value += value_step) { - char text[32]; - get_scale_indicator_text(scene, value, brevity_level, unit, sizeof(text), text); - float text_width = BLF_width(font_id, text, strlen(text)); - BLF_draw_default_ascii(xpos - text_width / 2.0f, ypos, 0.0f, text, sizeof(text)); - } - - BLF_batch_draw_end(); -} - -void UI_view2d_grid_draw_numbers_vertical(const Scene *scene, - const View2D *v2d, - const View2DGrid *grid, - const rcti *rect, - int unit, - float text_offset) -{ - BLI_assert(grid); - float ystep = grid->dy * UI_view2d_scale_get_y(v2d); - if (ystep <= 0.0f) { - return; - } - - const int font_id = BLF_default(); - UI_FontThemeColor(font_id, TH_TEXT); - - BLF_enable(font_id, BLF_ROTATION); - BLF_rotation(font_id, M_PI_2); - - float initial_value = grid->starty; - float value_step = grid->dy; - float xpos = rect->xmax - 2.0f * UI_DPI_FAC; - float initial_ypos = UI_view2d_view_to_region_y(v2d, grid->starty); - - /* Currently only used by the sequencer to display - * channel numbers in the center. */ - initial_ypos += text_offset * ystep; - - /* Skip first few steps if they don't intersect - * the rectangle that will contain the numbers. */ - while (initial_ypos < rect->ymin) { - initial_ypos += ystep; - initial_value += value_step; - } - - for (float ypos = initial_ypos, value = initial_value; ypos < rect->ymax; - ypos += ystep, value += value_step) { - char text[32]; - get_scale_indicator_text(scene, value, grid->powery, unit, sizeof(text), text); - float text_width = BLF_width(font_id, text, sizeof(text)); - BLF_draw_default_ascii(xpos, ypos - text_width / 2.0f, 0.0f, text, sizeof(text)); - } - - BLF_disable(font_id, BLF_ROTATION); -} - -/* the price we pay for not exposting structs :( */ -void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy) -{ - *r_dx = grid->dx; - *r_dy = grid->dy; -} - -/* free temporary memory used for drawing grid */ -void UI_view2d_grid_free(View2DGrid *grid) -{ - /* only free if there's a grid */ - if (grid) { - MEM_freeN(grid); - } -} - /* *********************************************************************** */ /* Scrollers */ @@ -1872,21 +1413,10 @@ struct View2DScrollers { rcti hor, vert; /* exact size of slider backdrop */ int horfull, vertfull; /* set if sliders are full, we don't draw them */ - - /* scales */ - View2DGrid *grid; /* grid for coordinate drawing */ - short xunits, xclamp; /* units and clamping options for x-axis */ - short yunits, yclamp; /* units and clamping options for y-axis */ }; /* Calculate relevant scroller properties */ -View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, - View2D *v2d, - const rcti *mask_custom, - short xunits, - short xclamp, - short yunits, - short yclamp) +View2DScrollers *UI_view2d_scrollers_calc(View2D *v2d, const rcti *mask_custom) { View2DScrollers *scrollers; rcti vert, hor; @@ -2014,30 +1544,11 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, } } - /* grid markings on scrollbars */ - if (scroll & (V2D_SCROLL_SCALE_HORIZONTAL | V2D_SCROLL_SCALE_VERTICAL)) { - /* store clamping */ - scrollers->xclamp = xclamp; - scrollers->xunits = xunits; - 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)); - } - - /* return scrollers */ return scrollers; } /* Draw scrollbars in the given 2d-region */ -void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *vs) +void UI_view2d_scrollers_draw(View2D *v2d, View2DScrollers *vs) { bTheme *btheme = UI_GetTheme(); rcti vert, hor; @@ -2084,13 +1595,6 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v } UI_draw_widget_scroll(&wcol, &hor, &slider, state); - - { - if (scroll & V2D_SCROLL_SCALE_HORIZONTAL) { - UI_view2d_grid_draw_numbers_horizontal( - CTX_data_scene(C), v2d, vs->grid, &vs->hor, vs->xunits, vs->xclamp == V2D_GRID_CLAMP); - } - } } /* vertical scrollbar */ @@ -2125,17 +1629,6 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v } UI_draw_widget_scroll(&wcol, &vert, &slider, state); - - { - if (scroll & V2D_SCROLL_SCALE_VERTICAL) { - float text_offset = 0.0f; - if (vs->yclamp & V2D_GRID_CLAMP) { - text_offset = 0.5f; - } - UI_view2d_grid_draw_numbers_vertical( - CTX_data_scene(C), v2d, vs->grid, &vs->vert, vs->yunits, text_offset); - } - } } /* Was changed above, so reset. */ @@ -2145,69 +1638,12 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v /* free temporary memory used for drawing scrollers */ void UI_view2d_scrollers_free(View2DScrollers *scrollers) { - /* need to free grid as well... */ - if (scrollers->grid) { - MEM_freeN(scrollers->grid); - } MEM_freeN(scrollers); } /* *********************************************************************** */ /* List View Utilities */ -/** Get the view-coordinates of the nominated cell - * - * \param columnwidth, rowheight: size of each 'cell' - * \param startx, starty: coordinates (in 'tot' rect space) that the list starts from. - * This should be (0,0) for most views. However, for those where the starting row was offsetted - * (like for Animation Editor channel lists, to make the first entry more visible), these will be - * the min-coordinates of the first item. - * \param column, row: The 2d-coordinates - * (in 2D-view / 'tot' rect space) the cell exists at - * \param rect: coordinates of the cell - * (passed as single var instead of 4 separate, as it's more useful this way) - */ -void UI_view2d_listview_cell_to_view(View2D *v2d, - float columnwidth, - float rowheight, - float startx, - float starty, - int column, - int row, - rctf *rect) -{ - /* sanity checks */ - if (ELEM(NULL, v2d, rect)) { - return; - } - - if ((columnwidth <= 0) && (rowheight <= 0)) { - rect->xmin = rect->xmax = 0.0f; - rect->ymin = rect->ymax = 0.0f; - return; - } - - /* x-coordinates */ - rect->xmin = startx + (float)(columnwidth * column); - rect->xmax = startx + (float)(columnwidth * (column + 1)); - - if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) { - /* simply negate the values for the coordinates if in negative half */ - rect->xmin = -rect->xmin; - rect->xmax = -rect->xmax; - } - - /* y-coordinates */ - rect->ymin = starty + (float)(rowheight * row); - rect->ymax = starty + (float)(rowheight * (row + 1)); - - if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) { - /* simply negate the values for the coordinates if in negative half */ - rect->ymin = -rect->ymin; - rect->ymax = -rect->ymax; - } -} - /** * Get the 'cell' (row, column) that the given 2D-view coordinates * (i.e. in 'tot' rect space) lie in. @@ -2220,8 +1656,7 @@ void UI_view2d_listview_cell_to_view(View2D *v2d, * \param viewx, viewy: 2D-coordinates (in 2D-view / 'tot' rect space) to get the cell for * \param r_column, r_row: the 'coordinates' of the relevant 'cell' */ -void UI_view2d_listview_view_to_cell(View2D *v2d, - float columnwidth, +void UI_view2d_listview_view_to_cell(float columnwidth, float rowheight, float startx, float starty, @@ -2230,80 +1665,24 @@ void UI_view2d_listview_view_to_cell(View2D *v2d, int *r_column, int *r_row) { - /* adjust view coordinates to be all positive ints, corrected for the start offset */ - const int x = (int)(floorf(fabsf(viewx) + 0.5f) - startx); - const int y = (int)(floorf(fabsf(viewy) + 0.5f) - starty); - - /* sizes must not be negative */ - if ((v2d == NULL) || ((columnwidth <= 0) && (rowheight <= 0))) { - if (r_column) { - *r_column = 0; + if (r_column) { + if (columnwidth > 0) { + /* Columns go from left to right (x increases). */ + *r_column = floorf((viewx - startx) / columnwidth); } - if (r_row) { - *r_row = 0; + else { + *r_column = 0; } - - return; } - /* get column */ - if ((r_column) && (columnwidth > 0)) { - *r_column = x / columnwidth; - } - else if (r_column) { - *r_column = 0; - } - - /* get row */ - if ((r_row) && (rowheight > 0)) { - *r_row = y / rowheight; - } - else if (r_row) { - *r_row = 0; - } -} - -/** - * Get the 'extreme' (min/max) column and row indices which are visible within the 'cur' rect - * - * \param columnwidth, rowheight: Size of each 'cell' - * \param startx, starty: Coordinates that the list starts from, - * which should be (0,0) for most views. - * \param column_min, column_max, row_min, row_max: The starting and ending column/row indices - */ -void UI_view2d_listview_visible_cells(View2D *v2d, - float columnwidth, - float rowheight, - float startx, - float starty, - int *column_min, - int *column_max, - int *row_min, - int *row_max) -{ - /* 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); - - /* max*/ - UI_view2d_listview_view_to_cell(v2d, - columnwidth, - rowheight, - startx, - starty, - v2d->cur.xmax, - v2d->cur.ymax, - column_max, - row_max); + if (r_row) { + if (rowheight > 0) { + /* Rows got from top to bottom (y decreases). */ + *r_row = floorf((starty - viewy) / rowheight); + } + else { + *r_row = 0; + } } } diff --git a/source/blender/editors/interface/view2d_draw.c b/source/blender/editors/interface/view2d_draw.c new file mode 100644 index 00000000000..2568193ee23 --- /dev/null +++ b/source/blender/editors/interface/view2d_draw.c @@ -0,0 +1,546 @@ +/* + * 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) 2008 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup edinterface + */ + +#include <float.h> +#include <limits.h> +#include <math.h> +#include <string.h> + +#include "MEM_guardedalloc.h" + +#include "DNA_scene_types.h" +#include "DNA_userdef_types.h" + +#include "BLI_array.h" +#include "BLI_utildefines.h" +#include "BLI_rect.h" +#include "BLI_math.h" +#include "BLI_timecode.h" +#include "BLI_string.h" + +#include "GPU_immediate.h" +#include "GPU_matrix.h" + +#include "WM_api.h" + +#include "BLF_api.h" + +#include "UI_interface.h" +#include "UI_view2d.h" + +#include "interface_intern.h" + +/* Compute display grid resolution + ********************************************************/ + +#define MIN_MAJOR_LINE_DISTANCE (UI_DPI_FAC * 50) + +static float select_major_distance(const float *possible_distances, + uint amount, + float pixel_width, + float view_width) +{ + BLI_assert(amount >= 1); + + if (IS_EQF(view_width, 0.0f)) { + return possible_distances[0]; + } + + float pixels_per_view_unit = pixel_width / view_width; + + for (uint i = 0; i < amount; i++) { + float distance = possible_distances[i]; + if (pixels_per_view_unit * distance >= MIN_MAJOR_LINE_DISTANCE) { + return distance; + } + } + return possible_distances[amount - 1]; +} + +static const float discrete_value_scales[] = { + 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000}; + +static const float continuous_value_scales[] = {0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, + 5, 10, 20, 50, 100, 200, 500, 1000, + 2000, 5000, 10000, 20000, 50000, 100000}; + +static uint view2d_major_step_x__discrete(const View2D *v2d) +{ + return select_major_distance(discrete_value_scales, + ARRAY_SIZE(discrete_value_scales), + BLI_rcti_size_x(&v2d->mask), + BLI_rctf_size_x(&v2d->cur)); +} + +static float view2d_major_step_x__continuous(const View2D *v2d) +{ + return select_major_distance(continuous_value_scales, + ARRAY_SIZE(continuous_value_scales), + BLI_rcti_size_x(&v2d->mask), + BLI_rctf_size_x(&v2d->cur)); +} + +static float view2d_major_step_y__continuous(const View2D *v2d) +{ + return select_major_distance(continuous_value_scales, + ARRAY_SIZE(continuous_value_scales), + BLI_rcti_size_y(&v2d->mask), + BLI_rctf_size_y(&v2d->cur)); +} + +static float view2d_major_step_x__time(const View2D *v2d, const Scene *scene) +{ + double fps = FPS; + + float *possible_distances = NULL; + BLI_array_staticdeclare(possible_distances, 32); + + for (uint step = 1; step < fps; step *= 2) { + BLI_array_append(possible_distances, step); + } + BLI_array_append(possible_distances, fps); + BLI_array_append(possible_distances, 2 * fps); + BLI_array_append(possible_distances, 5 * fps); + BLI_array_append(possible_distances, 10 * fps); + BLI_array_append(possible_distances, 30 * fps); + BLI_array_append(possible_distances, 60 * fps); + BLI_array_append(possible_distances, 2 * 60 * fps); + BLI_array_append(possible_distances, 5 * 60 * fps); + BLI_array_append(possible_distances, 10 * 60 * fps); + BLI_array_append(possible_distances, 30 * 60 * fps); + BLI_array_append(possible_distances, 60 * 60 * fps); + + float distance = select_major_distance(possible_distances, + BLI_array_len(possible_distances), + BLI_rcti_size_x(&v2d->mask), + BLI_rctf_size_x(&v2d->cur)); + + BLI_array_free(possible_distances); + return distance; +} + +/* Draw parallel lines + ************************************/ + +typedef struct ParallelLinesSet { + float offset; + float distance; +} ParallelLinesSet; + +static void get_parallel_lines_draw_steps(const ParallelLinesSet *lines, + float region_start, + float region_end, + float *r_first, + uint *r_steps) +{ + if (region_start >= region_end) { + *r_first = 0; + *r_steps = 0; + return; + } + + BLI_assert(lines->distance > 0); + BLI_assert(region_start <= region_end); + + *r_first = ceilf((region_start - lines->offset) / lines->distance) * lines->distance + + lines->offset; + + if (region_start <= *r_first && region_end >= *r_first) { + *r_steps = MAX2(0, floorf((region_end - *r_first) / lines->distance)) + 1; + } + else { + *r_steps = 0; + } +} + +static void draw_parallel_lines(const ParallelLinesSet *lines, + const rctf *rect, + const uchar *color, + char direction) +{ + float first; + uint steps; + + if (direction == 'v') { + get_parallel_lines_draw_steps(lines, rect->xmin, rect->xmax, &first, &steps); + } + else { + BLI_assert(direction == 'h'); + get_parallel_lines_draw_steps(lines, rect->ymin, rect->ymax, &first, &steps); + } + + if (steps == 0) { + return; + } + + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformColor3ubv(color); + immBegin(GPU_PRIM_LINES, steps * 2); + + if (direction == 'v') { + for (uint i = 0; i < steps; i++) { + float xpos = first + i * lines->distance; + immVertex2f(pos, xpos, rect->ymin); + immVertex2f(pos, xpos, rect->ymax); + } + } + else { + for (uint i = 0; i < steps; i++) { + float ypos = first + i * lines->distance; + immVertex2f(pos, rect->xmin, ypos); + immVertex2f(pos, rect->xmax, ypos); + } + } + + immEnd(); + immUnbindProgram(); +} + +static void view2d_draw_lines_internal(const View2D *v2d, + const ParallelLinesSet *lines, + const uchar *color, + char direction) +{ + GPU_matrix_push_projection(); + UI_view2d_view_ortho(v2d); + draw_parallel_lines(lines, &v2d->cur, color, direction); + GPU_matrix_pop_projection(); +} + +static void view2d_draw_lines(const View2D *v2d, + float major_distance, + bool display_minor_lines, + char direction) +{ + uchar major_color[3]; + uchar minor_color[3]; + UI_GetThemeColor3ubv(TH_GRID, major_color); + UI_GetThemeColorShade3ubv(TH_GRID, 16, minor_color); + + ParallelLinesSet major_lines; + major_lines.distance = major_distance; + major_lines.offset = 0; + view2d_draw_lines_internal(v2d, &major_lines, major_color, direction); + + if (display_minor_lines) { + ParallelLinesSet minor_lines; + minor_lines.distance = major_distance; + minor_lines.offset = major_distance / 2.0f; + view2d_draw_lines_internal(v2d, &minor_lines, minor_color, direction); + } +} + +/* Scale indicator text drawing + **************************************************/ + +typedef void (*PositionToString)( + void *user_data, float v2d_pos, float v2d_step, uint max_len, char *r_str); + +static void draw_horizontal_scale_indicators(const ARegion *ar, + const View2D *v2d, + float distance, + const rcti *rect, + PositionToString to_string, + void *to_string_data, + int colorid) +{ + GPU_matrix_push_projection(); + wmOrtho2_region_pixelspace(ar); + + float start; + uint steps; + { + ParallelLinesSet lines; + lines.distance = distance; + lines.offset = 0; + get_parallel_lines_draw_steps(&lines, + UI_view2d_region_to_view_x(v2d, rect->xmin), + UI_view2d_region_to_view_x(v2d, rect->xmax), + &start, + &steps); + } + + const int font_id = BLF_default(); + UI_FontThemeColor(font_id, colorid); + + BLF_batch_draw_begin(); + + float ypos = rect->ymin + 4 * UI_DPI_FAC; + float xmin = rect->xmin; + float xmax = rect->xmax; + + for (uint i = 0; i < steps; i++) { + float xpos_view = start + i * distance; + float xpos_region = UI_view2d_view_to_region_x(v2d, xpos_view); + char text[32]; + to_string(to_string_data, xpos_view, distance, sizeof(text), text); + float text_width = BLF_width(font_id, text, strlen(text)); + + if (xpos_region - text_width / 2.0f >= xmin && xpos_region + text_width / 2.0f <= xmax) { + BLF_draw_default_ascii(xpos_region - text_width / 2.0f, ypos, 0.0f, text, sizeof(text)); + } + } + + BLF_batch_draw_end(); + + GPU_matrix_pop_projection(); +} + +static void draw_vertical_scale_indicators(const ARegion *ar, + const View2D *v2d, + float distance, + float display_offset, + const rcti *rect, + PositionToString to_string, + void *to_string_data, + int colorid) +{ + GPU_matrix_push_projection(); + wmOrtho2_region_pixelspace(ar); + + float start; + uint steps; + { + ParallelLinesSet lines; + lines.distance = distance; + lines.offset = 0; + get_parallel_lines_draw_steps(&lines, + UI_view2d_region_to_view_y(v2d, rect->ymin), + UI_view2d_region_to_view_y(v2d, rect->ymax), + &start, + &steps); + } + + const int font_id = BLF_default(); + UI_FontThemeColor(font_id, colorid); + + BLF_enable(font_id, BLF_ROTATION); + BLF_rotation(font_id, M_PI_2); + + BLF_batch_draw_begin(); + + float xpos = rect->xmax - 2.0f * UI_DPI_FAC; + float ymin = rect->ymin; + float ymax = rect->ymax; + + for (uint i = 0; i < steps; i++) { + float ypos_view = start + i * distance; + float ypos_region = UI_view2d_view_to_region_y(v2d, ypos_view + display_offset); + char text[32]; + to_string(to_string_data, ypos_view, distance, sizeof(text), text); + float text_width = BLF_width(font_id, text, strlen(text)); + + if (ypos_region - text_width / 2.0f >= ymin && ypos_region + text_width / 2.0f <= ymax) { + BLF_draw_default_ascii(xpos, ypos_region - text_width / 2.0f, 0.0f, text, sizeof(text)); + } + } + + BLF_batch_draw_end(); + BLF_disable(font_id, BLF_ROTATION); + + GPU_matrix_pop_projection(); +} + +static void view_to_string__frame_number( + void *UNUSED(user_data), float v2d_pos, float UNUSED(v2d_step), uint max_len, char *r_str) +{ + BLI_snprintf(r_str, max_len, "%d", (int)v2d_pos); +} + +static void view_to_string__time( + void *user_data, float v2d_pos, float UNUSED(v2d_step), uint max_len, char *r_str) +{ + const Scene *scene = (const Scene *)user_data; + + int brevity_level = 0; + BLI_timecode_string_from_time( + r_str, max_len, brevity_level, v2d_pos / (float)FPS, FPS, U.timecode_style); +} + +static void view_to_string__value( + void *UNUSED(user_data), float v2d_pos, float v2d_step, uint max_len, char *r_str) +{ + if (v2d_step >= 1.0f) { + BLI_snprintf(r_str, max_len, "%d", (int)v2d_pos); + } + else if (v2d_step >= 0.1f) { + BLI_snprintf(r_str, max_len, "%.1f", v2d_pos); + } + else if (v2d_step >= 0.01f) { + BLI_snprintf(r_str, max_len, "%.2f", v2d_pos); + } + else { + BLI_snprintf(r_str, max_len, "%.3f", v2d_pos); + } +} + +/* Grid Resolution API + **************************************************/ + +float UI_view2d_grid_resolution_x__frames_or_seconds(const struct View2D *v2d, + const struct Scene *scene, + bool display_seconds) +{ + if (display_seconds) { + return view2d_major_step_x__time(v2d, scene); + } + else { + return view2d_major_step_x__continuous(v2d); + } +} + +float UI_view2d_grid_resolution_y__values(const struct View2D *v2d) +{ + return view2d_major_step_y__continuous(v2d); +} + +/* Line Drawing API + **************************************************/ + +void UI_view2d_draw_lines_x__discrete_values(const View2D *v2d) +{ + uint major_line_distance = view2d_major_step_x__discrete(v2d); + view2d_draw_lines(v2d, major_line_distance, major_line_distance > 1, 'v'); +} + +void UI_view2d_draw_lines_x__values(const View2D *v2d) +{ + float major_line_distance = view2d_major_step_x__continuous(v2d); + view2d_draw_lines(v2d, major_line_distance, true, 'v'); +} + +void UI_view2d_draw_lines_y__values(const View2D *v2d) +{ + float major_line_distance = view2d_major_step_y__continuous(v2d); + view2d_draw_lines(v2d, major_line_distance, true, 'h'); +} + +void UI_view2d_draw_lines_x__discrete_time(const View2D *v2d, const Scene *scene) +{ + float major_line_distance = view2d_major_step_x__time(v2d, scene); + view2d_draw_lines(v2d, major_line_distance, major_line_distance > 1, 'v'); +} + +void UI_view2d_draw_lines_x__discrete_frames_or_seconds(const View2D *v2d, + const Scene *scene, + bool display_seconds) +{ + if (display_seconds) { + UI_view2d_draw_lines_x__discrete_time(v2d, scene); + } + else { + UI_view2d_draw_lines_x__discrete_values(v2d); + } +} + +void UI_view2d_draw_lines_x__frames_or_seconds(const View2D *v2d, + const Scene *scene, + bool display_seconds) +{ + if (display_seconds) { + UI_view2d_draw_lines_x__discrete_time(v2d, scene); + } + else { + UI_view2d_draw_lines_x__values(v2d); + } +} + +/* Scale indicator text drawing API + **************************************************/ + +static void UI_view2d_draw_scale_x__discrete_values(const ARegion *ar, + const View2D *v2d, + const rcti *rect, + int colorid) +{ + float number_step = view2d_major_step_x__discrete(v2d); + draw_horizontal_scale_indicators( + ar, v2d, number_step, rect, view_to_string__frame_number, NULL, colorid); +} + +static void UI_view2d_draw_scale_x__discrete_time( + const ARegion *ar, const View2D *v2d, const rcti *rect, const Scene *scene, int colorid) +{ + float step = view2d_major_step_x__time(v2d, scene); + draw_horizontal_scale_indicators( + ar, v2d, step, rect, view_to_string__time, (void *)scene, colorid); +} + +static void UI_view2d_draw_scale_x__values(const ARegion *ar, + const View2D *v2d, + const rcti *rect, + int colorid) +{ + float step = view2d_major_step_x__continuous(v2d); + draw_horizontal_scale_indicators(ar, v2d, step, rect, view_to_string__value, NULL, colorid); +} + +void UI_view2d_draw_scale_y__values(const ARegion *ar, + const View2D *v2d, + const rcti *rect, + int colorid) +{ + float step = view2d_major_step_y__continuous(v2d); + draw_vertical_scale_indicators(ar, v2d, step, 0.0f, rect, view_to_string__value, NULL, colorid); +} + +void UI_view2d_draw_scale_y__block(const ARegion *ar, + const View2D *v2d, + const rcti *rect, + int colorid) +{ + draw_vertical_scale_indicators(ar, v2d, 1.0f, 0.5f, rect, view_to_string__value, NULL, colorid); +} + +void UI_view2d_draw_scale_x__discrete_frames_or_seconds(const struct ARegion *ar, + const struct View2D *v2d, + const struct rcti *rect, + const struct Scene *scene, + bool display_seconds, + int colorid) +{ + if (display_seconds) { + UI_view2d_draw_scale_x__discrete_time(ar, v2d, rect, scene, colorid); + } + else { + UI_view2d_draw_scale_x__discrete_values(ar, v2d, rect, colorid); + } +} + +void UI_view2d_draw_scale_x__frames_or_seconds(const struct ARegion *ar, + const struct View2D *v2d, + const struct rcti *rect, + const struct Scene *scene, + bool display_seconds, + int colorid) +{ + if (display_seconds) { + UI_view2d_draw_scale_x__discrete_time(ar, v2d, rect, scene, colorid); + } + else { + UI_view2d_draw_scale_x__values(ar, v2d, rect, colorid); + } +} diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 8880072b82b..ab8d1cf9bf6 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1785,8 +1785,7 @@ static void scroller_activate_init(bContext *C, /* 'zone' depends on where mouse is relative to bubble * - zooming must be allowed on this axis, otherwise, default to pan */ - scrollers = UI_view2d_scrollers_calc( - C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(v2d, NULL); /* use a union of 'cur' & 'tot' incase the current view is far outside 'tot'. In this cases * moving the scroll bars has far too little effect and the view can get stuck T31476. */ diff --git a/source/blender/editors/io/CMakeLists.txt b/source/blender/editors/io/CMakeLists.txt index fbbb8621ae6..5a35b251d0c 100644 --- a/source/blender/editors/io/CMakeLists.txt +++ b/source/blender/editors/io/CMakeLists.txt @@ -17,16 +17,16 @@ set(INC ../include + ../../alembic ../../blenkernel ../../blenlib ../../blentranslation ../../bmesh + ../../collada ../../depsgraph ../../makesdna ../../makesrna ../../windowmanager - ../../collada - ../../alembic ../../../../intern/guardedalloc ) diff --git a/source/blender/editors/io/io_cache.c b/source/blender/editors/io/io_cache.c index 6358c2c1370..3dd3b20bda3 100644 --- a/source/blender/editors/io/io_cache.c +++ b/source/blender/editors/io/io_cache.c @@ -38,6 +38,8 @@ #include "RNA_access.h" +#include "DEG_depsgraph.h" + #include "UI_interface.h" #include "WM_api.h" @@ -93,7 +95,7 @@ static int cachefile_open_exec(bContext *C, wmOperator *op) CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, BLI_path_basename(filename), 0); BLI_strncpy(cache_file->filepath, filename, FILE_MAX); - BKE_cachefile_reload(bmain, cache_file); + DEG_id_tag_update(&cache_file->id, ID_RECALC_COPY_ON_WRITE); /* Will be set when running invoke, not exec directly. */ if (op->customdata != NULL) { @@ -137,7 +139,7 @@ void CACHEFILE_OT_open(wmOperatorType *ot) /* ***************************** Reload Operator **************************** */ -static int cachefile_reload_exec(bContext *C, wmOperator *op) +static int cachefile_reload_exec(bContext *C, wmOperator *UNUSED(op)) { CacheFile *cache_file = CTX_data_edit_cachefile(C); @@ -145,14 +147,10 @@ static int cachefile_reload_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - Main *bmain = CTX_data_main(C); - - BLI_freelistN(&cache_file->object_paths); - BKE_cachefile_reload(bmain, cache_file); + Depsgraph *depsgraph = CTX_data_depsgraph(C); + BKE_cachefile_reload(depsgraph, cache_file); return OPERATOR_FINISHED; - - UNUSED_VARS(op); } void CACHEFILE_OT_reload(wmOperatorType *ot) diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index bfbd3722142..9796bf89cf3 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -174,7 +174,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) /* get editmode results */ ED_object_editmode_load(bmain, CTX_data_edit_object(C)); - //Scene *scene = CTX_data_scene(C); + // Scene *scene = CTX_data_scene(C); ExportSettings export_settings; @@ -748,7 +748,7 @@ void WM_OT_collada_import(wmOperatorType *ot) ot->exec = wm_collada_import_exec; ot->poll = WM_operator_winactive; - //ot->flag |= OPTYPE_PRESET; + // ot->flag |= OPTYPE_PRESET; ot->ui = wm_collada_import_draw; diff --git a/source/blender/editors/mask/CMakeLists.txt b/source/blender/editors/mask/CMakeLists.txt index 9dabcc0e8bb..81c861ab4e4 100644 --- a/source/blender/editors/mask/CMakeLists.txt +++ b/source/blender/editors/mask/CMakeLists.txt @@ -26,8 +26,8 @@ set(INC ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index 454e7e2a731..0c5591ed89b 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -520,6 +520,6 @@ void ED_operatormacros_mask(void) OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MASK_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); RNA_boolean_set(otmacro->ptr, "mirror", false); } diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index ab774fa13df..c0f3b1f8338 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -245,7 +245,7 @@ bool ED_mask_feather_find_nearest(const bContext *C, MaskSpline *spline; for (spline = masklay->splines.first; spline; spline = spline->next) { - //MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); + // MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); int i, tot_feather_point; float(*feather_points)[2], (*fp)[2]; diff --git a/source/blender/editors/mask/mask_relationships.c b/source/blender/editors/mask/mask_relationships.c index bb9359bad71..75b2aee3570 100644 --- a/source/blender/editors/mask/mask_relationships.c +++ b/source/blender/editors/mask/mask_relationships.c @@ -184,7 +184,7 @@ void MASK_OT_parent_set(wmOperatorType *ot) ot->idname = "MASK_OT_parent_set"; /* api callbacks */ - //ot->invoke = mask_parent_set_invoke; + // ot->invoke = mask_parent_set_invoke; ot->exec = mask_parent_set_exec; ot->poll = ED_space_clip_maskedit_mask_poll; diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index 00699c8ffe0..a592f39d24b 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -262,6 +262,7 @@ static int select_exec(bContext *C, wmOperator *op) bool extend = RNA_boolean_get(op->ptr, "extend"); bool deselect = RNA_boolean_get(op->ptr, "deselect"); bool toggle = RNA_boolean_get(op->ptr, "toggle"); + const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all"); eMaskWhichHandle which_handle; const float threshold = 19; @@ -368,6 +369,15 @@ static int select_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } + else if (deselect_all) { + ED_mask_select_toggle_all(mask, SEL_DESELECT); + + ED_mask_select_flush_all(mask); + + WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask); + + return OPERATOR_FINISHED; + } } return OPERATOR_PASS_THROUGH; diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index e67d63b01a5..57bf67e825e 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -21,8 +21,8 @@ set(INC ../../blenkernel ../../blenlib ../../blentranslation - ../../depsgraph ../../bmesh + ../../depsgraph ../../gpu ../../imbuf ../../makesdna @@ -30,8 +30,8 @@ set(INC ../../render/extern/include ../../windowmanager ../../../../intern/clog - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 28b697531ab..990250792a1 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -121,7 +121,7 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag) BKE_mesh_batch_cache_dirty_tag(me_eval, BKE_MESH_BATCH_DIRTY_ALL); } else { - BKE_mesh_batch_cache_dirty_tag(me_eval, BKE_MESH_BATCH_DIRTY_SELECT); + BKE_mesh_batch_cache_dirty_tag(me_eval, BKE_MESH_BATCH_DIRTY_SELECT_PAINT); } DEG_id_tag_update(ob->data, ID_RECALC_SELECT); diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 815f51a4772..a7d1e54ad59 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -490,8 +490,8 @@ void MESH_OT_primitive_grid_add(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - /* Note that if you use MESH_ADD_VERTS_MAXI for both x and y at the same time you will still reach - * impossible values (10^12 vertices or so...). */ + /* Note that if you use MESH_ADD_VERTS_MAXI for both x and y at the same time + * you will still reach impossible values (10^12 vertices or so...). */ RNA_def_int( ot->srna, "x_subdivisions", 10, 2, MESH_ADD_VERTS_MAXI, "X Subdivisions", "", 2, 1000); RNA_def_int( diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index f6940cae953..f5810d9ff61 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -907,7 +907,7 @@ void MESH_OT_bevel(wmOperatorType *ot) /* identifiers */ ot->name = "Bevel"; - ot->description = "Edge Bevel"; + ot->description = "Cut into selected items at an angle to create flat or rounded bevel or chamfer"; ot->idname = "MESH_OT_bevel"; /* api callbacks */ diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index 9314b96afee..82cff8363f8 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -440,7 +440,7 @@ void MESH_OT_extrude_region(wmOperatorType *ot) ot->description = "Extrude region of faces"; /* api callbacks */ - //ot->invoke = mesh_extrude_region_invoke; + // ot->invoke = mesh_extrude_region_invoke; ot->exec = edbm_extrude_region_exec; ot->poll = ED_operator_editmesh; diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c index 85be7d902ad..269ead7b23f 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c @@ -1018,7 +1018,8 @@ static void gizmo_mesh_spin_redo_draw_prepare(const bContext *UNUSED(C), wmGizmo ggd->data.op = WM_operator_last_redo((bContext *)ggd->data.context); } - /* Not essential, just avoids feedback loop where matrices could shift because of float precision. + /* Not essential, just avoids feedback loop where matrices + * could shift because of float precision. * Updates in this case are also redundant. */ bool is_modal = false; for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index cd5281e1273..cc0c2f5bbe4 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -157,7 +157,7 @@ typedef struct KnifeTool_OpData { void *draw_handle; /* for drawing preview loop */ ViewContext vc; /* note: _don't_ use 'mval', instead use the one we define below */ float mval[2]; /* mouse value with snapping applied */ - //bContext *C; + // bContext *C; Scene *scene; Object *ob; diff --git a/source/blender/editors/mesh/editmesh_path.c b/source/blender/editors/mesh/editmesh_path.c index 062008cd656..f8ec4334427 100644 --- a/source/blender/editors/mesh/editmesh_path.c +++ b/source/blender/editors/mesh/editmesh_path.c @@ -434,12 +434,12 @@ static bool facetag_filter_cb(BMFace *f, void *UNUSED(user_data_v)) { return !BM_elem_flag_test(f, BM_ELEM_HIDDEN); } -//static bool facetag_test_cb(Scene *UNUSED(scene), BMesh *UNUSED(bm), BMFace *f) +// static bool facetag_test_cb(Scene *UNUSED(scene), BMesh *UNUSED(bm), BMFace *f) static bool facetag_test_cb(BMFace *f, void *UNUSED(user_data_v)) { return BM_elem_flag_test_bool(f, BM_ELEM_SELECT); } -//static void facetag_set_cb(BMesh *bm, Scene *UNUSED(scene), BMFace *f, const bool val) +// static void facetag_set_cb(BMesh *bm, Scene *UNUSED(scene), BMFace *f, const bool val) static void facetag_set_cb(BMFace *f, bool val, void *user_data_v) { struct UserData *user_data = user_data_v; diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index a39944fc145..ffdb434405e 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -939,8 +939,8 @@ static int edbm_rip_invoke__edge(bContext *C, const wmEvent *event, Object *obed l_b; l = BM_loop_other_edge_loop(l, v); - /* important edge is manifold else we can be attempting to split off a fan that don't budge, - * not crashing but adds duplicate edge. */ + /* Important edge is manifold else we can be attempting to split off + * a fan that don't budge, not crashing but adds duplicate edge. */ if (BM_edge_is_manifold(l->e)) { l = l->radial_next; diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index d81de37add3..9df03a81762 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -462,7 +462,8 @@ static void findnearestvert__doClosest(void *userData, * * \param r_dist: (in/out), minimal distance to the nearest and at the end, actual distance * \param use_select_bias: - * - When true, selected vertices are given a 5 pixel bias to make them further than unselect verts. + * - When true, selected vertices are given a 5 pixel bias + * to make them further than unselect verts. * - When false, unselected vertices are given the bias. * \param use_cycle: Cycle over elements within #FIND_NEAR_CYCLE_THRESHOLD_MIN in order of index. */ diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 701d7f15abc..2181bf01583 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -336,6 +336,7 @@ void MESH_OT_subdivide_edgering(wmOperatorType *ot) { /* identifiers */ ot->name = "Subdivide Edge-Ring"; + ot->description = "Subdivide perpendicular edges to the selected edge ring"; ot->idname = "MESH_OT_subdivide_edgering"; /* api callbacks */ @@ -2209,7 +2210,7 @@ static int edbm_normals_make_consistent_exec(bContext *C, wmOperator *op) void MESH_OT_normals_make_consistent(wmOperatorType *ot) { /* identifiers */ - ot->name = "Make Normals Consistent"; + ot->name = "Recalculate Normals"; ot->description = "Make face and vertex normals point either outside or inside the mesh"; ot->idname = "MESH_OT_normals_make_consistent"; @@ -2774,7 +2775,7 @@ void MESH_OT_uvs_reverse(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - //RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror UVs around"); + // RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror UVs around"); } void MESH_OT_colors_rotate(wmOperatorType *ot) @@ -2810,7 +2811,9 @@ void MESH_OT_colors_reverse(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - //RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror colors around"); +#if 0 + RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror colors around"); +#endif } /** \} */ @@ -3167,8 +3170,8 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) void MESH_OT_remove_doubles(wmOperatorType *ot) { /* identifiers */ - ot->name = "Remove Doubles"; - ot->description = "Remove duplicate vertices"; + ot->name = "Merge by Distance"; + ot->description = "Merge vertices based on their proximity"; ot->idname = "MESH_OT_remove_doubles"; /* api callbacks */ @@ -3571,7 +3574,7 @@ static float bm_edge_seg_isect(const float sco_a[2], float threshold = 0.0; int i; - //threshold = 0.000001; /* tolerance for vertex intersection */ + // threshold = 0.000001; /* tolerance for vertex intersection */ // XXX threshold = scene->toolsettings->select_thresh / 100; /* Get screen coords of verts */ @@ -3713,7 +3716,7 @@ static float bm_edge_seg_isect(const float sco_a[2], else { perc = (yi - y21) / (y22 - y21); /* lower slope more accurate */ } - //isect = 32768.0 * (perc + 0.0000153); /* Percentage in 1 / 32768ths */ + // isect = 32768.0 * (perc + 0.0000153); /* Percentage in 1 / 32768ths */ break; } @@ -6791,7 +6794,7 @@ void MESH_OT_bridge_edge_loops(wmOperatorType *ot) /* identifiers */ ot->name = "Bridge Edge Loops"; - ot->description = "Make faces between two or more edge loops"; + ot->description = "Create a bridge of faces between two or more selected edge loops"; ot->idname = "MESH_OT_bridge_edge_loops"; /* api callbacks */ @@ -7010,7 +7013,8 @@ void MESH_OT_offset_edge_loops(wmOperatorType *ot) ot->exec = edbm_offset_edgeloop_exec; ot->poll = ED_operator_editmesh; - /* Keep internal, since this is only meant to be accessed via 'MESH_OT_offset_edge_loops_slide' */ + /* Keep internal, since this is only meant to be accessed via + * 'MESH_OT_offset_edge_loops_slide'. */ /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; @@ -8925,7 +8929,7 @@ static int edbm_smoothen_normals_exec(bContext *C, wmOperator *op) void MESH_OT_smoothen_normals(struct wmOperatorType *ot) { /* identifiers */ - ot->name = "Smoothen Normals"; + ot->name = "Smooth Normals Vectors"; ot->description = "Smoothen custom normals based on adjacent vertex normals"; ot->idname = "MESH_OT_smoothen_normals"; @@ -9002,7 +9006,7 @@ static int edbm_mod_weighted_strength_exec(bContext *C, wmOperator *op) void MESH_OT_mod_weighted_strength(struct wmOperatorType *ot) { /* identifiers */ - ot->name = "Face Strength"; + ot->name = "Face Normals Strength"; ot->description = "Set/Get strength of face (used in Weighted Normal modifier)"; ot->idname = "MESH_OT_mod_weighted_strength"; diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 275bbf36198..2a950677f13 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -242,7 +242,7 @@ void ED_operatormacros_mesh(void) OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); RNA_boolean_set(otmacro->ptr, "mirror", false); ot = WM_operatortype_append_macro("MESH_OT_rip_move", @@ -251,7 +251,7 @@ void ED_operatormacros_mesh(void) OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_rip"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); RNA_boolean_set(otmacro->ptr, "mirror", false); ot = WM_operatortype_append_macro("MESH_OT_rip_edge_move", @@ -260,7 +260,7 @@ void ED_operatormacros_mesh(void) OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_rip_edge"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); RNA_boolean_set(otmacro->ptr, "mirror", false); ot = WM_operatortype_append_macro("MESH_OT_extrude_region_move", @@ -269,34 +269,34 @@ void ED_operatormacros_mesh(void) OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); RNA_boolean_set(otmacro->ptr, "mirror", false); ot = WM_operatortype_append_macro("MESH_OT_extrude_context_move", "Extrude Region and Move", - "Extrude context and move result", + "Extrude region together along the average normal", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_context"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); RNA_boolean_set(otmacro->ptr, "mirror", false); ot = WM_operatortype_append_macro("MESH_OT_extrude_region_shrink_fatten", "Extrude Region and Shrink/Fatten", - "Extrude along normals and move result", + "Extrude region together along local normals", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); RNA_boolean_set(otmacro->ptr, "mirror", false); ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move", "Extrude Individual Faces and Move", - "Extrude faces and move result", + "Extrude each individual face separately along local normals", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_faces_indiv"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); RNA_boolean_set(otmacro->ptr, "mirror", false); ot = WM_operatortype_append_macro("MESH_OT_extrude_edges_move", @@ -305,7 +305,7 @@ void ED_operatormacros_mesh(void) OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_edges_indiv"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); RNA_boolean_set(otmacro->ptr, "mirror", false); ot = WM_operatortype_append_macro("MESH_OT_extrude_vertices_move", @@ -314,7 +314,7 @@ void ED_operatormacros_mesh(void) OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_verts_indiv"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); RNA_boolean_set(otmacro->ptr, "mirror", false); ot = WM_operatortype_append_macro("MESH_OT_polybuild_face_at_cursor_move", @@ -323,7 +323,7 @@ void ED_operatormacros_mesh(void) OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_polybuild_face_at_cursor"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); RNA_boolean_set(otmacro->ptr, "mirror", false); ot = WM_operatortype_append_macro("MESH_OT_polybuild_split_at_cursor_move", @@ -332,7 +332,7 @@ void ED_operatormacros_mesh(void) OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_polybuild_split_at_cursor"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); RNA_boolean_set(otmacro->ptr, "mirror", false); } diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c index 4de277901f4..c203ca56d74 100644 --- a/source/blender/editors/metaball/mball_ops.c +++ b/source/blender/editors/metaball/mball_ops.c @@ -59,7 +59,7 @@ void ED_operatormacros_metaball(void) OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MBALL_OT_duplicate_metaelems"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); } void ED_keymap_metaball(wmKeyConfig *keyconf) diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index 8ef0d85bcfd..eaef9313431 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -22,19 +22,19 @@ set(INC ../../blentranslation ../../bmesh ../../depsgraph + ../../gpencil_modifiers ../../gpu ../../ikplugin ../../imbuf ../../makesdna ../../makesrna ../../modifiers - ../../gpencil_modifiers - ../../shader_fx ../../python + ../../shader_fx ../../render/extern/include ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 87782e895b5..f8a13579732 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1452,7 +1452,8 @@ static int object_delete_exec(bContext *C, wmOperator *op) } /* remove from Grease Pencil parent */ - /* XXX This is likely not correct? Will also remove parent from grease pencil from other scenes, + /* XXX This is likely not correct? + * Will also remove parent from grease pencil from other scenes, * even when use_global is false... */ for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) { for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { @@ -2480,7 +2481,6 @@ static int add_named_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - BKE_scene_object_base_flag_sync_from_object(basen); basen->object->restrictflag &= ~OB_RESTRICT_VIEW; if (event) { diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 6e2f0dba969..70a9870e6ae 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -382,7 +382,7 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) bkr.number_of_rays = scene->r.bake_samples; bkr.threads = BKE_scene_num_threads(scene); bkr.user_scale = (scene->r.bake_flag & R_BAKE_USERSCALE) ? scene->r.bake_user_scale : -1.0f; - //bkr.reports= op->reports; + // bkr.reports= op->reports; /* create low-resolution DM (to bake to) and hi-resolution DM (to bake from) */ bkr.ob_image.array = bake_object_image_get_array(ob); @@ -427,7 +427,7 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj) bkj->number_of_rays = scene->r.bake_samples; bkj->threads = BKE_scene_num_threads(scene); bkj->user_scale = (scene->r.bake_flag & R_BAKE_USERSCALE) ? scene->r.bake_user_scale : -1.0f; - //bkj->reports = op->reports; + // bkj->reports = op->reports; CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { MultiresBakerJobData *data; @@ -484,7 +484,7 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa bkr.mode = bkj->mode; bkr.use_lores_mesh = bkj->use_lores_mesh; bkr.user_scale = bkj->user_scale; - //bkr.reports = bkj->reports; + // bkr.reports = bkj->reports; bkr.ob_image.array = data->ob_image.array; bkr.ob_image.len = data->ob_image.len; diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index 85801dbdd0a..5ae757cac56 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -386,7 +386,7 @@ static bool write_external_bake_pixels(const char *filepath, #ifndef WIN32 chmod(filepath, S_IRUSR | S_IWUSR); #endif - //printf("%s saving bake map: '%s'\n", __func__, filepath); + // printf("%s saving bake map: '%s'\n", __func__, filepath); } /* garbage collection */ diff --git a/source/blender/editors/object/object_collection.c b/source/blender/editors/object/object_collection.c index 54c50db99a5..fcaefaf220d 100644 --- a/source/blender/editors/object/object_collection.c +++ b/source/blender/editors/object/object_collection.c @@ -481,7 +481,7 @@ static int collection_link_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - /* Adding object to collection which is used as duplicollection for self is bad idea. + /* Adding object to collection which is used as dupli-collection for self is bad idea. * * It is also bad idea to add object to collection which is in collection which * contains our current object. diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 8ae736d42c0..078135f46ff 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -160,7 +160,7 @@ static void validate_pyconstraint_cb(Main *bmain, void *arg1, void *arg2) if (index) { /* innovative use of a for...loop to search */ for (text = bmain->texts.first, i = 1; text && index != i; i++, text = text->id.next) { - ; + /* pass */ } } data->text = text; @@ -1828,9 +1828,8 @@ static bool get_new_constraint_target( /* transform cent to global coords for loc */ if (pchanact) { - /* since by default, IK targets the tip of the last bone, use the tip of the active PoseChannel - * if adding a target for an IK Constraint - */ + /* Since by default, IK targets the tip of the last bone, + * use the tip of the active PoseChannel if adding a target for an IK Constraint. */ if (con_type == CONSTRAINT_TYPE_KINEMATIC) { mul_v3_m4v3(obt->loc, obact->obmat, pchanact->pose_tail); } @@ -1844,7 +1843,7 @@ static bool get_new_constraint_target( /* restore, BKE_object_add sets active */ BASACT(view_layer) = base; - base->flag |= BASE_SELECTED; + ED_object_base_select(base, BA_SELECT); /* make our new target the new object */ *tar_ob = obt; @@ -1879,14 +1878,6 @@ static int constraint_add_exec( if (type == CONSTRAINT_TYPE_NULL) { return OPERATOR_CANCELLED; } - if ((type == CONSTRAINT_TYPE_KINEMATIC) && ((!pchan) || (list != &pchan->constraints))) { - BKE_report(op->reports, RPT_ERROR, "IK constraint can only be added to bones"); - return OPERATOR_CANCELLED; - } - if ((type == CONSTRAINT_TYPE_SPLINEIK) && ((!pchan) || (list != &pchan->constraints))) { - BKE_report(op->reports, RPT_ERROR, "Spline IK constraint can only be added to bones"); - return OPERATOR_CANCELLED; - } /* Create a new constraint of the type required, * and add it to the active/given constraints list. */ @@ -2024,8 +2015,33 @@ static int pose_constraint_add_exec(bContext *C, wmOperator *op) /* ------------------ */ +/* Filters constraints that are only compatible with bones */ +static const EnumPropertyItem *object_constraint_add_itemf(bContext *UNUSED(C), + PointerRNA *UNUSED(ptr), + PropertyRNA *UNUSED(prop), + bool *r_free) +{ + const EnumPropertyItem *item = rna_enum_constraint_type_items; + EnumPropertyItem *object_constraint_items = NULL; + int totitem = 0; + + while(item->identifier) { + if((item->value != CONSTRAINT_TYPE_KINEMATIC) && (item->value != CONSTRAINT_TYPE_SPLINEIK)) { + RNA_enum_item_add(&object_constraint_items, &totitem, item); + } + item++; + } + + RNA_enum_item_end(&object_constraint_items, &totitem); + *r_free = true; + + return object_constraint_items; +} + void OBJECT_OT_constraint_add(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Add Constraint"; ot->description = "Add a constraint to the active object"; @@ -2040,11 +2056,15 @@ void OBJECT_OT_constraint_add(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_constraint_type_items, 0, "Type", ""); + prop = RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Type", ""); + RNA_def_enum_funcs(prop, object_constraint_add_itemf); + ot->prop = prop; } void OBJECT_OT_constraint_add_with_targets(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Add Constraint (with Targets)"; ot->description = @@ -2061,7 +2081,9 @@ void OBJECT_OT_constraint_add_with_targets(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_constraint_type_items, 0, "Type", ""); + prop = RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Type", ""); + RNA_def_enum_funcs(prop, object_constraint_add_itemf); + ot->prop = prop; } void POSE_OT_constraint_add(wmOperatorType *ot) @@ -2215,7 +2237,8 @@ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op)) CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) { bConstraint *con, *next; - /* TODO: should we be checking if these constraints were local before we try and remove them? */ + /* TODO: should we be checking if these constraints were local + * before we try and remove them? */ for (con = pchan->constraints.first; con; con = next) { next = con->next; if (con->type == CONSTRAINT_TYPE_KINEMATIC) { diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c index afa2c342452..690bc270605 100644 --- a/source/blender/editors/object/object_data_transfer.c +++ b/source/blender/editors/object/object_data_transfer.c @@ -520,7 +520,8 @@ 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. */ +/* Note this context poll is only really partial, + * it cannot check for all possible invalid cases. */ static bool data_transfer_poll(bContext *C) { Object *ob = ED_object_active_context(C); @@ -773,8 +774,8 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op) dtmd = (DataTransferModifierData *)edit_modifier_property_get( op, ob_act, eModifierType_DataTransfer); - /* If we have a modifier, we transfer data layout from this modifier's source object to active one. - * Else, we transfer data layout from active object to all selected ones. */ + /* If we have a modifier, we transfer data layout from this modifier's source object to + * active one. Else, we transfer data layout from active object to all selected ones. */ if (dtmd) { Object *ob_src = dtmd->ob_source; Object *ob_dst = ob_act; @@ -841,6 +842,7 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op) BLI_freelistN(&ctx_objects); } + DEG_relations_tag_update(CTX_data_main(C)); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL); return OPERATOR_FINISHED; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 95737453777..795e1dd66a5 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -703,8 +703,6 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op) } } - ED_space_image_uv_sculpt_update(bmain, CTX_wm_manager(C), scene); - WM_msg_publish_rna_prop(mbus, &obact->id, obact, Object, mode); if (G.background == false) { @@ -1420,7 +1418,7 @@ void OBJECT_OT_mode_set(wmOperatorType *ot) /* api callbacks */ ot->exec = object_mode_set_exec; - ot->poll = object_mode_set_poll; //ED_operator_object_active_editable; + ot->poll = object_mode_set_poll; // ED_operator_object_active_editable; /* flags */ ot->flag = 0; /* no register/undo here, leave it to operators being called */ @@ -1446,7 +1444,7 @@ void OBJECT_OT_mode_set_or_submode(wmOperatorType *ot) /* api callbacks */ ot->exec = object_mode_set_exec; - ot->poll = object_mode_set_poll; //ED_operator_object_active_editable; + ot->poll = object_mode_set_poll; // ED_operator_object_active_editable; /* flags */ ot->flag = 0; /* no register/undo here, leave it to operators being called */ diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index c1205635a96..c939cb0a61d 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -489,7 +489,7 @@ static bool hook_op_edit_poll(bContext *C) if (ED_operator_editlattice(C)) { return 1; } - //if (ED_operator_editmball(C)) return 1; + // if (ED_operator_editmball(C)) return 1; } return 0; diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index bc95360eab9..e555f0d940d 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -578,12 +578,11 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), static Mesh *modifier_apply_create_mesh_for_modifier(Depsgraph *depsgraph, Scene *UNUSED(scene), Object *object, - ModifierData *md, + ModifierData *md_eval, bool build_shapekey_layers) { Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *object_eval = DEG_get_evaluated_object(depsgraph, object); - ModifierData *md_eval = modifiers_findByName(object_eval, md->name); Mesh *mesh_applied = BKE_mesh_create_derived_for_modifier( depsgraph, scene_eval, object_eval, md_eval, build_shapekey_layers); return mesh_applied; @@ -594,11 +593,11 @@ static int modifier_apply_shape(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob, - ModifierData *md) + ModifierData *md_eval) { - const ModifierTypeInfo *mti = modifierType_getInfo(md->type); + const ModifierTypeInfo *mti = modifierType_getInfo(md_eval->type); - if (mti->isDisabled && mti->isDisabled(scene, md, 0)) { + if (mti->isDisabled && mti->isDisabled(scene, md_eval, 0)) { BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply"); return 0; } @@ -620,12 +619,12 @@ static int modifier_apply_shape(Main *bmain, Key *key = me->key; KeyBlock *kb; - if (!modifier_isSameTopology(md) || mti->type == eModifierTypeType_NonGeometrical) { + if (!modifier_isSameTopology(md_eval) || mti->type == eModifierTypeType_NonGeometrical) { BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to shapes"); return 0; } - mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, scene, ob, md, false); + mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, scene, ob, md_eval, false); if (!mesh_applied) { BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, skipping apply"); return 0; @@ -640,7 +639,7 @@ static int modifier_apply_shape(Main *bmain, BKE_keyblock_convert_from_mesh(me, key, kb); } - kb = BKE_keyblock_add(key, md->name); + kb = BKE_keyblock_add(key, md_eval->name); BKE_mesh_nomain_to_meshkey(mesh_applied, me, kb); BKE_id_free(NULL, mesh_applied); @@ -653,11 +652,11 @@ static int modifier_apply_shape(Main *bmain, } static int modifier_apply_obdata( - ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, ModifierData *md) + ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, ModifierData *md_eval) { - const ModifierTypeInfo *mti = modifierType_getInfo(md->type); + const ModifierTypeInfo *mti = modifierType_getInfo(md_eval->type); - if (mti->isDisabled && mti->isDisabled(scene, md, 0)) { + if (mti->isDisabled && mti->isDisabled(scene, md_eval, 0)) { BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply"); return 0; } @@ -665,7 +664,7 @@ static int modifier_apply_obdata( if (ob->type == OB_MESH) { Mesh *mesh_applied; Mesh *me = ob->data; - MultiresModifierData *mmd = find_multires_modifier_before(scene, md); + MultiresModifierData *mmd = find_multires_modifier_before(scene, md_eval); if (me->key && mti->type != eModifierTypeType_NonGeometrical) { BKE_report(reports, RPT_ERROR, "Modifier cannot be applied to a mesh with shape keys"); @@ -673,18 +672,18 @@ static int modifier_apply_obdata( } /* Multires: ensure that recent sculpting is applied */ - if (md->type == eModifierType_Multires) { + if (md_eval->type == eModifierType_Multires) { multires_force_update(ob); } if (mmd && mmd->totlvl && mti->type == eModifierTypeType_OnlyDeform) { - if (!multiresModifier_reshapeFromDeformModifier(depsgraph, mmd, ob, md)) { + if (!multiresModifier_reshapeFromDeformModifier(depsgraph, mmd, ob, md_eval)) { BKE_report(reports, RPT_ERROR, "Multires modifier returned error, skipping apply"); return 0; } } else { - mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, scene, ob, md, true); + mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, scene, ob, md_eval, true); if (!mesh_applied) { BKE_report(reports, RPT_ERROR, "Modifier returned error, skipping apply"); return 0; @@ -692,7 +691,7 @@ static int modifier_apply_obdata( BKE_mesh_nomain_to_mesh(mesh_applied, me, ob, &CD_MASK_MESH, true); - if (md->type == eModifierType_Multires) { + if (md_eval->type == eModifierType_Multires) { multires_customdata_delete(me); } } @@ -716,7 +715,7 @@ static int modifier_apply_obdata( "Applied modifier only changed CV points, not tessellated/bevel vertices"); vertexCos = BKE_curve_nurbs_vertexCos_get(&curve_eval->nurb, &numVerts); - mti->deformVerts(md, &mectx, NULL, vertexCos, numVerts); + mti->deformVerts(md_eval, &mectx, NULL, vertexCos, numVerts); BK_curve_nurbs_vertexCos_apply(&curve->nurb, vertexCos); MEM_freeN(vertexCos); @@ -2211,8 +2210,8 @@ static void oceanbake_free(void *customdata) /* called by oceanbake, only to check job 'stop' value */ static int oceanbake_breakjob(void *UNUSED(customdata)) { - //OceanBakeJob *ob = (OceanBakeJob *)customdata; - //return *(ob->stop); + // OceanBakeJob *ob = (OceanBakeJob *)customdata; + // return *(ob->stop); /* this is not nice yet, need to make the jobs list template better * for identifying/acting upon various different jobs */ diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 8e3f916b2e4..afc0297cb01 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -271,7 +271,7 @@ void ED_operatormacros_object(void) if (ot) { WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); } /* grr, should be able to pass options on... */ @@ -283,7 +283,7 @@ void ED_operatormacros_object(void) otmacro = WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate"); RNA_boolean_set(otmacro->ptr, "linked", true); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); } } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index bf74c17c361..e15d85a7953 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -994,15 +994,13 @@ static int parent_set_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) +static int parent_set_invoke_menu(bContext *C, wmOperatorType *ot) { Object *parent = ED_object_active_context(C); uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Set Parent To"), ICON_NONE); uiLayout *layout = UI_popup_menu_layout(pup); - wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_parent_set", true); PointerRNA opptr; - #if 0 uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_OBJECT); #else @@ -1072,6 +1070,14 @@ static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent return OPERATOR_INTERFACE; } +static int parent_set_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +{ + if (RNA_property_is_set(op->ptr, op->type->prop)) { + return parent_set_exec(C, op); + } + return parent_set_invoke_menu(C, op->type); +} + static bool parent_set_poll_property(const bContext *UNUSED(C), wmOperator *op, const PropertyRNA *prop) @@ -2152,8 +2158,7 @@ static bool make_local_all__instance_indirect_unused(Main *bmain, BKE_collection_object_add(bmain, collection, ob); base = BKE_view_layer_base_find(view_layer, ob); - base->flag |= BASE_SELECTED; - BKE_scene_object_base_flag_sync_from_base(base); + ED_object_base_select(base, BA_SELECT); DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); changed = true; diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index f0508b5f35c..afdda8d6b7f 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -87,7 +87,7 @@ * \{ */ /** - * simple API for object selection, rather than just using the flag + * Simple API for object selection, rather than just using the flag * this takes into account the 'restrict selection in 3d view' flag. * deselect works always, the restriction just prevents selection * @@ -655,8 +655,8 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) if (nr == OBJECT_SELECT_LINKED_IPO) { // XXX old animation system - //if (ob->ipo == 0) return OPERATOR_CANCELLED; - //object_select_all_by_ipo(C, ob->ipo) + // if (ob->ipo == 0) return OPERATOR_CANCELLED; + // object_select_all_by_ipo(C, ob->ipo) return OPERATOR_CANCELLED; } else if (nr == OBJECT_SELECT_LINKED_OBDATA) { diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 9e1ef96ab93..8836d913475 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -1298,7 +1298,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) ignore_parent_tx(C, bmain, scene, ob); /* other users? */ - //CTX_DATA_BEGIN (C, Object *, ob_other, selected_editable_objects) + // CTX_DATA_BEGIN (C, Object *, ob_other, selected_editable_objects) //{ /* use existing context looper */ @@ -1324,7 +1324,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) ignore_parent_tx(C, bmain, scene, ob_other); } } - //CTX_DATA_END; + // CTX_DATA_END; } } } diff --git a/source/blender/editors/object/object_utils.c b/source/blender/editors/object/object_utils.c index 06a755c30bd..dbca0bbf97b 100644 --- a/source/blender/editors/object/object_utils.c +++ b/source/blender/editors/object/object_utils.c @@ -133,7 +133,7 @@ bool ED_object_calc_active_center(Object *ob, const bool select_only, float r_ce return false; } else { - if (!select_only || (ob->flag & SELECT)) { + if (!select_only || (ob->base_flag & BASE_SELECTED)) { copy_v3_v3(r_center, ob->obmat[3]); return true; } diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index d422ee565a3..05a3d86a23c 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -58,6 +58,7 @@ #include "BKE_lattice.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" #include "DNA_armature_types.h" #include "RNA_access.h" @@ -893,7 +894,8 @@ void ED_vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum) * deform group. */ - /* TODO, this is slow in a loop, better pass def_nr directly, but leave for later... - campbell */ + /* TODO(campbell): This is slow in a loop, better pass def_nr directly, + * but leave for later. */ const int def_nr = BLI_findindex(&ob->defbase, dg); if (def_nr != -1) { @@ -1297,7 +1299,7 @@ static void getVerticalAndHorizontalChange(const float norm[3], dists[index] = dot_v3v3(norm, end) + d; /* vertical change */ changes[index][0] = dists[index] - distToStart; - //printf("vc %f %f\n", distance(end, projB, 3) - distance(start, projA, 3), changes[index][0]); + // printf("vc %f %f\n", distance(end, projB, 3) - distance(start, projA, 3), changes[index][0]); /* horizontal change */ changes[index][1] = len_v3v3(projA, projB); } @@ -2701,6 +2703,7 @@ static int vertex_group_add_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = ED_object_context(C); BKE_object_defgroup_add(ob); + DEG_relations_tag_update(CTX_data_main(C)); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); @@ -2738,6 +2741,7 @@ static int vertex_group_remove_exec(bContext *C, wmOperator *op) } DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + DEG_relations_tag_update(CTX_data_main(C)); WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); @@ -2941,6 +2945,7 @@ static int vertex_group_copy_exec(bContext *C, wmOperator *UNUSED(op)) vgroup_duplicate(ob); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + DEG_relations_tag_update(CTX_data_main(C)); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data); @@ -3471,6 +3476,7 @@ static int vertex_group_mirror_exec(bContext *C, wmOperator *op) ED_mesh_report_mirror(op, totmirr, totfail); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + DEG_relations_tag_update(CTX_data_main(C)); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); @@ -3559,6 +3565,7 @@ static int vertex_group_copy_to_selected_exec(bContext *C, wmOperator *op) if (obact != ob) { if (ED_vgroup_array_copy(ob, obact)) { DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + DEG_relations_tag_update(CTX_data_main(C)); WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob); changed_tot++; } diff --git a/source/blender/editors/physics/CMakeLists.txt b/source/blender/editors/physics/CMakeLists.txt index 3eb443320c3..021c17a94c2 100644 --- a/source/blender/editors/physics/CMakeLists.txt +++ b/source/blender/editors/physics/CMakeLists.txt @@ -25,8 +25,8 @@ set(INC ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 7178a485a6e..40b7a245f69 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -47,6 +47,7 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_query.h" #include "ED_mesh.h" #include "ED_screen.h" @@ -83,10 +84,8 @@ static int surface_slot_add_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } - /* set preview for this surface only and set active */ canvas->active_sur = 0; for (surface = surface->prev; surface; surface = surface->prev) { - surface->flags &= ~MOD_DPAINT_PREVIEW; canvas->active_sur++; } @@ -136,7 +135,6 @@ static int surface_slot_remove_exec(bContext *C, wmOperator *UNUSED(op)) id++; } - dynamicPaint_resetPreview(canvas); DEG_id_tag_update(&obj_ctx->id, ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obj_ctx); @@ -258,11 +256,13 @@ static int output_toggle_exec(bContext *C, wmOperator *op) else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) { if (!exists) { BKE_object_defgroup_add_name(ob, name); + DEG_relations_tag_update(CTX_data_main(C)); } else { bDeformGroup *defgroup = defgroup_find_name(ob, name); if (defgroup) { BKE_object_defgroup_remove(ob, defgroup); + DEG_relations_tag_update(CTX_data_main(C)); } } } @@ -361,6 +361,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job) DynamicPaintSurface *surface = job->surface; Object *cObject = job->ob; DynamicPaintCanvasSettings *canvas = surface->canvas; + Scene *input_scene = DEG_get_input_scene(job->depsgraph); Scene *scene = job->scene; int frame = 1, orig_frame; int frames; @@ -376,8 +377,8 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job) /* Set frame to start point (also inits modifier data) */ frame = surface->start_frame; - orig_frame = scene->r.cfra; - scene->r.cfra = (int)frame; + orig_frame = input_scene->r.cfra; + input_scene->r.cfra = (int)frame; ED_update_for_newframe(job->bmain, job->depsgraph); /* Init surface */ @@ -403,7 +404,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job) *(job->progress) = progress; /* calculate a frame */ - scene->r.cfra = (int)frame; + input_scene->r.cfra = (int)frame; ED_update_for_newframe(job->bmain, job->depsgraph); if (!dynamicPaint_calculateFrame(surface, job->depsgraph, scene, cObject, frame)) { job->success = 0; @@ -439,7 +440,8 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job) } } - scene->r.cfra = orig_frame; + input_scene->r.cfra = orig_frame; + ED_update_for_newframe(job->bmain, job->depsgraph); } static void dpaint_bake_startjob(void *customdata, short *stop, short *do_update, float *progress) @@ -471,25 +473,26 @@ static void dpaint_bake_startjob(void *customdata, short *stop, short *do_update */ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op) { - DynamicPaintModifierData *pmd = NULL; - DynamicPaintCanvasSettings *canvas; - Object *ob = ED_object_context(C); - Scene *scene = CTX_data_scene(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); + Object *ob_ = ED_object_context(C); + Object *object_eval = DEG_get_evaluated_object(depsgraph, ob_); + Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); DynamicPaintSurface *surface; /* * Get modifier data */ - pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint); - if (!pmd) { + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType( + object_eval, eModifierType_DynamicPaint); + if (pmd == NULL) { BKE_report(op->reports, RPT_ERROR, "Bake failed: no Dynamic Paint modifier found"); return OPERATOR_CANCELLED; } /* Make sure we're dealing with a canvas */ - canvas = pmd->canvas; - if (!canvas) { + DynamicPaintCanvasSettings *canvas = pmd->canvas; + if (canvas == NULL) { BKE_report(op->reports, RPT_ERROR, "Bake failed: invalid canvas"); return OPERATOR_CANCELLED; } @@ -501,15 +504,15 @@ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op) DynamicPaintBakeJob *job = MEM_mallocN(sizeof(DynamicPaintBakeJob), "DynamicPaintBakeJob"); job->bmain = CTX_data_main(C); - job->scene = scene; + job->scene = scene_eval; job->depsgraph = CTX_data_depsgraph(C); - job->ob = ob; + job->ob = object_eval; job->canvas = canvas; job->surface = surface; wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), - scene, + CTX_data_scene(C), "Dynamic Paint Bake", WM_JOB_PROGRESS, WM_JOB_TYPE_DPAINT_BAKE); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 9921ca02af9..dc634865a0a 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -371,7 +371,7 @@ void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra) } else { key->flag |= PEK_HIDE; - //key->flag &= ~PEK_SELECT; + // key->flag &= ~PEK_SELECT; } } } @@ -4162,7 +4162,8 @@ static void brush_add_count_iter(void *__restrict iter_data_v, add_pars[iter].num_dmcache = DMCACHE_ISCHILD; } else if (iter_data->mesh == psmd_eval->mesh_original) { - /* Final DM is not same topology as orig mesh, we have to map num_dmcache to real final dm. */ + /* Final DM is not same topology as orig mesh, + * we have to map num_dmcache to real final dm. */ add_pars[iter].num = add_pars[iter].num_dmcache; add_pars[iter].num_dmcache = psys_particle_dm_face_lookup(psmd_eval->mesh_final, psmd_eval->mesh_original, diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 1ec0aeffa17..fd092eb4b78 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -434,7 +434,8 @@ static void fluid_init_all_channels(bContext *C, /* now scene data should be current according to animation system, so we fill the channels */ /* Domain time */ - // TODO: have option for not running sim, time mangling, in which case second case comes in handy + /* TODO: have option for not running sim, time mangling, + * in which case second case comes in handy. */ if (channels->DomainTime) { time = get_fluid_rate(domainSettings) * (float)channels->aniFrameTime; timeAtFrame = channels->timeAtFrame[i] + time; diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt index 5d414c3af0f..6c62dbcb3a2 100644 --- a/source/blender/editors/render/CMakeLists.txt +++ b/source/blender/editors/render/CMakeLists.txt @@ -21,17 +21,17 @@ set(INC ../../blenlib ../../blenloader ../../blentranslation + ../../bmesh ../../depsgraph ../../draw ../../gpu ../../imbuf - ../../bmesh ../../makesdna ../../makesrna ../../render/extern/include ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 8403f178284..09bcc0a3058 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -358,7 +358,7 @@ static int screen_render_exec(bContext *C, wmOperator *op) * otherwise, invalidated cache entries can make their way into * the output rendering. We can't put that into RE_BlenderFrame, * since sequence rendering can call that recursively... (peter) */ - BKE_sequencer_cache_cleanup(); + BKE_sequencer_cache_cleanup(scene); RE_SetReports(re, op->reports); @@ -978,7 +978,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even * otherwise, invalidated cache entries can make their way into * the output rendering. We can't put that into RE_BlenderFrame, * since sequence rendering can call that recursively... (peter) */ - BKE_sequencer_cache_cleanup(); + BKE_sequencer_cache_cleanup(scene); // store spare // get view3d layer, local layer, make this nice api call to render @@ -1115,7 +1115,10 @@ void RENDER_OT_render(wmOperatorType *ot) ot->cancel = screen_render_cancel; ot->exec = screen_render_exec; - /*ot->poll = ED_operator_screenactive;*/ /* this isn't needed, causes failer in background mode */ + /* this isn't needed, causes failer in background mode */ +#if 0 + ot->poll = ED_operator_screenactive; +#endif prop = RNA_def_boolean(ot->srna, "animation", diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 41ef5d81901..342c6269419 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -381,9 +381,10 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R } } else { - draw_flags |= V3D_OFSDRAW_USE_GPENCIL; + draw_flags |= V3D_OFSDRAW_SHOW_ANNOTATION; ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(depsgraph, scene, + NULL, OB_SOLID, scene->camera, oglrender->sizex, @@ -488,8 +489,6 @@ static void screen_opengl_render_apply(const bContext *C, OGLRender *oglrender) for (view_id = 0; view_id < oglrender->views_len; view_id++) { context.view_id = view_id; context.gpu_offscreen = oglrender->ofs; - context.gpu_full_samples = oglrender->ofs_full_samples; - oglrender->seq_data.ibufs_arr[view_id] = BKE_sequencer_give_ibuf(&context, CFRA, chanshown); } } @@ -516,24 +515,6 @@ static void screen_opengl_render_apply(const bContext *C, OGLRender *oglrender) } } -static bool screen_opengl_fullsample_enabled(Scene *scene) -{ - if (scene->r.scemode & R_FULL_SAMPLE) { - return true; - } - else { - /* XXX TODO: - * Technically if the hardware supports MSAA we could keep using Blender 2.7x approach. - * However anti-aliasing without full_sample is not playing well even in 2.7x. - * - * For example, if you enable depth of field, there is aliasing, even if the viewport is fine. - * For 2.8x this is more complicated because so many things rely on shader. - * So until we fix the gpu_framebuffer anti-aliasing suupport we need to force full sample. - */ - return true; - } -} - static bool screen_opengl_render_init(bContext *C, wmOperator *op) { /* new render clears all callbacks */ @@ -547,8 +528,6 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op) GPUOffScreen *ofs; OGLRender *oglrender; int sizex, sizey; - const int samples = (scene->r.mode & R_OSA) ? scene->r.osa : 0; - const bool full_samples = (samples != 0) && screen_opengl_fullsample_enabled(scene); bool is_view_context = RNA_boolean_get(op->ptr, "view_context"); const bool is_animation = RNA_boolean_get(op->ptr, "animation"); const bool is_sequencer = RNA_boolean_get(op->ptr, "sequencer"); @@ -597,7 +576,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op) /* corrects render size with actual size, not every card supports non-power-of-two dimensions */ DRW_opengl_context_enable(); /* Offscreen creation needs to be done in DRW context. */ - ofs = GPU_offscreen_create(sizex, sizey, full_samples ? 0 : samples, true, true, err_out); + ofs = GPU_offscreen_create(sizex, sizey, 0, true, true, err_out); DRW_opengl_context_disable(); if (!ofs) { @@ -610,8 +589,6 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op) op->customdata = oglrender; oglrender->ofs = ofs; - oglrender->ofs_samples = samples; - oglrender->ofs_full_samples = full_samples; oglrender->sizex = sizex; oglrender->sizey = sizey; oglrender->bmain = CTX_data_main(C); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index c9a4f1948ce..64f20a4a348 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -331,28 +331,22 @@ static World *preview_get_localized_world(ShaderPreview *sp, World *world) return sp->worldcopy; } -static ID *duplicate_ids(ID *id, Depsgraph *depsgraph) +static ID *duplicate_ids(ID *id) { if (id == NULL) { /* Non-ID preview render. */ return NULL; } - ID *id_eval = id; - - if (depsgraph) { - id_eval = DEG_get_evaluated_id(depsgraph, id); - } - switch (GS(id->name)) { case ID_MA: - return (ID *)BKE_material_localize((Material *)id_eval); + return (ID *)BKE_material_localize((Material *)id); case ID_TE: - return (ID *)BKE_texture_localize((Tex *)id_eval); + return (ID *)BKE_texture_localize((Tex *)id); case ID_LA: - return (ID *)BKE_light_localize((Light *)id_eval); + return (ID *)BKE_light_localize((Light *)id); case ID_WO: - return (ID *)BKE_world_localize((World *)id_eval); + return (ID *)BKE_world_localize((World *)id); case ID_IM: case ID_BR: case ID_SCR: @@ -455,7 +449,7 @@ static Scene *preview_prepare_scene( } } else { - sce->r.mode &= ~(R_OSA); + sce->display.render_aa = SCE_DISPLAY_AA_OFF; } for (Base *base = view_layer->object_bases.first; base; base = base->next) { @@ -820,11 +814,6 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs char name[32]; int sizex; Main *pr_main = sp->pr_main; - ID *id_eval = id; - - if (sp->depsgraph) { - id_eval = DEG_get_evaluated_id(sp->depsgraph, id); - } /* in case of split preview, use border render */ if (split) { @@ -848,7 +837,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs } /* get the stuff from the builtin preview dbase */ - sce = preview_prepare_scene(sp->bmain, sp->scene, id_eval, idtype, sp); + sce = preview_prepare_scene(sp->bmain, sp->scene, id, idtype, sp); if (sce == NULL) { return; } @@ -872,7 +861,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs if (sp->pr_method == PR_ICON_RENDER) { sce->r.scemode |= R_NO_IMAGE_LOAD; - sce->r.mode |= R_OSA; + sce->display.render_aa = SCE_DISPLAY_AA_SAMPLES_8; } else if (sp->pr_method == PR_NODE_RENDER) { if (idtype == ID_MA) { @@ -881,10 +870,10 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs else if (idtype == ID_TE) { sce->r.scemode |= R_TEXNODE_PREVIEW; } - sce->r.mode &= ~R_OSA; + sce->display.render_aa = SCE_DISPLAY_AA_OFF; } else { /* PR_BUTS_RENDER */ - sce->r.mode |= R_OSA; + sce->display.render_aa = SCE_DISPLAY_AA_SAMPLES_8; } /* callbacs are cleared on GetRender() */ @@ -1327,7 +1316,7 @@ void ED_preview_icon_render( ip.scene = scene; ip.owner = BKE_previewimg_id_ensure(id); ip.id = id; - ip.id_copy = duplicate_ids(id, NULL); + ip.id_copy = duplicate_ids(id); icon_preview_add_size(&ip, rect, sizex, sizey); @@ -1368,7 +1357,7 @@ void ED_preview_icon_job( ip->depsgraph = CTX_data_depsgraph(C); ip->owner = owner; ip->id = id; - ip->id_copy = duplicate_ids(id, ip->depsgraph); + ip->id_copy = duplicate_ids(id); icon_preview_add_size(ip, rect, sizex, sizey); @@ -1434,7 +1423,7 @@ void ED_preview_shader_job(const bContext *C, sp->sizey = sizey; sp->pr_method = method; sp->id = id; - sp->id_copy = duplicate_ids(id, sp->depsgraph); + sp->id_copy = duplicate_ids(id); sp->own_id_copy = true; sp->parent = parent; sp->slot = slot; diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index 3f3f98bc6e5..55353039b24 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -265,7 +265,7 @@ static void image_changed(Main *bmain, Image *ima) /* textures */ for (tex = bmain->textures.first; tex; tex = tex->id.next) { - if (tex->ima == ima) { + if (tex->type == TEX_IMAGE && tex->ima == ima) { texture_changed(bmain, tex); } } diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt index 9576920bcd2..dc355148ad3 100644 --- a/source/blender/editors/screen/CMakeLists.txt +++ b/source/blender/editors/screen/CMakeLists.txt @@ -29,8 +29,8 @@ set(INC ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 5cd5153b060..8c73f4cd649 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -457,19 +457,6 @@ void ED_area_do_msg_notify_tag_refresh( ED_area_tag_refresh(sa); } -static void region_do_msg_notify_tag_redraw( - /* Follow wmMsgNotifyFn spec */ - bContext *UNUSED(C), - wmMsgSubscribeKey *UNUSED(msg_key), - wmMsgSubscribeValue *msg_val) -{ - ARegion *ar = msg_val->owner; - ED_region_tag_redraw(ar); - - /* FIXME(campbell): shouldn't be needed. */ - WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, NULL); -} - void ED_area_do_mgs_subscribe_for_tool_header( /* Follow ARegionType.message_subscribe */ const struct bContext *UNUSED(C), @@ -480,18 +467,39 @@ void ED_area_do_mgs_subscribe_for_tool_header( struct ARegion *ar, struct wmMsgBus *mbus) { + BLI_assert(ar->regiontype == RGN_TYPE_TOOL_HEADER); wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { .owner = ar, .user_data = ar, - /* TODO(campbell): investigate why - * ED_region_do_msg_notify_tag_redraw doesn't work here. */ - // .notify = ED_region_do_msg_notify_tag_redraw, - .notify = region_do_msg_notify_tag_redraw, + .notify = ED_region_do_msg_notify_tag_redraw, }; WM_msg_subscribe_rna_prop( mbus, &workspace->id, workspace, WorkSpace, tools, &msg_sub_value_region_tag_redraw); } +void ED_area_do_mgs_subscribe_for_tool_ui( + /* Follow ARegionType.message_subscribe */ + const struct bContext *UNUSED(C), + struct WorkSpace *workspace, + struct Scene *UNUSED(scene), + struct bScreen *UNUSED(screen), + struct ScrArea *UNUSED(sa), + struct ARegion *ar, + struct wmMsgBus *mbus) +{ + BLI_assert(ar->regiontype == RGN_TYPE_UI); + const char *category = UI_panel_category_active_get(ar, false); + if (category && STREQ(category, "Tool")) { + wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { + .owner = ar, + .user_data = ar, + .notify = ED_region_do_msg_notify_tag_redraw, + }; + WM_msg_subscribe_rna_prop( + mbus, &workspace->id, workspace, WorkSpace, tools, &msg_sub_value_region_tag_redraw); + } +} + /** * 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 @@ -1110,7 +1118,7 @@ static int rct_fits(const rcti *rect, char dir, int size) static void region_overlap_fix(ScrArea *sa, ARegion *ar) { ARegion *ar1; - const int align = ar->alignment & ~RGN_SPLIT_PREV; + const int align = RGN_ALIGN_ENUM_FROM_MASK(ar->alignment); int align1 = 0; /* find overlapping previous region on same place */ @@ -1227,7 +1235,7 @@ static void region_rect_recursive( } } - int alignment = ar->alignment & ~RGN_SPLIT_PREV; + int alignment = RGN_ALIGN_ENUM_FROM_MASK(ar->alignment); /* set here, assuming userpref switching forces to call this again */ ar->overlap = ED_region_is_overlap(sa->spacetype, ar->regiontype); @@ -1524,7 +1532,8 @@ static void area_calc_totrct(ScrArea *sa, const rcti *window_rect) sa->totrct.ymax -= px; } /* Although the following asserts are correct they lead to a very unstable Blender. - * And the asserts would fail even in 2.7x (they were added in 2.8x as part of the top-bar commit). + * And the asserts would fail even in 2.7x + * (they were added in 2.8x as part of the top-bar commit). * For more details see T54864. */ #if 0 BLI_assert(sa->totrct.xmin >= 0); @@ -1550,6 +1559,13 @@ static void region_subwindow(ARegion *ar) ar->visible = !hidden; } +static bool event_in_markers_region(const ARegion *ar, const wmEvent *event) +{ + rcti rect = ar->winrct; + rect.ymax = rect.ymin + UI_MARKER_MARGIN_Y; + return BLI_rcti_isect_pt(&rect, event->x, event->y); +} + /** * \param ar: Region, may be NULL when adding handlers for \a sa. */ @@ -1591,13 +1607,7 @@ static void ed_default_handlers( if (flag & ED_KEYMAP_MARKERS) { /* time-markers */ wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Markers", 0, 0); - - /* use a boundbox restricted map */ - /* same local check for all areas */ - static rcti rect = {0, 10000, 0, -1}; - rect.ymax = UI_MARKER_MARGIN_Y; - BLI_assert(ar->type->regionid == RGN_TYPE_WINDOW); - WM_event_add_keymap_handler_bb(handlers, keymap, &rect, &ar->winrct); + WM_event_add_keymap_handler_poll(handlers, keymap, event_in_markers_region); } if (flag & ED_KEYMAP_ANIMATION) { /* frame changing and timeline operators (for time spaces) */ @@ -1688,7 +1698,7 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar } /* Some AZones use View2D data which is only updated in region init, so call that first! */ - region_azones_add(screen, area, ar, ar->alignment & ~RGN_SPLIT_PREV); + region_azones_add(screen, area, ar, RGN_ALIGN_ENUM_FROM_MASK(ar->alignment)); } ED_area_azones_update(area, &win->eventstate->x); @@ -1759,7 +1769,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) } /* Some AZones use View2D data which is only updated in region init, so call that first! */ - region_azones_add(screen, sa, ar, ar->alignment & ~RGN_SPLIT_PREV); + region_azones_add(screen, sa, ar, RGN_ALIGN_ENUM_FROM_MASK(ar->alignment)); } /* Avoid re-initializing tools while resizing the window. */ @@ -2514,9 +2524,8 @@ void ED_region_panels_draw(const bContext *C, ARegion *ar) mask_buf.xmax -= UI_PANEL_CATEGORY_MARGIN_WIDTH; mask = &mask_buf; } - View2DScrollers *scrollers = UI_view2d_scrollers_calc( - C, v2d, mask, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); - UI_view2d_scrollers_draw(C, v2d, scrollers); + View2DScrollers *scrollers = UI_view2d_scrollers_calc(v2d, mask); + UI_view2d_scrollers_draw(v2d, scrollers); UI_view2d_scrollers_free(scrollers); } diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 6dcb9f8a82c..c60469e092f 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -98,7 +98,6 @@ const char *screen_context_dir[] = { "weight_paint_object", "image_paint_object", "particle_edit_object", - "uv_sculpt_object", "pose_object", "sequences", "selected_sequences", @@ -520,22 +519,6 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } - else if (CTX_data_equals(member, "uv_sculpt_object")) { - /* TODO(campbell): most likely we change rules for uv_sculpt. */ - if (obact && (obact->mode & OB_MODE_EDIT)) { - const ToolSettings *ts = scene->toolsettings; - if (ts->use_uv_sculpt) { - if (ED_uvedit_test(obedit)) { - WorkSpace *workspace = CTX_wm_workspace(C); - if ((workspace->tools_space_type == SPACE_IMAGE) && - (workspace->tools_mode == SI_MODE_UV)) { - CTX_data_id_pointer_set(result, &obact->id); - } - } - } - } - return 1; - } else if (CTX_data_equals(member, "pose_object")) { Object *obpose = BKE_object_pose_armature_get(obact); if (obpose) { diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c index 6fea27a9cff..1124070486f 100644 --- a/source/blender/editors/screen/screen_draw.c +++ b/source/blender/editors/screen/screen_draw.c @@ -40,7 +40,8 @@ #include "screen_intern.h" /** - * Draw horizontal shape visualizing future joining (left as well right direction of future joining). + * Draw horizontal shape visualizing future joining + * (left as well right direction of future joining). */ static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos) { diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 50f0ab9b96b..07a87982890 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -424,31 +424,6 @@ void ED_screen_do_listen(bContext *C, wmNotifier *note) } } -/* helper call for below, dpi changes headers */ -static void screen_refresh_headersizes(void) -{ - const ListBase *lb = BKE_spacetypes_list(); - SpaceType *st; - - for (st = lb->first; st; st = st->next) { - ARegionType *art; - art = BKE_regiontype_from_id(st, RGN_TYPE_HEADER); - if (art) { - art->prefsizey = ED_area_headersize(); - } - - art = BKE_regiontype_from_id(st, RGN_TYPE_TOOL_HEADER); - if (art) { - art->prefsizey = ED_area_headersize(); - } - - art = BKE_regiontype_from_id(st, RGN_TYPE_FOOTER); - if (art) { - art->prefsizey = ED_area_headersize(); - } - } -} - /* make this screen usable */ /* for file read and first use, for scaling window, area moves */ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) @@ -461,7 +436,6 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) WM_window_set_dpi(win); ED_screen_global_areas_refresh(win); - screen_refresh_headersizes(); screen_geom_vertices_scale(win, screen); @@ -910,9 +884,11 @@ static bScreen *screen_fullscreen_find_associated_normal_screen(const Main *bmai { for (bScreen *screen_iter = bmain->screens.first; screen_iter; screen_iter = screen_iter->id.next) { - ScrArea *sa = screen_iter->areabase.first; - if (sa && sa->full == screen) { - return screen_iter; + if ((screen_iter != screen) && ELEM(screen_iter->state, SCREENMAXIMIZED, SCREENFULL)) { + ScrArea *sa = screen_iter->areabase.first; + if (sa && sa->full == screen) { + return screen_iter; + } } } @@ -931,9 +907,7 @@ bScreen *screen_change_prepare( return NULL; } - if (ELEM(screen_new->state, SCREENMAXIMIZED, SCREENFULL)) { - screen_new = screen_fullscreen_find_associated_normal_screen(bmain, screen_new); - } + screen_new = screen_fullscreen_find_associated_normal_screen(bmain, screen_new); /* check for valid winid */ if (!(screen_new->winid == 0 || screen_new->winid == win->winid)) { diff --git a/source/blender/editors/screen/screen_geometry.c b/source/blender/editors/screen/screen_geometry.c index a0d9c232195..25855382307 100644 --- a/source/blender/editors/screen/screen_geometry.c +++ b/source/blender/editors/screen/screen_geometry.c @@ -160,7 +160,6 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc) 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; @@ -192,37 +191,55 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc) 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); } - } - - /* 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; + /* test for collapsed areas. This could happen in some blender version... */ + /* ton: removed option now, it needs Context... */ + + int headery = ED_area_headersize() + (U.pixelsize * 2); + + if (facy > 1) { + /* Keep timeline small in video edit workspace. */ + for (sa = sc->areabase.first; sa; sa = sa->next) { + if (sa->spacetype == SPACE_ACTION && sa->v1->vec.y == screen_rect.ymin && + screen_geom_area_height(sa) <= headery * facy + 1) { + ScrEdge *se = BKE_screen_find_edge(sc, sa->v2, sa->v3); + if (se) { + const int yval = sa->v1->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->v1 && sv != sa->v4) { + if (sv->flag) { + sv->vec.y = yval; + } + } + } + } + } + } } - - 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; + if (facy < 1) { + /* make each window at least ED_area_headersize() high */ + for (sa = sc->areabase.first; sa; sa = sa->next) { + 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 not a collapsed area */ + if (sv != sa->v2 && sv != sa->v3) { + if (sv->flag) { + sv->vec.y = yval; + } + } } } } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 8e7475ec511..61fa05f243f 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -67,6 +67,7 @@ #include "WM_types.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" #include "ED_anim_api.h" #include "ED_armature.h" @@ -728,7 +729,9 @@ static bool azone_clipped_rect_calc(const AZone *az, rcti *r_rect_clip) const ARegion *ar = az->ar; *r_rect_clip = az->rect; if (az->type == AZONE_REGION) { - if (ar->overlap && (ar->v2d.keeptot != V2D_KEEPTOT_STRICT)) { + if (ar->overlap && (ar->v2d.keeptot != V2D_KEEPTOT_STRICT) && + /* Only when this isn't hidden (where it's displayed as an button that expands). */ + ((az->ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) == 0)) { /* A floating region to be resized, clip by the visible region. */ switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: @@ -988,7 +991,8 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event) AZone *az = screen_actionzone_find_xy(sc, &event->x); sActionzoneData *sad; - /* quick escape - Scroll azones only hide/unhide the scroll-bars, they have their own handling. */ + /* 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; } @@ -2428,7 +2432,7 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge) /* regions in regions. */ if (scalear->alignment & RGN_SPLIT_PREV) { - const int align = scalear->alignment & RGN_ALIGN_ENUM_MASK; + const int align = RGN_ALIGN_ENUM_FROM_MASK(scalear->alignment); if (ELEM(align, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) { ARegion *ar = scalear->prev; @@ -2767,7 +2771,7 @@ static int frame_offset_exec(bContext *C, wmOperator *op) areas_do_frame_follow(C, false); - BKE_sound_seek_scene(bmain, scene); + BKE_sound_update_and_seek(bmain, CTX_data_depsgraph(C)); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); @@ -2829,7 +2833,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op) areas_do_frame_follow(C, true); - BKE_sound_seek_scene(bmain, scene); + BKE_sound_update_and_seek(bmain, CTX_data_depsgraph(C)); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } @@ -2945,7 +2949,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op) else { areas_do_frame_follow(C, true); - BKE_sound_seek_scene(bmain, scene); + BKE_sound_update_and_seek(bmain, CTX_data_depsgraph(C)); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); @@ -3012,7 +3016,7 @@ static int marker_jump_exec(bContext *C, wmOperator *op) areas_do_frame_follow(C, true); - BKE_sound_seek_scene(bmain, scene); + BKE_sound_update_and_seek(bmain, CTX_data_depsgraph(C)); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); @@ -4284,7 +4288,8 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv if (screen->animtimer && screen->animtimer == event->customdata) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); + Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); wmTimer *wt = screen->animtimer; ScreenAnimData *sad = wt->customdata; wmWindowManager *wm = CTX_wm_manager(C); @@ -4305,7 +4310,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv } if ((scene->audio.flag & AUDIO_SYNC) && (sad->flag & ANIMPLAY_FLAG_REVERSE) == false && - isfinite(time = BKE_sound_sync_scene(scene))) { + isfinite(time = BKE_sound_sync_scene(scene_eval))) { double newfra = (double)time * FPS; /* give some space here to avoid jumps */ @@ -4398,7 +4403,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv } if (sad->flag & ANIMPLAY_FLAG_JUMPED) { - BKE_sound_seek_scene(bmain, scene); + BKE_sound_update_and_seek(bmain, depsgraph); #ifdef PROFILE_AUDIO_SYNCH old_frame = CFRA; #endif @@ -4520,11 +4525,12 @@ int ED_screen_animation_play(bContext *C, int sync, int mode) { bScreen *screen = CTX_wm_screen(C); Scene *scene = CTX_data_scene(C); + Scene *scene_eval = DEG_get_evaluated_scene(CTX_data_depsgraph(C)); if (ED_screen_animation_playing(CTX_wm_manager(C))) { /* stop playback now */ ED_screen_animation_timer(C, 0, 0, 0, 0); - BKE_sound_stop_scene(scene); + BKE_sound_stop_scene(scene_eval); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } @@ -4533,7 +4539,7 @@ int ED_screen_animation_play(bContext *C, int sync, int mode) int refresh = SPACE_ACTION; if (mode == 1) { /* XXX only play audio forwards!? */ - BKE_sound_play_scene(scene); + BKE_sound_play_scene(scene_eval); } ED_screen_animation_timer(C, screen->redraws_flag, refresh, sync, mode); diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index 6294a64af0f..2dfa05cf6b0 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -165,7 +165,9 @@ bool ED_workspace_change(WorkSpace *workspace_new, bContext *C, wmWindowManager } screen_new = screen_change_prepare(screen_old, screen_new, bmain, C, win); - BLI_assert(BKE_workspace_layout_screen_get(layout_new) == screen_new); + if (BKE_workspace_layout_screen_get(layout_new) != screen_new) { + layout_new = BKE_workspace_layout_find(workspace_new, screen_new); + } if (screen_new == NULL) { return false; diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index cddaf69b965..23617e687ea 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -29,8 +29,8 @@ set(INC ../../makesrna ../../render/extern/include ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 697622aae96..65e24cecf82 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -833,7 +833,7 @@ static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups, x -= vc->ar->winrct.xmin; y -= vc->ar->winrct.ymin; - /* coloured overlay should be drawn separately */ + /* Colored overlay should be drawn separately. */ if (col) { if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY)) { paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, true, true); diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index 78832bbbd8f..474d3a8ceba 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -999,8 +999,8 @@ static void paint_2d_lift_soften( /* subtract blurred image from normal image gives high pass filter */ sub_v3_v3v3(outrgb, rgba, outrgb); - /* now rgba_ub contains the edge result, but this should be converted to luminance to avoid - * colored speckles appearing in final image, and also to check for threshold */ + /* Now rgba_ub contains the edge result, but this should be converted to luminance to + * avoid colored speckles appearing in final image, and also to check for threshold. */ outrgb[0] = outrgb[1] = outrgb[2] = IMB_colormanagement_get_luminance(outrgb); if (fabsf(outrgb[0]) > threshold) { float mask = BKE_brush_alpha_get(s->scene, s->brush); diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 5436c5912bc..0340a4989e1 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -759,9 +759,9 @@ static bool project_paint_PickColor(const ProjPaintState *ps, } } else { - //xi = (int)((uv[0]*ibuf->x) + 0.5f); - //yi = (int)((uv[1]*ibuf->y) + 0.5f); - //if (xi < 0 || xi >= ibuf->x || yi < 0 || yi >= ibuf->y) return 0; + // xi = (int)((uv[0]*ibuf->x) + 0.5f); + // yi = (int)((uv[1]*ibuf->y) + 0.5f); + // if (xi < 0 || xi >= ibuf->x || yi < 0 || yi >= ibuf->y) return 0; /* wrap */ xi = mod_i((int)(uv[0] * ibuf->x), ibuf->x); @@ -1772,8 +1772,8 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps, } /* otherwise no mask normal is needed, were within the limit */ } - /* This only works when the opacity doesn't change while painting, stylus pressure messes with this - * so don't use it. */ + /* This only works when the opacity doesn't change while painting, stylus pressure messes with + * this so don't use it. */ // if (ps->is_airbrush == 0) mask *= BKE_brush_alpha_get(ps->brush); return mask; @@ -1888,14 +1888,14 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps, x_round = x_tile * IMAPAINT_TILE_SIZE; y_round = y_tile * IMAPAINT_TILE_SIZE; - //memset(projPixel, 0, size); + // memset(projPixel, 0, size); tile_offset = (x_px - x_round) + (y_px - y_round) * IMAPAINT_TILE_SIZE; tile_index = project_paint_undo_subtiles(tinf, x_tile, y_tile); /* other thread may be initializing the tile so wait here */ while (projima->undoRect[tile_index] == TILE_PENDING) { - ; + /* pass */ } BLI_assert(tile_index < (IMAPAINT_TILE_NUMBER(ibuf->x) * IMAPAINT_TILE_NUMBER(ibuf->y))); @@ -2203,8 +2203,8 @@ static bool line_clip_rect2f(const rctf *cliprect, /** * Scale the tri about its center - * scaling by #PROJ_FACE_SCALE_SEAM (0.99x) is used for getting fake UV pixel coords that are on the - * edge of the face but slightly inside it occlusion tests don't return hits on adjacent faces + * scaling by #PROJ_FACE_SCALE_SEAM (0.99x) is used for getting fake UV pixel coords that are on + * the edge of the face but slightly inside it occlusion tests don't return hits on adjacent faces. */ #ifndef PROJ_DEBUG_NOSEAMBLEED @@ -2227,7 +2227,7 @@ static void scale_tri(float insetCos[3][3], const float *origCos[4], const float add_v3_v3(insetCos[1], cent); add_v3_v3(insetCos[2], cent); } -#endif //PROJ_DEBUG_NOSEAMBLEED +#endif // PROJ_DEBUG_NOSEAMBLEED static float len_squared_v2v2_alt(const float v1[2], const float v2_1, const float v2_2) { @@ -2303,8 +2303,8 @@ static bool project_bucket_isect_circle(const float cent[2], /* Note for rect_to_uvspace_ortho() and rect_to_uvspace_persp() * in ortho view this function gives good results when bucket_bounds are outside the triangle - * however in some cases, perspective view will mess up with faces that have minimal screenspace area - * (viewed from the side) + * however in some cases, perspective view will mess up with faces + * that have minimal screenspace area (viewed from the side). * * for this reason its not reliable in this case so we'll use the Simple Barycentric' * funcs that only account for points inside the triangle. @@ -2329,17 +2329,17 @@ static void rect_to_uvspace_ortho(const rctf *bucket_bounds, barycentric_weights_v2(v1coSS, v2coSS, v3coSS, uv, w); interp_v2_v2v2v2(bucket_bounds_uv[flip ? 3 : 0], uv1co, uv2co, uv3co, w); - //uv[0] = bucket_bounds->xmax; // set above + // uv[0] = bucket_bounds->xmax; // set above uv[1] = bucket_bounds->ymax; barycentric_weights_v2(v1coSS, v2coSS, v3coSS, uv, w); interp_v2_v2v2v2(bucket_bounds_uv[flip ? 2 : 1], uv1co, uv2co, uv3co, w); uv[0] = bucket_bounds->xmin; - //uv[1] = bucket_bounds->ymax; // set above + // uv[1] = bucket_bounds->ymax; // set above barycentric_weights_v2(v1coSS, v2coSS, v3coSS, uv, w); interp_v2_v2v2v2(bucket_bounds_uv[flip ? 1 : 2], uv1co, uv2co, uv3co, w); - //uv[0] = bucket_bounds->xmin; // set above + // uv[0] = bucket_bounds->xmin; // set above uv[1] = bucket_bounds->ymin; barycentric_weights_v2(v1coSS, v2coSS, v3coSS, uv, w); interp_v2_v2v2v2(bucket_bounds_uv[flip ? 0 : 3], uv1co, uv2co, uv3co, w); @@ -2365,17 +2365,17 @@ static void rect_to_uvspace_persp(const rctf *bucket_bounds, barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, uv, w); interp_v2_v2v2v2(bucket_bounds_uv[flip ? 3 : 0], uv1co, uv2co, uv3co, w); - //uv[0] = bucket_bounds->xmax; // set above + // uv[0] = bucket_bounds->xmax; // set above uv[1] = bucket_bounds->ymax; barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, uv, w); interp_v2_v2v2v2(bucket_bounds_uv[flip ? 2 : 1], uv1co, uv2co, uv3co, w); uv[0] = bucket_bounds->xmin; - //uv[1] = bucket_bounds->ymax; // set above + // uv[1] = bucket_bounds->ymax; // set above barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, uv, w); interp_v2_v2v2v2(bucket_bounds_uv[flip ? 1 : 2], uv1co, uv2co, uv3co, w); - //uv[0] = bucket_bounds->xmin; // set above + // uv[0] = bucket_bounds->xmin; // set above uv[1] = bucket_bounds->ymin; barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, uv, w); interp_v2_v2v2v2(bucket_bounds_uv[flip ? 0 : 3], uv1co, uv2co, uv3co, w); @@ -3093,13 +3093,13 @@ static void project_paint_face_init(const ProjPaintState *ps, has_isect = 0; for (y = bounds_px.ymin; y < bounds_px.ymax; y++) { - //uv[1] = (((float)y) + 0.5f) / (float)ibuf->y; + // uv[1] = (((float)y) + 0.5f) / (float)ibuf->y; /* use pixel offset UV coords instead */ uv[1] = (float)y / ibuf_yf; has_x_isect = 0; for (x = bounds_px.xmin; x < bounds_px.xmax; x++) { - //uv[0] = (((float)x) + 0.5f) / ibuf->x; + // uv[0] = (((float)x) + 0.5f) / ibuf->x; /* use pixel offset UV coords instead */ uv[0] = (float)x / ibuf_xf; @@ -3134,7 +3134,7 @@ static void project_paint_face_init(const ProjPaintState *ps, /* Is this UV visible from the view? - raytrace */ /* project_paint_PickFace is less complex, use for testing */ - //if (project_paint_PickFace(ps, pixelScreenCo, w, &side) == tri_index) { + // if (project_paint_PickFace(ps, pixelScreenCo, w, &side) == tri_index) { if ((ps->do_occlude == false) || !project_bucket_point_occluded(ps, bucketFaceNodes, tri_index, pixelScreenCo)) { mask = project_paint_uvpixel_mask(ps, tri_index, w); @@ -3307,7 +3307,7 @@ static void project_paint_face_init(const ProjPaintState *ps, for (x = bounds_px.xmin; x < bounds_px.xmax; x++) { float puv[2] = {(float)x, (float)y}; bool in_bounds; - //uv[0] = (((float)x) + 0.5f) / (float)ibuf->x; + // uv[0] = (((float)x) + 0.5f) / (float)ibuf->x; /* use offset uvs instead */ uv[0] = (float)x / ibuf_xf; @@ -4228,7 +4228,7 @@ static bool project_paint_winclip(const ProjPaintState *ps, const ProjPaintFaceC (coSS->v1[1] > ps->screenMax[1] && coSS->v2[1] > ps->screenMax[1] && coSS->v3[1] > ps->screenMax[1]))); } -#endif //PROJ_DEBUG_WINCLIP +#endif // PROJ_DEBUG_WINCLIP static void project_paint_build_proj_ima(ProjPaintState *ps, MemArena *arena, @@ -4306,6 +4306,7 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps, * It's less trouble to set all faces to valid UV's, * avoiding NULL checks all over. */ skip_tri = true; + tpage = NULL; } else { tpage = slot->ima; @@ -4343,7 +4344,7 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps, continue; } -#endif //PROJ_DEBUG_WINCLIP +#endif // PROJ_DEBUG_WINCLIP /* backface culls individual triangles but mask normal will use polygon */ if (ps->do_backfacecull) { @@ -4448,7 +4449,7 @@ static void project_paint_begin(const bContext *C, proj_paint_layer_clone_init(ps, &layer_clone); if (ps->do_layer_stencil || ps->do_stencil_brush) { - //int layer_num = CustomData_get_stencil_layer(&ps->me_eval->ldata, CD_MLOOPUV); + // int layer_num = CustomData_get_stencil_layer(&ps->me_eval->ldata, CD_MLOOPUV); int layer_num = CustomData_get_stencil_layer(&((Mesh *)ps->ob->data)->ldata, CD_MLOOPUV); if (layer_num != -1) { ps->mloopuv_stencil_eval = CustomData_get_layer_n( @@ -4740,7 +4741,7 @@ static bool project_bucket_iter_next(ProjPaintState *ps, BLI_thread_lock(LOCK_CUSTOM1); } - //printf("%d %d\n", ps->context_bucket_x, ps->context_bucket_y); + // printf("%d %d\n", ps->context_bucket_x, ps->context_bucket_y); for (; ps->context_bucket_y < ps->bucketMax[1]; ps->context_bucket_y++) { for (; ps->context_bucket_x < ps->bucketMax[0]; ps->context_bucket_x++) { @@ -5564,7 +5565,7 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po for (a = 0; a < ps->thread_tot; a++) { /* set defaults in handles */ - //memset(&handles[a], 0, sizeof(BakeShade)); + // memset(&handles[a], 0, sizeof(BakeShade)); handles[a].ps = ps; copy_v2_v2(handles[a].mval, pos); diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 1a8d2f79290..ea4814857ba 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -279,9 +279,6 @@ struct ListBase *ED_image_undosys_step_get_tiles(struct UndoStep *us_p); struct ListBase *ED_image_undo_get_tiles(void); /* sculpt_uv.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); /* paint_utils.c */ diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index e15912efdd4..f58afcdadc1 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -524,37 +524,6 @@ static void PAINT_OT_brush_select(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } -static int brush_uv_sculpt_tool_set_exec(bContext *C, wmOperator *op) -{ - Brush *brush; - Scene *scene = CTX_data_scene(C); - ToolSettings *ts = scene->toolsettings; - ts->uv_sculpt_tool = RNA_enum_get(op->ptr, "tool"); - brush = ts->uvsculpt->paint.brush; - /* To update toolshelf */ - WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush); - - return OPERATOR_FINISHED; -} - -static void BRUSH_OT_uv_sculpt_tool_set(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "UV Sculpt Tool Set"; - ot->description = "Set the UV sculpt tool"; - ot->idname = "BRUSH_OT_uv_sculpt_tool_set"; - - /* api callbacks */ - ot->exec = brush_uv_sculpt_tool_set_exec; - ot->poll = uv_sculpt_poll; - - /* flags */ - ot->flag = 0; - - /* props */ - ot->prop = RNA_def_enum(ot->srna, "tool", rna_enum_uv_sculpt_tool_items, 0, "Tool", ""); -} - /***** Stencil Control *****/ typedef enum { @@ -583,7 +552,8 @@ typedef struct { float area_size[2]; StencilControlMode mode; StencilConstraint constrain_mode; - int mask; /* we are twaking mask or colour stencil */ + /** We are tweaking mask or color stencil. */ + int mask; Brush *br; float *dim_target; float *rot_target; @@ -1013,7 +983,6 @@ void ED_operatortypes_paint(void) /* note, particle uses a different system, can be added with existing operators in wm.py */ WM_operatortype_append(PAINT_OT_brush_select); - WM_operatortype_append(BRUSH_OT_uv_sculpt_tool_set); /* image */ WM_operatortype_append(PAINT_OT_texture_paint_toggle); @@ -1100,9 +1069,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap = WM_keymap_ensure(keyconf, "Face Mask", 0, 0); keymap->poll = facemask_paint_poll; - keymap = WM_keymap_ensure(keyconf, "UV Sculpt", 0, 0); - keymap->poll = uv_sculpt_keymap_poll; - /* paint stroke */ keymap = paint_stroke_modal_keymap(keyconf); WM_modalkeymap_assign(keymap, "SCULPT_OT_brush_stroke"); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 91a2ebd0603..6d003820723 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -483,7 +483,7 @@ void paint_sample_color( } if (CTX_wm_view3d(C) && texpaint_proj) { - /* first try getting a colour directly from the mesh faces if possible */ + /* first try getting a color directly from the mesh faces if possible */ ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); 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 29d150c44fe..c1c2964156f 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c @@ -130,6 +130,7 @@ static int weight_from_bones_exec(bContext *C, wmOperator *op) op->reports, depsgraph, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X)); DEG_id_tag_update(&me->id, 0); + DEG_relations_tag_update(CTX_data_main(C)); WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); return OPERATOR_FINISHED; diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c index 88aed201b48..c71315872f6 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c @@ -41,6 +41,8 @@ #include "BKE_report.h" #include "BKE_object.h" +#include "DEG_depsgraph_build.h" + /* Only for blend modes. */ #include "IMB_imbuf.h" @@ -93,6 +95,7 @@ bool ED_wpaint_ensure_data(bContext *C, bDeformGroup *dg = defgroup_find_name(ob, pchan->name); if (dg == NULL) { dg = BKE_object_defgroup_add_name(ob, pchan->name); /* sets actdef */ + DEG_relations_tag_update(CTX_data_main(C)); } else { int actdef = 1 + BLI_findindex(&ob->defbase, dg); @@ -105,6 +108,7 @@ bool ED_wpaint_ensure_data(bContext *C, } if (BLI_listbase_is_empty(&ob->defbase)) { BKE_object_defgroup_add(ob); + DEG_relations_tag_update(CTX_data_main(C)); } /* ensure we don't try paint onto an invalid group */ diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 5ae004fde5f..9ba7561b18b 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3455,6 +3455,10 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t return; } + if (is_zero_v3(ss->cache->grab_delta_symmetry)) { + return; + } + mul_v3_v3v3(temp, area_no_sp, ss->cache->scale); mul_v3_fl(temp, displace); add_v3_v3(area_co, temp); diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 3cda90ea3f9..36cc3605273 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -139,121 +139,6 @@ typedef struct UvSculptData { char invert; } UvSculptData; -static Brush *uv_sculpt_brush(bContext *C) -{ - Scene *scene = CTX_data_scene(C); - ToolSettings *settings = scene->toolsettings; - - if (!settings->uvsculpt) { - return NULL; - } - return BKE_paint_brush(&settings->uvsculpt->paint); -} - -static bool uv_sculpt_brush_poll_do(bContext *C, const bool check_region) -{ - BMEditMesh *em; - int ret; - Object *obedit = CTX_data_edit_object(C); - SpaceImage *sima = CTX_wm_space_image(C); - Scene *scene = CTX_data_scene(C); - ToolSettings *toolsettings = scene->toolsettings; - - if (!uv_sculpt_brush(C) || !obedit || obedit->type != OB_MESH || !sima || - ED_space_image_show_render(sima) || (sima->mode == SI_MODE_PAINT)) { - return 0; - } - - em = BKE_editmesh_from_object(obedit); - ret = EDBM_uv_check(em); - - if (ret) { - ARegion *ar = CTX_wm_region(C); - if ((!toolsettings->use_uv_sculpt) || - (check_region && ar && (ar->regiontype != RGN_TYPE_WINDOW))) { - ret = 0; - } - } - - return ret; -} - -static bool uv_sculpt_brush_poll(bContext *C) -{ - return uv_sculpt_brush_poll_do(C, true); -} - -static void brush_drawcursor_uvsculpt(bContext *C, int x, int y, void *UNUSED(customdata)) -{ -#define PX_SIZE_FADE_MAX 12.0f -#define PX_SIZE_FADE_MIN 4.0f - - Scene *scene = CTX_data_scene(C); - //Brush *brush = image_paint_brush(C); - Paint *paint = BKE_paint_get_active_from_context(C); - Brush *brush = BKE_paint_brush(paint); - - if (paint && brush && paint->flags & PAINT_SHOW_BRUSH) { - const float size = (float)BKE_brush_size_get(scene, brush); - float alpha = 0.5f; - - /* fade out the brush (cheap trick to work around brush interfering with sampling [#])*/ - if (size < PX_SIZE_FADE_MIN) { - return; - } - else if (size < PX_SIZE_FADE_MAX) { - alpha *= (size - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN); - } - - uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor3fvAlpha(brush->add_col, alpha); - - GPU_line_smooth(true); - GPU_blend(true); - imm_draw_circle_wire_2d(pos, (float)x, (float)y, size, 40); - GPU_blend(false); - GPU_line_smooth(false); - - immUnbindProgram(); - } -#undef PX_SIZE_FADE_MAX -#undef PX_SIZE_FADE_MIN -} - -void ED_space_image_uv_sculpt_update(Main *bmain, wmWindowManager *wm, Scene *scene) -{ - ToolSettings *settings = scene->toolsettings; - if (settings->use_uv_sculpt) { - if (settings->uvsculpt == NULL) { - settings->uv_sculpt_tool = UV_SCULPT_TOOL_GRAB; - settings->uv_sculpt_settings = UV_SCULPT_LOCK_BORDERS | UV_SCULPT_ALL_ISLANDS; - settings->uv_relax_method = UV_SCULPT_TOOL_RELAX_LAPLACIAN; - } - BKE_paint_ensure(settings, (Paint **)&settings->uvsculpt); - BKE_paint_init(bmain, scene, PAINT_MODE_SCULPT_UV, PAINT_CURSOR_SCULPT); - - settings->uvsculpt->paint.paint_cursor = WM_paint_cursor_activate( - wm, SPACE_IMAGE, RGN_TYPE_WINDOW, uv_sculpt_brush_poll, brush_drawcursor_uvsculpt, NULL); - } - else { - if (settings->uvsculpt) { - WM_paint_cursor_end(wm, settings->uvsculpt->paint.paint_cursor); - settings->uvsculpt->paint.paint_cursor = NULL; - } - } -} - -bool uv_sculpt_poll(bContext *C) -{ - return uv_sculpt_brush_poll_do(C, true); -} - -bool uv_sculpt_keymap_poll(bContext *C) -{ - return uv_sculpt_brush_poll_do(C, false); -} - /*********** Improved Laplacian Relaxation Operator ************************/ /* original code by Raul Fernandez Hernandez "farsthary" * * adapted to uv smoothing by Antony Riakiatakis * @@ -631,8 +516,9 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm int island_index = 0; /* Holds, for each UvElement in elementMap, a pointer to its unique uv.*/ int *uniqueUv; - data->tool = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_SMOOTH) ? UV_SCULPT_TOOL_RELAX : - ts->uv_sculpt_tool; + data->tool = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_SMOOTH) ? + UV_SCULPT_TOOL_RELAX : + ts->uvsculpt->paint.brush->uv_sculpt_tool; data->invert = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_INVERT) ? 1 : 0; data->uvsculpt = &ts->uvsculpt->paint; @@ -714,7 +600,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm if (do_island_optimization && (element->island != island_index)) { /* skip this uv if not on the active island */ for (; element->next && !(element->next->separate); element = element->next) { - ; + /* pass */ } continue; } @@ -951,7 +837,7 @@ void SCULPT_OT_uv_sculpt_stroke(wmOperatorType *ot) /* api callbacks */ ot->invoke = uv_sculpt_stroke_invoke; ot->modal = uv_sculpt_stroke_modal; - ot->poll = uv_sculpt_poll; + ot->poll = ED_operator_uvedit_space_image; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/sound/CMakeLists.txt b/source/blender/editors/sound/CMakeLists.txt index c2a88041a85..7f4b5a45aa3 100644 --- a/source/blender/editors/sound/CMakeLists.txt +++ b/source/blender/editors/sound/CMakeLists.txt @@ -19,6 +19,7 @@ set(INC ../include ../../blenkernel ../../blenlib + ../../depsgraph ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index c2165e8ec70..8ac49e447fe 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -62,6 +62,8 @@ # include <AUD_Special.h> #endif +#include "DEG_depsgraph_query.h" + #include "ED_sound.h" #include "ED_util.h" @@ -88,7 +90,6 @@ static int sound_open_exec(bContext *C, wmOperator *op) bSound *sound; PropertyPointerRNA *pprop; PointerRNA idptr; - AUD_SoundInfo info; Main *bmain = CTX_data_main(C); RNA_string_get(op->ptr, "filepath", path); @@ -98,29 +99,8 @@ static int sound_open_exec(bContext *C, wmOperator *op) sound_open_init(C, op); } - if (sound->playback_handle == NULL) { - if (op->customdata) { - MEM_freeN(op->customdata); - } - BKE_id_free(bmain, sound); - BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); - return OPERATOR_CANCELLED; - } - - info = AUD_getInfo(sound->playback_handle); - - if (info.specs.channels == AUD_CHANNELS_INVALID) { - BKE_id_free(bmain, sound); - if (op->customdata) { - MEM_freeN(op->customdata); - } - BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); - return OPERATOR_CANCELLED; - } - if (RNA_boolean_get(op->ptr, "mono")) { sound->flags |= SOUND_FLAGS_MONO; - BKE_sound_load(bmain, sound); } if (RNA_boolean_get(op->ptr, "cache")) { @@ -140,11 +120,13 @@ static int sound_open_exec(bContext *C, wmOperator *op) RNA_property_update(C, &pprop->ptr, pprop->prop); } + DEG_relations_tag_update(bmain); + MEM_freeN(op->customdata); return OPERATOR_FINISHED; } -#else //WITH_AUDASPACE +#else // WITH_AUDASPACE static int sound_open_exec(bContext *UNUSED(C), wmOperator *op) { @@ -361,8 +343,9 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op) #ifdef WITH_AUDASPACE char path[FILE_MAX]; char filename[FILE_MAX]; - Scene *scene; - Main *bmain; + Depsgraph *depsgraph = CTX_data_depsgraph(C); + Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); + Main *bmain = CTX_data_main(C); int split; int bitrate, accuracy; @@ -380,18 +363,20 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op) container = RNA_enum_get(op->ptr, "container"); codec = RNA_enum_get(op->ptr, "codec"); split = RNA_boolean_get(op->ptr, "split_channels"); - scene = CTX_data_scene(C); - bmain = CTX_data_main(C); - specs.channels = scene->r.ffcodecdata.audio_channels; - specs.rate = scene->r.ffcodecdata.audio_mixrate; + specs.channels = scene_eval->r.ffcodecdata.audio_channels; + specs.rate = scene_eval->r.ffcodecdata.audio_mixrate; BLI_strncpy(filename, path, sizeof(filename)); BLI_path_abs(filename, BKE_main_blendfile_path(bmain)); + const double fps = (((double)scene_eval->r.frs_sec) / (double)scene_eval->r.frs_sec_base); + const int start_frame = scene_eval->r.sfra; + const int end_frame = scene_eval->r.efra; + if (split) { - result = AUD_mixdown_per_channel(scene->sound_scene, - SFRA * specs.rate / FPS, - (EFRA - SFRA + 1) * specs.rate / FPS, + result = AUD_mixdown_per_channel(scene_eval->sound_scene, + start_frame * specs.rate / fps, + (end_frame - start_frame + 1) * specs.rate / fps, accuracy, filename, specs, @@ -400,9 +385,9 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op) bitrate); } else { - result = AUD_mixdown(scene->sound_scene, - SFRA * specs.rate / FPS, - (EFRA - SFRA + 1) * specs.rate / FPS, + result = AUD_mixdown(scene_eval->sound_scene, + start_frame * specs.rate / fps, + (end_frame - start_frame + 1) * specs.rate / fps, accuracy, filename, specs, @@ -411,7 +396,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op) bitrate); } - BKE_sound_reset_scene_specs(scene); + BKE_sound_reset_scene_specs(scene_eval); if (result) { BKE_report(op->reports, RPT_ERROR, result); diff --git a/source/blender/editors/space_action/CMakeLists.txt b/source/blender/editors/space_action/CMakeLists.txt index 5251ebb1267..6c43f8b9549 100644 --- a/source/blender/editors/space_action/CMakeLists.txt +++ b/source/blender/editors/space_action/CMakeLists.txt @@ -24,8 +24,8 @@ set(INC ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 9827967f947..2a6ae93fc99 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -71,68 +71,50 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) int filter; View2D *v2d = &ar->v2d; - float y = 0.0f; size_t items; - int height; /* build list of channels to draw */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - height = ((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac))); - if (height > BLI_rcti_size_y(&v2d->mask)) { - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) - */ - v2d->tot.ymin = (float)(-height); - } + int height = ACHANNEL_TOT_HEIGHT(ac, items); + v2d->tot.ymin = -height; + /* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */ UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY); /* loop through channels, and set up drawing depending on their type */ { /* first pass: just the standard GL-drawing for backdrop + text */ size_t channel_index = 0; + float ymax = ACHANNEL_FIRST_TOP(ac); - y = (float)ACHANNEL_FIRST(ac); - - for (ale = anim_data.first; ale; ale = ale->next) { - float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); - float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); + for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac), channel_index++) { + float ymin = ymax - ACHANNEL_HEIGHT(ac); /* check if visible */ - if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) { + if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) { /* draw all channels using standard channel-drawing API */ - ANIM_channel_draw(ac, ale, yminc, ymaxc, channel_index); + ANIM_channel_draw(ac, ale, ymin, ymax, channel_index); } - - /* adjust y-position for next one */ - y -= ACHANNEL_STEP(ac); - channel_index++; } } { /* second pass: widgets */ uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; + float ymax = ACHANNEL_FIRST_TOP(ac); - y = (float)ACHANNEL_FIRST(ac); - - for (ale = anim_data.first; ale; ale = ale->next) { - float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); - float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); + for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac), channel_index++) { + float ymin = ymax - ACHANNEL_HEIGHT(ac); /* check if visible */ - if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) { + if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) { /* draw all channels using standard channel-drawing API */ rctf channel_rect; - BLI_rctf_init(&channel_rect, 0, v2d->cur.xmax, yminc, ymaxc); + BLI_rctf_init(&channel_rect, 0, v2d->cur.xmax, ymin, ymax); ANIM_channel_draw_widgets(C, ac, ale, block, &channel_rect, channel_index); } - - /* adjust y-position for next one */ - y -= ACHANNEL_STEP(ac); - channel_index++; } UI_block_end(C, block); @@ -159,8 +141,6 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) bDopeSheet *ads = &saction->ads; AnimData *adt = NULL; - float y; - unsigned char col1[4], col2[4]; unsigned char col1a[4], col2a[4]; unsigned char col1b[4], col2b[4]; @@ -181,14 +161,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - int height = ((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac))); - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) - */ - v2d->tot.ymin = (float)(-height); - - /* first backdrop strips */ - y = (float)(-ACHANNEL_HEIGHT(ac)); + int height = ACHANNEL_TOT_HEIGHT(ac, items); + v2d->tot.ymin = -height; GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -197,13 +171,15 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) GPU_blend(true); - for (ale = anim_data.first; ale; ale = ale->next) { - const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); - const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); + /* first backdrop strips */ + float ymax = ACHANNEL_FIRST_TOP(ac); + + for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac)) { + float ymin = ymax - ACHANNEL_HEIGHT(ac); /* check if visible */ - if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) { + if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); int sel = 0; @@ -264,11 +240,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) } /* draw region twice: firstly backdrop, then the current range */ - immRectf(pos, - v2d->cur.xmin, - (float)y - ACHANNEL_HEIGHT_HALF(ac), - v2d->cur.xmax + EXTRA_SCROLL_PAD, - (float)y + ACHANNEL_HEIGHT_HALF(ac)); + immRectf(pos, v2d->cur.xmin, ymin, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymax); } else if (ac->datatype == ANIMCONT_GPENCIL) { unsigned char *color; @@ -285,44 +257,25 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) } /* frames less than one get less saturated background */ immUniformColor4ubv(color); - immRectf(pos, - 0.0f, - (float)y - ACHANNEL_HEIGHT_HALF(ac), - v2d->cur.xmin, - (float)y + ACHANNEL_HEIGHT_HALF(ac)); + immRectf(pos, 0.0f, ymin, v2d->cur.xmin, ymax); /* frames one and higher get a saturated background */ immUniformColor3ubvAlpha(color, MIN2(255, color[3] * 2)); - immRectf(pos, - v2d->cur.xmin, - (float)y - ACHANNEL_HEIGHT_HALF(ac), - v2d->cur.xmax + EXTRA_SCROLL_PAD, - (float)y + ACHANNEL_HEIGHT_HALF(ac)); + immRectf(pos, v2d->cur.xmin, ymin, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymax); } else if (ac->datatype == ANIMCONT_MASK) { /* TODO --- this is a copy of gpencil */ /* frames less than one get less saturated background */ unsigned char *color = sel ? col1 : col2; immUniformColor4ubv(color); - immRectf(pos, - 0.0f, - (float)y - ACHANNEL_HEIGHT_HALF(ac), - v2d->cur.xmin, - (float)y + ACHANNEL_HEIGHT_HALF(ac)); + immRectf(pos, 0.0f, ymin, v2d->cur.xmin, ymax); /* frames one and higher get a saturated background */ immUniformColor3ubvAlpha(color, MIN2(255, color[3] * 2)); - immRectf(pos, - v2d->cur.xmin, - (float)y - ACHANNEL_HEIGHT_HALF(ac), - v2d->cur.xmax + EXTRA_SCROLL_PAD, - (float)y + ACHANNEL_HEIGHT_HALF(ac)); + immRectf(pos, v2d->cur.xmin, ymin, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymax); } } } - - /* Increment the step */ - y -= ACHANNEL_STEP(ac); } GPU_blend(false); @@ -342,21 +295,21 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) * This is to try to optimize this for heavier data sets * 2) Keyframes which are out of view horizontally are disregarded */ - y = (float)(-ACHANNEL_HEIGHT(ac)); - int action_flag = saction->flag; if (saction->mode == SACTCONT_TIMELINE) { action_flag &= ~(SACTION_SHOW_INTERPOLATION | SACTION_SHOW_EXTREMES); } - for (ale = anim_data.first; ale; ale = ale->next) { - const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); - const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); + ymax = ACHANNEL_FIRST_TOP(ac); + + for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac)) { + float ymin = ymax - ACHANNEL_HEIGHT(ac); + float ycenter = (ymin + ymax) / 2.0f; /* check if visible */ - if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) { + if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) { /* check if anything to show for this channel */ if (ale->datatype != ALE_NONE) { adt = ANIM_nla_mapping_get(ac, ale); @@ -364,34 +317,32 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) /* draw 'keyframes' for each specific datatype */ switch (ale->datatype) { case ALE_ALL: - draw_summary_channel(v2d, ale->data, y, ac->yscale_fac, action_flag); + draw_summary_channel(v2d, ale->data, ycenter, ac->yscale_fac, action_flag); break; case ALE_SCE: - draw_scene_channel(v2d, ads, ale->key_data, y, ac->yscale_fac, action_flag); + draw_scene_channel(v2d, ads, ale->key_data, ycenter, ac->yscale_fac, action_flag); break; case ALE_OB: - draw_object_channel(v2d, ads, ale->key_data, y, ac->yscale_fac, action_flag); + draw_object_channel(v2d, ads, ale->key_data, ycenter, ac->yscale_fac, action_flag); break; case ALE_ACT: - draw_action_channel(v2d, adt, ale->key_data, y, ac->yscale_fac, action_flag); + draw_action_channel(v2d, adt, ale->key_data, ycenter, ac->yscale_fac, action_flag); break; case ALE_GROUP: - draw_agroup_channel(v2d, adt, ale->data, y, ac->yscale_fac, action_flag); + draw_agroup_channel(v2d, adt, ale->data, ycenter, ac->yscale_fac, action_flag); break; case ALE_FCURVE: - draw_fcurve_channel(v2d, adt, ale->key_data, y, ac->yscale_fac, action_flag); + draw_fcurve_channel(v2d, adt, ale->key_data, ycenter, ac->yscale_fac, action_flag); break; case ALE_GPFRAME: - draw_gpl_channel(v2d, ads, ale->data, y, ac->yscale_fac, action_flag); + draw_gpl_channel(v2d, ads, ale->data, ycenter, ac->yscale_fac, action_flag); break; case ALE_MASKLAY: - draw_masklay_channel(v2d, ads, ale->data, y, ac->yscale_fac, action_flag); + draw_masklay_channel(v2d, ads, ale->data, ycenter, ac->yscale_fac, action_flag); break; } } } - - y -= ACHANNEL_STEP(ac); } /* free temporary channels used for drawing */ diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 93beb3e851e..d8ed25c86d3 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -132,7 +132,8 @@ static int act_markers_make_local_exec(bContext *C, wmOperator *UNUSED(op)) } } - /* now enable the "show posemarkers only" setting, so that we can see that something did happen */ + /* Now enable the "show posemarkers only" setting, + * so that we can see that something did happen */ sact->flag |= SACTION_POSEMARKERS_SHOW; /* notifiers - both sets, as this change affects both */ @@ -324,24 +325,23 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *min, /* NOTE: not bool, since we want prioritise individual channels over expanders */ short found = 0; - float y; /* get all items - we need to do it this way */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through all channels, finding the first one that's selected */ - y = (float)ACHANNEL_FIRST(ac); + float ymax = ACHANNEL_FIRST_TOP(ac); - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac)) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); /* must be selected... */ if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) && ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT)) { /* update best estimate */ - *min = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); - *max = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); + *min = ymax - ACHANNEL_HEIGHT(ac); + *max = ymax; /* is this high enough priority yet? */ found = acf->channel_role; @@ -353,9 +353,6 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *min, break; } } - - /* adjust y-position for next one */ - y -= ACHANNEL_STEP(ac); } /* free all temp data */ @@ -733,11 +730,14 @@ static void insert_action_keys(bAnimContext *ac, short mode) FCurve *fcu = (FCurve *)ale->key_data; float cfra = (float)CFRA; - /* read value from property the F-Curve represents, or from the curve only? - * - ale->id != NULL: Typically, this means that we have enough info to try resolving the path - * - ale->owner != NULL: If this is set, then the path may not be resolvable from the ID alone, - * so it's easier for now to just read the F-Curve directly. - * (TODO: add the full-blown PointerRNA relative parsing case here...) + /* Read value from property the F-Curve represents, or from the curve only? + * - ale->id != NULL: + * Typically, this means that we have enough info to try resolving the path. + * + * - ale->owner != NULL: + * If this is set, then the path may not be resolvable from the ID alone, + * so it's easier for now to just read the F-Curve directly. + * (TODO: add the full-blown PointerRNA relative parsing case here...) */ if (ale->id && !ale->owner) { insert_keyframe(ac->bmain, @@ -1099,7 +1099,7 @@ void ACTION_OT_clean(wmOperatorType *ot) ot->description = "Simplify F-Curves by removing closely spaced keyframes"; /* api callbacks */ - //ot->invoke = // XXX we need that number popup for this! + // ot->invoke = // XXX we need that number popup for this! ot->exec = actkeys_clean_exec; ot->poll = ED_operator_action_active; diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index b91ac3c39a3..cba86ac5131 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -102,7 +102,7 @@ void ED_operatormacros_action(void) WM_operatortype_macro_define(ot, "ACTION_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform"); RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE); - RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); } /* ************************** registration - keymaps **********************************/ diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index fb35afb6770..8ecd25bda76 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -230,7 +230,6 @@ static void box_select_action(bAnimContext *ac, const rcti rect, short mode, sho KeyframeEditFunc ok_cb, select_cb; View2D *v2d = &ac->ar->v2d; rctf rectf; - float ymin = 0, ymax = (float)(-ACHANNEL_HEIGHT_HALF(ac)); /* Convert mouse coordinates to frame ranges and channel * coordinates corrected for view pan/zoom. */ @@ -254,12 +253,14 @@ static void box_select_action(bAnimContext *ac, const rcti rect, short mode, sho /* init editing data */ memset(&ked, 0, sizeof(KeyframeEditData)); + float ymax = ACHANNEL_FIRST_TOP(ac); + /* loop over data, doing box select */ - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac)) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* get new vertical minimum extent of channel */ - ymin = ymax - ACHANNEL_STEP(ac); + float ymin = ymax - ACHANNEL_STEP(ac); /* set horizontal range (if applicable) */ if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) { @@ -314,9 +315,6 @@ static void box_select_action(bAnimContext *ac, const rcti rect, short mode, sho } } } - - /* set minimum extent to be the maximum of the next channel */ - ymax = ymin; } /* cleanup */ @@ -418,7 +416,6 @@ static void region_select_action_keys( KeyframeEditFunc ok_cb, select_cb; View2D *v2d = &ac->ar->v2d; rctf rectf, scaled_rectf; - float ymin = 0, ymax = (float)(-ACHANNEL_HEIGHT_HALF(ac)); /* Convert mouse coordinates to frame ranges and channel * coordinates corrected for view pan/zoom. */ @@ -448,15 +445,17 @@ static void region_select_action_keys( ked.data = &scaled_rectf; } + float ymax = ACHANNEL_FIRST_TOP(ac); + /* loop over data, doing region select */ - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac)) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* get new vertical minimum extent of channel */ - ymin = ymax - ACHANNEL_STEP(ac); + float ymin = ymax - ACHANNEL_STEP(ac); /* compute midpoint of channel (used for testing if the key is in the region or not) */ - ked.channel_y = ymin + ACHANNEL_HEIGHT_HALF(ac); + ked.channel_y = (ymin + ymax) / 2.0f; /* if channel is mapped in NLA, apply correction * - Apply to the bounds being checked, not all the keyframe points, @@ -520,9 +519,6 @@ static void region_select_action_keys( break; } } - - /* set minimum extent to be the maximum of the next channel */ - ymax = ymin; } /* cleanup */ @@ -1423,8 +1419,12 @@ static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, s /* ------------------- */ -static void mouse_action_keys( - bAnimContext *ac, const int mval[2], short select_mode, bool column, bool same_channel) +static void mouse_action_keys(bAnimContext *ac, + const int mval[2], + short select_mode, + const bool deselect_all, + const bool column, + const bool same_channel) { ListBase anim_data = {NULL, NULL}; DLRBT_Tree anim_keys; @@ -1449,7 +1449,7 @@ static void mouse_action_keys( /* use View2D to determine the index of the channel (i.e a row in the list) where keyframe was */ UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); UI_view2d_listview_view_to_cell( - v2d, 0, ACHANNEL_STEP(ac), 0, (float)ACHANNEL_HEIGHT_HALF(ac), x, y, NULL, &channel_index); + 0, ACHANNEL_STEP(ac), 0, ACHANNEL_FIRST_TOP(ac), x, y, NULL, &channel_index); /* x-range to check is +/- 7px for standard keyframe under standard dpi/y-scale * (in screen/region-space), on either side of mouse click (size of keyframe icon). @@ -1469,14 +1469,7 @@ static void mouse_action_keys( /* try to get channel */ ale = BLI_findlink(&anim_data, channel_index); - if (ale == NULL) { - /* channel not found */ - printf("Error: animation channel (index = %d) not found in mouse_action_keys()\n", - channel_index); - ANIM_animdata_freelist(&anim_data); - return; - } - else { + if (ale != NULL) { /* found match - must return here... */ AnimData *adt = ANIM_nla_mapping_get(ac, ale); ActKeyColumn *ak, *akn = NULL; @@ -1556,13 +1549,15 @@ static void mouse_action_keys( /* cleanup temporary lists */ BLI_dlrbTree_free(&anim_keys); - - /* free list of channels, since it's not used anymore */ - ANIM_animdata_freelist(&anim_data); } - /* for replacing selection, firstly need to clear existing selection */ - if (select_mode == SELECT_REPLACE) { + /* free list of channels, since it's not used anymore */ + ANIM_animdata_freelist(&anim_data); + + /* For replacing selection, if we have something to select, we have to clear existing selection. + * The same goes if we found nothing to select, and deselect_all is true + * (deselect on nothing behavior). */ + if ((select_mode == SELECT_REPLACE && found) || (!found && deselect_all)) { /* reset selection mode for next steps */ select_mode = SELECT_ADD; @@ -1575,7 +1570,7 @@ static void mouse_action_keys( ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); /* Highlight Action-Group or F-Curve? */ - if (ale && ale->data) { + if (ale != NULL && ale->data) { if (ale->type == ANIMTYPE_GROUP) { bActionGroup *agrp = ale->data; @@ -1595,11 +1590,11 @@ static void mouse_action_keys( ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); /* Highlight GPencil Layer */ - if ((ale && ale->data) && (ale->type == ANIMTYPE_GPLAYER)) { + if (ale != NULL && ale->data != NULL && ale->type == ANIMTYPE_GPLAYER) { bGPDlayer *gpl = ale->data; gpl->flag |= GP_LAYER_SELECT; - //gpencil_layer_setactive(gpd, gpl); + // gpencil_layer_setactive(gpd, gpl); } } else if (ac->datatype == ANIMCONT_MASK) { @@ -1607,17 +1602,17 @@ static void mouse_action_keys( ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); /* Highlight GPencil Layer */ - if ((ale && ale->data) && (ale->type == ANIMTYPE_MASKLAYER)) { + if (ale != NULL && ale->data != NULL && ale->type == ANIMTYPE_MASKLAYER) { MaskLayer *masklay = ale->data; masklay->flag |= MASK_LAYERFLAG_SELECT; - //gpencil_layer_setactive(gpd, gpl); + // gpencil_layer_setactive(gpd, gpl); } } } /* only select keyframes if we clicked on a valid channel and hit something */ - if (ale) { + if (ale != NULL) { if (found) { /* apply selection to keyframes */ if (column) { @@ -1652,9 +1647,6 @@ static void mouse_action_keys( static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent *event) { bAnimContext ac; - /* ARegion *ar; */ /* UNUSED */ - short selectmode; - bool column, channel; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) { @@ -1665,19 +1657,15 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent /* ar = ac.ar; */ /* UNUSED */ /* select mode is either replace (deselect all, then add) or add/extend */ - if (RNA_boolean_get(op->ptr, "extend")) { - selectmode = SELECT_INVERT; - } - else { - selectmode = SELECT_REPLACE; - } + const short selectmode = RNA_boolean_get(op->ptr, "extend") ? SELECT_INVERT : SELECT_REPLACE; + const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all"); /* column selection */ - column = RNA_boolean_get(op->ptr, "column"); - channel = RNA_boolean_get(op->ptr, "channel"); + const bool column = RNA_boolean_get(op->ptr, "column"); + const bool channel = RNA_boolean_get(op->ptr, "channel"); /* select keyframe(s) based upon mouse position*/ - mouse_action_keys(&ac, event->mval, selectmode, column, channel); + mouse_action_keys(&ac, event->mval, selectmode, deselect_all, column, channel); /* set notifier that keyframe selection (and channels too) have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); @@ -1712,6 +1700,13 @@ void ACTION_OT_clickselect(wmOperatorType *ot) "Toggle keyframe selection instead of leaving newly selected keyframes only"); // SHIFTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, + "deselect_all", + false, + "Deselect On Nothing", + "Deselect all when nothing under the cursor"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean( ot->srna, "column", diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index d6d46904db3..5ac6297e108 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -166,7 +166,7 @@ static void action_main_region_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ keymap = WM_keymap_ensure(wm->defaultconf, "Dopesheet", SPACE_ACTION, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -179,11 +179,9 @@ static void action_main_region_draw(const bContext *C, ARegion *ar) Object *obact = CTX_data_active_object(C); bAnimContext ac; View2D *v2d = &ar->v2d; - View2DGrid *grid; View2DScrollers *scrollers; short marker_flag = 0; short cfra_flag = 0; - short unit = 0; /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); @@ -192,17 +190,7 @@ static void action_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(v2d); /* time grid */ - unit = (saction->flag & SACTION_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; - grid = UI_view2d_grid_calc(CTX_data_scene(C), - v2d, - unit, - V2D_GRID_CLAMP, - V2D_ARG_DUMMY, - V2D_ARG_DUMMY, - ar->winx, - ar->winy); - UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); - UI_view2d_grid_free(grid); + UI_view2d_draw_lines_x__discrete_frames_or_seconds(v2d, scene, saction->flag & SACTION_DRAWTIME); ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); @@ -247,11 +235,14 @@ static void action_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc( - C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); - UI_view2d_scrollers_draw(C, v2d, scrollers); + scrollers = UI_view2d_scrollers_calc(v2d, NULL); + UI_view2d_scrollers_draw(v2d, scrollers); UI_view2d_scrollers_free(scrollers); + /* frame numbers */ + UI_view2d_draw_scale_x__discrete_frames_or_seconds( + ar, v2d, &v2d->hor, scene, saction->flag & SACTION_DRAWTIME, TH_TEXT); + /* draw current frame number-indicator on top of scrollers */ if ((saction->flag & SACTION_NODRAWCFRANUM) == 0) { UI_view2d_view_orthoSpecial(ar, v2d, 1); @@ -271,7 +262,7 @@ static void action_channel_region_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ keymap = WM_keymap_ensure(wm->defaultconf, "Animation Channels", 0, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); @@ -710,7 +701,7 @@ static void action_header_region_listener( break; case ND_KEYFRAME: /* new keyframed added -> active action may have changed */ - //saction->flag |= SACTION_TEMP_NEEDCHANSYNC; + // saction->flag |= SACTION_TEMP_NEEDCHANSYNC; ED_region_tag_redraw(ar); break; } diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt index ce08b62e8ef..25ff6bbd098 100644 --- a/source/blender/editors/space_buttons/CMakeLists.txt +++ b/source/blender/editors/space_buttons/CMakeLists.txt @@ -24,8 +24,8 @@ set(INC ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 607c3ddbb10..577f7a7af8a 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -785,7 +785,8 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r SpaceProperties *sbuts = CTX_wm_space_properties(C); ButsContextPath *path = sbuts ? sbuts->path : NULL; - if (!path) { + /* A zero sized path will be set for 'BCONTEXT_TOOL'. */ + if (!path || !path->len) { return 0; } diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 1b1c3bf6d13..f9244049d54 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -203,14 +203,14 @@ static void buttons_main_region_layout_properties(const bContext *C, static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar) { - const WorkSpace *workspace = CTX_wm_workspace(C); const enum eContextObjectMode mode = CTX_data_mode_enum(C); const char *contexts_base[5] = {NULL}; contexts_base[0] = ".active_tool"; const char **contexts = &contexts_base[1]; - if (workspace->tools_space_type == SPACE_VIEW3D) { + /* Hard coded to 3D view. */ + { switch (mode) { case CTX_MODE_EDIT_MESH: ARRAY_SET_ITEMS(contexts, ".mesh_edit"); @@ -267,22 +267,6 @@ static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar) break; } } - else if (workspace->tools_space_type == SPACE_IMAGE) { - switch (workspace->tools_mode) { - case SI_MODE_VIEW: - break; - case SI_MODE_PAINT: - ARRAY_SET_ITEMS(contexts, ".paint_common_2d", ".imagepaint_2d"); - break; - case SI_MODE_MASK: - break; - case SI_MODE_UV: - if (mode == CTX_MODE_EDIT_MESH) { - ARRAY_SET_ITEMS(contexts, ".uv_sculpt"); - } - break; - } - } /* for grease pencil we don't use tool system yet, so we need check outside * workspace->tools_space_type because this value is not available diff --git a/source/blender/editors/space_clip/CMakeLists.txt b/source/blender/editors/space_clip/CMakeLists.txt index ed98dcdc159..2ea4bc97d18 100644 --- a/source/blender/editors/space_clip/CMakeLists.txt +++ b/source/blender/editors/space_clip/CMakeLists.txt @@ -24,13 +24,13 @@ set(INC ../../blenlib ../../blentranslation ../../depsgraph - ../../imbuf ../../gpu + ../../imbuf ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 8a5f48d11d2..ef5de1acee3 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -339,14 +339,10 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene) { MovieClip *clip = ED_space_clip_get_clip(sc); View2D *v2d = &ar->v2d; - View2DGrid *grid; - short unitx = V2D_UNIT_FRAMESCALE, unity = V2D_UNIT_VALUES; /* grid */ - grid = UI_view2d_grid_calc( - scene, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, ar->winx, ar->winy); - UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); - UI_view2d_grid_free(grid); + UI_view2d_draw_lines_x__values(v2d); + UI_view2d_draw_lines_y__values(v2d); if (clip) { uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 3f971c4444a..8b3f221f3a5 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -971,7 +971,7 @@ static void change_frame_apply(bContext *C, wmOperator *op) SUBFRA = 0.0f; /* do updates */ - BKE_sound_seek_scene(CTX_data_main(C), scene); + BKE_sound_update_and_seek(CTX_data_main(C), CTX_data_depsgraph(C)); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index f176763abf5..5364c4bc3ca 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -859,14 +859,14 @@ static void clip_main_region_init(wmWindowManager *wm, ARegion *ar) /* mask polls mode */ keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); /* own keymap */ keymap = WM_keymap_ensure(wm->defaultconf, "Clip", SPACE_CLIP, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Clip Editor", SPACE_CLIP, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); } static void clip_main_region_draw(const bContext *C, ARegion *ar) @@ -1002,13 +1002,13 @@ static void clip_preview_region_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ keymap = WM_keymap_ensure(wm->defaultconf, "Clip", SPACE_CLIP, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Clip Graph Editor", SPACE_CLIP, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Clip Dopesheet Editor", SPACE_CLIP, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); } static void graph_region_draw(const bContext *C, ARegion *ar) @@ -1017,7 +1017,6 @@ static void graph_region_draw(const bContext *C, ARegion *ar) View2DScrollers *scrollers; SpaceClip *sc = CTX_wm_space_clip(C); Scene *scene = CTX_data_scene(C); - short unitx, unity; short cfra_flag = 0; if (sc->flag & SC_LOCK_TIMECURSOR) { @@ -1043,13 +1042,15 @@ static void graph_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - unitx = (sc->flag & SC_SHOW_SECONDS) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; - unity = V2D_UNIT_VALUES; - scrollers = UI_view2d_scrollers_calc( - C, v2d, NULL, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP); - UI_view2d_scrollers_draw(C, v2d, scrollers); + scrollers = UI_view2d_scrollers_calc(v2d, NULL); + UI_view2d_scrollers_draw(v2d, scrollers); UI_view2d_scrollers_free(scrollers); + /* scale indicators */ + UI_view2d_draw_scale_x__discrete_frames_or_seconds( + ar, v2d, &v2d->hor, scene, sc->flag & SC_SHOW_SECONDS, TH_TEXT); + UI_view2d_draw_scale_y__values(ar, v2d, &v2d->vert, TH_TEXT); + /* current frame indicator */ if (sc->flag & SC_SHOW_SECONDS) { cfra_flag |= DRAWCFRA_UNIT_SECONDS; @@ -1064,9 +1065,8 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar) SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); View2D *v2d = &ar->v2d; - View2DGrid *grid; View2DScrollers *scrollers; - short unit = 0, cfra_flag = 0; + short cfra_flag = 0; if (clip) { BKE_tracking_dopesheet_update(&clip->tracking); @@ -1079,11 +1079,7 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(v2d); /* time grid */ - unit = (sc->flag & SC_SHOW_SECONDS) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; - grid = UI_view2d_grid_calc( - scene, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); - UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); - UI_view2d_grid_free(grid); + UI_view2d_draw_lines_x__discrete_frames_or_seconds(v2d, scene, sc->flag & SC_SHOW_SECONDS); /* data... */ clip_draw_dopesheet_main(sc, ar, scene); @@ -1098,11 +1094,14 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc( - C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); - UI_view2d_scrollers_draw(C, v2d, scrollers); + scrollers = UI_view2d_scrollers_calc(v2d, NULL); + UI_view2d_scrollers_draw(v2d, scrollers); UI_view2d_scrollers_free(scrollers); + /* frame numbers */ + UI_view2d_draw_scale_x__discrete_frames_or_seconds( + ar, v2d, &v2d->hor, scene, sc->flag & SC_SHOW_SECONDS, TH_TEXT); + /* current frame number indicator */ UI_view2d_view_orthoSpecial(ar, v2d, 1); ANIM_draw_cfra_number(C, v2d, cfra_flag); @@ -1140,7 +1139,7 @@ static void clip_channels_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); keymap = WM_keymap_ensure(wm->defaultconf, "Clip Dopesheet Editor", SPACE_CLIP, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); } static void clip_channels_region_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 18d48b426e0..441e65cefe4 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -1350,7 +1350,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op) if (CFRA != sc->user.framenr) { CFRA = sc->user.framenr; - BKE_sound_seek_scene(CTX_data_main(C), scene); + BKE_sound_update_and_seek(CTX_data_main(C), CTX_data_depsgraph(C)); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } diff --git a/source/blender/editors/space_clip/tracking_ops_detect.c b/source/blender/editors/space_clip/tracking_ops_detect.c index ead150bba7f..a9c97258def 100644 --- a/source/blender/editors/space_clip/tracking_ops_detect.c +++ b/source/blender/editors/space_clip/tracking_ops_detect.c @@ -90,7 +90,7 @@ static int detect_features_exec(bContext *C, wmOperator *op) } /* Deselect existing tracks. */ - ed_tracking_delect_all_tracks(tracksbase); + ed_tracking_deselect_all_tracks(tracksbase); /* Run detector. */ BKE_tracking_detect_harris(tracking, tracksbase, diff --git a/source/blender/editors/space_clip/tracking_ops_intern.h b/source/blender/editors/space_clip/tracking_ops_intern.h index 8d2d61f050e..c29a485e234 100644 --- a/source/blender/editors/space_clip/tracking_ops_intern.h +++ b/source/blender/editors/space_clip/tracking_ops_intern.h @@ -38,7 +38,7 @@ void clip_tracking_hide_cursor(struct bContext *C); /* tracking_select.h */ -void ed_tracking_delect_all_tracks(struct ListBase *tracks_base); -void ed_tracking_delect_all_plane_tracks(struct ListBase *plane_tracks_base); +void ed_tracking_deselect_all_tracks(struct ListBase *tracks_base); +void ed_tracking_deselect_all_plane_tracks(struct ListBase *plane_tracks_base); #endif /* __TRACKING_OPS_INTERN_H__ */ diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index 207a0f1aff6..2b70aec02bb 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -263,7 +263,7 @@ static MovieTrackingPlaneTrack *find_nearest_plane_track(SpaceClip *sc, return plane_track; } -void ed_tracking_delect_all_tracks(ListBase *tracks_base) +void ed_tracking_deselect_all_tracks(ListBase *tracks_base) { MovieTrackingTrack *track; for (track = tracks_base->first; track != NULL; track = track->next) { @@ -271,7 +271,7 @@ void ed_tracking_delect_all_tracks(ListBase *tracks_base) } } -void ed_tracking_delect_all_plane_tracks(ListBase *plane_tracks_base) +void ed_tracking_deselect_all_plane_tracks(ListBase *plane_tracks_base) { MovieTrackingPlaneTrack *plane_track; for (plane_track = plane_tracks_base->first; plane_track != NULL; @@ -280,7 +280,7 @@ void ed_tracking_delect_all_plane_tracks(ListBase *plane_tracks_base) } } -static int mouse_select(bContext *C, float co[2], int extend) +static int mouse_select(bContext *C, float co[2], const bool extend, const bool deselect_all) { SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); @@ -295,6 +295,15 @@ static int mouse_select(bContext *C, float co[2], int extend) track = find_nearest_track(sc, tracksbase, co, &distance_to_track); plane_track = find_nearest_plane_track(sc, plane_tracks_base, co, &distance_to_plane_track); + /* Do not select beyond some reasonable distance, that is useless and + * prevents the 'deselect on nothing' behavior. */ + if (distance_to_track > 0.05f) { + track = NULL; + } + if (distance_to_plane_track > 0.05f) { + plane_track = NULL; + } + /* Between track and plane we choose closest to the mouse for selection here. */ if (track && plane_track) { if (distance_to_track < distance_to_plane_track) { @@ -305,11 +314,11 @@ static int mouse_select(bContext *C, float co[2], int extend) } } - if (!extend) { - ed_tracking_delect_all_plane_tracks(plane_tracks_base); - } - if (track) { + if (!extend) { + ed_tracking_deselect_all_plane_tracks(plane_tracks_base); + } + int area = track_mouse_area(C, co, track); if (!extend || !TRACK_VIEW_SELECTED(sc, track)) { @@ -337,7 +346,7 @@ static int mouse_select(bContext *C, float co[2], int extend) } else if (plane_track) { if (!extend) { - ed_tracking_delect_all_tracks(tracksbase); + ed_tracking_deselect_all_tracks(tracksbase); } if (PLANE_TRACK_VIEW_SELECTED(plane_track)) { @@ -352,6 +361,10 @@ static int mouse_select(bContext *C, float co[2], int extend) clip->tracking.act_track = NULL; clip->tracking.act_plane_track = plane_track; } + else if (deselect_all) { + ed_tracking_deselect_all_tracks(tracksbase); + ed_tracking_deselect_all_plane_tracks(plane_tracks_base); + } if (!extend) { sc->xlockof = 0.0f; @@ -380,12 +393,12 @@ static bool select_poll(bContext *C) static int select_exec(bContext *C, wmOperator *op) { float co[2]; - int extend; RNA_float_get_array(op->ptr, "location", co); - extend = RNA_boolean_get(op->ptr, "extend"); + const bool extend = RNA_boolean_get(op->ptr, "extend"); + const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all"); - return mouse_select(C, co, extend); + return mouse_select(C, co, extend, deselect_all); } static int select_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -433,11 +446,19 @@ void CLIP_OT_select(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; /* properties */ + PropertyRNA *prop; RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection rather than clearing the existing selection"); + prop = RNA_def_boolean(ot->srna, + "deselect_all", + false, + "Deselect On Nothing", + "Deselect all when nothing under the cursor"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + RNA_def_float_vector( ot->srna, "location", diff --git a/source/blender/editors/space_console/CMakeLists.txt b/source/blender/editors/space_console/CMakeLists.txt index 5070b6fcf65..33934832ccc 100644 --- a/source/blender/editors/space_console/CMakeLists.txt +++ b/source/blender/editors/space_console/CMakeLists.txt @@ -24,8 +24,8 @@ set(INC ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 2cf8f6c46b9..999255aef88 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -77,7 +77,7 @@ static SpaceLink *console_new(const ScrArea *UNUSED(area), const Scene *UNUSED(s ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f; /* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */ - //ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM); + // ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM); return (SpaceLink *)sconsole; } @@ -136,7 +136,7 @@ static void console_main_region_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ keymap = WM_keymap_ensure(wm->defaultconf, "Console", SPACE_CONSOLE, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); /* add drop boxes */ lb = WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW); @@ -231,9 +231,8 @@ static void console_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc( - C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP); - UI_view2d_scrollers_draw(C, v2d, scrollers); + scrollers = UI_view2d_scrollers_calc(v2d, NULL); + UI_view2d_scrollers_draw(v2d, scrollers); UI_view2d_scrollers_free(scrollers); } diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt index 6bf975b98e0..33f57b9c235 100644 --- a/source/blender/editors/space_file/CMakeLists.txt +++ b/source/blender/editors/space_file/CMakeLists.txt @@ -22,15 +22,15 @@ set(INC ../../blenlib ../../blenloader ../../blentranslation - ../../imbuf ../../gpu + ../../imbuf ../../makesdna ../../makesrna ../../render/extern/include ../../windowmanager ../../../../intern/atomic - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 7d3a042d75a..674735f3e1d 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -1461,8 +1461,7 @@ int file_exec(bContext *C, wmOperator *exec_op) else if (sfile->op) { wmOperator *op = sfile->op; - /* when used as a macro, for doubleclick, - * to prevent closing when doubleclicking on .. item */ + /* When used as a macro, for double-click, to prevent closing when double-clicking on item. */ if (RNA_boolean_get(exec_op->ptr, "need_active")) { const int numfiles = filelist_files_ensure(sfile->files); int i, active = 0; @@ -1723,8 +1722,8 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w (sfile->scroll_offset < offset + numfiles_layout - numfiles_layout_margin)) { WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer); sfile->smoothscroll_timer = NULL; - /* Postscroll (after rename has been validated by user) is done, - * rename process is totally finisehd, cleanup. */ + /* Post-scroll (after rename has been validated by user) is done, + * rename process is totally finished, cleanup. */ if ((params->rename_flag & FILE_PARAMS_RENAME_POSTSCROLL_ACTIVE) != 0) { params->renamefile[0] = '\0'; params->rename_flag = 0; diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 982c663cd18..38423a87447 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -296,8 +296,8 @@ void fsmenu_insert_entry(struct FSMenu *fsmenu, fsm_iter->save = (flag & FS_INSERT_SAVE) != 0; if ((category == FS_CATEGORY_RECENT) && (!name || !name[0])) { - /* Special handling when adding new recent entry - check if dir exists in some other categories, - * and try to use name from there if so. */ + /* Special handling when adding new recent entry - check if dir exists in + * some other categories, and try to use name from there if so. */ FSMenuCategory cats[] = { FS_CATEGORY_SYSTEM, FS_CATEGORY_SYSTEM_BOOKMARKS, FS_CATEGORY_BOOKMARKS}; int i = ARRAY_SIZE(cats); @@ -522,7 +522,8 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) # ifdef __APPLE__ { /* Get mounted volumes better method OSX 10.6 and higher, see: - * https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html */ + * https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html + */ /* We get all volumes sorted including network and do not relay * on user-defined finder visibility, less confusing. */ diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index e0d370cdde2..4629f33d210 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -83,6 +83,7 @@ static SpaceLink *file_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen BLI_addtail(&sfile->regionbase, ar); ar->regiontype = RGN_TYPE_TOOL_PROPS; ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; + ar->flag |= RGN_FLAG_DYNAMIC_SIZE; /* ui list region */ ar = MEM_callocN(sizeof(ARegion), "ui region for file"); @@ -316,10 +317,10 @@ static void file_main_region_init(wmWindowManager *wm, ARegion *ar) /* own keymaps */ keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "File Browser Main", SPACE_FILE, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); } static void file_main_region_listener(wmWindow *UNUSED(win), @@ -441,9 +442,8 @@ static void file_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc( - C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); - UI_view2d_scrollers_draw(C, v2d, scrollers); + scrollers = UI_view2d_scrollers_calc(v2d, NULL); + UI_view2d_scrollers_draw(v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -498,7 +498,7 @@ static void file_tools_region_init(wmWindowManager *wm, ARegion *ar) /* own keymaps */ keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); } static void file_tools_region_draw(const bContext *C, ARegion *ar) @@ -528,7 +528,7 @@ static void file_header_region_init(wmWindowManager *wm, ARegion *ar) ED_region_header_init(ar); keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); } static void file_header_region_draw(const bContext *C, ARegion *ar) @@ -545,10 +545,10 @@ static void file_ui_region_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "File Browser Buttons", SPACE_FILE, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); } static void file_ui_region_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/space_graph/CMakeLists.txt b/source/blender/editors/space_graph/CMakeLists.txt index cf5ffdb2be5..f4d31886e3f 100644 --- a/source/blender/editors/space_graph/CMakeLists.txt +++ b/source/blender/editors/space_graph/CMakeLists.txt @@ -25,8 +25,8 @@ set(INC ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index eb392538d23..062c9f86fab 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -493,20 +493,18 @@ static void draw_fcurve_samples(SpaceGraph *sipo, ARegion *ar, FCurve *fcu) /* Helper func - just draw the F-Curve by sampling the visible region * (for drawing curves with modifiers). */ static void draw_fcurve_curve( - bAnimContext *ac, ID *id, FCurve *fcu_, View2D *v2d, View2DGrid *grid, unsigned int pos) + bAnimContext *ac, ID *id, FCurve *fcu_, View2D *v2d, unsigned int pos) { SpaceGraph *sipo = (SpaceGraph *)ac->sl; float samplefreq; float stime, etime; float unitFac, offset; - float dx, dy; short mapping_flag = ANIM_get_normalization_flags(ac); int i, n; /* when opening a blend file on a different sized screen or while dragging the toolbar this can * happen best just bail out in this case. */ - UI_view2d_grid_size(grid, &dx, &dy); - if (dx <= 0.0f) { + if (UI_view2d_scale_get_x(v2d) <= 0.0f) { return; } @@ -529,11 +527,11 @@ static void draw_fcurve_curve( * loop (i.e. too close to 0), then clamp it to a determined "safe" value. The value * chosen here is just the coarsest value which still looks reasonable... */ - /* grid->dx represents the number of 'frames' between gridlines, - * but we divide by U.v2d_min_gridsize to get pixels-steps */ + /* TODO: perhaps we should have 1.0 frames * as upper limit so that curves don't get too distorted? */ - samplefreq = dx / (U.v2d_min_gridsize * U.pixelsize); + float pixels_per_sample = 1.5f; + samplefreq = pixels_per_sample / UI_view2d_scale_get_x(v2d); if (sipo->flag & SIPO_BEAUTYDRAW_OFF) { /* Low Precision = coarse lower-bound clamping @@ -883,7 +881,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) float unitfac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset); /* for now, only show when debugging driver... */ - //if ((driver->flag & DRIVER_FLAG_SHOWDEBUG) == 0) + // if ((driver->flag & DRIVER_FLAG_SHOWDEBUG) == 0) // return; const uint shdr_pos = GPU_vertformat_attr_add( @@ -1043,8 +1041,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *ar) /* This is called twice from space_graph.c -> graph_main_region_draw() * Unselected then selected F-Curves are drawn so that they do not occlude each other. */ -void graph_draw_curves( - bAnimContext *ac, SpaceGraph *sipo, ARegion *ar, View2DGrid *grid, short sel) +void graph_draw_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *ar, short sel) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; @@ -1131,7 +1128,7 @@ void graph_draw_curves( /* draw a curve affected by modifiers or only allowed to have integer values * by sampling it at various small-intervals over the visible region */ - draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, grid, shdr_pos); + draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, shdr_pos); } else if (((fcu->bezt) || (fcu->fpt)) && (fcu->totvert)) { /* just draw curve based on defined data (i.e. no modifiers) */ @@ -1140,7 +1137,7 @@ void graph_draw_curves( draw_fcurve_curve_bezts(ac, ale->id, fcu, &ar->v2d, shdr_pos); } else { - draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, grid, shdr_pos); + draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, shdr_pos); } } else if (fcu->fpt) { @@ -1157,7 +1154,8 @@ void graph_draw_curves( } /* 2) draw handles and vertices as appropriate based on active - * - if the option to only show controls if the F-Curve is selected is enabled, we must obey this + * - If the option to only show controls if the F-Curve is selected is enabled, + * we must obey this. */ if (!(sipo->flag & SIPO_SELCUVERTSONLY) || (fcu->flag & FCURVE_SELECTED)) { if (!fcurve_are_keyframes_usable(fcu) && !(fcu->fpt && fcu->totvert)) { @@ -1181,7 +1179,8 @@ void graph_draw_curves( GPU_matrix_scale_2f(1.0f, unit_scale); GPU_matrix_translate_2f(0.0f, offset); - /* set this once and for all - all handles and handle-verts should use the same thickness */ + /* Set this once and for all - + * all handles and handle-verts should use the same thickness. */ GPU_line_width(1.0); if (fcu->bezt) { @@ -1231,9 +1230,8 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) int filter; View2D *v2d = &ar->v2d; - float y = 0.0f, height; + float height; size_t items; - int i = 0; /* build list of channels to draw */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); @@ -1241,62 +1239,47 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) /* Update max-extent of channels here (taking into account scrollers): * - this is done to allow the channel list to be scrollable, but must be done here - * to avoid regenerating the list again and/or also because channels list is drawn first - * - offset of ACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for - * start of list offset, and the second is as a correction for the scrollers. - */ - height = (float)((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac) * 2)); - UI_view2d_totRect_set(v2d, BLI_rcti_size_x(&ar->v2d.mask), height); + * to avoid regenerating the list again and/or also because channels list is drawn first */ + height = ACHANNEL_TOT_HEIGHT(ac, items); + v2d->tot.ymin = -height; /* loop through channels, and set up drawing depending on their type */ { /* first pass: just the standard GL-drawing for backdrop + text */ size_t channel_index = 0; + float ymax = ACHANNEL_FIRST_TOP(ac); - y = (float)ACHANNEL_FIRST(ac); - - for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) { - const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); - const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); + for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac), channel_index++) { + float ymin = ymax - ACHANNEL_HEIGHT(ac); /* check if visible */ - if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) { + if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) { /* draw all channels using standard channel-drawing API */ - ANIM_channel_draw(ac, ale, yminc, ymaxc, channel_index); + ANIM_channel_draw(ac, ale, ymin, ymax, channel_index); } - - /* adjust y-position for next one */ - y -= ACHANNEL_STEP(ac); - channel_index++; } } { /* second pass: widgets */ uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; - - y = (float)ACHANNEL_FIRST(ac); + float ymax = ACHANNEL_FIRST_TOP(ac); /* set blending again, as may not be set in previous step */ 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)); - const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); + for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac), channel_index++) { + float ymin = ymax - ACHANNEL_HEIGHT(ac); /* check if visible */ - if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) { + if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) { /* draw all channels using standard channel-drawing API */ rctf channel_rect; - BLI_rctf_init(&channel_rect, 0, v2d->cur.xmax - V2D_SCROLL_WIDTH, yminc, ymaxc); + BLI_rctf_init(&channel_rect, 0, v2d->cur.xmax - V2D_SCROLL_WIDTH, ymin, ymax); ANIM_channel_draw_widgets(C, ac, ale, block, &channel_rect, channel_index); } - - /* adjust y-position for next one */ - y -= ACHANNEL_STEP(ac); - channel_index++; } UI_block_end(C, block); diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 1bb14bc3ce2..0954538e430 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -932,9 +932,15 @@ static short copy_graph_keys(bAnimContext *ac) /* clear buffer first */ ANIM_fcurves_copybuf_free(); - /* filter data */ + /* filter data + * - First time we try to filter more strictly, allowing only selected channels + * to allow copying animation between channels + */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); - ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + + if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0) { + ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + } /* copy keyframes */ ok = copy_animedit_keys(ac, &anim_data); @@ -1275,7 +1281,7 @@ void GRAPH_OT_clean(wmOperatorType *ot) ot->description = "Simplify F-Curves by removing closely spaced keyframes"; /* api callbacks */ - //ot->invoke = // XXX we need that number popup for this! + // ot->invoke = // XXX we need that number popup for this! ot->exec = graphkeys_clean_exec; ot->poll = graphop_editable_keyframes_poll; @@ -1484,7 +1490,7 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -#else //WITH_AUDASPACE +#else // WITH_AUDASPACE static int graphkeys_sound_bake_exec(bContext *UNUSED(C), wmOperator *op) { @@ -1493,7 +1499,7 @@ static int graphkeys_sound_bake_exec(bContext *UNUSED(C), wmOperator *op) return OPERATOR_CANCELLED; } -#endif //WITH_AUDASPACE +#endif // WITH_AUDASPACE static int graphkeys_sound_bake_invoke(bContext *C, wmOperator *op, const wmEvent *event) { diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index 606f4bc3fe3..6ec8e54dce9 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -28,7 +28,6 @@ struct ARegion; struct ARegionType; struct ScrArea; struct SpaceGraph; -struct View2DGrid; struct bAnimContext; struct bAnimListElem; struct bContext; @@ -42,7 +41,6 @@ void graph_draw_channel_names(struct bContext *C, struct bAnimContext *ac, struc void graph_draw_curves(struct bAnimContext *ac, struct SpaceGraph *sipo, struct ARegion *ar, - struct View2DGrid *grid, short sel); void graph_draw_ghost_curves(struct bAnimContext *ac, struct SpaceGraph *sipo, struct ARegion *ar); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 79df4760939..054a1e3d8ee 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -105,7 +105,7 @@ static void graphview_cursor_apply(bContext *C, wmOperator *op) } SUBFRA = 0.0f; - BKE_sound_seek_scene(bmain, scene); + BKE_sound_update_and_seek(bmain, CTX_data_depsgraph(C)); } /* set the cursor value */ @@ -494,7 +494,7 @@ void ED_operatormacros_graph(void) WM_operatortype_macro_define(ot, "GRAPH_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform"); RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE); - RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF); + RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); } /* ************************** registration - keymaps **********************************/ diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index a5376cd0c0e..13a42f091f6 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -117,7 +117,8 @@ void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channel /* affect channel selection status? */ if (do_channels) { - /* only change selection of channel when the visibility of keyframes doesn't depend on this */ + /* Only change selection of channel when the visibility of keyframes + * doesn't depend on this. */ if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) { /* deactivate the F-Curve, and deselect if deselecting keyframes. * otherwise select the F-Curve too since we've selected all the keyframes @@ -324,7 +325,8 @@ static void box_select_graphkeys(bAnimContext *ac, /* select keyframes that are in the appropriate places */ ANIM_fcurve_keyframes_loop(&ked, fcu, ok_cb, select_cb, NULL); - /* only change selection of channel when the visibility of keyframes doesn't depend on this */ + /* Only change selection of channel when the visibility of keyframes + * doesn't depend on this. */ if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) { /* select the curve too now that curve will be touched */ if (selectmode == SELECT_ADD) { @@ -1188,7 +1190,8 @@ static void nearest_fcurve_vert_store(ListBase *matches, tNearestVertInfo *nvi = (tNearestVertInfo *)matches->last; bool replace = false; - /* if there is already a point for the F-Curve, check if this point is closer than that was */ + /* If there is already a point for the F-Curve, + * check if this point is closer than that was. */ if ((nvi) && (nvi->fcu == fcu)) { /* replace if we are closer, or if equal and that one wasn't selected but we are... */ if ((nvi->dist > dist) || ((nvi->sel == 0) && BEZT_ISSEL_ANY(bezt))) { @@ -1343,8 +1346,9 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches) for (nvi = matches->first; nvi; nvi = nvi->next) { /* which mode of search are we in: find first selected, or find vert? */ if (found) { - /* just take this vert now that we've found the selected one - * - we'll need to remove this from the list so that it can be returned to the original caller + /* Just take this vert now that we've found the selected one + * - We'll need to remove this from the list + * so that it can be returned to the original caller. */ BLI_remlink(matches, nvi); return nvi; @@ -1392,7 +1396,8 @@ static tNearestVertInfo *find_nearest_fcurve_vert(bAnimContext *ac, const int mv static void mouse_graph_keys(bAnimContext *ac, const int mval[2], short select_mode, - short curves_only) + const bool deselect_all, + const bool curves_only) { SpaceGraph *sipo = (SpaceGraph *)ac->sl; tNearestVertInfo *nvi; @@ -1401,13 +1406,10 @@ static void mouse_graph_keys(bAnimContext *ac, /* find the beztriple that we're selecting, and the handle that was clicked on */ nvi = find_nearest_fcurve_vert(ac, mval); - /* check if anything to select */ - if (nvi == NULL) { - return; - } - - /* deselect all other curves? */ - if (select_mode == SELECT_REPLACE) { + /* For replacing selection, if we have something to select, we have to clear existing selection. + * The same goes if we found nothing to select, and deselect_all is true + * (deselect on nothing behavior). */ + if ((nvi != NULL && select_mode == SELECT_REPLACE) || (nvi == NULL && deselect_all)) { /* reset selection mode */ select_mode = SELECT_ADD; @@ -1423,9 +1425,13 @@ static void mouse_graph_keys(bAnimContext *ac, } } + if (nvi == NULL) { + return; + } + /* if points can be selected on this F-Curve */ // TODO: what about those with no keyframes? - if ((curves_only == 0) && ((nvi->fcu->flag & FCURVE_PROTECTED) == 0)) { + if (!curves_only && ((nvi->fcu->flag & FCURVE_PROTECTED) == 0)) { /* only if there's keyframe */ if (nvi->bezt) { bezt = nvi->bezt; /* used to check bezt seletion is set */ @@ -1600,7 +1606,6 @@ static void graphkeys_mselect_column(bAnimContext *ac, const int mval[2], short static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent *event) { bAnimContext ac; - short selectmode; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) { @@ -1608,12 +1613,8 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEve } /* select mode is either replace (deselect all, then add) or add/extend */ - if (RNA_boolean_get(op->ptr, "extend")) { - selectmode = SELECT_INVERT; - } - else { - selectmode = SELECT_REPLACE; - } + const short selectmode = RNA_boolean_get(op->ptr, "extend") ? SELECT_INVERT : SELECT_REPLACE; + const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all"); /* figure out action to take */ if (RNA_boolean_get(op->ptr, "column")) { @@ -1622,11 +1623,11 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEve } else if (RNA_boolean_get(op->ptr, "curves")) { /* select all keyframes in the same F-Curve as the one under the mouse */ - mouse_graph_keys(&ac, event->mval, selectmode, 1); + mouse_graph_keys(&ac, event->mval, selectmode, deselect_all, true); } else { /* select keyframe under mouse */ - mouse_graph_keys(&ac, event->mval, selectmode, 0); + mouse_graph_keys(&ac, event->mval, selectmode, deselect_all, false); } /* set notifier that keyframe selection (and also channel selection in some cases) has changed */ @@ -1662,6 +1663,13 @@ void GRAPH_OT_clickselect(wmOperatorType *ot) "Toggle keyframe selection instead of leaving newly selected keyframes only"); // SHIFTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, + "deselect_all", + false, + "Deselect On Nothing", + "Deselect all when nothing under the cursor"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean( ot->srna, "column", diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c index b823ddec696..d582ac557fa 100644 --- a/source/blender/editors/space_graph/graph_utils.c +++ b/source/blender/editors/space_graph/graph_utils.c @@ -50,7 +50,8 @@ /* Set Up Drivers Editor */ /* Set up UI configuration for Drivers Editor */ -/* NOTE: Currently called from windowmanager (new drivers editor window) and RNA (mode switching) */ +/* NOTE: Currently called from windowmanager + * (new drivers editor window) and RNA (mode switching) */ void ED_drivers_editor_init(bContext *C, ScrArea *sa) { SpaceGraph *sipo = (SpaceGraph *)sa->spacedata.first; diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index e45a27a08fb..390ea0cf00b 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -186,7 +186,7 @@ static void graph_main_region_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor", SPACE_GRAPH, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_GRAPH, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -198,10 +198,9 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) Scene *scene = CTX_data_scene(C); bAnimContext ac; View2D *v2d = &ar->v2d; - View2DGrid *grid; View2DScrollers *scrollers; float col[3]; - short unitx = 0, unity = V2D_UNIT_VALUES, cfra_flag = 0; + short cfra_flag = 0; /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); @@ -211,18 +210,9 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(v2d); /* grid */ - unitx = ((sipo->mode == SIPO_MODE_ANIMATION) && (sipo->flag & SIPO_DRAWTIME)) ? - V2D_UNIT_SECONDS : - V2D_UNIT_FRAMESCALE; - grid = UI_view2d_grid_calc(CTX_data_scene(C), - v2d, - unitx, - V2D_GRID_NOCLAMP, - unity, - V2D_GRID_NOCLAMP, - ar->winx, - ar->winy); - UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); + bool display_seconds = (sipo->mode == SIPO_MODE_ANIMATION) && (sipo->flag & SIPO_DRAWTIME); + UI_view2d_draw_lines_x__frames_or_seconds(v2d, scene, display_seconds); + UI_view2d_draw_lines_y__values(v2d); ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); @@ -237,8 +227,8 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) graph_draw_ghost_curves(&ac, sipo, ar); /* draw curves twice - unselected, then selected, so that the are fewer occlusion problems */ - graph_draw_curves(&ac, sipo, ar, grid, 0); - graph_draw_curves(&ac, sipo, ar, grid, 1); + graph_draw_curves(&ac, sipo, ar, 0); + graph_draw_curves(&ac, sipo, ar, 1); /* XXX the slow way to set tot rect... but for nice sliders needed (ton) */ get_graph_keyframe_extents( @@ -248,9 +238,6 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) v2d->tot.xmax += 10.0f; } - /* only free grid after drawing data, as we need to use it to determine sampling rate */ - UI_view2d_grid_free(grid); - if (((sipo->flag & SIPO_NODRAWCURSOR) == 0) || (sipo->mode == SIPO_MODE_DRIVERS)) { uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -324,11 +311,14 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) /* scrollers */ // FIXME: args for scrollers depend on the type of data being shown... - scrollers = UI_view2d_scrollers_calc( - C, v2d, NULL, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP); - UI_view2d_scrollers_draw(C, v2d, scrollers); + scrollers = UI_view2d_scrollers_calc(v2d, NULL); + UI_view2d_scrollers_draw(v2d, scrollers); UI_view2d_scrollers_free(scrollers); + /* scale numbers */ + UI_view2d_draw_scale_x__frames_or_seconds(ar, v2d, &v2d->hor, scene, display_seconds, TH_TEXT); + UI_view2d_draw_scale_y__values(ar, v2d, &v2d->vert, TH_TEXT); + /* draw current frame number-indicator on top of scrollers */ if ((sipo->mode != SIPO_MODE_DRIVERS) && ((sipo->flag & SIPO_NODRAWCFRANUM) == 0)) { UI_view2d_view_orthoSpecial(ar, v2d, 1); @@ -353,7 +343,7 @@ static void graph_channel_region_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ keymap = WM_keymap_ensure(wm->defaultconf, "Animation Channels", 0, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_GRAPH, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -381,9 +371,8 @@ static void graph_channel_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc( - C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); - UI_view2d_scrollers_draw(C, v2d, scrollers); + scrollers = UI_view2d_scrollers_calc(v2d, NULL); + UI_view2d_scrollers_draw(v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -406,7 +395,7 @@ static void graph_buttons_region_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_GRAPH, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); } static void graph_buttons_region_draw(const bContext *C, ARegion *ar) @@ -627,7 +616,7 @@ static void graph_listener(wmWindow *UNUSED(win), break; // XXX: restore the case below if not enough updates occur... - //default: + // default: // if (wmn->data == ND_KEYS) // ED_area_tag_redraw(sa); } diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt index 70b7387bf6b..61e6b065cba 100644 --- a/source/blender/editors/space_image/CMakeLists.txt +++ b/source/blender/editors/space_image/CMakeLists.txt @@ -23,14 +23,14 @@ set(INC ../../blentranslation ../../bmesh ../../depsgraph - ../../imbuf ../../gpu + ../../imbuf ../../makesdna ../../makesrna ../../render/extern/include ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index f5dd0c4ad53..752eedebe71 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -1371,6 +1371,7 @@ void image_buttons_register(ARegionType *art) pt = MEM_callocN(sizeof(PanelType), "spacetype image panel metadata"); strcpy(pt->idname, "IMAGE_PT_metadata"); strcpy(pt->label, N_("Metadata")); + strcpy(pt->category, "Image"); strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); pt->poll = metadata_panel_context_poll; pt->draw = metadata_panel_context_draw; diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 3baee1d723b..9b57644b6ec 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -673,7 +673,7 @@ void draw_image_grease_pencil(bContext *C, bool onlyv2d) } else { /* assume that UI_view2d_restore(C) has been called... */ - //SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C); + // SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C); /* draw grease-pencil ('screen' strokes) */ ED_annotation_draw_view2d(C, 0); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 2c99997bbad..0710ecf3bd6 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -65,6 +65,7 @@ #include "DEG_depsgraph.h" #include "GPU_draw.h" +#include "GPU_state.h" #include "GPU_immediate.h" #include "IMB_colormanagement.h" @@ -290,7 +291,8 @@ static bool image_sample_poll(bContext *C) if (sima) { Object *obedit = CTX_data_edit_object(C); if (obedit) { - /* Disable when UV editing so it doesn't swallow all click events (use for setting cursor). */ + /* Disable when UV editing so it doesn't swallow all click events + * (use for setting cursor). */ if (ED_space_image_show_uvedit(sima, obedit)) { return false; } @@ -579,7 +581,7 @@ static void image_zoom_apply(ViewZoomData *vpd, zfac = 1.0f + ((fac / 20.0f) * time_step); vpd->timer_lastdraw = time; /* this is the final zoom, but instead make it into a factor */ - //zoom = vpd->sima->zoom * zfac; + // zoom = vpd->sima->zoom * zfac; factor = (vpd->sima->zoom * zfac) / vpd->zoom; } else { @@ -1734,7 +1736,7 @@ static int image_save_options_init(Main *bmain, } ///* XXX - this is lame, we need to make these available too! */ - //opts->subimtype = scene->r.subimtype; + // opts->subimtype = scene->r.subimtype; BLI_strncpy(opts->filepath, ibuf->name, sizeof(opts->filepath)); @@ -2759,6 +2761,7 @@ static void image_sample_draw(const bContext *C, ARegion *ar, void *arg_info) glEnable(GL_COLOR_LOGIC_OP); glLogicOp(GL_XOR); + GPU_line_width(1.0f); imm_draw_box_wire_2d(pos, (float)sample_rect_fl.xmin, (float)sample_rect_fl.ymin, @@ -3539,7 +3542,7 @@ static void change_frame_apply(bContext *C, wmOperator *op) SUBFRA = 0.0f; /* do updates */ - BKE_sound_seek_scene(CTX_data_main(C), scene); + BKE_sound_update_and_seek(CTX_data_main(C), CTX_data_depsgraph(C)); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 1e1d1e570b3..3b2386d94e6 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -140,6 +140,7 @@ static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(sce BLI_addtail(&simage->regionbase, ar); ar->regiontype = RGN_TYPE_TOOL_HEADER; ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; + ar->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER; /* header */ ar = MEM_callocN(sizeof(ARegion), "header for image"); @@ -536,29 +537,26 @@ static void image_main_region_init(wmWindowManager *wm, ARegion *ar) /* mask polls mode */ keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); /* image paint polls for mode */ keymap = WM_keymap_ensure(wm->defaultconf, "Curve", 0, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Paint Curve", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Image Paint", 0, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "UV Editor", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - keymap = WM_keymap_ensure(wm->defaultconf, "UV Sculpt", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); - /* own keymaps */ keymap = WM_keymap_ensure(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Image", SPACE_IMAGE, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); } static void image_main_region_draw(const bContext *C, ARegion *ar) @@ -573,7 +571,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); View2D *v2d = &ar->v2d; - //View2DScrollers *scrollers; + // View2DScrollers *scrollers; float col[3]; /* XXX This is in order to draw UI batches with the DRW @@ -607,7 +605,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); - ED_uvedit_draw_main(sima, ar, scene, view_layer, obedit, obact, depsgraph); + ED_uvedit_draw_main(sima, scene, view_layer, obedit, obact, depsgraph); /* check for mask (delay draw) */ if (ED_space_image_show_uvedit(sima, obedit)) { @@ -685,14 +683,6 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) WM_gizmomap_draw(ar->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D); draw_image_cache(C, ar); - - /* scrollers? */ -#if 0 - scrollers = UI_view2d_scrollers_calc( - C, v2d, V2D_UNIT_VALUES, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); - UI_view2d_scrollers_draw(C, v2d, scrollers); - UI_view2d_scrollers_free(scrollers); -#endif } static void image_main_region_listener( @@ -750,6 +740,33 @@ static void image_buttons_region_init(wmWindowManager *wm, ARegion *ar) WM_event_add_keymap_handler(&ar->handlers, keymap); } +static void image_buttons_region_layout(const bContext *C, ARegion *ar) +{ + const enum eContextObjectMode mode = CTX_data_mode_enum(C); + const char *contexts_base[3] = {NULL}; + + const char **contexts = contexts_base; + + SpaceImage *sima = CTX_wm_space_image(C); + switch (sima->mode) { + case SI_MODE_VIEW: + break; + case SI_MODE_PAINT: + ARRAY_SET_ITEMS(contexts, ".paint_common_2d", ".imagepaint_2d"); + break; + case SI_MODE_MASK: + break; + case SI_MODE_UV: + if (mode == CTX_MODE_EDIT_MESH) { + ARRAY_SET_ITEMS(contexts, ".uv_sculpt"); + } + break; + } + + const bool vertical = true; + ED_region_panels_layout_ex(C, ar, contexts_base, -1, vertical); +} + static void image_buttons_region_draw(const bContext *C, ARegion *ar) { SpaceImage *sima = CTX_wm_space_image(C); @@ -776,7 +793,8 @@ static void image_buttons_region_draw(const bContext *C, ARegion *ar) } ED_space_image_release_buffer(sima, ibuf, lock); - ED_region_panels(C, ar); + /* Layout handles details. */ + ED_region_panels_draw(C, ar); } static void image_buttons_region_listener(wmWindow *UNUSED(win), @@ -1020,7 +1038,9 @@ void ED_spacetype_image(void) art->prefsizex = 220; // XXX art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; art->listener = image_buttons_region_listener; + art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_ui; art->init = image_buttons_region_init; + art->layout = image_buttons_region_layout; art->draw = image_buttons_region_draw; BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_info/CMakeLists.txt b/source/blender/editors/space_info/CMakeLists.txt index bb403751fe2..ad410e0aade 100644 --- a/source/blender/editors/space_info/CMakeLists.txt +++ b/source/blender/editors/space_info/CMakeLists.txt @@ -22,15 +22,15 @@ set(INC ../../blenlib ../../blenloader ../../blentranslation - ../../depsgraph - ../../imbuf ../../bmesh + ../../depsgraph ../../gpu + ../../imbuf ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c index a7d6694b362..c588df9528f 100644 --- a/source/blender/editors/space_info/info_draw.c +++ b/source/blender/editors/space_info/info_draw.c @@ -116,7 +116,7 @@ static int report_textview_begin(TextViewContext *tvc) // SpaceConsole *sc = (SpaceConsole *)tvc->arg1; ReportList *reports = (ReportList *)tvc->arg2; - tvc->lheight = 14 * UI_DPI_FAC; //sc->lheight; + tvc->lheight = 14 * UI_DPI_FAC; // sc->lheight; tvc->sel_start = 0; tvc->sel_end = 0; @@ -256,7 +256,7 @@ static int info_textview_main__internal(struct SpaceInfo *sinfo, /* view */ tvc.sel_start = 0; tvc.sel_end = 0; - tvc.lheight = 14 * UI_DPI_FAC; //sc->lheight; + tvc.lheight = 14 * UI_DPI_FAC; // sc->lheight; tvc.ymin = v2d->cur.ymin; tvc.ymax = v2d->cur.ymax; tvc.winx = ar->winx - V2D_SCROLL_WIDTH; diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c index 1521a400779..4c00512d838 100644 --- a/source/blender/editors/space_info/info_report.c +++ b/source/blender/editors/space_info/info_report.c @@ -41,6 +41,37 @@ #include "info_intern.h" +static void reports_select_all(ReportList *reports, int report_mask, int action) +{ + if (action == SEL_TOGGLE) { + action = SEL_SELECT; + for (Report *report = reports->list.last; report; report = report->prev) { + if ((report->type & report_mask) && (report->flag & SELECT)) { + action = SEL_DESELECT; + break; + } + } + } + + for (Report *report = reports->list.last; report; report = report->prev) { + if (report->type & report_mask) { + switch (action) { + case SEL_SELECT: + report->flag = SELECT; + break; + case SEL_DESELECT: + report->flag = ~SELECT; + break; + case SEL_INVERT: + report->flag ^= SELECT; + break; + default: + BLI_assert(0); + } + } + } +} + int info_report_mask(SpaceInfo *UNUSED(sinfo)) { #if 0 @@ -112,12 +143,20 @@ void INFO_OT_report_replay(wmOperatorType *ot) static int select_report_pick_exec(bContext *C, wmOperator *op) { int report_index = RNA_int_get(op->ptr, "report_index"); + bool extend = RNA_boolean_get(op->ptr, "extend"); + Report *report = BLI_findlink(&CTX_wm_reports(C)->list, report_index); + SpaceInfo *sinfo = CTX_wm_space_info(C); + ReportList *reports = CTX_wm_reports(C); + const int report_mask = info_report_mask(sinfo); if (!report) { return OPERATOR_CANCELLED; } + if (!extend) { + reports_select_all(reports, report_mask, SEL_DESELECT); + } report->flag ^= SELECT; /* toggle */ ED_area_tag_redraw(CTX_wm_area(C)); @@ -155,8 +194,11 @@ void INFO_OT_select_pick(wmOperatorType *ot) /* ot->flag = OPTYPE_REGISTER; */ /* properties */ + PropertyRNA *prop; RNA_def_int( ot->srna, "report_index", 0, 0, INT_MAX, "Report", "Index of the report", 0, INT_MAX); + prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend report selection"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } static int report_select_all_exec(bContext *C, wmOperator *op) @@ -166,34 +208,7 @@ static int report_select_all_exec(bContext *C, wmOperator *op) const int report_mask = info_report_mask(sinfo); int action = RNA_enum_get(op->ptr, "action"); - - if (action == SEL_TOGGLE) { - action = SEL_SELECT; - for (Report *report = reports->list.last; report; report = report->prev) { - if ((report->type & report_mask) && (report->flag & SELECT)) { - action = SEL_DESELECT; - break; - } - } - } - - for (Report *report = reports->list.last; report; report = report->prev) { - if (report->type & report_mask) { - switch (action) { - case SEL_SELECT: - report->flag = SELECT; - break; - case SEL_DESELECT: - report->flag = ~SELECT; - break; - case SEL_INVERT: - report->flag ^= SELECT; - break; - default: - BLI_assert(0); - } - } - } + reports_select_all(reports, report_mask, action); ED_area_tag_redraw(CTX_wm_area(C)); diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 6ed9d80d145..8eddf90b06b 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -85,7 +85,7 @@ static SpaceLink *info_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f; /* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */ - //ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM); + // ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM); return (SpaceLink *)sinfo; } @@ -160,9 +160,8 @@ static void info_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc( - C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP); - UI_view2d_scrollers_draw(C, v2d, scrollers); + scrollers = UI_view2d_scrollers_calc(v2d, NULL); + UI_view2d_scrollers_draw(v2d, scrollers); UI_view2d_scrollers_free(scrollers); } diff --git a/source/blender/editors/space_nla/CMakeLists.txt b/source/blender/editors/space_nla/CMakeLists.txt index 3048c64c49e..60152bffaf4 100644 --- a/source/blender/editors/space_nla/CMakeLists.txt +++ b/source/blender/editors/space_nla/CMakeLists.txt @@ -25,8 +25,8 @@ set(INC ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index d6353a9b0d4..719efc7eeac 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -59,7 +59,7 @@ static void do_nla_region_buttons(bContext *C, void *UNUSED(arg), int UNUSED(event)) { - //Scene *scene = CTX_data_scene(C); + // Scene *scene = CTX_data_scene(C); #if 0 switch (event) { /* pass */ diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index 638ad62592e..3e4eb6af098 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -136,7 +136,6 @@ static int mouse_nla_channels( if (selectmode == SELECT_INVERT) { /* swap select */ ED_object_base_select(base, BA_INVERT); - BKE_scene_object_base_flag_sync_from_base(base); if (adt) { adt->flag ^= ADT_UI_SELECTED; @@ -147,7 +146,6 @@ static int mouse_nla_channels( /* TODO: should this deselect all other types of channels too? */ for (Base *b = view_layer->object_bases.first; b; b = b->next) { ED_object_base_select(b, BA_DESELECT); - BKE_scene_object_base_flag_sync_from_base(b); if (b->object->adt) { b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE); } @@ -155,7 +153,6 @@ static int mouse_nla_channels( /* select object now */ ED_object_base_select(base, BA_SELECT); - BKE_scene_object_base_flag_sync_from_base(base); if (adt) { adt->flag |= ADT_UI_SELECTED; } @@ -387,19 +384,12 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmEv selectmode = SELECT_REPLACE; } - /** - * Figure out which channel user clicked in: - * - * \note Although channels technically start at y= NLACHANNEL_FIRST, - * we need to adjust by half a channel's height so that the tops of channels get caught ok. - * Since NLACHANNEL_FIRST is really NLACHANNEL_HEIGHT, we simply use NLACHANNEL_HEIGHT_HALF. - */ + /* Figure out which channel user clicked in. */ UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y); - UI_view2d_listview_view_to_cell(v2d, - NLACHANNEL_NAMEWIDTH, + UI_view2d_listview_view_to_cell(NLACHANNEL_NAMEWIDTH, NLACHANNEL_STEP(snla), 0, - (float)NLACHANNEL_HEIGHT_HALF(snla), + NLACHANNEL_FIRST_TOP(snla), x, y, NULL, diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 1df2190b7af..b821a246dc5 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -689,23 +689,19 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ - int height = ((items * NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla) * 2)); - - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) - */ - v2d->tot.ymin = (float)(-height); + int height = NLACHANNEL_TOT_HEIGHT(snla, items); + v2d->tot.ymin = -height; /* loop through channels, and set up drawing depending on their type */ - float y = (float)(-NLACHANNEL_HEIGHT(snla)); + float ymax = NLACHANNEL_FIRST_TOP(snla); - for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) { - const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); - const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); + for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next, ymax -= NLACHANNEL_STEP(snla)) { + float ymin = ymax - NLACHANNEL_HEIGHT(snla); + float ycenter = (ymax + ymin) / 2.0f; /* check if visible */ - if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) { + if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) { /* data to draw depends on the type of channel */ switch (ale->type) { case ANIMTYPE_NLATRACK: { @@ -721,18 +717,18 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) const float xmaxc = strip->end + text_margin_x; /* draw the visualization of the strip */ - nla_draw_strip(snla, adt, nlt, strip, v2d, yminc, ymaxc); + nla_draw_strip(snla, adt, nlt, strip, v2d, ymin, ymax); /* add the text for this strip to the cache */ if (xminc < xmaxc) { - nla_draw_strip_text(adt, nlt, strip, index, v2d, xminc, xmaxc, yminc, ymaxc); + nla_draw_strip_text(adt, nlt, strip, index, v2d, xminc, xmaxc, ymin, ymax); } /* if transforming strips (only real reason for temp-metas currently), * add to the cache the frame numbers of the strip's extents */ if (strip->flag & NLASTRIP_FLAG_TEMP_META) { - nla_draw_strip_frames_text(nlt, strip, v2d, yminc, ymaxc); + nla_draw_strip_frames_text(nlt, strip, v2d, ymin, ymax); } } } @@ -761,27 +757,27 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) * but also slightly shorter for some more contrast when viewing the strips */ immRectf( - pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP); + pos, v2d->cur.xmin, ymin + NLACHANNEL_SKIP, v2d->cur.xmax, ymax - NLACHANNEL_SKIP); /* draw 'embossed' lines above and below the strip for effect */ /* white base-lines */ GPU_line_width(2.0f); immUniformColor4f(1.0f, 1.0f, 1.0f, 0.3f); immBegin(GPU_PRIM_LINES, 4); - immVertex2f(pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP); - immVertex2f(pos, v2d->cur.xmax, yminc + NLACHANNEL_SKIP); - immVertex2f(pos, v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP); - immVertex2f(pos, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP); + immVertex2f(pos, v2d->cur.xmin, ymin + NLACHANNEL_SKIP); + immVertex2f(pos, v2d->cur.xmax, ymin + NLACHANNEL_SKIP); + immVertex2f(pos, v2d->cur.xmin, ymax - NLACHANNEL_SKIP); + immVertex2f(pos, v2d->cur.xmax, ymax - NLACHANNEL_SKIP); immEnd(); /* black top-lines */ GPU_line_width(1.0f); immUniformColor3f(0.0f, 0.0f, 0.0f); immBegin(GPU_PRIM_LINES, 4); - immVertex2f(pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP); - immVertex2f(pos, v2d->cur.xmax, yminc + NLACHANNEL_SKIP); - immVertex2f(pos, v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP); - immVertex2f(pos, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP); + immVertex2f(pos, v2d->cur.xmin, ymin + NLACHANNEL_SKIP); + immVertex2f(pos, v2d->cur.xmax, ymin + NLACHANNEL_SKIP); + immVertex2f(pos, v2d->cur.xmin, ymax - NLACHANNEL_SKIP); + immVertex2f(pos, v2d->cur.xmax, ymax - NLACHANNEL_SKIP); immEnd(); /* TODO: these lines but better --^ */ @@ -790,16 +786,13 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* draw keyframes in the action */ nla_action_draw_keyframes( - v2d, adt, ale->data, y, yminc + NLACHANNEL_SKIP, ymaxc - NLACHANNEL_SKIP); + v2d, adt, ale->data, ycenter, ymin + NLACHANNEL_SKIP, ymax - NLACHANNEL_SKIP); GPU_blend(false); break; } } } - - /* adjust y-position for next one */ - y -= NLACHANNEL_STEP(snla); } /* free tempolary channels */ @@ -817,7 +810,6 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar) SpaceNla *snla = (SpaceNla *)ac->sl; View2D *v2d = &ar->v2d; - float y = 0.0f; size_t items; /* build list of channels to draw */ @@ -830,11 +822,9 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar) * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ - int height = ((items * NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla) * 2)); - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) - */ - v2d->tot.ymin = (float)(-height); + int height = NLACHANNEL_TOT_HEIGHT(snla, items); + v2d->tot.ymin = -height; + /* need to do a view-sync here, so that the keys area doesn't jump around * (it must copy this) */ UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY); @@ -842,30 +832,24 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar) /* draw channels */ { /* first pass: just the standard GL-drawing for backdrop + text */ size_t channel_index = 0; + float ymax = NLACHANNEL_FIRST_TOP(snla); - y = (float)(-NLACHANNEL_HEIGHT(snla)); - - for (ale = anim_data.first; ale; ale = ale->next) { - float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); - float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); + for (ale = anim_data.first; ale; + ale = ale->next, ymax -= NLACHANNEL_STEP(snla), channel_index++) { + float ymin = ymax - NLACHANNEL_HEIGHT(snla); /* check if visible */ - if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) { + if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) { /* draw all channels using standard channel-drawing API */ - ANIM_channel_draw(ac, ale, yminc, ymaxc, channel_index); + ANIM_channel_draw(ac, ale, ymin, ymax, channel_index); } - - /* adjust y-position for next one */ - y -= NLACHANNEL_STEP(snla); - channel_index++; } } { /* second pass: UI widgets */ uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; - - y = (float)(-NLACHANNEL_HEIGHT(snla)); + float ymax = NLACHANNEL_FIRST_TOP(snla); /* set blending again, as may not be set in previous step */ GPU_blend_set_func_separate( @@ -873,22 +857,18 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar) GPU_blend(true); /* loop through channels, and set up drawing depending on their type */ - for (ale = anim_data.first; ale; ale = ale->next) { - const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); - const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); + for (ale = anim_data.first; ale; + ale = ale->next, ymax -= NLACHANNEL_STEP(snla), channel_index++) { + float ymin = ymax - NLACHANNEL_HEIGHT(snla); /* check if visible */ - if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) { + if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) { /* draw all channels using standard channel-drawing API */ rctf channel_rect; - BLI_rctf_init(&channel_rect, 0, v2d->cur.xmax, yminc, ymaxc); + BLI_rctf_init(&channel_rect, 0, v2d->cur.xmax, ymin, ymax); ANIM_channel_draw_widgets(C, ac, ale, block, &channel_rect, channel_index); } - - /* adjust y-position for next one */ - y -= NLACHANNEL_STEP(snla); - channel_index++; } UI_block_end(C, block); diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 76930d3117b..07853e5850a 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -421,27 +421,25 @@ static bool nla_channels_get_selected_extents(bAnimContext *ac, float *min, floa int filter; SpaceNla *snla = (SpaceNla *)ac->sl; - const float half_height = NLACHANNEL_HEIGHT_HALF(snla); /* NOTE: not bool, since we want prioritise individual channels over expanders */ short found = 0; - float y; /* get all items - we need to do it this way */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through all channels, finding the first one that's selected */ - y = (float)NLACHANNEL_FIRST; + float ymax = NLACHANNEL_FIRST_TOP(snla); - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = anim_data.first; ale; ale = ale->next, ymax -= NLACHANNEL_STEP(snla)) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); /* must be selected... */ if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) && ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT)) { /* update best estimate */ - *min = (float)(y - half_height); - *max = (float)(y + half_height); + *min = ymax - NLACHANNEL_HEIGHT(snla); + *max = ymax; /* is this high enough priority yet? */ found = acf->channel_role; @@ -453,9 +451,6 @@ static bool nla_channels_get_selected_extents(bAnimContext *ac, float *min, floa break; } } - - /* adjust y-position for next one */ - y -= NLACHANNEL_STEP(snla); } /* free all temp data */ @@ -617,7 +612,7 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op) if (act == NULL) { BKE_report(op->reports, RPT_ERROR, "No valid action to add"); - //printf("Add strip - actname = '%s'\n", actname); + // printf("Add strip - actname = '%s'\n", actname); return OPERATOR_CANCELLED; } else if (act->idroot == 0) { @@ -657,8 +652,9 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op) AnimData *adt = ale->adt; NlaStrip *strip = NULL; - /* sanity check: only apply actions of the right type for this ID - * NOTE: in the case that this hasn't been set, we've already warned the user about this already + /* Sanity check: only apply actions of the right type for this ID. + * NOTE: in the case that this hasn't been set, + * we've already warned the user about this already */ if ((act->idroot) && (act->idroot != GS(ale->id->name))) { BKE_reportf( diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index cb54129a820..accd82525f5 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -523,7 +523,8 @@ void NLA_OT_select_leftright(wmOperatorType *ot) /* ******************** Mouse-Click Select Operator *********************** */ /* select strip directly under mouse */ -static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], short select_mode) +static void mouse_nla_strips( + bContext *C, bAnimContext *ac, const int mval[2], short select_mode, const bool deselect_all) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale = NULL; @@ -540,15 +541,8 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s /* use View2D to determine the index of the channel * (i.e a row in the list) where keyframe was */ UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); - UI_view2d_listview_view_to_cell(v2d, - 0, - NLACHANNEL_STEP(snla), - 0, - (float)NLACHANNEL_HEIGHT_HALF(snla), - x, - y, - NULL, - &channel_index); + UI_view2d_listview_view_to_cell( + 0, NLACHANNEL_STEP(snla), 0, NLACHANNEL_FIRST_TOP(snla), x, y, NULL, &channel_index); /* x-range to check is +/- 7 (in screen/region-space) on either side of mouse click * (that is the size of keyframe icons, so user should be expecting similar tolerances) @@ -562,14 +556,7 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s /* try to get channel */ ale = BLI_findlink(&anim_data, channel_index); - if (ale == NULL) { - /* channel not found */ - printf("Error: animation channel (index = %d) not found in mouse_nla_strips()\n", - channel_index); - ANIM_animdata_freelist(&anim_data); - return; - } - else { + if (ale != NULL) { /* found some channel - we only really should do something when its an Nla-Track */ if (ale->type == ANIMTYPE_NLATRACK) { NlaTrack *nlt = (NlaTrack *)ale->data; @@ -586,11 +573,11 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s /* remove active channel from list of channels for separate treatment * (since it's needed later on) */ BLI_remlink(&anim_data, ale); - - /* free list of channels, since it's not used anymore */ - ANIM_animdata_freelist(&anim_data); } + /* free list of channels, since it's not used anymore */ + ANIM_animdata_freelist(&anim_data); + /* if currently in tweakmode, exit tweakmode before changing selection states * now that we've found our target... */ @@ -598,8 +585,10 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, NULL); } - /* for replacing selection, firstly need to clear existing selection */ - if (select_mode == SELECT_REPLACE) { + /* For replacing selection, if we have something to select, we have to clear existing selection. + * The same goes if we found nothing to select, and deselect_all is true + * (deselect on nothing behavior). */ + if ((strip != NULL && select_mode == SELECT_REPLACE) || (strip == NULL && deselect_all)) { /* reset selection mode for next steps */ select_mode = SELECT_ADD; @@ -611,9 +600,9 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s } /* only select strip if we clicked on a valid channel and hit something */ - if (ale) { + if (ale != NULL) { /* select the strip accordingly (if a matching one was found) */ - if (strip) { + if (strip != NULL) { select_mode = selmodes_to_flagmodes(select_mode); ACHANNEL_SET_FLAG(strip, select_mode, NLASTRIP_FLAG_SELECT); @@ -647,31 +636,18 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent *event) { bAnimContext ac; - /* Scene *scene; */ /* UNUSED */ - /* ARegion *ar; */ /* UNUSED */ - // View2D *v2d; /*UNUSED*/ - short selectmode; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; } - /* get useful pointers from animation context data */ - /* scene= ac.scene; */ /* UNUSED */ - /* ar= ac.ar; */ /* UNUSED */ - // v2d= &ar->v2d; - /* select mode is either replace (deselect all, then add) or add/extend */ - if (RNA_boolean_get(op->ptr, "extend")) { - selectmode = SELECT_INVERT; - } - else { - selectmode = SELECT_REPLACE; - } + const short selectmode = RNA_boolean_get(op->ptr, "extend") ? SELECT_INVERT : SELECT_REPLACE; + const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all"); /* select strips based upon mouse position */ - mouse_nla_strips(C, &ac, event->mval, selectmode); + mouse_nla_strips(C, &ac, event->mval, selectmode, deselect_all); /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL); @@ -699,6 +675,13 @@ void NLA_OT_click_select(wmOperatorType *ot) /* properties */ prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); + + prop = RNA_def_boolean(ot->srna, + "deselect_all", + false, + "Deselect On Nothing", + "Deselect all when nothing under the cursor"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /* *********************************************** */ diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 527a4f6e5f6..ba660945d32 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -174,13 +174,13 @@ static void nla_channel_region_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ /* own channels map first to override some channel keymaps */ keymap = WM_keymap_ensure(wm->defaultconf, "NLA Channels", SPACE_NLA, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); /* now generic channels map for everything else that can apply */ keymap = WM_keymap_ensure(wm->defaultconf, "Animation Channels", 0, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "NLA Generic", SPACE_NLA, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); } /* draw entirely, view changes should be handled here */ @@ -205,9 +205,8 @@ static void nla_channel_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc( - C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); - UI_view2d_scrollers_draw(C, v2d, scrollers); + scrollers = UI_view2d_scrollers_calc(v2d, NULL); + UI_view2d_scrollers_draw(v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -220,7 +219,7 @@ static void nla_main_region_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ keymap = WM_keymap_ensure(wm->defaultconf, "NLA Editor", SPACE_NLA, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "NLA Generic", SPACE_NLA, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -232,9 +231,8 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar) Scene *scene = CTX_data_scene(C); bAnimContext ac; View2D *v2d = &ar->v2d; - View2DGrid *grid; View2DScrollers *scrollers; - short unit = 0, cfra_flag = 0; + short cfra_flag = 0; /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); @@ -243,17 +241,7 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(v2d); /* time grid */ - unit = (snla->flag & SNLA_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; - grid = UI_view2d_grid_calc(CTX_data_scene(C), - v2d, - unit, - V2D_GRID_CLAMP, - V2D_ARG_DUMMY, - V2D_ARG_DUMMY, - ar->winx, - ar->winy); - UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); - UI_view2d_grid_free(grid); + UI_view2d_draw_lines_x__discrete_frames_or_seconds(v2d, scene, snla->flag & SNLA_DRAWTIME); ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); @@ -297,11 +285,14 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc( - C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); - UI_view2d_scrollers_draw(C, v2d, scrollers); + scrollers = UI_view2d_scrollers_calc(v2d, NULL); + UI_view2d_scrollers_draw(v2d, scrollers); UI_view2d_scrollers_free(scrollers); + /* frame numbers */ + UI_view2d_draw_scale_x__discrete_frames_or_seconds( + ar, v2d, &v2d->hor, scene, snla->flag & SNLA_DRAWTIME, TH_TEXT); + /* draw current frame number-indicator on top of scrollers */ if ((snla->flag & SNLA_NODRAWCFRANUM) == 0) { UI_view2d_view_orthoSpecial(ar, v2d, 1); @@ -328,7 +319,7 @@ static void nla_buttons_region_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); keymap = WM_keymap_ensure(wm->defaultconf, "NLA Generic", SPACE_NLA, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); } static void nla_buttons_region_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt index df1b7c03aab..03c83305618 100644 --- a/source/blender/editors/space_node/CMakeLists.txt +++ b/source/blender/editors/space_node/CMakeLists.txt @@ -22,16 +22,16 @@ set(INC ../../blenlib ../../blentranslation ../../depsgraph - ../../imbuf ../../gpu + ../../imbuf ../../makesdna ../../makesrna ../../nodes ../../render/extern/include - ../../windowmanager ../../compositor - ../../../../intern/guardedalloc + ../../windowmanager ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index a694ac2c38b..020bdbf60a1 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -1309,7 +1309,7 @@ static void node_draw_hidden(const bContext *C, nodeLabel(ntree, node, showname, sizeof(showname)); /* XXX - don't print into self! */ - //if (node->flag & NODE_MUTED) + // if (node->flag & NODE_MUTED) // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); uiBut *but = uiDefBut(node->block, @@ -1728,8 +1728,7 @@ void drawnodespace(const bContext *C, ARegion *ar) draw_tree_path(snode); /* scrollers */ - scrollers = UI_view2d_scrollers_calc( - C, v2d, NULL, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); - UI_view2d_scrollers_draw(C, v2d, scrollers); + scrollers = UI_view2d_scrollers_calc(v2d, NULL); + UI_view2d_scrollers_draw(v2d, scrollers); UI_view2d_scrollers_free(scrollers); } diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index 3c65c4854b8..08328681f7a 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -823,8 +823,8 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, /* update the group node and interface node sockets, * so the new interface socket can be linked. */ - node_group_verify(ntree, gnode, (ID *)ngroup); - node_group_input_verify(ngroup, input_node, (ID *)ngroup); + node_group_update(ntree, gnode); + node_group_input_update(ngroup, input_node); /* create new internal link */ input_sock = node_group_input_find_socket(input_node, iosock->identifier); @@ -857,8 +857,8 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, /* update the group node and interface node sockets, * so the new interface socket can be linked. */ - node_group_verify(ntree, gnode, (ID *)ngroup); - node_group_output_verify(ngroup, output_node, (ID *)ngroup); + node_group_update(ntree, gnode); + node_group_output_update(ngroup, output_node); /* create new internal link */ output_sock = node_group_output_find_socket(output_node, iosock->identifier); @@ -898,7 +898,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock); - node_group_input_verify(ngroup, input_node, (ID *)ngroup); + node_group_input_update(ngroup, input_node); /* create new internal link */ input_sock = node_group_input_find_socket(input_node, iosock->identifier); @@ -919,7 +919,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock); - node_group_output_verify(ngroup, output_node, (ID *)ngroup); + node_group_output_update(ngroup, output_node); /* create new internal link */ output_sock = node_group_output_find_socket(output_node, iosock->identifier); diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 58531ec32b1..b52d1d3b78f 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -429,8 +429,13 @@ void node_select_single(bContext *C, bNode *node) WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); } -static int node_mouse_select( - Main *bmain, SpaceNode *snode, ARegion *ar, const int mval[2], bool extend, bool socket_select) +static int node_mouse_select(Main *bmain, + SpaceNode *snode, + ARegion *ar, + const int mval[2], + const bool extend, + const bool socket_select, + const bool deselect_all) { bNode *node, *tnode; bNodeSocket *sock = NULL; @@ -500,13 +505,15 @@ static int node_mouse_select( /* find the closest visible node */ node = node_under_mouse_select(snode->edittree, cursor[0], cursor[1]); - if (node) { + if (node != NULL || deselect_all) { for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) { nodeSetSelected(tnode, false); } - nodeSetSelected(node, true); - ED_node_set_active(bmain, snode->edittree, node); selected = true; + if (node != NULL) { + nodeSetSelected(node, true); + ED_node_set_active(bmain, snode->edittree, node); + } } } } @@ -526,19 +533,18 @@ static int node_select_exec(bContext *C, wmOperator *op) SpaceNode *snode = CTX_wm_space_node(C); ARegion *ar = CTX_wm_region(C); int mval[2]; - short extend; - bool socket_select; /* get settings from RNA properties for operator */ mval[0] = RNA_int_get(op->ptr, "mouse_x"); mval[1] = RNA_int_get(op->ptr, "mouse_y"); - extend = RNA_boolean_get(op->ptr, "extend"); + const bool extend = RNA_boolean_get(op->ptr, "extend"); /* always do socket_select when extending selection. */ - socket_select = extend || RNA_boolean_get(op->ptr, "socket_select"); + const bool socket_select = extend || RNA_boolean_get(op->ptr, "socket_select"); + const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all"); /* perform the select */ - if (node_mouse_select(bmain, snode, ar, mval, extend, socket_select)) { + if (node_mouse_select(bmain, snode, ar, mval, extend, socket_select, deselect_all)) { /* send notifiers */ WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); @@ -575,10 +581,17 @@ void NODE_OT_select(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ + PropertyRNA *prop; RNA_def_int(ot->srna, "mouse_x", 0, INT_MIN, INT_MAX, "Mouse X", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "mouse_y", 0, INT_MIN, INT_MAX, "Mouse Y", "", INT_MIN, INT_MAX); RNA_def_boolean(ot->srna, "extend", false, "Extend", ""); RNA_def_boolean(ot->srna, "socket_select", false, "Socket Select", ""); + prop = RNA_def_boolean(ot->srna, + "deselect_all", + false, + "Deselect On Nothing", + "Deselect all when nothing under the cursor"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /** \} */ diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 94380814fe8..2152bb9847a 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -617,7 +617,7 @@ static void node_main_region_init(wmWindowManager *wm, ARegion *ar) WM_event_add_keymap_handler(&ar->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Node Editor", SPACE_NODE, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); /* add drop boxes */ lb = WM_dropboxmap_find("Node Editor", SPACE_NODE, RGN_TYPE_WINDOW); diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index f08069c418b..d235dd47136 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -21,13 +21,13 @@ set(INC ../../blenlib ../../blentranslation ../../depsgraph - ../../imbuf ../../gpu + ../../imbuf ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c index 4cb80bd1394..49ba397a108 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.c +++ b/source/blender/editors/space_outliner/outliner_dragdrop.c @@ -175,7 +175,8 @@ static TreeElement *outliner_drop_insert_find(bContext *C, } } else { - /* mouse doesn't hover any item (ignoring x-axis), so it's either above list bounds or below. */ + /* Mouse doesn't hover any item (ignoring x-axis), + * so it's either above list bounds or below. */ TreeElement *first = soops->tree.first; TreeElement *last = soops->tree.last; diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 9dbea3c5b1b..9d6008ce3a8 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -627,6 +627,10 @@ static void outliner_draw_restrictbuts(uiBlock *block, UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); UI_but_drawflag_enable(bt, UI_BUT_ICON_REVERSE); } + else if ((tselem->type == 0 && te->idcode == ID_OB) && + (te->flag & TE_CHILD_NOT_IN_COLLECTION)) { + /* Don't show restrict columns for children that are not directly inside the collection. */ + } else if (tselem->type == 0 && te->idcode == ID_OB) { PointerRNA ptr; Object *ob = (Object *)tselem->id; @@ -898,7 +902,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, ICON_HIDE_OFF; } bt = uiDefIconBut(block, - UI_BTYPE_TOGGLE, + UI_BTYPE_ICON_TOGGLE, 0, icon, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), @@ -1010,7 +1014,7 @@ static void outliner_draw_userbuts(uiBlock *block, ARegion *ar, SpaceOutliner *s tip = TIP_("Data-block has no users and will be deleted"); } bt = uiDefIconButBitS(block, - UI_BTYPE_TOGGLE, + UI_BTYPE_ICON_TOGGLE, LIB_FAKEUSER, 1, icon, @@ -1045,7 +1049,7 @@ static void outliner_draw_userbuts(uiBlock *block, ARegion *ar, SpaceOutliner *s UI_but_flag_enable(bt, but_flag); bt = uiDefButBitS(block, - UI_BTYPE_TOGGLE, + UI_BTYPE_ICON_TOGGLE, LIB_FAKEUSER, 1, (id->flag & LIB_FAKEUSER) ? "F" : " ", @@ -2074,7 +2078,10 @@ static void outliner_draw_tree_element(bContext *C, tselem = TREESTORE(te); if (*starty + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && *starty <= ar->v2d.cur.ymax) { - const float alpha_fac = ((te->flag & TE_DISABLED) || draw_grayed_out) ? 0.5f : 1.0f; + const float alpha_fac = ((te->flag & TE_DISABLED) || (te->flag & TE_CHILD_NOT_IN_COLLECTION) || + draw_grayed_out) ? + 0.5f : + 1.0f; const float alpha = 0.5f * alpha_fac; int xmax = ar->v2d.cur.xmax; @@ -2100,7 +2107,8 @@ static void outliner_draw_tree_element(bContext *C, } else if (te->idcode == ID_OB) { Object *ob = (Object *)tselem->id; - Base *base = BKE_view_layer_base_find(view_layer, ob); + Base *base = (te->directdata) ? (Base *)te->directdata : + BKE_view_layer_base_find(view_layer, ob); const bool is_selected = (base != NULL) && ((base->flag & BASE_SELECTED) != 0); if (ob == obact || is_selected) { @@ -2255,26 +2263,6 @@ static void outliner_draw_tree_element(bContext *C, GPU_blend(true); - /* divider */ - { - GPUVertFormat *format = immVertexFormat(); - uint pos = GPU_vertformat_attr_add( - format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); - unsigned char col[4]; - - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - UI_GetThemeColorShade4ubv(TH_BACK, -40, col); - col[3] *= alpha_fac; - - immUniformColor4ubv(col); - immRecti(pos, - tempx - 10.0f * ufac, - *starty + 4.0f * ufac, - tempx - 8.0f * ufac, - *starty + UI_UNIT_Y - 4.0f * ufac); - immUnbindProgram(); - } - MergedIconRow merged = {{0}}; outliner_draw_iconrow(C, block, @@ -2338,17 +2326,28 @@ static void outliner_draw_hierarchy_lines_recursive(unsigned pos, bool draw_grayed_out, int *starty) { - TreeElement *te, *te_vertical_line_last = NULL; - int y1, y2; + TreeElement *te, *te_vertical_line_last = NULL, *te_vertical_line_last_dashed = NULL; + int y1, y2, y1_dashed, y2_dashed; if (BLI_listbase_is_empty(lb)) { return; } + struct { + int steps_num; + int step_len; + int gap_len; + } dash = { + .steps_num = 4, + }; + + dash.step_len = UI_UNIT_X / dash.steps_num; + dash.gap_len = dash.step_len / 2; + const unsigned char grayed_alpha = col[3] / 2; /* For vertical lines between objects. */ - y1 = y2 = *starty; + y1 = y2 = y1_dashed = y2_dashed = *starty; for (te = lb->first; te; te = te->next) { bool draw_childs_grayed_out = draw_grayed_out || (te->flag & TE_DRAGGING); TreeStoreElem *tselem = TREESTORE(te); @@ -2360,15 +2359,30 @@ static void outliner_draw_hierarchy_lines_recursive(unsigned pos, immUniformColor4ubv(col); } - /* Horizontal Line? */ - if (tselem->type == 0 && (te->idcode == ID_OB || te->idcode == ID_SCE)) { - immRecti(pos, startx, *starty, startx + UI_UNIT_X, *starty - 1); + if ((te->flag & TE_CHILD_NOT_IN_COLLECTION) == 0) { + /* Horizontal Line? */ + if (tselem->type == 0 && (te->idcode == ID_OB || te->idcode == ID_SCE)) { + immRecti(pos, startx, *starty, startx + UI_UNIT_X, *starty - U.pixelsize); - /* Vertical Line? */ - if (te->idcode == ID_OB) { - te_vertical_line_last = te; - y2 = *starty; + /* Vertical Line? */ + if (te->idcode == ID_OB) { + te_vertical_line_last = te; + y2 = *starty; + } + y1_dashed = *starty - UI_UNIT_Y; + } + } + else { + BLI_assert(te->idcode == ID_OB); + /* Horizontal line - dashed. */ + int start = startx; + for (int i = 0; i < dash.steps_num; i++) { + immRecti(pos, start, *starty, start + dash.step_len - dash.gap_len, *starty - U.pixelsize); + start += dash.step_len; } + + te_vertical_line_last_dashed = te; + y2_dashed = *starty; } *starty -= UI_UNIT_Y; @@ -2389,7 +2403,19 @@ static void outliner_draw_hierarchy_lines_recursive(unsigned pos, /* Vertical line. */ te = te_vertical_line_last; if ((te != NULL) && (te->parent || lb->first != lb->last)) { - immRecti(pos, startx, y1 + UI_UNIT_Y, startx + 1, y2); + immRecti(pos, startx, y1 + UI_UNIT_Y, startx + U.pixelsize, y2); + } + + /* Children that are not in the collection are always in the end of the subtree. + * This way we can draw their own dashed vertical lines. */ + te = te_vertical_line_last_dashed; + if ((te != NULL) && (te->parent || lb->first != lb->last)) { + const int steps_num = ((y1_dashed + UI_UNIT_Y) - y2_dashed) / dash.step_len; + int start = y1_dashed + UI_UNIT_Y; + for (int i = 0; i < steps_num; i++) { + immRecti(pos, startx, start, startx + U.pixelsize, start - dash.step_len + dash.gap_len); + start -= dash.step_len; + } } } @@ -2473,7 +2499,7 @@ static void outliner_draw_highlights_recursive(unsigned pos, /* selection status */ if (tselem->flag & TSE_SELECTED) { immUniformColor4fv(col_selection); - immRecti(pos, 0, start_y + 1, (int)ar->v2d.cur.xmax, start_y + UI_UNIT_Y - 1); + immRecti(pos, 0, start_y, (int)ar->v2d.cur.xmax, start_y + UI_UNIT_Y); } /* highlights */ @@ -2487,15 +2513,19 @@ static void outliner_draw_highlights_recursive(unsigned pos, if (tselem->flag & TSE_DRAG_BEFORE) { immUniformColor4fv(col); - immRecti(pos, start_x, start_y + UI_UNIT_Y - 1, end_x, start_y + UI_UNIT_Y + 1); + immRecti(pos, + start_x, + start_y + UI_UNIT_Y - U.pixelsize, + end_x, + start_y + UI_UNIT_Y + U.pixelsize); } else if (tselem->flag & TSE_DRAG_AFTER) { immUniformColor4fv(col); - immRecti(pos, start_x, start_y - 1, end_x, start_y + 1); + immRecti(pos, start_x, start_y - U.pixelsize, end_x, start_y + U.pixelsize); } else { immUniformColor3fvAlpha(col, col[3] * 0.5f); - immRecti(pos, start_x, start_y + 1, end_x, start_y + UI_UNIT_Y - 1); + immRecti(pos, start_x, start_y, end_x, start_y + UI_UNIT_Y); } } else { @@ -2504,12 +2534,12 @@ static void outliner_draw_highlights_recursive(unsigned pos, * we don't expand items when searching in the datablocks but we * still want to highlight any filter matches. */ immUniformColor4fv(col_searchmatch); - immRecti(pos, start_x, start_y + 1, end_x, start_y + UI_UNIT_Y - 1); + immRecti(pos, start_x, start_y, end_x, start_y + UI_UNIT_Y); } else if (tselem->flag & TSE_HIGHLIGHTED) { /* mouse hover highlight */ immUniformColor4fv(col_highlight); - immRecti(pos, 0, start_y + 1, end_x, start_y + UI_UNIT_Y - 1); + immRecti(pos, 0, start_y, end_x, start_y + UI_UNIT_Y); } } } @@ -2588,7 +2618,7 @@ static void outliner_draw_tree(bContext *C, // gray hierarchy lines starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y / 2 - OL_Y_OFFSET; - startx = UI_UNIT_X / 2 - 1.0f; + startx = UI_UNIT_X / 2 - (U.pixelsize + 1) / 2; outliner_draw_hierarchy_lines(soops, &soops->tree, startx, &starty); // items themselves @@ -2650,29 +2680,6 @@ static void outliner_back(ARegion *ar) immUnbindProgram(); } -static void outliner_draw_restrictcols(ARegion *ar) -{ - GPU_line_width(1.0f); - - uint pos = GPU_vertformat_attr_add( - immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformThemeColorShadeAlpha(TH_BACK, -15, -200); - immBegin(GPU_PRIM_LINES, 6); - - immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)ar->v2d.cur.ymax); - immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)ar->v2d.cur.ymin); - - immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)ar->v2d.cur.ymax); - immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)ar->v2d.cur.ymin); - - immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)ar->v2d.cur.ymax); - immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)ar->v2d.cur.ymin); - - immEnd(); - immUnbindProgram(); -} - /* ****************************************************** */ /* Main Entrypoint - Draw contents of Outliner editor */ @@ -2717,7 +2724,7 @@ void draw_outliner(const bContext *C) else { /* width must take into account restriction columns (if visible) * so that entries will still be visible */ - //outliner_width(soops, &soops->tree, &sizex); + // outliner_width(soops, &soops->tree, &sizex); // XXX should use outliner_width instead when te->xend will be set correctly... outliner_rna_width(soops, &soops->tree, &sizex, 0); @@ -2760,13 +2767,10 @@ void draw_outliner(const bContext *C) } else if ((soops->outlinevis == SO_ID_ORPHANS) && has_restrict_icons) { /* draw user toggle columns */ - outliner_draw_restrictcols(ar); outliner_draw_userbuts(block, ar, soops, &soops->tree); } else if (has_restrict_icons) { /* draw restriction columns */ - outliner_draw_restrictcols(ar); - outliner_draw_restrictbuts(block, scene, view_layer, ar, soops, &soops->tree); } diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index d939f84e186..a943e972cf5 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1634,7 +1634,8 @@ static void tree_element_to_path(TreeElement *te, /* check if we're looking for first ID, or appending to path */ if (*id) { /* just 'append' property to path - * - to prevent memory leaks, we must write to newpath not path, then free old path + swap them + * - to prevent memory leaks, we must write to newpath not path, + * then free old path + swap them. */ if (tse->type == TSE_RNA_PROPERTY) { if (RNA_property_type(prop) == PROP_POINTER) { diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index d382384076b..8211e3005c7 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -130,6 +130,7 @@ enum { TE_FREE_NAME = (1 << 3), TE_DISABLED = (1 << 4), TE_DRAGGING = (1 << 5), + TE_CHILD_NOT_IN_COLLECTION = (1 << 6), }; /* button events */ @@ -235,10 +236,6 @@ eOLDrawState tree_element_active(struct bContext *C, void outliner_item_do_activate_from_tree_element( struct bContext *C, TreeElement *te, TreeStoreElem *tselem, bool extend, bool recursive); -int outliner_item_do_activate_from_cursor(struct bContext *C, - const int mval[2], - bool extend, - bool recursive); void outliner_item_select(struct SpaceOutliner *soops, const struct TreeElement *te, diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 459736a730d..995f41382cd 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -1297,10 +1297,11 @@ void outliner_item_do_activate_from_tree_element( * * May expend/collapse branches or activate items. * */ -int outliner_item_do_activate_from_cursor(bContext *C, - const int mval[2], - bool extend, - bool recursive) +static int outliner_item_do_activate_from_cursor(bContext *C, + const int mval[2], + const bool extend, + const bool recursive, + const bool deselect_all) { ARegion *ar = CTX_wm_region(C); SpaceOutliner *soops = CTX_wm_space_outliner(C); @@ -1315,7 +1316,10 @@ int outliner_item_do_activate_from_cursor(bContext *C, } if (!(te = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]))) { - /* skip */ + if (deselect_all) { + outliner_flag_set(&soops->tree, TSE_SELECTED, false); + changed = true; + } } else if (outliner_item_is_co_within_close_toggle(te, view_mval[0])) { outliner_item_toggle_closed(te, extend); @@ -1351,9 +1355,10 @@ int outliner_item_do_activate_from_cursor(bContext *C, /* event can enterkey, then it opens/closes */ static int outliner_item_activate_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - bool extend = RNA_boolean_get(op->ptr, "extend"); - bool recursive = RNA_boolean_get(op->ptr, "recursive"); - return outliner_item_do_activate_from_cursor(C, event->mval, extend, recursive); + const bool extend = RNA_boolean_get(op->ptr, "extend"); + const bool recursive = RNA_boolean_get(op->ptr, "recursive"); + const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all"); + return outliner_item_do_activate_from_cursor(C, event->mval, extend, recursive, deselect_all); } void OUTLINER_OT_item_activate(wmOperatorType *ot) @@ -1366,8 +1371,15 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot) ot->poll = ED_operator_outliner_active; + PropertyRNA *prop; RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection for activation"); RNA_def_boolean(ot->srna, "recursive", false, "Recursive", "Select Objects and their children"); + prop = RNA_def_boolean(ot->srna, + "deselect_all", + false, + "Deselect On Nothing", + "Deselect all when nothing under the cursor"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /* ****************************************************** */ diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 650827a17c7..0f9efb0d2e1 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -283,7 +283,7 @@ static void unlink_collection_cb(bContext *C, static void unlink_object_cb(bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), - TreeElement *UNUSED(te), + TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem, void *UNUSED(user_data)) @@ -291,6 +291,15 @@ static void unlink_object_cb(bContext *C, Main *bmain = CTX_data_main(C); Object *ob = (Object *)tselem->id; + if (GS(tsep->id->name) == ID_OB) { + /* Parented objects need to find which collection to unlink from. */ + TreeElement *te_parent = te->parent; + while (tsep && GS(tsep->id->name) == ID_OB) { + te_parent = te_parent->parent; + tsep = te_parent ? TREESTORE(te_parent) : NULL; + } + } + if (tsep) { if (GS(tsep->id->name) == ID_GR) { Collection *parent = (Collection *)tsep->id; @@ -452,8 +461,8 @@ static void object_select_cb(bContext *C, Object *ob = (Object *)tselem->id; Base *base = BKE_view_layer_base_find(view_layer, ob); - if (base && ((base->flag & BASE_VISIBLE) != 0)) { - base->flag |= BASE_SELECTED; + if (base) { + ED_object_base_select(base, BA_SELECT); } } @@ -1837,8 +1846,8 @@ typedef enum eOutliner_AnimDataOps { OUTLINER_ANIMOP_REFRESH_DRV, OUTLINER_ANIMOP_CLEAR_DRV - //OUTLINER_ANIMOP_COPY_DRIVERS, - //OUTLINER_ANIMOP_PASTE_DRIVERS + // OUTLINER_ANIMOP_COPY_DRIVERS, + // OUTLINER_ANIMOP_PASTE_DRIVERS } eOutliner_AnimDataOps; static const EnumPropertyItem prop_animdata_op_types[] = { @@ -1904,7 +1913,7 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) soops, datalevel, event, &soops->tree, refreshdrivers_animdata_cb, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL); - //ED_undo_push(C, "Refresh Drivers"); /* no undo needed - shouldn't have any impact? */ + // ED_undo_push(C, "Refresh Drivers"); /* no undo needed - shouldn't have any impact? */ updateDeps = 1; break; diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 69449f46677..4e3fd6037bb 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -48,6 +48,7 @@ #include "DNA_linestyle_types.h" #include "BLI_blenlib.h" +#include "BLI_listbase.h" #include "BLI_utildefines.h" #include "BLI_mempool.h" #include "BLI_fnmatch.h" @@ -359,12 +360,12 @@ static void outliner_add_object_contents(SpaceOutliner *soops, pchan->temp = (void *)ten; if (pchan->constraints.first) { - //Object *target; + // Object *target; bConstraint *con; TreeElement *ten1; TreeElement *tenla1 = outliner_add_element( soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0); - //char *str; + // char *str; tenla1->name = IFACE_("Constraints"); for (con = pchan->constraints.first; con; con = con->next, const_index++) { @@ -425,11 +426,11 @@ static void outliner_add_object_contents(SpaceOutliner *soops, } if (ob->constraints.first) { - //Object *target; + // Object *target; bConstraint *con; TreeElement *ten; TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0); - //char *str; + // char *str; int a; tenla->name = IFACE_("Constraints"); @@ -653,7 +654,7 @@ static void outliner_add_id_contents(SpaceOutliner *soops, } case ID_AC: { // XXX do we want to be exposing the F-Curves here? - //bAction *act = (bAction *)id; + // bAction *act = (bAction *)id; break; } case ID_AR: { @@ -1477,6 +1478,104 @@ static void outliner_make_object_parent_hierarchy(ListBase *lb) } } +/** + * For all objects in the tree, lookup the parent in this map, + * and move or add tree elements as needed. + */ +static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *soops, + GHash *object_tree_elements_hash) +{ + GHashIterator gh_iter; + GHASH_ITER (gh_iter, object_tree_elements_hash) { + Object *child = BLI_ghashIterator_getKey(&gh_iter); + + if (child->parent == NULL) { + continue; + } + + ListBase *child_ob_tree_elements = BLI_ghashIterator_getValue(&gh_iter); + ListBase *parent_ob_tree_elements = BLI_ghash_lookup(object_tree_elements_hash, child->parent); + if (parent_ob_tree_elements == NULL) { + continue; + } + + for (LinkData *link = parent_ob_tree_elements->first; link; link = link->next) { + TreeElement *parent_ob_tree_element = link->data; + TreeElement *parent_ob_collection_tree_element = NULL; + bool found = false; + + /* We always want to remove the child from the direct collection its parent is nested under. + * This is particularly important when dealing with multi-level nesting (grandchildren). */ + parent_ob_collection_tree_element = parent_ob_tree_element->parent; + while (!ELEM(TREESTORE(parent_ob_collection_tree_element)->type, + TSE_VIEW_COLLECTION_BASE, + TSE_LAYER_COLLECTION)) { + parent_ob_collection_tree_element = parent_ob_collection_tree_element->parent; + } + + for (LinkData *link_iter = child_ob_tree_elements->first; link_iter; + link_iter = link_iter->next) { + TreeElement *child_ob_tree_element = link_iter->data; + + if (child_ob_tree_element->parent == parent_ob_collection_tree_element) { + /* Move from the collection subtree into the parent object subtree. */ + BLI_remlink(&parent_ob_collection_tree_element->subtree, child_ob_tree_element); + BLI_addtail(&parent_ob_tree_element->subtree, child_ob_tree_element); + child_ob_tree_element->parent = parent_ob_tree_element; + found = true; + break; + } + } + + if (!found) { + /* We add the child in the tree even if it is not in the collection. + * We deliberately clear its subtree though, to make it less proeminent. */ + TreeElement *child_ob_tree_element = outliner_add_element( + soops, &parent_ob_tree_element->subtree, child, parent_ob_tree_element, 0, 0); + outliner_free_tree(&child_ob_tree_element->subtree); + child_ob_tree_element->flag |= TE_CHILD_NOT_IN_COLLECTION; + BLI_addtail(child_ob_tree_elements, BLI_genericNodeN(child_ob_tree_element)); + } + } + } +} + +/** + * Build a map from Object* to a list of TreeElement* matching the object. + */ +static void outliner_object_tree_elements_lookup_create_recursive(GHash *object_tree_elements_hash, + TreeElement *te_parent) +{ + for (TreeElement *te = te_parent->subtree.first; te; te = te->next) { + TreeStoreElem *tselem = TREESTORE(te); + + if (tselem->type == TSE_LAYER_COLLECTION) { + outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, te); + } + else if (tselem->type == 0 && te->idcode == ID_OB) { + Object *ob = (Object *)tselem->id; + ListBase *tree_elements = BLI_ghash_lookup(object_tree_elements_hash, ob); + + if (tree_elements == NULL) { + tree_elements = MEM_callocN(sizeof(ListBase), __func__); + BLI_ghash_insert(object_tree_elements_hash, ob, tree_elements); + } + + BLI_addtail(tree_elements, BLI_genericNodeN(te)); + outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, te); + } + } +} + +static void outliner_object_tree_elements_lookup_free(GHash *object_tree_elements_hash) +{ + GHASH_FOREACH_BEGIN (ListBase *, tree_elements, object_tree_elements_hash) { + BLI_freelistN(tree_elements); + MEM_freeN(tree_elements); + } + GHASH_FOREACH_END(); +} + /* Sorting ------------------------------------------------------ */ typedef struct tTreeSort { @@ -1505,6 +1604,13 @@ static int treesort_alpha_ob(const void *v1, const void *v2) return -1; } else if (comp == 3) { + /* Among objects first come the ones in the collection, followed by the ones not on it. + * This way we can have the dashed lines in a separate style connecting the former. */ + if ((x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) != + (x2->te->flag & TE_CHILD_NOT_IN_COLLECTION)) { + return (x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) ? 1 : -1; + } + comp = strcmp(x1->name, x2->name); if (comp > 0) { @@ -1518,6 +1624,19 @@ static int treesort_alpha_ob(const void *v1, const void *v2) return 0; } +/* Move children that are not in the collection to the end of the list. */ +static int treesort_child_not_in_collection(const void *v1, const void *v2) +{ + const tTreeSort *x1 = v1, *x2 = v2; + + /* Among objects first come the ones in the collection, followed by the ones not on it. + * This way we can have the dashed lines in a separate style connecting the former. */ + if ((x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) != (x2->te->flag & TE_CHILD_NOT_IN_COLLECTION)) { + return (x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) ? 1 : -1; + } + return 0; +} + /* alphabetical comparator */ static int treesort_alpha(const void *v1, const void *v2) { @@ -1641,6 +1760,50 @@ static void outliner_sort(ListBase *lb) } } +static void outliner_collections_children_sort(ListBase *lb) +{ + TreeElement *te; + TreeStoreElem *tselem; + + te = lb->last; + if (te == NULL) { + return; + } + tselem = TREESTORE(te); + + /* Sorting rules: only object lists. */ + if (tselem->type == 0 && te->idcode == ID_OB) { + int totelem = BLI_listbase_count(lb); + + if (totelem > 1) { + tTreeSort *tear = MEM_mallocN(totelem * sizeof(tTreeSort), "tree sort array"); + tTreeSort *tp = tear; + + for (te = lb->first; te; te = te->next, tp++) { + tselem = TREESTORE(te); + tp->te = te; + tp->name = te->name; + tp->idcode = te->idcode; + tp->id = tselem->id; + } + + qsort(tear, totelem, sizeof(tTreeSort), treesort_child_not_in_collection); + + BLI_listbase_clear(lb); + tp = tear; + while (totelem--) { + BLI_addtail(lb, tp->te); + tp++; + } + MEM_freeN(tear); + } + } + + for (te = lb->first; te; te = te->next) { + outliner_sort(&te->subtree); + } +} + /* Filtering ----------------------------------------------- */ typedef struct OutlinerTreeElementFocus { @@ -2191,12 +2354,28 @@ void outliner_build_tree( bool show_objects = !(soops->filter & SO_FILTER_NO_OBJECT); outliner_add_view_layer(soops, &ten->subtree, ten, view_layer, show_objects); + + if ((soops->filter & SO_FILTER_NO_CHILDREN) == 0) { + GHash *object_tree_elements_hash = BLI_ghash_new( + BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__); + outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, ten); + outliner_make_object_parent_hierarchy_collections(soops, object_tree_elements_hash); + outliner_object_tree_elements_lookup_free(object_tree_elements_hash); + BLI_ghash_free(object_tree_elements_hash, NULL, NULL); + } } } if ((soops->flag & SO_SKIP_SORT_ALPHA) == 0) { outliner_sort(&soops->tree); } + else if ((soops->filter & SO_FILTER_NO_CHILDREN) == 0) { + /* We group the children that are in the collection before the ones that are not. + * This way we can try to draw them in a different style altogether. + * We also have to respect the original order of the elements in case alphabetical + * sorting is not enabled. This keep object data and modifiers before its children. */ + outliner_collections_children_sort(&soops->tree); + } outliner_filter_tree(soops, view_layer); outliner_restore_scrolling_position(soops, ar, &focus); diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 26b97a1cdd9..a8e3129b5b4 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -74,8 +74,7 @@ static void outliner_main_region_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ keymap = WM_keymap_ensure(wm->defaultconf, "Outliner", SPACE_OUTLINER, 0); - /* don't pass on view2d mask, it's always set with scrollbar space, hide fails */ - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, NULL, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); /* Add dropboxes */ lb = WM_dropboxmap_find("Outliner", SPACE_OUTLINER, RGN_TYPE_WINDOW); @@ -97,9 +96,8 @@ static void outliner_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc( - C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); - UI_view2d_scrollers_draw(C, v2d, scrollers); + scrollers = UI_view2d_scrollers_calc(v2d, NULL); + UI_view2d_scrollers_draw(v2d, scrollers); UI_view2d_scrollers_free(scrollers); } diff --git a/source/blender/editors/space_script/CMakeLists.txt b/source/blender/editors/space_script/CMakeLists.txt index 1abc05d2270..0bd2a01a151 100644 --- a/source/blender/editors/space_script/CMakeLists.txt +++ b/source/blender/editors/space_script/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c index 3ffa54727e6..b99c2eaf54e 100644 --- a/source/blender/editors/space_script/space_script.c +++ b/source/blender/editors/space_script/space_script.c @@ -47,7 +47,7 @@ #include "script_intern.h" // own include #include "GPU_framebuffer.h" -//static script_run_python(char *funcname, ) +// static script_run_python(char *funcname, ) /* ******************** default callbacks for script space ***************** */ @@ -116,7 +116,7 @@ static void script_main_region_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ keymap = WM_keymap_ensure(wm->defaultconf, "Script", SPACE_SCRIPT, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); } static void script_main_region_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt index 8b97f7537f8..d57be0c85c3 100644 --- a/source/blender/editors/space_sequencer/CMakeLists.txt +++ b/source/blender/editors/space_sequencer/CMakeLists.txt @@ -20,14 +20,15 @@ set(INC ../../blenkernel ../../blenlib ../../blentranslation - ../../imbuf ../../gpu + ../../depsgraph + ../../imbuf ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/atomic - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 218804b0ab4..1cad9e4f734 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -64,6 +64,8 @@ # include <AUD_Sequence.h> #endif +#include "DEG_depsgraph.h" + /* own include */ #include "sequencer_intern.h" @@ -334,7 +336,7 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel); seq->type = SEQ_TYPE_SCENE; - seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */ + seq->blend_mode = SEQ_TYPE_ALPHAOVER; seq->scene = sce_seq; @@ -355,6 +357,7 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) sequencer_add_apply_replace_sel(C, op, seq); sequencer_add_apply_overlap(C, op, seq); + DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -422,7 +425,7 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel); seq->type = SEQ_TYPE_MOVIECLIP; - seq->blend_mode = SEQ_TYPE_CROSS; + seq->blend_mode = SEQ_TYPE_ALPHAOVER; seq->clip = clip; id_us_ensure_real(&seq->clip->id); @@ -441,6 +444,7 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) sequencer_add_apply_replace_sel(C, op, seq); sequencer_add_apply_overlap(C, op, seq); + DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -508,7 +512,7 @@ static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op) seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel); seq->type = SEQ_TYPE_MASK; - seq->blend_mode = SEQ_TYPE_CROSS; + seq->blend_mode = SEQ_TYPE_ALPHAOVER; seq->mask = mask; id_us_ensure_real(&seq->mask->id); @@ -527,6 +531,7 @@ static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op) sequencer_add_apply_replace_sel(C, op, seq); sequencer_add_apply_overlap(C, op, seq); + DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -641,6 +646,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad BKE_sequencer_sort(scene); BKE_sequencer_update_muting(ed); + DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -715,7 +721,7 @@ static int sequencer_add_movie_strip_invoke(bContext *C, WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; - //return sequencer_add_movie_strip_exec(C, op); + // return sequencer_add_movie_strip_exec(C, op); } static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op) @@ -797,7 +803,7 @@ static int sequencer_add_sound_strip_invoke(bContext *C, WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; - //return sequencer_add_sound_strip_exec(C, op); + // return sequencer_add_sound_strip_exec(C, op); } void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) @@ -968,6 +974,7 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) MEM_freeN(op->customdata); } + DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -1098,14 +1105,8 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) if (seq->type == SEQ_TYPE_COLOR) { SolidColorVars *colvars = (SolidColorVars *)seq->effectdata; RNA_float_get_array(op->ptr, "color", colvars->col); - seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */ - } - else if (seq->type == SEQ_TYPE_ADJUSTMENT) { - seq->blend_mode = SEQ_TYPE_CROSS; - } - else if (seq->type == SEQ_TYPE_TEXT) { - seq->blend_mode = SEQ_TYPE_ALPHAOVER; } + seq->blend_mode = SEQ_TYPE_ALPHAOVER; /* an unset channel is a special case where we automatically go above * the other strips. */ @@ -1129,6 +1130,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) * it was NOT called in blender 2.4x, but wont hurt */ BKE_sequencer_sort(scene); + DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -1180,7 +1182,7 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot) RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, - SEQ_TYPE_CROSS, + SEQ_TYPE_ALPHAOVER, "Type", "Sequencer effect type"); RNA_def_float_vector(ot->srna, diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 550aa9d7f8d..72f186d4c1a 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -259,11 +259,6 @@ static void drawseqwave(View2D *v2d, return; } - if (!sound->spinlock) { - sound->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock"); - BLI_spin_init(sound->spinlock); - } - BLI_spin_lock(sound->spinlock); if (!sound->waveform) { if (!(sound->tags & SOUND_TAGS_WAVEFORM_LOADING)) { @@ -461,7 +456,7 @@ static void draw_seq_handle(View2D *v2d, const short direction, unsigned int pos) { - float v1[2], v2[2], v3[2], rx1 = 0, rx2 = 0; //for triangles and rect + float v1[2], v2[2], v3[2], rx1 = 0, rx2 = 0; // for triangles and rect float x1, x2, y1, y2; unsigned int whichsel = 0; @@ -817,7 +812,7 @@ static void draw_seq_strip(const bContext *C, immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* get the correct color per strip type*/ - //color3ubv_from_seq(scene, seq, col); + // color3ubv_from_seq(scene, seq, col); color3ubv_from_seq(scene, seq, background_col); if (seq->flag & SEQ_MUTE) { @@ -1812,6 +1807,181 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) GPU_blend(false); } +typedef struct CacheDrawData { + const bContext *C; + uint pos; + float stripe_offs; + float stripe_ht; +} CacheDrawData; + +/* Called as a callback */ +static bool draw_cache_view_cb( + void *userdata, struct Sequence *seq, int cfra, int cache_type, float UNUSED(cost)) +{ + CacheDrawData *drawdata = userdata; + const bContext *C = drawdata->C; + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + struct View2D *v2d = &ar->v2d; + Editing *ed = scene->ed; + uint pos = drawdata->pos; + + if ((ed->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT) == 0) { + return true; + } + + float stripe_bot, stripe_top, stripe_offs, stripe_ht; + float color[4]; + color[3] = 0.4f; + + switch (cache_type) { + case SEQ_CACHE_STORE_FINAL_OUT: + if (scene->ed->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT) { + color[0] = 1.0f; + color[1] = 0.4f; + color[2] = 0.2f; + stripe_ht = UI_view2d_region_to_view_y(v2d, 4.0f * UI_DPI_FAC * U.pixelsize) - + v2d->cur.ymin; + stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HEIGHT_TEXT); + stripe_top = stripe_bot + stripe_ht; + break; + } + else { + return false; + } + + case SEQ_CACHE_STORE_RAW: + if (scene->ed->cache_flag & SEQ_CACHE_VIEW_RAW) { + color[0] = 1.0f; + color[1] = 0.1f; + color[2] = 0.02f; + stripe_offs = drawdata->stripe_offs; + stripe_ht = drawdata->stripe_ht; + stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + stripe_offs; + stripe_top = stripe_bot + stripe_ht; + break; + } + else { + return false; + } + + case SEQ_CACHE_STORE_PREPROCESSED: + if (scene->ed->cache_flag & SEQ_CACHE_VIEW_PREPROCESSED) { + color[0] = 0.1f; + color[1] = 0.1f; + color[2] = 0.75f; + stripe_offs = drawdata->stripe_offs; + stripe_ht = drawdata->stripe_ht; + stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + (stripe_offs + stripe_ht) + stripe_offs; + stripe_top = stripe_bot + stripe_ht; + break; + } + else { + return false; + } + + case SEQ_CACHE_STORE_COMPOSITE: + if (scene->ed->cache_flag & SEQ_CACHE_VIEW_COMPOSITE) { + color[0] = 1.0f; + color[1] = 0.6f; + color[2] = 0.0f; + stripe_offs = drawdata->stripe_offs; + stripe_ht = drawdata->stripe_ht; + stripe_top = seq->machine + SEQ_STRIP_OFSTOP - stripe_offs; + stripe_bot = stripe_top - stripe_ht; + break; + } + else { + return false; + } + } + + immUniformColor4f(color[0], color[1], color[2], color[3]); + immRectf(pos, cfra, stripe_bot, cfra + 1, stripe_top); + + return false; +} + +static void draw_cache_view(const bContext *C) +{ + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + struct View2D *v2d = &ar->v2d; + + if ((scene->ed->cache_flag & SEQ_CACHE_VIEW_ENABLE) == 0) { + return; + } + + GPU_blend(true); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + + float stripe_bot, stripe_top, stripe_offs; + float stripe_ht = UI_view2d_region_to_view_y(v2d, 4.0f * UI_DPI_FAC * U.pixelsize) - + v2d->cur.ymin; + + if (scene->ed->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT) { + stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HEIGHT_TEXT); + stripe_top = stripe_bot + stripe_ht; + float bg_color[4] = {1.0f, 0.4f, 0.2f, 0.1f}; + + immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]); + immRectf(pos, scene->r.sfra, stripe_bot, scene->r.efra, stripe_top); + } + + for (Sequence *seq = scene->ed->seqbasep->first; seq != NULL; seq = seq->next) { + if (seq->type == SEQ_TYPE_SOUND_RAM) { + continue; + } + + if (seq->startdisp > v2d->cur.xmax || seq->enddisp < v2d->cur.xmin) { + continue; + } + + CLAMP_MAX(stripe_ht, 0.2f); + stripe_offs = UI_view2d_region_to_view_y(v2d, 1.0f) - v2d->cur.ymin; + CLAMP_MIN(stripe_offs, stripe_ht / 2); + + stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + stripe_offs; + stripe_top = stripe_bot + stripe_ht; + + if (scene->ed->cache_flag & SEQ_CACHE_VIEW_RAW) { + float bg_color[4] = {1.0f, 0.1f, 0.02f, 0.1f}; + immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]); + immRectf(pos, seq->startdisp, stripe_bot, seq->enddisp, stripe_top); + } + + stripe_bot += stripe_ht + stripe_offs; + stripe_top = stripe_bot + stripe_ht; + + if (scene->ed->cache_flag & SEQ_CACHE_VIEW_PREPROCESSED) { + float bg_color[4] = {0.1f, 0.1f, 0.75f, 0.1f}; + immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]); + immRectf(pos, seq->startdisp, stripe_bot, seq->enddisp, stripe_top); + } + + stripe_top = seq->machine + SEQ_STRIP_OFSTOP - stripe_offs; + stripe_bot = stripe_top - stripe_ht; + + if (scene->ed->cache_flag & SEQ_CACHE_VIEW_COMPOSITE) { + float bg_color[4] = {1.0f, 0.6f, 0.0f, 0.1f}; + immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]); + immRectf(pos, seq->startdisp, stripe_bot, seq->enddisp, stripe_top); + } + } + + CacheDrawData userdata; + userdata.C = C; + userdata.pos = pos; + userdata.stripe_offs = stripe_offs; + userdata.stripe_ht = stripe_ht; + + BKE_sequencer_cache_iterate(scene, &userdata, draw_cache_view_cb); + + immUnbindProgram(); + GPU_blend(false); +} + /* Draw Timeline/Strip Editor Mode for Sequencer */ void draw_timeline_seq(const bContext *C, ARegion *ar) { @@ -1820,7 +1990,7 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) SpaceSeq *sseq = CTX_wm_space_seq(C); View2D *v2d = &ar->v2d; View2DScrollers *scrollers; - short unit = 0, cfra_flag = 0; + short cfra_flag = 0; float col[3]; /* clear and setup matrix */ @@ -1860,6 +2030,7 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) if (ed) { /* draw the data */ draw_seq_strips(C, ed, ar); + draw_cache_view(C); /* text draw cached (for sequence names), in pixelspace now */ UI_view2d_text_cache_draw(ar); @@ -1910,12 +2081,15 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - unit = (sseq->flag & SEQ_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS; - scrollers = UI_view2d_scrollers_calc( - C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_UNIT_VALUES, V2D_GRID_CLAMP); - UI_view2d_scrollers_draw(C, v2d, scrollers); + scrollers = UI_view2d_scrollers_calc(v2d, NULL); + UI_view2d_scrollers_draw(v2d, scrollers); UI_view2d_scrollers_free(scrollers); + /* scale numbers */ + UI_view2d_draw_scale_x__discrete_frames_or_seconds( + ar, v2d, &v2d->hor, scene, !(sseq->flag & SEQ_DRAWFRAMES), TH_TEXT); + UI_view2d_draw_scale_y__block(ar, v2d, &v2d->vert, TH_TEXT); + /* draw current frame number-indicator on top of scrollers */ if ((sseq->flag & SEQ_NO_DRAW_CFRANUM) == 0) { UI_view2d_view_orthoSpecial(ar, v2d, 1); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 4a6cfaae42f..0f5c02327cc 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -64,6 +64,8 @@ #include "UI_view2d.h" #include "UI_interface.h" +#include "DEG_depsgraph.h" + /* own include */ #include "sequencer_intern.h" @@ -2379,6 +2381,7 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op)) ms = ms->prev; } + DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -3891,7 +3894,7 @@ void SEQUENCER_OT_change_effect_type(struct wmOperatorType *ot) ot->prop = RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, - SEQ_TYPE_CROSS, + SEQ_TYPE_ALPHAOVER, "Type", "Sequencer effect type"); } diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 9244bbb3034..dd04260d80e 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -91,7 +91,7 @@ int seq_effect_find_selected(struct Scene *scene, /* operator helpers */ bool sequencer_edit_poll(struct bContext *C); /* UNUSED */ -//bool sequencer_strip_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); diff --git a/source/blender/editors/space_sequencer/sequencer_preview.c b/source/blender/editors/space_sequencer/sequencer_preview.c index 546c2a8a9f0..8a4e8c007f7 100644 --- a/source/blender/editors/space_sequencer/sequencer_preview.c +++ b/source/blender/editors/space_sequencer/sequencer_preview.c @@ -50,6 +50,7 @@ typedef struct PreviewJob { typedef struct PreviewJobAudio { struct PreviewJobAudio *next, *prev; + struct Main *bmain; bSound *sound; int lr; /* sample left or right */ int startframe; @@ -79,7 +80,9 @@ static void preview_startjob(void *data, short *stop, short *do_update, float *p PreviewJobAudio *preview_next; bSound *sound = previewjb->sound; + BKE_sound_load_audio(previewjb->bmain, sound); BKE_sound_read_waveform(sound, stop); + BKE_sound_free_audio(sound); if (*stop || G.is_break) { BLI_mutex_lock(pj->mutex); @@ -153,6 +156,7 @@ void sequencer_preview_add_sound(const bContext *C, Sequence *seq) /* attempt to lock mutex of job here */ + audiojob->bmain = CTX_data_main(C); audiojob->sound = seq->sound; BLI_mutex_lock(pj->mutex); diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 09cc4635254..f40514e7574 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -60,8 +60,8 @@ static void select_surrounding_handles(Scene *scene, Sequence *test) /* XXX BRIN neighbor = find_neighboring_sequence(scene, test, SEQ_SIDE_LEFT, -1); if (neighbor) { - /* Only select neighbor handle if matching handle from test seq is also selected, or if neighbor - * was not selected at all up till now. + /* Only select neighbor handle if matching handle from test seq is also selected, + * or if neighbor was not selected at all up till now. * Otherwise, we get odd mismatch when shift-alt-rmb selecting neighbor strips... */ if (!(neighbor->flag & SELECT) || (test->flag & SEQ_LEFTSEL)) { neighbor->flag |= SEQ_RIGHTSEL; @@ -318,6 +318,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); const bool extend = RNA_boolean_get(op->ptr, "extend"); + const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all"); const bool linked_handle = RNA_boolean_get(op->ptr, "linked_handle"); const bool linked_time = RNA_boolean_get(op->ptr, "linked_time"); int left_right = RNA_enum_get(op->ptr, "left_right"); @@ -330,7 +331,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e return OPERATOR_CANCELLED; } - marker = find_nearest_marker(SCE_MARKERS, 1); //XXX - dummy function for now + marker = find_nearest_marker(SCE_MARKERS, 1); // XXX - dummy function for now seq = find_nearest_seq(scene, v2d, &hand, event->mval); @@ -401,15 +402,13 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e } } else { - // seq = find_nearest_seq(scene, v2d, &hand, mval); - act_orig = ed->act_seq; - if (extend == 0 && linked_handle == 0) { - ED_sequencer_deselect_all(scene); - } - if (seq) { + if (!extend && !linked_handle) { + ED_sequencer_deselect_all(scene); + } + BKE_sequencer_active_set(scene, seq); if ((seq->type == SEQ_TYPE_IMAGE) || (seq->type == SEQ_TYPE_MOVIE)) { @@ -427,8 +426,8 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e if (linked_handle) { if (!ELEM(hand, SEQ_SIDE_LEFT, SEQ_SIDE_RIGHT)) { /* First click selects the strip and its adjacent handles (if valid). - * Second click selects the strip, both of its handles and its adjacent handles (if valid). - */ + * Second click selects the strip, + * both of its handles and its adjacent handles (if valid). */ const bool is_striponly_selected = ((seq->flag & SEQ_ALLSEL) == SELECT); if (!extend) { @@ -535,25 +534,10 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e select_linked_time(ed->seqbasep, seq); } } - } - - /* marker transform */ -#if 0 // XXX probably need to redo this differently for 2.5 - if (marker) { - int mval[2], xo, yo; - // getmouseco_areawin(mval); - xo = mval[0]; - yo = mval[1]; - - while (get_mbut()) { - // getmouseco_areawin(mval); - if (abs(mval[0] - xo) + abs(mval[1] - yo) > 4) { - transform_markers('g', 0); - return; - } + else if (deselect_all) { + ED_sequencer_deselect_all(scene); } } -#endif WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene); @@ -584,7 +568,14 @@ void SEQUENCER_OT_select(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ + PropertyRNA *prop; RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); + prop = RNA_def_boolean(ot->srna, + "deselect_all", + false, + "Deselect On Nothing", + "Deselect all when nothing under the cursor"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); RNA_def_boolean( ot->srna, "linked_handle", 0, "Linked Handle", "Select handles next to the active strip"); /* for animation this is an enum but atm having an enum isn't useful for us */ diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 30aca84f4e0..2b0c29a02ad 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -468,15 +468,15 @@ static void sequencer_main_region_init(wmWindowManager *wm, ARegion *ar) #if 0 keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); #endif keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); /* own keymap */ keymap = WM_keymap_ensure(wm->defaultconf, "Sequencer", SPACE_SEQ, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); /* add drop boxes */ lb = WM_dropboxmap_find("Sequencer", SPACE_SEQ, RGN_TYPE_WINDOW); @@ -614,15 +614,15 @@ static void sequencer_preview_region_init(wmWindowManager *wm, ARegion *ar) #if 0 keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); #endif keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); /* own keymap */ keymap = WM_keymap_ensure(wm->defaultconf, "SequencerPreview", SPACE_SEQ, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); } static void sequencer_preview_region_draw(const bContext *C, ARegion *ar) @@ -695,8 +695,6 @@ static void sequencer_preview_region_listener(wmWindow *UNUSED(win), case NC_ANIMATION: switch (wmn->data) { case ND_KEYFRAME: - /* Otherwise, often prevents seeing immediately effects of keyframe editing... */ - BKE_sequencer_cache_cleanup(); ED_region_tag_redraw(ar); break; } @@ -729,7 +727,7 @@ static void sequencer_buttons_region_init(wmWindowManager *wm, ARegion *ar) wmKeyMap *keymap; keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); ED_region_panels_init(wm, ar); } diff --git a/source/blender/editors/space_statusbar/CMakeLists.txt b/source/blender/editors/space_statusbar/CMakeLists.txt index 39957c6792c..ad4c060a1f6 100644 --- a/source/blender/editors/space_statusbar/CMakeLists.txt +++ b/source/blender/editors/space_statusbar/CMakeLists.txt @@ -25,8 +25,8 @@ set(INC ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/space_text/CMakeLists.txt b/source/blender/editors/space_text/CMakeLists.txt index f5db86ac4c2..740fc9948ef 100644 --- a/source/blender/editors/space_text/CMakeLists.txt +++ b/source/blender/editors/space_text/CMakeLists.txt @@ -25,8 +25,8 @@ set(INC ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 49d5ae06413..24f282ff920 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -273,9 +273,9 @@ static void text_main_region_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Text", SPACE_TEXT, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); /* add drop boxes */ lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW); @@ -287,7 +287,7 @@ static void text_main_region_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ SpaceText *st = CTX_wm_space_text(C); - //View2D *v2d = &ar->v2d; + // View2D *v2d = &ar->v2d; /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); @@ -394,7 +394,7 @@ static void text_properties_region_init(wmWindowManager *wm, ARegion *ar) /* own keymaps */ keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, 0); - WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); } static void text_properties_region_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c index 243642b2e8c..c36175489b3 100644 --- a/source/blender/editors/space_text/text_autocomplete.c +++ b/source/blender/editors/space_text/text_autocomplete.c @@ -74,7 +74,7 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar) /* Count the visible lines to the cursor */ for (tmp = st->text->curl, l = -st->top; tmp; tmp = tmp->prev, l++) { - ; + /* pass */ } if (l < 0) { return 0; @@ -101,7 +101,7 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar) /* Work out which of the items is at the top of the visible list */ for (i = 0, item = first; i < *top && item->next; i++, item = item->next) { - ; + /* pass */ } /* Work out the target item index in the visible list */ @@ -111,7 +111,7 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar) } for (i = tgti; i > 0 && item->next; i--, item = item->next) { - ; + /* pass */ } if (item) { texttool_suggest_select(item); diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index cdd691fe879..678879018a7 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1186,7 +1186,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc /* Set the top 'item' of the visible list */ for (i = 0, item = first; i < *top && item->next; i++, item = item->next) { - ; + /* pass */ } for (i = 0; i < SUGG_LIST_SIZE && item; i++, item = item->next) { diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 4d904822360..d0809ec33fc 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -61,6 +61,83 @@ static void txt_screen_clamp(SpaceText *st, ARegion *ar); +/************************ util ***************************/ + +/** + * Tests if the given character represents a start of a new line or the + * indentation part of a line. + * \param c: The current character. + * \param r_last_state: A pointer to a flag representing the last state. The + * flag may be modified. + */ +static void test_line_start(char c, bool *r_last_state) +{ + if (c == '\n') { + *r_last_state = true; + } + else if (!ELEM(c, '\t', ' ')) { + *r_last_state = false; + } +} + +/** + * This function converts the indentation tabs from a buffer to spaces. + * \param buf: A pointer to a cstring. + * \param tab_size: The size, in spaces, of the tab character. + */ +static char *buf_tabs_to_spaces(const char *in_buf, const int tab_size) +{ + /* Get the number of tab characters in buffer. */ + bool line_start = true; + int num_tabs = 0; + + for (int in_offset = 0; in_buf[in_offset]; in_offset++) { + /* Verify if is an indentation whitespace character. */ + test_line_start(in_buf[in_offset], &line_start); + + if (in_buf[in_offset] == '\t' && line_start) { + num_tabs++; + } + } + + /* Allocate output before with extra space for expanded tabs. */ + const int out_size = strlen(in_buf) + num_tabs * (tab_size - 1); + char *out_buf = MEM_mallocN(out_size * sizeof(char), __func__); + + /* Fill output buffer. */ + int spaces_until_tab = 0; + int out_offset = 0; + line_start = true; + + for (int in_offset = 0; in_buf[in_offset]; in_offset++) { + /* Verify if is an indentation whitespace character. */ + test_line_start(in_buf[in_offset], &line_start); + + if (in_buf[in_offset] == '\t' && line_start) { + /* Calculate tab size so it fills until next indentation. */ + int num_spaces = tab_size - (spaces_until_tab % tab_size); + spaces_until_tab = 0; + + /* Write to buffer. */ + memset(&out_buf[out_offset], ' ', num_spaces); + out_offset += num_spaces; + } + else { + if (in_buf[in_offset] == ' ') { + spaces_until_tab++; + } + else if (in_buf[in_offset] == '\n') { + spaces_until_tab = 0; + } + + out_buf[out_offset++] = in_buf[in_offset]; + } + } + + out_buf[out_offset] = '\0'; + return out_buf; +} + /************************ poll ***************************/ BLI_INLINE int text_pixel_x_to_column(SpaceText *st, const int x) @@ -308,7 +385,7 @@ void TEXT_OT_open(wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); //XXX TODO, relative_path + FILE_SORT_ALPHA); // XXX TODO, relative_path RNA_def_boolean( ot->srna, "internal", 0, "Make internal", "Make text file internal after loading"); } @@ -608,7 +685,7 @@ void TEXT_OT_save_as(wmOperatorType *ot) FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); //XXX TODO, relative_path + FILE_SORT_ALPHA); // XXX TODO, relative_path } /******************* run script operator *********************/ @@ -764,6 +841,14 @@ static int text_paste_exec(bContext *C, wmOperator *op) text_drawcache_tag_update(CTX_wm_space_text(C), 0); TextUndoBuf *utxt = ED_text_undo_push_init(C); + + /* Convert clipboard content indentation to spaces if specified */ + if (text->flags & TXT_TABSTOSPACES) { + char *new_buf = buf_tabs_to_spaces(buf, TXT_TABSIZE); + MEM_freeN(buf); + buf = new_buf; + } + txt_insert_buf(text, utxt, buf); text_update_edited(text); @@ -1183,7 +1268,7 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op) for (j = 1; (j < tab_len) && (a + j < text_check_line_len) && (text_check_line[a + j] == ' '); j++) { - ; + /* pass */ } if (j == tab_len) { diff --git a/source/blender/editors/space_topbar/CMakeLists.txt b/source/blender/editors/space_topbar/CMakeLists.txt index 71e61a07ff7..d56e1da334d 100644 --- a/source/blender/editors/space_topbar/CMakeLists.txt +++ b/source/blender/editors/space_topbar/CMakeLists.txt @@ -25,8 +25,8 @@ set(INC ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt index 1514f7a236b..dc375958eb4 100644 --- a/source/blender/editors/space_view3d/CMakeLists.txt +++ b/source/blender/editors/space_view3d/CMakeLists.txt @@ -28,10 +28,10 @@ set(INC ../../makesdna ../../makesrna ../../render/extern/include - ../../windowmanager ../../depsgraph - ../../../../intern/guardedalloc + ../../windowmanager ../../../../intern/glew-mx + ../../../../intern/guardedalloc ../../../../intern/smoke/extern ) diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 42dd3dec538..dbf2160d39b 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -303,6 +303,7 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) BLI_addtail(&v3d->regionbase, ar); ar->regiontype = RGN_TYPE_TOOL_HEADER; ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; + ar->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER; /* header */ ar = MEM_callocN(sizeof(ARegion), "header for view3d"); @@ -1510,6 +1511,7 @@ void ED_spacetype_view3d(void) art->prefsizex = 180; /* XXX */ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; art->listener = view3d_buttons_region_listener; + art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_ui; art->init = view3d_buttons_region_init; art->draw = view3d_buttons_region_draw; BLI_addhead(&st->regiontypes, art); @@ -1535,9 +1537,9 @@ void ED_spacetype_view3d(void) art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; art->listener = view3d_header_region_listener; + art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_header; art->init = view3d_header_region_init; art->draw = view3d_header_region_draw; - art->message_subscribe = view3d_header_region_message_subscribe; BLI_addhead(&st->regiontypes, art); /* regions: header */ @@ -1546,9 +1548,9 @@ void ED_spacetype_view3d(void) art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; art->listener = view3d_header_region_listener; + art->message_subscribe = view3d_header_region_message_subscribe; art->init = view3d_header_region_init; art->draw = view3d_header_region_draw; - art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_header; BLI_addhead(&st->regiontypes, art); /* regions: hud */ diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 52feff4b65a..3d3c73ad27c 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1066,7 +1066,7 @@ static void v3d_object_dimension_buts(bContext *C, uiLayout *layout, View3D *v3d 0, ""); UI_block_align_begin(block); - const float lim = 10000; + const float lim = FLT_MAX; for (int i = 0; i < 3; i++) { uiBut *but; char text[3] = {'X' + i, ':', '\0'}; @@ -1605,7 +1605,7 @@ void view3d_buttons_register(ARegionType *art) pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel object"); strcpy(pt->idname, "VIEW3D_PT_transform"); strcpy(pt->label, N_("Transform")); /* XXX C panels unavailable through RNA bpy.types! */ - strcpy(pt->category, "View"); + strcpy(pt->category, "Item"); strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); pt->draw = view3d_panel_transform; pt->poll = view3d_panel_transform_poll; @@ -1614,7 +1614,7 @@ void view3d_buttons_register(ARegionType *art) pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel vgroup"); strcpy(pt->idname, "VIEW3D_PT_vgroup"); strcpy(pt->label, N_("Vertex Weights")); /* XXX C panels unavailable through RNA bpy.types! */ - strcpy(pt->category, "View"); + strcpy(pt->category, "Item"); strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); pt->draw = view3d_panel_vgroup; pt->poll = view3d_panel_vgroup_poll; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 12ce793e3ef..8c5f1c16438 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -758,7 +758,6 @@ void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, bool a short flag = v3d->flag; float glalphaclip = U.glalphaclip; - int obcenter_dia = U.obcenter_dia; /* temp set drawtype to solid */ /* Setting these temporarily is not nice */ v3d->flag &= ~V3D_SELECT_OUTLINE; @@ -766,8 +765,6 @@ void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, bool a /* not that nice but means we wont zoom into billboards */ U.glalphaclip = alphaoverride ? 0.5f : glalphaclip; - U.obcenter_dia = 0; - /* Tools may request depth outside of regular drawing code. */ UI_Theme_Store(&theme_state); UI_SetTheme(SPACE_VIEW3D, RGN_TYPE_WINDOW); @@ -797,7 +794,6 @@ void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, bool a U.glalphaclip = glalphaclip; v3d->flag = flag; - U.obcenter_dia = obcenter_dia; UI_Theme_Restore(&theme_state); } @@ -1824,6 +1820,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph, */ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph, Scene *scene, + View3DShading *shading_override, int drawtype, Object *camera, int width, @@ -1846,22 +1843,25 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph, ar.regiontype = RGN_TYPE_WINDOW; v3d.camera = camera; + View3DShading *source_shading_settings = &scene->display.shading; + if (draw_flags & V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS && shading_override != NULL) { + source_shading_settings = shading_override; + } + memcpy(&v3d.shading, source_shading_settings, sizeof(View3DShading)); v3d.shading.type = drawtype; + + if (drawtype == OB_MATERIAL) { + v3d.shading.flag = V3D_SHADING_SCENE_WORLD | V3D_SHADING_SCENE_LIGHTS; + } + v3d.flag2 = V3D_HIDE_OVERLAYS; - if (draw_flags & V3D_OFSDRAW_USE_GPENCIL) { + if (draw_flags & V3D_OFSDRAW_SHOW_ANNOTATION) { v3d.flag2 |= V3D_SHOW_ANNOTATION; } v3d.shading.background_type = V3D_SHADING_BACKGROUND_WORLD; - if (draw_flags & V3D_OFSDRAW_USE_CAMERA_DOF) { - if (camera->type == OB_CAMERA) { - v3d.fx_settings.dof = &((Camera *)camera->data)->gpu_dof; - v3d.fx_settings.fx_flag |= GPU_FX_FLAG_DOF; - } - } - rv3d.persp = RV3D_CAMOB; copy_m4_m4(rv3d.viewinv, v3d.camera->obmat); diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index f029fd9bfc7..b0cee18f8e3 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -347,7 +347,7 @@ uint ED_view3d_select_id_read_nearest(struct ViewContext *UNUSED(vc), uint *r_dist) { /* Create region around mouse cursor. This must be square and have an odd - * width, the spiralling algorithm does not work with arbitrary rectangles. */ + * width, the spiraling algorithm does not work with arbitrary rectangles. */ rcti rect; BLI_rcti_init_pt_radius(&rect, mval, *r_dist); rect.xmax += 1; @@ -995,8 +995,8 @@ void ED_scene_draw_fps(Scene *scene, int xoffset, int *yoffset) if (tot) { fpsi->redrawtime_index = (fpsi->redrawtime_index + 1) % REDRAW_FRAME_AVERAGE; - //fpsi->redrawtime_index++; - //if (fpsi->redrawtime >= REDRAW_FRAME_AVERAGE) { + // fpsi->redrawtime_index++; + // if (fpsi->redrawtime >= REDRAW_FRAME_AVERAGE) { // fpsi->redrawtime = 0; //} diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c index f98a87e84a8..5af6fd8b04b 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c @@ -259,8 +259,7 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *g navgroup->state.rv3d.is_camera = (rv3d->persp == RV3D_CAMOB); navgroup->state.rv3d.viewlock = rv3d->viewlock; - const bool show_rotate = (((rv3d->viewlock & RV3D_LOCKED) == 0) && - (navgroup->state.rv3d.is_camera == false)); + const bool show_rotate = (rv3d->viewlock & RV3D_LOCKED) == 0; const bool show_fixed_offset = navgroup->state.rv3d.is_camera; const float icon_size = GIZMO_SIZE; const float icon_offset = (icon_size * 0.52f) * GIZMO_OFFSET_FAC * UI_DPI_FAC; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 443c7ab9368..2ce23486476 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1911,8 +1911,7 @@ static bool ed_object_select_pick(bContext *C, } } - basact->flag |= BASE_SELECTED; - BKE_scene_object_base_flag_sync_from_base(basact); + ED_object_base_select(basact, BA_SELECT); retval = true; @@ -1945,8 +1944,7 @@ static bool ed_object_select_pick(bContext *C, /* we make the armature selected: * not-selected active object in posemode won't work well for tools */ - basact->flag |= BASE_SELECTED; - BKE_scene_object_base_flag_sync_from_base(basact); + ED_object_base_select(basact, BA_SELECT); retval = true; WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, basact->object); @@ -2213,7 +2211,7 @@ static int view3d_select_exec(bContext *C, wmOperator *op) } } - /* passthrough allows tweaks + /* Pass-through allows tweaks * FINISHED to signal one operator worked * */ if (retval) { @@ -2251,9 +2249,6 @@ void VIEW3D_OT_select(wmOperatorType *ot) /* properties */ WM_operator_properties_mouse_select(ot); - prop = RNA_def_boolean( - ot->srna, "deselect_all", 0, "Deselect", "Deselect all when nothing under the cursor"); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); prop = RNA_def_boolean( ot->srna, diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 7ac8291a385..2454358b687 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -146,7 +146,7 @@ void ED_view3d_smooth_view_ex( } sms.org_view = rv3d->view; - /* sms.to_camera = false; */ /* initizlized to zero anyway */ + /* sms.to_camera = false; */ /* initialized to zero anyway */ /* note on camera locking, this is a little confusing but works ok. * we may be changing the view 'as if' there is no active camera, but in fact diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt index 05e0659637b..9696f0fb315 100644 --- a/source/blender/editors/transform/CMakeLists.txt +++ b/source/blender/editors/transform/CMakeLists.txt @@ -27,10 +27,10 @@ set(INC ../../makesdna ../../makesrna ../../render/extern/include - ../../windowmanager ../../depsgraph - ../../../../intern/guardedalloc + ../../windowmanager ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index c80a0eaa597..81405b55ac2 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -601,18 +601,18 @@ static void viewRedrawForce(const bContext *C, TransInfo *t) } } else if (t->spacetype == SPACE_ACTION) { - //SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; + // SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } else if (t->spacetype == SPACE_GRAPH) { - //SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first; + // SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first; WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } else if (t->spacetype == SPACE_NLA) { WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); } else if (t->spacetype == SPACE_NODE) { - //ED_area_tag_redraw(t->sa); + // ED_area_tag_redraw(t->sa); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); } else if (t->spacetype == SPACE_SEQ) { @@ -2101,20 +2101,16 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) } } - /* convert flag to enum */ - switch (t->flag & T_PROP_EDIT_ALL) { - case T_PROP_EDIT: - proportional = PROP_EDIT_ON; - break; - case (T_PROP_EDIT | T_PROP_CONNECTED): - proportional = PROP_EDIT_CONNECTED; - break; - case (T_PROP_EDIT | T_PROP_PROJECTED): - proportional = PROP_EDIT_PROJECTED; - break; - default: - proportional = PROP_EDIT_OFF; - break; + if (t->flag & T_PROP_EDIT_ALL) { + if (t->flag & T_PROP_EDIT) { + proportional |= PROP_EDIT_USE; + } + if (t->flag & T_PROP_CONNECTED) { + proportional |= PROP_EDIT_CONNECTED; + } + if (t->flag & T_PROP_PROJECTED) { + proportional |= PROP_EDIT_PROJECTED; + } } // If modal, save settings back in scene if not set as operator argument @@ -2123,7 +2119,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) /* skip saving proportional edit if it was not actually used */ if (!(t->options & CTX_NO_PET)) { - if ((prop = RNA_struct_find_property(op->ptr, "proportional")) && + if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit")) && !RNA_property_is_set(op->ptr, prop)) { if (t->spacetype == SPACE_GRAPH) { ts->proportional_fcurve = proportional; @@ -2132,13 +2128,13 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) ts->proportional_action = proportional; } else if (t->obedit_type != -1) { - ts->proportional = proportional; + ts->proportional_edit = proportional; } else if (t->options & CTX_MASK) { - ts->proportional_mask = (proportional != PROP_EDIT_OFF); + ts->proportional_mask = proportional != 0; } else { - ts->proportional_objects = (proportional != PROP_EDIT_OFF); + ts->proportional_objects = proportional != 0; } } @@ -2177,8 +2173,10 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) } } - if ((prop = RNA_struct_find_property(op->ptr, "proportional"))) { - RNA_property_enum_set(op->ptr, prop, proportional); + if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) { + RNA_property_boolean_set(op->ptr, prop, proportional & PROP_EDIT_USE); + RNA_boolean_set(op->ptr, "use_proportional_connected", proportional & PROP_EDIT_CONNECTED); + RNA_boolean_set(op->ptr, "use_proportional_projected", proportional & PROP_EDIT_PROJECTED); RNA_enum_set(op->ptr, "proportional_edit_falloff", t->prop_mode); RNA_float_set(op->ptr, "proportional_size", t->prop_size); } @@ -3293,7 +3291,7 @@ static void initBend(TransInfo *t) t->flag |= T_NO_CONSTRAINT; - //copy_v3_v3(t->center, ED_view3d_cursor3d_get(t->scene, t->view)); + // copy_v3_v3(t->center, ED_view3d_cursor3d_get(t->scene, t->view)); if ((t->flag & T_OVERRIDE_CENTER) == 0) { calculateCenterCursor(t, t->center_global); } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index e4f2adff77d..6c1da5ae825 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -500,7 +500,7 @@ static void createTransEdge(TransInfo *t) BM_mesh_cd_flag_ensure(em->bm, BKE_mesh_from_object(tc->obedit), ME_CDFLAG_EDGE_BWEIGHT); cd_edge_float_offset = CustomData_get_offset(&em->bm->edata, CD_BWEIGHT); } - else { //if (t->mode == TFM_CREASE) { + else { // if (t->mode == TFM_CREASE) { BLI_assert(t->mode == TFM_CREASE); BM_mesh_cd_flag_ensure(em->bm, BKE_mesh_from_object(tc->obedit), ME_CDFLAG_EDGE_CREASE); cd_edge_float_offset = CustomData_get_offset(&em->bm->edata, CD_CREASE); @@ -611,38 +611,19 @@ static short apply_targetless_ik(Object *ob) /* apply and decompose, doesn't work for constraints or non-uniform scale well */ { float rmat3[3][3], qrmat[3][3], imat3[3][3], smat[3][3]; - copy_m3_m4(rmat3, rmat); /* rotation */ /* [#22409] is partially caused by this, as slight numeric error introduced during * the solving process leads to locked-axis values changing. However, we cannot modify * the values here, or else there are huge discrepancies between IK-solver (interactive) - * and applied poses. - */ - if (parchan->rotmode > 0) { - mat3_to_eulO(parchan->eul, parchan->rotmode, rmat3); - } - else if (parchan->rotmode == ROT_MODE_AXISANGLE) { - mat3_to_axis_angle(parchan->rotAxis, &parchan->rotAngle, rmat3); - } - else { - mat3_to_quat(parchan->quat, rmat3); - } + * and applied poses. */ + BKE_pchan_mat3_to_rot(parchan, rmat3, false); /* for size, remove rotation */ /* causes problems with some constraints (so apply only if needed) */ if (data->flag & CONSTRAINT_IK_STRETCH) { - if (parchan->rotmode > 0) { - eulO_to_mat3(qrmat, parchan->eul, parchan->rotmode); - } - else if (parchan->rotmode == ROT_MODE_AXISANGLE) { - axis_angle_to_mat3(qrmat, parchan->rotAxis, parchan->rotAngle); - } - else { - quat_to_mat3(qrmat, parchan->quat); - } - + BKE_pchan_rot_to_mat3(parchan, qrmat); invert_m3_m3(imat3, qrmat); mul_m3_m3m3(smat, rmat3, imat3); mat3_to_size(parchan->size, smat); @@ -1325,10 +1306,18 @@ static void createTransPose(TransInfo *t) void restoreBones(TransDataContainer *tc) { - bArmature *arm = tc->obedit->data; + bArmature *arm; BoneInitData *bid = tc->custom.type.data; EditBone *ebo; + if (tc->obedit) { + arm = tc->obedit->data; + } + else { + BLI_assert(tc->poseobj != NULL); + arm = tc->poseobj->data; + } + while (bid->bone) { ebo = bid->bone; @@ -2764,9 +2753,9 @@ static void VertsToTransData(TransInfo *t, BLI_assert(BM_elem_flag_test(eve, BM_ELEM_HIDDEN) == 0); td->flag = 0; - //if (key) + // if (key) // td->loc = key->co; - //else + // else td->loc = eve->co; copy_v3_v3(td->iloc, td->loc); @@ -3052,7 +3041,7 @@ static void createTransEditVerts(TransInfo *t) /* Mirror? */ if ((mirror > 0 && tob->iloc[0] > 0.0f) || (mirror < 0 && tob->iloc[0] < 0.0f)) { - BMVert *vmir = EDBM_verts_mirror_get(em, eve); //t->obedit, em, eve, tob->iloc, a); + BMVert *vmir = EDBM_verts_mirror_get(em, eve); // t->obedit, em, eve, tob->iloc, a); if (vmir && vmir != eve) { tob->extra = vmir; } @@ -6471,7 +6460,7 @@ static void clear_trans_object_base_flags(TransInfo *t) for (base = view_layer->object_bases.first; base; base = base->next) { if (base->flag_legacy & BA_WAS_SEL) { - base->flag |= BASE_SELECTED; + ED_object_base_select(base, BA_SELECT); } base->flag_legacy &= ~(BA_WAS_SEL | BA_SNAP_FIX_DEPS_FIASCO | BA_TEMP_TAG | @@ -6851,7 +6840,7 @@ static void special_aftertrans_update__mask(bContext *C, TransInfo *t) if (t->scene->nodetree) { /* tracks can be used for stabilization nodes, * flush update for such nodes */ - //if (nodeUpdateID(t->scene->nodetree, &mask->id)) + // if (nodeUpdateID(t->scene->nodetree, &mask->id)) { WM_event_add_notifier(C, NC_MASK | ND_DATA, &mask->id); } @@ -7740,7 +7729,7 @@ static void markerToTransDataInit(TransData *td, td->loc = td2d->loc; copy_v3_v3(td->iloc, td->loc); - //copy_v3_v3(td->center, td->loc); + // copy_v3_v3(td->center, td->loc); td->flag |= TD_INDIVIDUAL_SCALE; td->center[0] = marker->pos[0] * aspect[0]; td->center[1] = marker->pos[1] * aspect[1]; @@ -9334,7 +9323,7 @@ void createTransData(bContext *C, TransInfo *t) if (t->data_len_all && (t->flag & T_PROP_EDIT)) { sort_trans_data(t); // makes selected become first in array /* don't do that, distance has been set in createTransActionData already */ - //set_prop_dist(t, false); + // set_prop_dist(t, false); sort_trans_data_dist(t); } } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index e816f4b31ff..a840c04ab5a 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -968,6 +968,23 @@ static void recalcData_objects(TransInfo *t) } } } + else if (t->flag & T_POSE && (t->mode == TFM_BONESIZE)) { + /* Handle the exception where for TFM_BONESIZE in edit mode we pretend to be + * in pose mode (to use bone orientation matrix), + * in that case we have to do mirroring as well. */ + FOREACH_TRANS_DATA_CONTAINER (t, tc) { + Object *ob = tc->poseobj; + bArmature *arm = ob->data; + if (arm->flag & ARM_MIRROR_EDIT) { + if (t->state != TRANS_CANCEL) { + ED_armature_edit_transform_mirror_update(ob); + } + else { + restoreBones(tc); + } + } + } + } else if (t->flag & T_POSE) { GSet *motionpath_updates = BLI_gset_ptr_new("motionpath updates"); @@ -1094,18 +1111,17 @@ static void recalcData_sequencer(TransInfo *t) if (seq != seq_prev) { if (BKE_sequence_tx_fullupdate_test(seq)) { - /* A few effect strip types need a complete recache on transform. */ BKE_sequence_invalidate_cache(t->scene, seq); } else { - BKE_sequence_invalidate_dependent(t->scene, seq); + BKE_sequence_invalidate_cache(t->scene, seq); } } seq_prev = seq; } - BKE_sequencer_preprocessed_cache_cleanup(); + DEG_id_tag_update(&t->scene->id, ID_RECALC_SEQUENCER); flushTransSeq(t); } @@ -1225,16 +1241,17 @@ void resetTransRestrictions(TransInfo *t) static int initTransInfo_edit_pet_to_flag(const int proportional) { - switch (proportional) { - case PROP_EDIT_ON: - return T_PROP_EDIT; - case PROP_EDIT_CONNECTED: - return T_PROP_EDIT | T_PROP_CONNECTED; - case PROP_EDIT_PROJECTED: - return T_PROP_EDIT | T_PROP_PROJECTED; - default: - return 0; + int flag = 0; + if (proportional & PROP_EDIT_USE) { + flag |= T_PROP_EDIT; + } + if (proportional & PROP_EDIT_CONNECTED) { + flag |= T_PROP_CONNECTED; + } + if (proportional & PROP_EDIT_PROJECTED) { + flag |= T_PROP_PROJECTED; } + return flag; } void initTransDataContainers_FromObjectData(TransInfo *t, @@ -1637,9 +1654,19 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } /* setting PET flag only if property exist in operator. Otherwise, assume it's not supported */ - if (op && (prop = RNA_struct_find_property(op->ptr, "proportional"))) { + if (op && (prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) { if (RNA_property_is_set(op->ptr, prop)) { - t->flag |= initTransInfo_edit_pet_to_flag(RNA_property_enum_get(op->ptr, prop)); + int proportional = 0; + if (RNA_property_boolean_get(op->ptr, prop)) { + proportional |= PROP_EDIT_USE; + if (RNA_boolean_get(op->ptr, "use_proportional_connected")) { + proportional |= PROP_EDIT_CONNECTED; + } + if (RNA_boolean_get(op->ptr, "use_proportional_projected")) { + proportional |= PROP_EDIT_PROJECTED; + } + } + t->flag |= initTransInfo_edit_pet_to_flag(proportional); } else { /* use settings from scene only if modal */ @@ -1652,16 +1679,16 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional_action); } else if (t->obedit_type != -1) { - t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional); + t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional_edit); } else if (t->options & CTX_GPENCIL_STROKES) { - t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional); + t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional_edit); } else if (t->options & CTX_MASK) { if (ts->proportional_mask) { t->flag |= T_PROP_EDIT; - if (ts->proportional == PROP_EDIT_CONNECTED) { + if (ts->proportional_edit & PROP_EDIT_CONNECTED) { t->flag |= T_PROP_CONNECTED; } } diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index b4c539fba8e..8606cd19c96 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -547,10 +547,9 @@ static bool transform_poll_property(const bContext *UNUSED(C), /* Proportional Editing. */ { - PropertyRNA *prop_pet = RNA_struct_find_property(op->ptr, "proportional"); - if (prop_pet && (prop_pet != prop) && - (RNA_property_enum_get(op->ptr, prop_pet) == PROP_EDIT_OFF)) { - if (STRPREFIX(prop_id, "proportional")) { + PropertyRNA *prop_pet = RNA_struct_find_property(op->ptr, "use_proportional_edit"); + if (prop_pet && (prop_pet != prop) && (RNA_property_boolean_get(op->ptr, prop_pet) == false)) { + if (STRPREFIX(prop_id, "proportional") || STRPREFIX(prop_id, "use_proportional")) { return false; } } @@ -610,12 +609,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) } if (flags & P_PROPORTIONAL) { - RNA_def_enum(ot->srna, - "proportional", - rna_enum_proportional_editing_items, - 0, - "Proportional Editing", - ""); + RNA_def_boolean(ot->srna, "use_proportional_edit", 0, "Proportional Editing", ""); prop = RNA_def_enum(ot->srna, "proportional_edit_falloff", rna_enum_proportional_falloff_items, @@ -633,6 +627,9 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) "", 0.001f, 100.0f); + + RNA_def_boolean(ot->srna, "use_proportional_connected", 0, "Connected", ""); + RNA_def_boolean(ot->srna, "use_proportional_projected", 0, "Projected (2D)", ""); } if (flags & P_SNAP) { @@ -977,7 +974,7 @@ static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot) { /* identifiers */ ot->name = "To Sphere"; - //added "around mesh center" to differentiate between "MESH_OT_vertices_to_sphere()" + // added "around mesh center" to differentiate between "MESH_OT_vertices_to_sphere()" ot->description = "Move selected vertices outward in a spherical shape around mesh center"; ot->idname = OP_TOSPHERE; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; @@ -1163,7 +1160,7 @@ static void TRANSFORM_OT_seq_slide(struct wmOperatorType *ot) static void TRANSFORM_OT_rotate_normal(struct wmOperatorType *ot) { /* identifiers */ - ot->name = "Normal Rotate"; + ot->name = "Rotate Normals"; ot->description = "Rotate split normal of selected items"; ot->idname = OP_NORMAL_ROTATION; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index e8bd8e905c9..58a50da9846 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -360,7 +360,7 @@ void applyProject(TransInfo *t) } } - //XXX constraintTransLim(t, td); + // XXX constraintTransLim(t, td); } } } @@ -1563,24 +1563,11 @@ static void applyGridIncrement( /* custom aspect for fcurve */ if (t->spacetype == SPACE_GRAPH) { View2D *v2d = &t->ar->v2d; - View2DGrid *grid; + Scene *scene = t->scene; SpaceGraph *sipo = t->sa->spacedata.first; - int unity = V2D_UNIT_VALUES; - int unitx = (sipo->flag & SIPO_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMESCALE; - - /* grid */ - grid = UI_view2d_grid_calc(t->scene, - v2d, - unitx, - V2D_GRID_NOCLAMP, - unity, - V2D_GRID_NOCLAMP, - t->ar->winx, - t->ar->winy); - - UI_view2d_grid_size(grid, &asp_local[0], &asp_local[1]); - UI_view2d_grid_free(grid); - + asp_local[0] = UI_view2d_grid_resolution_x__frames_or_seconds( + v2d, scene, sipo->flag & SIPO_DRAWTIME); + asp_local[1] = UI_view2d_grid_resolution_y__values(v2d); asp = asp_local; } } diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 9174f6950ae..829365367ee 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -953,7 +953,7 @@ static void cb_mlooptri_edges_get(const int index, int v_index[3], const BVHTree const MEdge *ed = &medge[mloop[lt->tri[j]].e]; unsigned int tri_edge[2] = {mloop[lt->tri[j]].v, mloop[lt->tri[j_next]].v}; if (ELEM(ed->v1, tri_edge[0], tri_edge[1]) && ELEM(ed->v2, tri_edge[0], tri_edge[1])) { - //printf("real edge found\n"); + // printf("real edge found\n"); v_index[j] = mloop[lt->tri[j]].e; } else { diff --git a/source/blender/editors/undo/CMakeLists.txt b/source/blender/editors/undo/CMakeLists.txt index 7c1a074bb13..0f4152c9128 100644 --- a/source/blender/editors/undo/CMakeLists.txt +++ b/source/blender/editors/undo/CMakeLists.txt @@ -24,8 +24,8 @@ set(INC ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/clog + ../../../../intern/guardedalloc ) set(SRC diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index a1893d8e6f1..3b49784d5eb 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -22,14 +22,14 @@ set(INC ../../blentranslation ../../bmesh ../../depsgraph - ../../imbuf ../../gpu + ../../imbuf ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/clog ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 867271229e2..df1906ea8a8 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -330,7 +330,7 @@ void unpack_menu(bContext *C, break; case PF_EQUAL: BLI_snprintf(line, sizeof(line), IFACE_("Use %s (identical)"), local_name); - //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL); + // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); @@ -338,13 +338,13 @@ void unpack_menu(bContext *C, break; case PF_DIFFERS: BLI_snprintf(line, sizeof(line), IFACE_("Use %s (differs)"), local_name); - //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL); + // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); BLI_snprintf(line, sizeof(line), IFACE_("Overwrite %s"), local_name); - //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_LOCAL); + // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_LOCAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); @@ -356,27 +356,27 @@ void unpack_menu(bContext *C, switch (checkPackedFile(BKE_main_blendfile_path(bmain), abs_name, pf)) { case PF_NOFILE: BLI_snprintf(line, sizeof(line), IFACE_("Create %s"), abs_name); - //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL); + // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_EQUAL: BLI_snprintf(line, sizeof(line), IFACE_("Use %s (identical)"), abs_name); - //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL); + // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_DIFFERS: BLI_snprintf(line, sizeof(line), IFACE_("Use %s (differs)"), abs_name); - //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL); + // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); BLI_snprintf(line, sizeof(line), IFACE_("Overwrite %s"), abs_name); - //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL); + // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr); RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); diff --git a/source/blender/editors/uvedit/CMakeLists.txt b/source/blender/editors/uvedit/CMakeLists.txt index 240cfd382a4..d2ba9ab9591 100644 --- a/source/blender/editors/uvedit/CMakeLists.txt +++ b/source/blender/editors/uvedit/CMakeLists.txt @@ -26,9 +26,9 @@ set(INC ../../makesdna ../../makesrna ../../windowmanager - ../../../../intern/guardedalloc ../../../../intern/eigen ../../../../intern/glew-mx + ../../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c index 3983cce6769..1482fea456d 100644 --- a/source/blender/editors/uvedit/uvedit_buttons.c +++ b/source/blender/editors/uvedit/uvedit_buttons.c @@ -258,6 +258,8 @@ void ED_uvedit_buttons_register(ARegionType *art) pt = MEM_callocN(sizeof(PanelType), "spacetype image panel uv"); strcpy(pt->idname, "IMAGE_PT_uv"); strcpy(pt->label, N_("UV Vertex")); /* XXX C panels unavailable through RNA bpy.types! */ + /* Could be 'Item' matching 3D view, avoid new tab for two buttons. */ + strcpy(pt->category, "Image"); pt->draw = image_panel_uv; 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 4fb2c6441a3..804b9c22104 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -479,14 +479,12 @@ static void draw_uv_shadows_get( } void ED_uvedit_draw_main(SpaceImage *sima, - ARegion *ar, Scene *scene, ViewLayer *view_layer, Object *obedit, Object *obact, Depsgraph *depsgraph) { - ToolSettings *toolsettings = scene->toolsettings; bool show_uvedit, show_uvshadow, show_texpaint_uvshadow; show_uvedit = ED_space_image_show_uvedit(sima, obedit); @@ -509,9 +507,5 @@ void ED_uvedit_draw_main(SpaceImage *sima, else { draw_uvs_texpaint(scene, obact, depsgraph); } - - if (show_uvedit && !(toolsettings->use_uv_sculpt)) { - 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 16a4b647cfe..30ded60bd84 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -128,15 +128,6 @@ bool ED_uvedit_test(Object *obedit) return ret; } -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); - Object *obedit = CTX_data_edit_object(C); - - return ED_space_image_show_uvedit(sima, obedit) && !(toolsettings->use_uv_sculpt); -} - static int UNUSED_FUNCTION(ED_operator_uvmap_mesh)(bContext *C) { Object *ob = CTX_data_active_object(C); @@ -2212,7 +2203,7 @@ static int uv_remove_doubles_exec(bContext *C, wmOperator *op) static void UV_OT_remove_doubles(wmOperatorType *ot) { /* identifiers */ - ot->name = "Remove Doubles UV"; + ot->name = "Merge UVs by Distance"; ot->description = "Selected UV vertices that are within a radius of each other are welded together"; ot->idname = "UV_OT_remove_doubles"; @@ -2457,8 +2448,13 @@ static bool uv_sticky_select( return false; } -static int uv_mouse_select_multi( - bContext *C, Object **objects, uint objects_len, const float co[2], bool extend, bool loop) +static int uv_mouse_select_multi(bContext *C, + Object **objects, + uint objects_len, + const float co[2], + const bool extend, + const bool deselect_all, + const bool loop) { Depsgraph *depsgraph = CTX_data_depsgraph(C); SpaceImage *sima = CTX_wm_space_image(C); @@ -2472,6 +2468,7 @@ static int uv_mouse_select_multi( UvNearestHit hit = UV_NEAREST_HIT_INIT; int i, selectmode, sticky, sync, *hitv = NULL; bool select = true; + bool found_item = false; /* 0 == don't flush, 1 == sel, -1 == desel; only use when selection sync is enabled */ int flush = 0; int hitlen = 0; @@ -2516,79 +2513,86 @@ static int uv_mouse_select_multi( /* find nearest element */ if (loop) { /* find edge */ - if (!uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit)) { - return OPERATOR_CANCELLED; - } - - hitlen = 0; + found_item = uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit); } else if (selectmode == UV_SELECT_VERTEX) { /* find vertex */ - if (!uv_find_nearest_vert_multi(scene, ima, objects, objects_len, co, penalty_dist, &hit)) { - return OPERATOR_CANCELLED; - } + found_item = uv_find_nearest_vert_multi( + scene, ima, objects, objects_len, co, penalty_dist, &hit); + found_item = found_item && (!deselect_all || hit.dist_sq < penalty_dist); - /* mark 1 vertex as being hit */ - hitv = BLI_array_alloca(hitv, hit.efa->len); - hituv = BLI_array_alloca(hituv, hit.efa->len); - copy_vn_i(hitv, hit.efa->len, 0xFFFFFFFF); + if (found_item) { + /* mark 1 vertex as being hit */ + hitv = BLI_array_alloca(hitv, hit.efa->len); + hituv = BLI_array_alloca(hituv, hit.efa->len); + copy_vn_i(hitv, hit.efa->len, 0xFFFFFFFF); - hitv[hit.lindex] = BM_elem_index_get(hit.l->v); - hituv[hit.lindex] = hit.luv->uv; + hitv[hit.lindex] = BM_elem_index_get(hit.l->v); + hituv[hit.lindex] = hit.luv->uv; - hitlen = hit.efa->len; + hitlen = hit.efa->len; + } } else if (selectmode == UV_SELECT_EDGE) { /* find edge */ - if (!uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit)) { - return OPERATOR_CANCELLED; - } + found_item = uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit); + found_item = found_item && (!deselect_all || hit.dist_sq < penalty_dist); - /* mark 2 edge vertices as being hit */ - hitv = BLI_array_alloca(hitv, hit.efa->len); - hituv = BLI_array_alloca(hituv, hit.efa->len); - copy_vn_i(hitv, hit.efa->len, 0xFFFFFFFF); + if (found_item) { + /* mark 2 edge vertices as being hit */ + hitv = BLI_array_alloca(hitv, hit.efa->len); + hituv = BLI_array_alloca(hituv, hit.efa->len); + copy_vn_i(hitv, hit.efa->len, 0xFFFFFFFF); - hitv[hit.lindex] = BM_elem_index_get(hit.l->v); - hitv[(hit.lindex + 1) % hit.efa->len] = BM_elem_index_get(hit.l->next->v); - hituv[hit.lindex] = hit.luv->uv; - hituv[(hit.lindex + 1) % hit.efa->len] = hit.luv_next->uv; + hitv[hit.lindex] = BM_elem_index_get(hit.l->v); + hitv[(hit.lindex + 1) % hit.efa->len] = BM_elem_index_get(hit.l->next->v); + hituv[hit.lindex] = hit.luv->uv; + hituv[(hit.lindex + 1) % hit.efa->len] = hit.luv_next->uv; - hitlen = hit.efa->len; + hitlen = hit.efa->len; + } } else if (selectmode == UV_SELECT_FACE) { /* find face */ - if (!uv_find_nearest_face_multi(scene, ima, objects, objects_len, co, &hit)) { - return OPERATOR_CANCELLED; - } + found_item = uv_find_nearest_face_multi(scene, ima, objects, objects_len, co, &hit); + found_item = found_item && (!deselect_all || hit.dist_sq < penalty_dist); - BMEditMesh *em = BKE_editmesh_from_object(hit.ob); - const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); + if (found_item) { + BMEditMesh *em = BKE_editmesh_from_object(hit.ob); + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - /* make active */ - BM_mesh_active_face_set(em->bm, hit.efa); + /* make active */ + BM_mesh_active_face_set(em->bm, hit.efa); - /* mark all face vertices as being hit */ + /* mark all face vertices as being hit */ - hitv = BLI_array_alloca(hitv, hit.efa->len); - hituv = BLI_array_alloca(hituv, hit.efa->len); - BM_ITER_ELEM_INDEX (l, &liter, hit.efa, BM_LOOPS_OF_FACE, i) { - luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - hituv[i] = luv->uv; - hitv[i] = BM_elem_index_get(l->v); - } + hitv = BLI_array_alloca(hitv, hit.efa->len); + hituv = BLI_array_alloca(hituv, hit.efa->len); + BM_ITER_ELEM_INDEX (l, &liter, hit.efa, BM_LOOPS_OF_FACE, i) { + luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + hituv[i] = luv->uv; + hitv[i] = BM_elem_index_get(l->v); + } - hitlen = hit.efa->len; + hitlen = hit.efa->len; + } } else if (selectmode == UV_SELECT_ISLAND) { - if (!uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit)) { - return OPERATOR_CANCELLED; - } - - hitlen = 0; + found_item = uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit); + found_item = found_item && (!deselect_all || hit.dist_sq < penalty_dist); } - else { - hitlen = 0; + + if (!found_item) { + if (deselect_all) { + uv_select_all_perform_multi(scene, ima, objects, objects_len, SEL_DESELECT); + + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + uv_select_tag_update_for_object(depsgraph, ts, obedit); + } + + return OPERATOR_PASS_THROUGH | OPERATOR_FINISHED; + } return OPERATOR_CANCELLED; } @@ -2742,13 +2746,14 @@ static int uv_mouse_select_multi( return OPERATOR_PASS_THROUGH | OPERATOR_FINISHED; } -static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loop) +static int uv_mouse_select( + bContext *C, const float co[2], const bool extend, const bool deselect_all, const bool loop) { ViewLayer *view_layer = CTX_data_view_layer(C); uint objects_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs( view_layer, ((View3D *)NULL), &objects_len); - int ret = uv_mouse_select_multi(C, objects, objects_len, co, extend, loop); + int ret = uv_mouse_select_multi(C, objects, objects_len, co, extend, deselect_all, loop); MEM_freeN(objects); return ret; } @@ -2756,13 +2761,13 @@ static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loo static int uv_select_exec(bContext *C, wmOperator *op) { float co[2]; - bool extend, loop; RNA_float_get_array(op->ptr, "location", co); - extend = RNA_boolean_get(op->ptr, "extend"); - loop = false; + const bool extend = RNA_boolean_get(op->ptr, "extend"); + const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all"); + const bool loop = false; - return uv_mouse_select(C, co, extend, loop); + return uv_mouse_select(C, co, extend, deselect_all, loop); } static int uv_select_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -2790,11 +2795,19 @@ static void UV_OT_select(wmOperatorType *ot) ot->poll = ED_operator_uvedit; /* requires space image */ /* properties */ + PropertyRNA *prop; RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection rather than clearing the existing selection"); + prop = RNA_def_boolean(ot->srna, + "deselect_all", + false, + "Deselect On Nothing", + "Deselect all when nothing under the cursor"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + RNA_def_float_vector( ot->srna, "location", @@ -2817,13 +2830,13 @@ static void UV_OT_select(wmOperatorType *ot) static int uv_select_loop_exec(bContext *C, wmOperator *op) { float co[2]; - bool extend, loop; RNA_float_get_array(op->ptr, "location", co); - extend = RNA_boolean_get(op->ptr, "extend"); - loop = true; + const bool extend = RNA_boolean_get(op->ptr, "extend"); + const bool deselect_all = false; + const bool loop = true; - return uv_mouse_select(C, co, extend, loop); + return uv_mouse_select(C, co, extend, deselect_all, loop); } static int uv_select_loop_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -2875,7 +2888,7 @@ static void UV_OT_select_loop(wmOperatorType *ot) /** \name Select Linked Operator * \{ */ -static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent *event, int pick) +static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent *event, bool pick) { SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); @@ -2962,7 +2975,7 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent static int uv_select_linked_exec(bContext *C, wmOperator *op) { - return uv_select_linked_internal(C, op, NULL, 0); + return uv_select_linked_internal(C, op, NULL, false); } static void UV_OT_select_linked(wmOperatorType *ot) @@ -2976,6 +2989,9 @@ static void UV_OT_select_linked(wmOperatorType *ot) /* api callbacks */ ot->exec = uv_select_linked_exec; ot->poll = ED_operator_uvedit; /* requires space image */ + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /** \} */ @@ -2986,12 +3002,12 @@ static void UV_OT_select_linked(wmOperatorType *ot) static int uv_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - return uv_select_linked_internal(C, op, event, 1); + return uv_select_linked_internal(C, op, event, true); } static int uv_select_linked_pick_exec(bContext *C, wmOperator *op) { - return uv_select_linked_internal(C, op, NULL, 1); + return uv_select_linked_internal(C, op, NULL, true); } static void UV_OT_select_linked_pick(wmOperatorType *ot) @@ -3000,7 +3016,9 @@ static void UV_OT_select_linked_pick(wmOperatorType *ot) ot->name = "Select Linked Pick"; ot->description = "Select all UV vertices linked under the mouse"; ot->idname = "UV_OT_select_linked_pick"; - ot->flag = OPTYPE_UNDO; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ ot->invoke = uv_select_linked_pick_invoke; @@ -4986,7 +5004,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf) wmKeyMap *keymap; keymap = WM_keymap_ensure(keyconf, "UV Editor", 0, 0); - keymap->poll = ED_operator_uvedit_can_uv_sculpt; + keymap->poll = ED_operator_uvedit; } /** \} */ |