[Bf-blender-cvs] [591a2a6] soc-2016-layer_manager: Scrolling support for layer manager editor

Julian Eisel noreply at git.blender.org
Tue May 24 18:51:48 CEST 2016


Commit: 591a2a69294b485175e62518049811ebc8e848c0
Author: Julian Eisel
Date:   Tue May 24 18:51:08 2016 +0200
Branches: soc-2016-layer_manager
https://developer.blender.org/rB591a2a69294b485175e62518049811ebc8e848c0

Scrolling support for layer manager editor

Vertical scrolling only for now.

===================================================================

M	source/blender/editors/space_layers/layers_draw.c
M	source/blender/editors/space_layers/space_layers.c

===================================================================

diff --git a/source/blender/editors/space_layers/layers_draw.c b/source/blender/editors/space_layers/layers_draw.c
index f149134..359c9ed 100644
--- a/source/blender/editors/space_layers/layers_draw.c
+++ b/source/blender/editors/space_layers/layers_draw.c
@@ -23,6 +23,7 @@
  */
 
 #include "BLI_listbase.h"
+#include "BLI_rect.h"
 
 #include "BKE_context.h"
 #include "BKE_layer.h"
@@ -41,7 +42,6 @@ void layers_draw_tiles(const bContext *C, ARegion *ar)
 	uiStyle *style = UI_style_get_dpi();
 	SpaceLayers *slayer = CTX_wm_space_layers(C);
 	View2D *v2d = &ar->v2d;
-	float size_x = ar->winx;
 	float size_y = 0.0f;
 
 	uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
@@ -52,7 +52,8 @@ void layers_draw_tiles(const bContext *C, ARegion *ar)
 		if (litem->draw) {
 			uiLayout *layout = UI_block_layout(
 			                       block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER,
-			                       0, ar->winy - size_y, litem->height, 0, 0, style);
+			                       -v2d->cur.xmin, -v2d->cur.ymin - size_y,
+			                       litem->height, 0, 0, style);
 			litem->draw(litem, layout);
 			UI_block_layout_resolve(block, NULL, NULL);
 		}
@@ -63,5 +64,5 @@ void layers_draw_tiles(const bContext *C, ARegion *ar)
 	UI_block_draw(C, block);
 
 	/* update size of tot-rect (extents of data/viewable area) */
-	UI_view2d_totRect_set(v2d, size_x, size_y);
+	UI_view2d_totRect_set(v2d, ar->winx - BLI_rcti_size_x(&v2d->vert), size_y);
 }
diff --git a/source/blender/editors/space_layers/space_layers.c b/source/blender/editors/space_layers/space_layers.c
index 36554a1..1cbadc0 100644
--- a/source/blender/editors/space_layers/space_layers.c
+++ b/source/blender/editors/space_layers/space_layers.c
@@ -58,16 +58,16 @@ static SpaceLink *layers_new(const bContext *UNUSED(C))
 
 	/* header */
 	ar = MEM_callocN(sizeof(ARegion), "header for layer manager");
-
 	BLI_addtail(&slayer->regionbase, ar);
 	ar->regiontype = RGN_TYPE_HEADER;
 	ar->alignment = RGN_ALIGN_BOTTOM;
 
 	/* main region */
 	ar = MEM_callocN(sizeof(ARegion), "main region for layer manager");
-
 	BLI_addtail(&slayer->regionbase, ar);
 	ar->regiontype = RGN_TYPE_WINDOW;
+	ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM | V2D_SCROLL_HORIZONTAL_HIDE | V2D_SCROLL_VERTICAL_HIDE);
+	ar->v2d.align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y);
 
 	return (SpaceLink *)slayer;
 }
@@ -99,16 +99,17 @@ static void layer_init(wmWindowManager *wm, ScrArea *sa)
 /* add handlers, stuff you only do once or on area/region changes */
 static void layer_main_region_init(wmWindowManager *UNUSED(wm), ARegion *ar)
 {
-	/* do not use here, the properties changed in userprefs do a system-wide refresh, then scroller jumps back */
-	/*	ar->v2d.flag &= ~V2D_IS_INITIALISED; */
-	
-	ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
+	UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
+	ar->v2d.scroll |= (V2D_SCROLL_VERTICAL_FULLR | V2D_SCROLL_HORIZONTAL_FULLR);
 }
 
 static void layers_main_region_draw(const bContext *C, ARegion *ar)
 {
 	View2D *v2d = &ar->v2d;
 
+	/* v2d has initialized flag, so this call will only set the mask correct */
+	UI_view2d_region_reinit(v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
+
 	UI_ThemeClearColor(TH_BACK);
 	glClear(GL_COLOR_BUFFER_BIT);
 
@@ -168,7 +169,7 @@ void ED_spacetype_layers(void)
 	art->init = layer_main_region_init;
 	art->draw = layers_main_region_draw;
 	art->listener = layers_main_region_listener;
-	art->keymapflag = ED_KEYMAP_UI;
+	art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
 	BLI_addhead(&st->regiontypes, art);
 
 	/* regions: header */




More information about the Bf-blender-cvs mailing list