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
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2019-05-21 12:59:10 +0300
committerJacques Lucke <mail@jlucke.com>2019-05-21 12:59:15 +0300
commitb03ee4828be1032052ee4f81f15691a56cde3415 (patch)
tree5f323461a60d19dd2808588e0ad4caeba849cdd0
parentdcec863b2f2fce7fc5caa138ad3816c88e2aa2a3 (diff)
Graph Editor: view-selected takes scrubbing and marker region into account
-rw-r--r--source/blender/blenlib/BLI_rect.h4
-rw-r--r--source/blender/blenlib/intern/rct.c19
-rw-r--r--source/blender/editors/space_graph/graph_edit.c11
3 files changed, 33 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h
index f23580916b1..85cee866c68 100644
--- a/source/blender/blenlib/BLI_rect.h
+++ b/source/blender/blenlib/BLI_rect.h
@@ -62,6 +62,10 @@ void BLI_rcti_resize(struct rcti *rect, int x, int y);
void BLI_rctf_resize(struct rctf *rect, float x, float y);
void BLI_rcti_scale(rcti *rect, const float scale);
void BLI_rctf_scale(rctf *rect, const float scale);
+void BLI_rctf_padding_y(struct rctf *rect,
+ const float boundary_height,
+ const float padding_top,
+ const float padding_bottom);
void BLI_rctf_interp(struct rctf *rect,
const struct rctf *rect_a,
const struct rctf *rect_b,
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index 5000b3df92b..bf0e92b39fb 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -643,6 +643,25 @@ void BLI_rctf_scale(rctf *rect, const float scale)
rect->ymax = cent_y + size_y_half;
}
+void BLI_rctf_padding_y(rctf *rect,
+ const float boundary_height,
+ const float padding_top,
+ const float padding_bottom)
+{
+ BLI_assert(padding_top >= 0.0f);
+ BLI_assert(padding_bottom >= 0.0f);
+ BLI_assert(boundary_height > 0.0f);
+
+ float total_padding = padding_top + padding_bottom;
+ if (total_padding == 0.0f) {
+ return;
+ }
+
+ float total_extend = BLI_rctf_size_y(rect) * total_padding / (boundary_height - total_padding);
+ rect->ymax += total_extend * (padding_top / total_padding);
+ rect->ymin -= total_extend * (padding_bottom / total_padding);
+}
+
void BLI_rctf_interp(rctf *rect, const rctf *rect_a, const rctf *rect_b, const float fac)
{
const float ifac = 1.0f - fac;
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 8329218eea9..90cba617129 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -55,6 +55,7 @@
#include "DEG_depsgraph_build.h"
#include "UI_view2d.h"
+#include "UI_interface.h"
#include "ED_anim_api.h"
#include "ED_keyframing.h"
@@ -282,10 +283,18 @@ static int graphkeys_viewall(bContext *C,
do_sel_only,
include_handles);
+ /* Give some more space at the borders. */
BLI_rctf_scale(&cur_new, 1.1f);
- UI_view2d_smooth_view(C, ac.ar, &cur_new, smooth_viewtx);
+ /* Take regions into account, that could block the view. */
+ float padding_top = UI_SCRUBBING_MARGIN_Y;
+ float padding_bottom = 0;
+ if (!BLI_listbase_is_empty(ED_context_get_markers(C))) {
+ padding_bottom = UI_MARKER_MARGIN_Y;
+ }
+ BLI_rctf_padding_y(&cur_new, ac.ar->sizey * UI_DPI_FAC, padding_top, padding_bottom);
+ UI_view2d_smooth_view(C, ac.ar, &cur_new, smooth_viewtx);
return OPERATOR_FINISHED;
}