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:
authorCampbell Barton <ideasman42@gmail.com>2014-02-22 06:07:02 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-02-22 06:07:02 +0400
commit543b57fbeb6592421d3f133d4d40cc161a46894c (patch)
tree06381d4ba3e5f3dbcc0412a04c1e7dba986ce9a9 /source/blender/editors
parentb7fa08f88a260bbd9008c11875cb14052d6c7eb1 (diff)
Fix T38348: Panel remains scrolled when switching tabs
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/UI_view2d.h2
-rw-r--r--source/blender/editors/interface/interface_panel.c7
-rw-r--r--source/blender/editors/interface/view2d.c29
3 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 3bae255f297..fe8ddee136c 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -205,6 +205,8 @@ void UI_view2d_getscale_inverse(struct View2D *v2d, float *x, float *y);
void UI_view2d_getcenter(struct View2D *v2d, float *x, float *y);
void UI_view2d_setcenter(struct View2D *v2d, float x, float y);
+void UI_view2d_offset(struct View2D *v2d, float xfac, float yfac);
+
short UI_view2d_mouse_in_scrollers(const struct bContext *C, struct View2D *v2d, int x, int y);
/* cached text drawing in v2d, to allow pixel-aligned draw as post process */
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 3a5d1f6fdf3..fada118e037 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -61,6 +61,7 @@
#include "ED_screen.h"
+#include "UI_view2d.h"
#include "UI_interface.h"
#include "UI_interface_icons.h"
#include "UI_resources.h"
@@ -1638,6 +1639,10 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar)
if (pc_dyn) {
UI_panel_category_active_set(ar, pc_dyn->idname);
ED_region_tag_redraw(ar);
+
+ /* reset scroll to the top [#38348] */
+ UI_view2d_offset(&ar->v2d, -1.0f, 1.0f);
+
retval = WM_UI_HANDLER_BREAK;
}
}
@@ -1652,6 +1657,8 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar)
if (LIKELY(pc_dyn)) {
pc_dyn = (event->type == WHEELDOWNMOUSE) ? pc_dyn->next : pc_dyn->prev;
if (pc_dyn) {
+ /* intentionally don't reset scroll in this case,
+ * this allows for quick browsing between tabs */
UI_panel_category_active_set(ar, pc_dyn->idname);
ED_region_tag_redraw(ar);
}
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index ea350fd08df..f20a196627e 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -2114,6 +2114,35 @@ void UI_view2d_setcenter(struct View2D *v2d, float x, float y)
UI_view2d_curRect_validate(v2d);
}
+/**
+ * Simple pan function
+ * (0.0, 0.0) bottom left
+ * (0.5, 0.5) center
+ * (1.0, 1.0) top right.
+ */
+void UI_view2d_offset(struct View2D *v2d, float xfac, float yfac)
+{
+ if (xfac != -1.0f) {
+ const float xsize = BLI_rctf_size_x(&v2d->cur);
+ const float xmin = v2d->tot.xmin;
+ const float xmax = v2d->tot.xmax - xsize;
+
+ v2d->cur.xmin = (xmin * (1.0f - xfac)) + (xmax * xfac);
+ v2d->cur.xmax = v2d->cur.xmin + xsize;
+ }
+
+ if (yfac != -1.0f) {
+ const float ysize = BLI_rctf_size_y(&v2d->cur);
+ const float ymin = v2d->tot.ymin;
+ const float ymax = v2d->tot.ymax - ysize;
+
+ v2d->cur.ymin = (ymin * (1.0f - yfac)) + (ymax * yfac);
+ v2d->cur.ymax = v2d->cur.ymin + ysize;
+ }
+
+ UI_view2d_curRect_validate(v2d);
+}
+
/* Check if mouse is within scrollers
* - Returns appropriate code for match
* 'h' = in horizontal scroller