Fix #126728: Movie Clip Editor "Sync Visible Range" option not working

True for both `Graph` and `Dopesheet` views in the MCE.

For all other time-based editors, the main region (`RGN_TYPE_WINDOW`) is
of interest to be tagged for syncing `V2D_VIEWSYNC_SCREEN_TIME`. In the
case of the Movie Clip Editor however, the `Graph` and `Dopesheet`
regions in question are of type `RGN_TYPE_PREVIEW`.

So to resolve, we have to take this into account in view2d_sync RNA code

NOTE: this PR does not add versioning code, so any "falsely" tagged
`Graph` and `Dopesheet` view will "loose" the setting (will have to be
enabled again on the "right" region), this could be added though -- it
would be impossible to tell **which**  view exactly, so on each
`RGN_TYPE_WINDOW` encountered, we'd have to then tag **both** `Graph`
and `Dopesheet` afaict

Pull Request: https://projects.blender.org/blender/blender/pulls/126785
This commit is contained in:
Philipp Oeser
2024-08-27 16:54:32 +02:00
parent 87d2a5b679
commit 9dd1315cc0
3 changed files with 36 additions and 4 deletions
@@ -31,7 +31,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 66
#define BLENDER_FILE_SUBVERSION 67
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and cancel loading the file, showing a warning to
@@ -62,6 +62,7 @@
#include "BKE_nla.h"
#include "BKE_node_runtime.hh"
#include "BKE_scene.hh"
#include "BKE_screen.hh"
#include "BKE_tracking.h"
#include "IMB_imbuf_enums.h"
@@ -4329,6 +4330,22 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
fix_built_in_curve_attribute_defaults(bmain);
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 67)) {
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_CLIP) {
ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
if (region != nullptr) {
View2D *v2d = &region->v2d;
v2d->flag &= ~V2D_VIEWSYNC_SCREEN_TIME;
}
}
}
}
}
}
/**
* Always bump subversion in BKE_blender_version.h when adding versioning
* code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.
+18 -3
View File
@@ -877,7 +877,12 @@ static bool rna_Space_view2d_sync_get(PointerRNA *ptr)
ARegion *region;
area = rna_area_from_space(ptr); /* can be nullptr */
region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
if (area->spacetype == SPACE_CLIP) {
region = BKE_area_find_region_type(area, RGN_TYPE_PREVIEW);
}
else {
region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
}
if (region) {
View2D *v2d = &region->v2d;
return (v2d->flag & V2D_VIEWSYNC_SCREEN_TIME) != 0;
@@ -900,7 +905,12 @@ static void rna_Space_view2d_sync_set(PointerRNA *ptr, bool value)
return;
}
region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
if (area->spacetype == SPACE_CLIP) {
region = BKE_area_find_region_type(area, RGN_TYPE_PREVIEW);
}
else {
region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
}
if (region) {
View2D *v2d = &region->v2d;
if (value) {
@@ -918,7 +928,12 @@ static void rna_Space_view2d_sync_update(Main * /*bmain*/, Scene * /*scene*/, Po
ARegion *region;
area = rna_area_from_space(ptr); /* can be nullptr */
region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
if (area->spacetype == SPACE_CLIP) {
region = BKE_area_find_region_type(area, RGN_TYPE_PREVIEW);
}
else {
region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
}
if (region) {
bScreen *screen = (bScreen *)ptr->owner_id;