Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2008-12-22 03:11:33 +0300
committerJoshua Leung <aligorith@gmail.com>2008-12-22 03:11:33 +0300
commit1c3e358fd89e8874358e8df7a6a0b43b9f6725b4 (patch)
treebe8dd9a1718e17bb3d8f164460a432ee36656983 /source
parent48a93c3ea6dcc55ec8a5a4f252c4334910c589a3 (diff)
View2D - View alignment flags are now taken into account in curRect_Validate()
Alignment flags are now checked for after keeptot settings, as these flags are of even greater importance. This is necessary for the syncing of the channels region and timeline areas in Action Editor (and later NLA Editor).
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/view2d.c49
-rw-r--r--source/blender/editors/space_action/space_action.c4
2 files changed, 48 insertions, 5 deletions
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 447286336bf..d644a74e04b 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -235,6 +235,7 @@ void UI_view2d_curRect_validate(View2D *v2d)
tot= &v2d->tot;
/* we must satisfy the following constraints (in decreasing order of importance):
+ * - alignment restrictions are respected
* - cur must not fall outside of tot
* - axis locks (zoom and offset) must be maintained
* - zoom must not be excessive (check either sizes or zoom values)
@@ -353,11 +354,11 @@ void UI_view2d_curRect_validate(View2D *v2d)
v2d->oldwiny= winy;
}
- /* Step 2: apply new sizes of cur rect to cur rect */
+ /* Step 2: apply new sizes to cur rect, but need to take into account alignment settings here... */
if ((width != curwidth) || (height != curheight)) {
float temp, dh;
- /* resize around 'center' of frame */
+ /* resize from centerpoint */
if (width != curwidth) {
temp= (cur->xmax + cur->xmin) * 0.5f;
dh= width * 0.5f;
@@ -374,7 +375,7 @@ void UI_view2d_curRect_validate(View2D *v2d)
}
}
- /* Step 3: adjust so that it doesn't fall outside of bounds of tot */
+ /* Step 3: adjust so that it doesn't fall outside of bounds of 'tot' */
if (v2d->keeptot) {
float temp, diff;
@@ -504,6 +505,48 @@ void UI_view2d_curRect_validate(View2D *v2d)
}
}
+ /* Step 4: Make sure alignment restrictions are respected */
+ if (v2d->align) {
+ /* If alignment flags are set (but keeptot is not), they must still be respected, as although
+ * they don't specify any particular bounds to stay within, they do define ranges which are
+ * invalid.
+ *
+ * Here, we only check to make sure that on each axis, the 'cur' rect doesn't stray into these
+ * invalid zones, otherwise we offset.
+ */
+
+ /* handle width - posx and negx flags are mutually exclusive, so watch out */
+ if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
+ /* width is in negative-x half */
+ if (v2d->cur.xmax > 0) {
+ v2d->cur.xmin -= v2d->cur.xmax;
+ v2d->cur.xmax= 0.0f;
+ }
+ }
+ else if ((v2d->align & V2D_ALIGN_NO_NEG_X) && !(v2d->align & V2D_ALIGN_NO_POS_X)) {
+ /* width is in positive-x half */
+ if (v2d->cur.xmin < 0) {
+ v2d->cur.xmax -= v2d->cur.xmin;
+ v2d->cur.xmin = 0.0f;
+ }
+ }
+
+ /* handle height - posx and negx flags are mutually exclusive, so watch out */
+ if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
+ /* height is in negative-y half */
+ if (v2d->cur.ymax > 0) {
+ v2d->cur.ymin -= v2d->cur.ymax;
+ v2d->cur.ymax = 0.0f;
+ }
+ }
+ else if ((v2d->align & V2D_ALIGN_NO_NEG_Y) && !(v2d->align & V2D_ALIGN_NO_POS_Y)) {
+ /* height is in positive-y half */
+ if (v2d->cur.ymin < 0) {
+ v2d->cur.ymax -= v2d->cur.ymin;
+ v2d->cur.ymin = 0.0f;
+ }
+ }
+ }
}
/* ------------------ */
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index 93e5ee0e16a..af43f65af82 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -103,9 +103,9 @@ static SpaceLink *action_new(void)
ar->v2d.tot.ymax= 0.0f;
ar->v2d.cur.xmin= -2.0f;
- ar->v2d.cur.ymin= -200.0f;
+ ar->v2d.cur.ymin= -2000.0f; /* ideally this would be the size of the region, but since we don't know that, set for 1:1 */
ar->v2d.cur.xmax= 100.0f;
- ar->v2d.cur.ymax= -20.0f;
+ ar->v2d.cur.ymax= 0.0f;
ar->v2d.min[0]= 0.0f;
ar->v2d.min[1]= 0.0f;