[Bf-blender-cvs] [bfd8b5d] soc-2016-layer_manager: Use a bit more interesting background drawing for layer manager
Julian Eisel
noreply at git.blender.org
Sun May 29 21:07:09 CEST 2016
Commit: bfd8b5d9bb21f160f00a6fe530ec974150de3f69
Author: Julian Eisel
Date: Sun May 29 20:51:04 2016 +0200
Branches: soc-2016-layer_manager
https://developer.blender.org/rBbfd8b5d9bb21f160f00a6fe530ec974150de3f69
Use a bit more interesting background drawing for layer manager
The layer manager editor now draws a background similar to the on in the outliner. Since layer tiles can be of a dynamic height, I had to make sure that's supported though.
===================================================================
M source/blender/editors/include/BIF_glutil.h
M source/blender/editors/screen/glutil.c
M source/blender/editors/space_layers/layers_draw.c
M source/blender/editors/space_layers/layers_intern.h
M source/blender/editors/space_layers/layers_util.c
===================================================================
diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h
index 0ac5c17..8435c77 100644
--- a/source/blender/editors/include/BIF_glutil.h
+++ b/source/blender/editors/include/BIF_glutil.h
@@ -41,6 +41,7 @@ struct ColorManagedDisplaySettings;
void fdrawbezier(float vec[4][3]);
void fdrawline(float x1, float y1, float x2, float y2);
void fdrawbox(float x1, float y1, float x2, float y2);
+void fdrawbox_filled(float x1, float y1, float x2, float y2);
void sdrawline(int x1, int y1, int x2, int y2);
#if 0
void sdrawtri(int x1, int y1, int x2, int y2);
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index cbf8706..dba711a 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -109,6 +109,18 @@ void fdrawbox(float x1, float y1, float x2, float y2)
glEnd();
}
+void fdrawbox_filled(float x1, float y1, float x2, float y2)
+{
+ glBegin(GL_POLYGON);
+
+ glVertex2f(x1, y1);
+ glVertex2f(x1, y2);
+ glVertex2f(x2, y2);
+ glVertex2f(x2, y1);
+
+ glEnd();
+}
+
void fdrawcheckerboard(float x1, float y1, float x2, float y2)
{
unsigned char col1[4] = {40, 40, 40}, col2[4] = {50, 50, 50};
diff --git a/source/blender/editors/space_layers/layers_draw.c b/source/blender/editors/space_layers/layers_draw.c
index 3807df4..fb0e793 100644
--- a/source/blender/editors/space_layers/layers_draw.c
+++ b/source/blender/editors/space_layers/layers_draw.c
@@ -22,6 +22,8 @@
* \ingroup splayers
*/
+#include "BIF_glutil.h"
+
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
#include "BLI_listbase.h"
@@ -70,6 +72,7 @@ typedef struct TileDrawInfo {
uiStyle *style;
float size_y;
+ int idx;
} TileDrawInfo;
static bool layer_tile_draw_cb(LayerTreeItem *litem, void *userdata)
@@ -77,20 +80,25 @@ static bool layer_tile_draw_cb(LayerTreeItem *litem, void *userdata)
TileDrawInfo *drawinfo = userdata;
View2D *v2d = &drawinfo->ar->v2d;
LayerTile *tile = BLI_ghash_lookup(drawinfo->slayer->tiles, litem);
- const float padx = 4.0f * UI_DPI_FAC;
+ const float pad_x = 4.0f * UI_DPI_FAC;
const float height = tile->height;
const float ofs_x = layer_tile_indent_level_get(litem) * LAYERITEM_INDENT_SIZE;
const float ofs_y = drawinfo->size_y;
- rctf rect = {padx + ofs_x, drawinfo->ar->winx - padx, -v2d->cur.ymin - ofs_y - height};
+ rctf rect = {ofs_x, drawinfo->ar->winx, -v2d->cur.ymin - ofs_y - height};
rect.ymax = rect.ymin + height;
+ /* draw background */
+ if (drawinfo->idx % 2) {
+ UI_ThemeColorShade(TH_BACK, 10);
+ fdrawbox_filled(0, rect.ymin, rect.xmax, rect.ymax);
+ }
/* draw selection */
if (tile->flag & LAYERTILE_SELECTED) {
UI_draw_roundbox_corner_set(UI_CNR_ALL);
UI_ThemeColor(TH_HILITE);
- UI_draw_roundbox(rect.xmin, rect.ymin, rect.xmax, rect.ymax, 5.0f);
+ UI_draw_roundbox(rect.xmin + pad_x, rect.ymin, rect.xmax - pad_x, rect.ymax, 5.0f);
}
/* draw item itself */
if (litem->draw) {
@@ -121,6 +129,7 @@ static bool layer_tile_draw_cb(LayerTreeItem *litem, void *userdata)
UI_block_layout_resolve(block, NULL, NULL);
}
drawinfo->size_y += height;
+ drawinfo->idx++;
return true;
}
@@ -135,6 +144,16 @@ void layers_tiles_draw(const bContext *C, ARegion *ar)
/* draw tiles */
BKE_layertree_iterate(slayer->act_tree, layer_tile_draw_cb, &drawinfo);
+ /* fill remaining space with empty boxes */
+ const float tot_fill_tiles = (-ar->v2d.cur.ymin - drawinfo.size_y) / LAYERTILE_DEFAULT_HEIGHT + 1;
+ for (int i = 0; i < tot_fill_tiles; i++) {
+ if ((i + drawinfo.idx - 1) % 2) {
+ const float pos[2] = {0, -ar->v2d.cur.ymin - drawinfo.size_y - (LAYERTILE_DEFAULT_HEIGHT * i)};
+ UI_ThemeColorShade(TH_BACK, 10);
+ fdrawbox_filled(pos[0], pos[1], pos[0] + ar->winx, pos[1] + LAYERTILE_DEFAULT_HEIGHT);
+ }
+ }
+
UI_block_end(C, block);
UI_block_draw(C, block);
diff --git a/source/blender/editors/space_layers/layers_intern.h b/source/blender/editors/space_layers/layers_intern.h
index 7f6446e..ab781e9 100644
--- a/source/blender/editors/space_layers/layers_intern.h
+++ b/source/blender/editors/space_layers/layers_intern.h
@@ -28,6 +28,8 @@
struct ARegion;
struct wmKeyConfig;
+#define LAYERTILE_DEFAULT_HEIGHT U.widget_unit
+
typedef enum eLayerTileFlag {
LAYERTILE_SELECTED = (1 << 0),
LAYERTILE_RENAME = (1 << 1),
diff --git a/source/blender/editors/space_layers/layers_util.c b/source/blender/editors/space_layers/layers_util.c
index dc5f804..2a1d23f 100644
--- a/source/blender/editors/space_layers/layers_util.c
+++ b/source/blender/editors/space_layers/layers_util.c
@@ -37,8 +37,6 @@
#include "layers_intern.h"
-#define LAYERITEM_DEFAULT_HEIGHT U.widget_unit
-
/**
* Allocate and register a LayerTile for \a litem.
@@ -48,7 +46,7 @@ LayerTile *layers_tile_add(const SpaceLayers *slayer, LayerTreeItem *litem)
LayerTile *tile = MEM_callocN(sizeof(LayerTile), __func__);
tile->litem = litem;
- tile->height = LAYERITEM_DEFAULT_HEIGHT;
+ tile->height = LAYERTILE_DEFAULT_HEIGHT;
BLI_ghash_insert(slayer->tiles, litem, tile);
return tile;
More information about the Bf-blender-cvs
mailing list