diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-01-19 08:30:35 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-01-19 08:47:57 +0300 |
commit | 09c83d6fea0fc55b54900329c1b81d992d814b9e (patch) | |
tree | bacfcef098e078ee6afb0ce8fc7e417a3ccade00 /source/blender/editors/interface/interface_draw.c | |
parent | 9f54a73b3283177d478110977c907955ef86e77a (diff) |
Viewport: Add adjustable safe areas, 3d-view & VSE
Also adds safe-area presets.
D325 by Diego Gangl with own edits.
Diffstat (limited to 'source/blender/editors/interface/interface_draw.c')
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index bcd9b9a5547..cca4df30811 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -450,6 +450,51 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w #endif } +/** + * Draw title and text safe areas. + * + * The first 4 parameters are the offsets for the view, not the zones. + */ +void UI_draw_safe_areas( + float x1, float x2, float y1, float y2, + const float title_aspect[2], const float action_aspect[2]) +{ + const float size_x_half = (x2 - x1) * 0.5f; + const float size_y_half = (y2 - y1) * 0.5f; + + const float *safe_areas[] = {title_aspect, action_aspect}; + int i, safe_len = ARRAY_SIZE(safe_areas); + bool is_first = true; + + for (i = 0; i < safe_len; i++) { + if (safe_areas[i][0] || safe_areas[i][1]) { + float margin_x, margin_y; + float minx, miny, maxx, maxy; + + if (is_first) { + UI_ThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25f, 0); + is_first = false; + } + + margin_x = safe_areas[i][0] * size_x_half; + margin_y = safe_areas[i][1] * size_y_half; + + minx = x1 + margin_x; + miny = y1 + margin_y; + maxx = x2 - margin_x; + maxy = y2 - margin_y; + + glBegin(GL_LINE_LOOP); + glVertex2f(maxx, miny); + glVertex2f(maxx, maxy); + glVertex2f(minx, maxy); + glVertex2f(minx, miny); + glEnd(); + } + } +} + + static void draw_scope_end(const rctf *rect, GLint *scissor) { /* restore scissortest */ |