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 | |
parent | 9f54a73b3283177d478110977c907955ef86e77a (diff) |
Viewport: Add adjustable safe areas, 3d-view & VSE
Also adds safe-area presets.
D325 by Diego Gangl with own edits.
24 files changed, 331 insertions, 44 deletions
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 8fd09c3bc19..da303ce5690 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -1417,6 +1417,7 @@ def get_panels(): "DATA_PT_vertex_colors", "DATA_PT_camera", "DATA_PT_camera_display", + "DATA_PT_camera_safe_areas", "DATA_PT_lens", "DATA_PT_speaker", "DATA_PT_distance", diff --git a/release/scripts/presets/safe_areas/14_colon_9_in_16_colon_9.py b/release/scripts/presets/safe_areas/14_colon_9_in_16_colon_9.py new file mode 100644 index 00000000000..e486b413de8 --- /dev/null +++ b/release/scripts/presets/safe_areas/14_colon_9_in_16_colon_9.py @@ -0,0 +1,7 @@ +import bpy +safe_areas = bpy.context.scene.safe_areas + +safe_areas.title = (0.035, 0.035) +safe_areas.action = (0.1, 0.05) +safe_areas.title_center = (0.15, 0.05) +safe_areas.action_center = (0.1, 0.05) diff --git a/release/scripts/presets/safe_areas/16_colon_9.py b/release/scripts/presets/safe_areas/16_colon_9.py new file mode 100644 index 00000000000..221b8db84bd --- /dev/null +++ b/release/scripts/presets/safe_areas/16_colon_9.py @@ -0,0 +1,7 @@ +import bpy +safe_areas = bpy.context.scene.safe_areas + +safe_areas.title = (0.035, 0.035) +safe_areas.action = (0.1, 0.05) +safe_areas.title_center = (0.0, 0.0) +safe_areas.action_center = (0.0, 0.0) diff --git a/release/scripts/presets/safe_areas/4_colon_3_in_16_colon_9.py b/release/scripts/presets/safe_areas/4_colon_3_in_16_colon_9.py new file mode 100644 index 00000000000..c10bc6cf285 --- /dev/null +++ b/release/scripts/presets/safe_areas/4_colon_3_in_16_colon_9.py @@ -0,0 +1,7 @@ +import bpy +safe_areas = bpy.context.scene.safe_areas + +safe_areas.title = (0.035, 0.035) +safe_areas.action = (0.1, 0.05) +safe_areas.title_center = (0.175, 0.05) +safe_areas.action_center = (0.15, 0.05) diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index f89792bea6e..5e3485a27a4 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -277,6 +277,26 @@ class AddPresetCamera(AddPresetBase, Operator): return preset_values +class AddPresetSafeAreas(AddPresetBase, Operator): + """Add or remove a Safe Areas Preset""" + bl_idname = "safe_areas.preset_add" + bl_label = "Add Safe Area Preset" + preset_menu = "SAFE_AREAS_MT_presets" + + preset_defines = [ + "safe_areas = bpy.context.scene.safe_areas" + ] + + preset_values = [ + "safe_areas.title", + "safe_areas.action", + "safe_areas.title_center", + "safe_areas.action_center", + ] + + preset_subdir = "safe_areas" + + class AddPresetSSS(AddPresetBase, Operator): """Add or remove a Subsurface Scattering Preset""" bl_idname = "material.sss_preset_add" diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py index fee3e589074..9c94c9cf7d5 100644 --- a/release/scripts/startup/bl_ui/properties_data_camera.py +++ b/release/scripts/startup/bl_ui/properties_data_camera.py @@ -41,6 +41,14 @@ class CAMERA_MT_presets(Menu): draw = Menu.draw_preset +class SAFE_AREAS_MT_presets(Menu): + bl_label = "Camera Presets" + preset_subdir = "safe_areas" + preset_operator = "script.execute_preset" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} + draw = Menu.draw_preset + + class DATA_PT_context_camera(CameraButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} @@ -195,7 +203,7 @@ class DATA_PT_camera_display(CameraButtonsPanel, Panel): col = split.column() col.prop(cam, "show_limits", text="Limits") col.prop(cam, "show_mist", text="Mist") - col.prop(cam, "show_title_safe", text="Safe Areas") + col.prop(cam, "show_sensor", text="Sensor") col.prop(cam, "show_name", text="Name") @@ -210,10 +218,57 @@ class DATA_PT_camera_display(CameraButtonsPanel, Panel): sub.prop(cam, "passepartout_alpha", text="Alpha", slider=True) +class DATA_PT_camera_safe_areas(CameraButtonsPanel, Panel): + bl_label = "Safe Areas" + bl_options = {'DEFAULT_CLOSED'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} + + def draw_header(self, context): + cam = context.camera + + self.layout.prop(cam, "show_safe_areas", text="") + + def draw(self, context): + layout = self.layout + cam = context.camera + + draw_display_safe_settings(layout, cam) + + class DATA_PT_custom_props_camera(CameraButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "object.data" _property_type = bpy.types.Camera + +def draw_display_safe_settings(layout, settings): + + safe_data = bpy.context.scene.safe_areas + show_safe_areas = settings.show_safe_areas + show_safe_center = settings.show_safe_center + + split = layout.split() + + col = split.column() + row = col.row(align=True) + row.menu("SAFE_AREAS_MT_presets", text=bpy.types.SAFE_AREAS_MT_presets.bl_label) + row.operator("safe_areas.preset_add", text="", icon='ZOOMIN') + row.operator("safe_areas.preset_add", text="", icon='ZOOMOUT').remove_active = True + + col = split.column() + col.prop(settings, "show_safe_center", text="Center-Cut Safe Areas") + + split = layout.split() + col = split.column() + col.active = show_safe_areas + col.prop(safe_data, "title", slider=True) + col.prop(safe_data, "action", slider=True) + + col = split.column() + col.active = show_safe_areas and show_safe_center + col.prop(safe_data, "title_center", slider=True) + col.prop(safe_data, "action_center", slider=True) + + if __name__ == "__main__": # only for live edit. bpy.utils.register_module(__name__) diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 66b3cbe73d9..bf63b847996 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -22,6 +22,7 @@ from bpy.types import Header, Menu, Panel from bl_ui.properties_grease_pencil_common import GreasePencilDataPanel, GreasePencilToolsPanel from bpy.app.translations import pgettext_iface as iface_ +from bl_ui.properties_data_camera import draw_display_safe_settings def act_strip(context): try: @@ -205,7 +206,7 @@ class SEQUENCER_MT_view(Menu): if is_preview: if st.display_mode == 'IMAGE': - layout.prop(st, "show_safe_margin") + layout.prop(st, "show_safe_areas") elif st.display_mode == 'WAVEFORM': layout.prop(st, "show_separate_color") @@ -973,12 +974,38 @@ class SEQUENCER_PT_view(SequencerButtonsPanel_Output, Panel): col = layout.column() if st.display_mode == 'IMAGE': col.prop(st, "draw_overexposed") - col.prop(st, "show_safe_margin") + col.separator() + elif st.display_mode == 'WAVEFORM': col.prop(st, "show_separate_color") + + col = layout.column() + col.separator() col.prop(st, "proxy_render_size") +class SEQUENCER_PT_view_safe_areas(SequencerButtonsPanel_Output, Panel): + bl_label = "Safe Areas" + bl_options = {'DEFAULT_CLOSED'} + + @classmethod + def poll(cls, context): + st = context.space_data + is_preview = st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'} + return is_preview and (st.display_mode == 'IMAGE') + + def draw_header(self, context): + st = context.space_data + + self.layout.prop(st, "show_safe_areas", text="") + + def draw(self, context): + layout = self.layout + st = context.space_data + + draw_display_safe_settings(layout, st) + + class SEQUENCER_PT_modifiers(SequencerButtonsPanel, Panel): bl_label = "Modifiers" diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index eac4f6a56a5..149472db8fa 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -39,6 +39,7 @@ extern "C" { struct AviCodecData; struct Base; +struct DisplaySafeAreas; struct EvaluationContext; struct bglMats; struct Main; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 13e9b7fb0c4..577dbd6d323 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -689,6 +689,12 @@ Scene *BKE_scene_add(Main *bmain, const char *name) BLI_strncpy(sce->sequencer_colorspace_settings.name, colorspace_name, sizeof(sce->sequencer_colorspace_settings.name)); + /* Safe Areas */ + copy_v2_fl2(sce->safe_areas.title, 3.5f / 100.0f, 3.5f / 100.0f); + copy_v2_fl2(sce->safe_areas.action, 10.0f / 100.0f, 5.0f / 100.0f); + copy_v2_fl2(sce->safe_areas.title_center, 17.5f / 100.0f, 5.0f / 100.0f); + copy_v2_fl2(sce->safe_areas.action_center, 15.0f / 100.0f, 5.0f / 100.0f); + return sce; } diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index e6e43758e11..bde3f0f2512 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -458,4 +458,18 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) #undef BRUSH_RAKE #undef BRUSH_RANDOM_ROTATION } + + /* Customizable Safe Areas */ + if (!MAIN_VERSION_ATLEAST(main, 273, 2)) { + if (!DNA_struct_elem_find(fd->filesdna, "Scene", "DisplaySafeAreas", "safe_areas")) { + Scene *scene; + + for (scene = main->scene.first; scene; scene = scene->id.next) { + copy_v2_fl2(scene->safe_areas.title, 3.5f / 100.0f, 3.5f / 100.0f); + copy_v2_fl2(scene->safe_areas.action, 10.0f / 100.0f, 5.0f / 100.0f); + copy_v2_fl2(scene->safe_areas.title_center, 17.5f / 100.0f, 5.0f / 100.0f); + copy_v2_fl2(scene->safe_areas.action_center, 15.0f / 100.0f, 5.0f / 100.0f); + } + } + } } diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 6f298923397..a28ca7d187a 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -2183,8 +2183,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) cam->flag |= CAM_SHOWPASSEPARTOUT; /* make sure old cameras have title safe on */ - if (!(cam->flag & CAM_SHOWTITLESAFE)) - cam->flag |= CAM_SHOWTITLESAFE; + if (!(cam->flag & CAM_SHOW_SAFE_MARGINS)) + cam->flag |= CAM_SHOW_SAFE_MARGINS; /* set an appropriate camera passepartout alpha */ if (!(cam->passepartalpha)) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 8789e837f17..159fda89f59 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -316,6 +316,10 @@ void UI_draw_roundbox_shade_x(int mode, float minx, float miny, float maxx, floa void UI_draw_roundbox_shade_y(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight); void UI_draw_text_underline(int pos_x, int pos_y, int len, int height); +void UI_draw_safe_areas( + float x1, float x2, float y1, float y2, + const float title_aspect[2], const float action_aspect[2]); + /* state for scrolldrawing */ #define UI_SCROLL_PRESSED (1 << 0) #define UI_SCROLL_ARROWS (1 << 1) 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 */ diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index afb650f8cfd..3233c4192b9 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1292,24 +1292,18 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq glEnd(); /* safety border */ - if ((sseq->flag & SEQ_DRAW_SAFE_MARGINS) != 0) { - float fac = 0.1; - - float a = fac * (x2 - x1); - x1 += a; - x2 -= a; - - a = fac * (y2 - y1); - y1 += a; - y2 -= a; - - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - - UI_draw_roundbox_corner_set(UI_CNR_ALL); - UI_draw_roundbox_gl_mode(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); - - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - + if (sseq->flag & SEQ_SHOW_SAFE_MARGINS) { + UI_draw_safe_areas( + x1, x2, y1, y2, + scene->safe_areas.title, + scene->safe_areas.action); + + if (sseq->flag & SEQ_SHOW_SAFE_CENTER) { + UI_draw_safe_areas( + x1, x2, y1, y2, + scene->safe_areas.title_center, + scene->safe_areas.action_center); + } } setlinestyle(0); diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 6231f02907a..4d97056c4c5 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -599,6 +599,7 @@ static void sequencer_preview_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED case ND_MARKERS: case ND_SEQUENCER: case ND_RENDER_OPTIONS: + case ND_DRAW_RENDER_VIEWPORT: ED_region_tag_redraw(ar); break; } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index d0ba3a9f793..17cecc3dc1d 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -817,6 +817,16 @@ static void view3d_main_area_listener(bScreen *sc, ScrArea *sa, ARegion *ar, wmN case ND_WORLD: /* handled by space_view3d_listener() for v3d access */ break; + case ND_DRAW_RENDER_VIEWPORT: + { + if (v3d->camera && (scene == wmn->reference)) { + RegionView3D *rv3d = ar->regiondata; + if (rv3d->persp == RV3D_CAMOB) { + ED_region_tag_redraw(ar); + } + } + break; + } } if (wmn->action == NA_EDITED) ED_region_tag_redraw(ar); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 65721d52dff..24050697585 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1066,14 +1066,13 @@ static void drawviewborder_triangle(float x1, float x2, float y1, float y2, cons static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) { - float hmargin, vmargin; float x1, x2, y1, y2; float x1i, x2i, y1i, y2i; rctf viewborder; Camera *ca = NULL; RegionView3D *rv3d = ar->regiondata; - + if (v3d->camera == NULL) return; if (v3d->camera->type == OB_CAMERA) @@ -1225,17 +1224,20 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) drawviewborder_triangle(x1, x2, y1, y2, 1, 'B'); } - if (ca->flag & CAM_SHOWTITLESAFE) { - UI_ThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25, 0); - - hmargin = 0.1f * (x2 - x1); - vmargin = 0.05f * (y2 - y1); - UI_draw_roundbox_gl_mode(GL_LINE_LOOP, x1 + hmargin, y1 + vmargin, x2 - hmargin, y2 - vmargin, 2.0f); + if (ca->flag & CAM_SHOW_SAFE_MARGINS) { + UI_draw_safe_areas( + x1, x2, y1, y2, + scene->safe_areas.title, + scene->safe_areas.action); - hmargin = 0.035f * (x2 - x1); - vmargin = 0.035f * (y2 - y1); - UI_draw_roundbox_gl_mode(GL_LINE_LOOP, x1 + hmargin, y1 + vmargin, x2 - hmargin, y2 - vmargin, 2.0f); + if (ca->flag & CAM_SHOW_SAFE_CENTER) { + UI_draw_safe_areas( + x1, x2, y1, y2, + scene->safe_areas.title_center, + scene->safe_areas.action_center); + } } + if (ca->flag & CAM_SHOWSENSOR) { /* determine sensor fit, and get sensor x/y, for auto fit we * assume and square sensor and only use sensor_x */ diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h index c99494ce00e..da7d98d2b22 100644 --- a/source/blender/makesdna/DNA_camera_types.h +++ b/source/blender/makesdna/DNA_camera_types.h @@ -56,7 +56,7 @@ typedef struct Camera { float lens, ortho_scale, drawsize; float sensor_x, sensor_y; float shiftx, shifty; - + /* yafray: dof params */ /* qdn: yafray var 'YF_dofdist' now enabled for defocus composite node as well. * The name was not changed so that no other files need to be modified */ @@ -96,12 +96,13 @@ enum { CAM_SHOWLIMITS = (1 << 0), CAM_SHOWMIST = (1 << 1), CAM_SHOWPASSEPARTOUT = (1 << 2), - CAM_SHOWTITLESAFE = (1 << 3), + CAM_SHOW_SAFE_MARGINS = (1 << 3), CAM_SHOWNAME = (1 << 4), CAM_ANGLETOGGLE = (1 << 5), CAM_DS_EXPAND = (1 << 6), CAM_PANORAMA = (1 << 7), /* deprecated */ CAM_SHOWSENSOR = (1 << 8), + CAM_SHOW_SAFE_CENTER = (1 << 9), }; #if (DNA_DEPRECATED_GCC_POISON == 1) diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 49f8b3cd4d0..9371170a004 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1216,6 +1216,21 @@ typedef struct PhysicsSettings { int flag, quick_cache_step, rt; } PhysicsSettings; +/* ------------------------------------------- */ +/* Safe Area options used in Camera View & VSE + */ +typedef struct DisplaySafeAreas { + /* each value represents the (x,y) margins as a multiplier. + * 'center' in this context is just the name for a different kind of safe-area */ + + float title[2]; /* Title Safe */ + float action[2]; /* Image/Graphics Safe */ + + /* use for alternate aspect ratio */ + float title_center[2]; + float action_center[2]; +} DisplaySafeAreas; + /* *************************************************************** */ /* Scene ID-Block */ @@ -1251,6 +1266,7 @@ typedef struct Scene { struct ToolSettings *toolsettings; /* default allocated now */ struct SceneStats *stats; /* default allocated now */ + struct DisplaySafeAreas safe_areas; /* migrate or replace? depends on some internal things... */ /* no, is on the right place (ton) */ diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 82ab0cce30c..723964364f6 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -528,12 +528,13 @@ typedef enum eSpaceSeq_Flag { SEQ_DRAWFRAMES = (1 << 0), SEQ_MARKER_TRANS = (1 << 1), SEQ_DRAW_COLOR_SEPARATED = (1 << 2), - SEQ_DRAW_SAFE_MARGINS = (1 << 3), + SEQ_SHOW_SAFE_MARGINS = (1 << 3), SEQ_SHOW_GPENCIL = (1 << 4), SEQ_NO_DRAW_CFRANUM = (1 << 5), SEQ_USE_ALPHA = (1 << 6), /* use RGBA display mode for preview */ SEQ_ALL_WAVEFORMS = (1 << 7), /* draw all waveforms */ SEQ_NO_WAVEFORMS = (1 << 8), /* draw no waveforms */ + SEQ_SHOW_SAFE_CENTER = (1 << 9), } eSpaceSeq_Flag; /* sseq->view */ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 6167164a7ac..34c2e5a3f25 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -203,6 +203,7 @@ extern StructRNA RNA_DataTransferModifier; extern StructRNA RNA_DecimateModifier; extern StructRNA RNA_DelaySensor; extern StructRNA RNA_DisplaceModifier; +extern StructRNA RNA_DisplaySafeAreas; extern StructRNA RNA_DistortedNoiseTexture; extern StructRNA RNA_DomainFluidSettings; extern StructRNA RNA_DopeSheet; diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index 9f119b33889..5704004b4b6 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -258,9 +258,14 @@ void RNA_def_camera(BlenderRNA *brna) "Show a darkened overlay outside the image area in Camera view"); RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL); - prop = RNA_def_property(srna, "show_title_safe", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_SHOWTITLESAFE); - RNA_def_property_ui_text(prop, "Show Safe Areas", "Show TV title safe and action safe zones in Camera view"); + prop = RNA_def_property(srna, "show_safe_areas", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_SHOW_SAFE_MARGINS); + RNA_def_property_ui_text(prop, "Show Safe Areas", "Show TV title safe and action safe areas in Camera view"); + RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL); + + prop = RNA_def_property(srna, "show_safe_center", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_SHOW_SAFE_CENTER); + RNA_def_property_ui_text(prop, "Show Center-cut safe areas", "Show safe areas to fit content in a different aspect ratio"); RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL); prop = RNA_def_property(srna, "show_name", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index d9587b8d983..57d50958e2c 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -5390,6 +5390,55 @@ static void rna_def_selected_uv_element(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Face Index", ""); } +static void rna_def_display_safe_areas(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static float default_title[2] = {0.035f, 0.035f}; + static float default_action[2] = {0.1f, 0.05f}; + + static float default_title_center[2] = {0.175f, 0.05f}; + static float default_action_center[2] = {0.15f, 0.05f}; + + srna = RNA_def_struct(brna, "DisplaySafeAreas", NULL); + RNA_def_struct_ui_text(srna, "Safe Areas", "Safe Areas used in 3D view and the VSE"); + RNA_def_struct_sdna(srna, "DisplaySafeAreas"); + + /* SAFE AREAS */ + prop = RNA_def_property(srna, "title", PROP_FLOAT, PROP_XYZ); + RNA_def_property_float_sdna(prop, NULL, "title"); + RNA_def_property_array(prop, 2); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_float_array_default(prop, default_title); + RNA_def_property_ui_text(prop, "Title Safe margins", "Safe area for text and graphics"); + RNA_def_property_update(prop, NC_SCENE | ND_DRAW_RENDER_VIEWPORT, NULL); + + prop = RNA_def_property(srna, "action", PROP_FLOAT, PROP_XYZ); + RNA_def_property_float_sdna(prop, NULL, "action"); + RNA_def_property_array(prop, 2); + RNA_def_property_float_array_default(prop, default_action); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Action Safe Margins", "Safe area for general elements"); + RNA_def_property_update(prop, NC_SCENE | ND_DRAW_RENDER_VIEWPORT, NULL); + + + prop = RNA_def_property(srna, "title_center", PROP_FLOAT, PROP_XYZ); + RNA_def_property_float_sdna(prop, NULL, "title_center"); + RNA_def_property_array(prop, 2); + RNA_def_property_float_array_default(prop, default_title_center); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Center Title Safe Margins", "Safe area for text and graphics in a different aspect ratio"); + RNA_def_property_update(prop, NC_SCENE | ND_DRAW_RENDER_VIEWPORT, NULL); + + prop = RNA_def_property(srna, "action_center", PROP_FLOAT, PROP_XYZ); + RNA_def_property_float_sdna(prop, NULL, "action_center"); + RNA_def_property_array(prop, 2); + RNA_def_property_float_array_default(prop, default_action_center); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Center Action Safe Margins", "Safe area for general elements in a different aspect ratio"); + RNA_def_property_update(prop, NC_SCENE | ND_DRAW_RENDER_VIEWPORT, NULL); +} void RNA_def_scene(BlenderRNA *brna) @@ -5685,6 +5734,13 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_struct_type(prop, "RenderSettings"); RNA_def_property_ui_text(prop, "Render Data", ""); + /* Safe Areas */ + prop = RNA_def_property(srna, "safe_areas", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "safe_areas"); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "DisplaySafeAreas"); + RNA_def_property_ui_text(prop, "Safe Areas", ""); + /* Markers */ prop = RNA_def_property(srna, "timeline_markers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "markers", NULL); @@ -5799,6 +5855,7 @@ void RNA_def_scene(BlenderRNA *brna) rna_def_scene_game_data(brna); rna_def_transform_orientation(brna); rna_def_selected_uv_element(brna); + rna_def_display_safe_areas(brna); RNA_define_animate_sdna(true); /* *** Animated *** */ rna_def_scene_render_data(brna); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index d1d39d65913..58476c43b73 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2570,11 +2570,16 @@ static void rna_def_space_sequencer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Separate Colors", "Separate color channels in preview"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); - prop = RNA_def_property(srna, "show_safe_margin", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_DRAW_SAFE_MARGINS); - RNA_def_property_ui_text(prop, "Safe Margin", "Draw title safe margins in preview"); + prop = RNA_def_property(srna, "show_safe_areas", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_SHOW_SAFE_MARGINS); + RNA_def_property_ui_text(prop, "Safe Areas", "Show TV title safe and action safe areas in preview"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); - + + prop = RNA_def_property(srna, "show_safe_center", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_SHOW_SAFE_CENTER); + RNA_def_property_ui_text(prop, "Center-Cut Safe Areas", "Show safe areas to fit content in a different aspect ratio"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); + prop = RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SEQ_DRAWFRAMES); RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames"); |