Add expand stretch/ascpect - no more black bars
This commit is contained in:
parent
8a4bce6ebd
commit
b2ca500545
3 changed files with 8 additions and 6 deletions
|
@ -1275,6 +1275,8 @@ bool Main::start() {
|
|||
sml_aspect = SceneTree::STRETCH_ASPECT_KEEP_WIDTH;
|
||||
else if (stretch_aspect == "keep_height")
|
||||
sml_aspect = SceneTree::STRETCH_ASPECT_KEEP_HEIGHT;
|
||||
else if (stretch_aspect == "expand")
|
||||
sml_aspect = SceneTree::STRETCH_ASPECT_EXPAND;
|
||||
|
||||
sml->set_screen_stretch(sml_sm, sml_aspect, stretch_size, stretch_shrink);
|
||||
|
||||
|
@ -1302,7 +1304,7 @@ bool Main::start() {
|
|||
GLOBAL_DEF("display/window/stretch/mode", "disabled");
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/mode", PropertyInfo(Variant::STRING, "display/window/stretch/mode", PROPERTY_HINT_ENUM, "disabled,2d,viewport"));
|
||||
GLOBAL_DEF("display/window/stretch/aspect", "ignore");
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/aspect", PropertyInfo(Variant::STRING, "display/window/stretch/aspect", PROPERTY_HINT_ENUM, "ignore,keep,keep_width,keep_height"));
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/aspect", PropertyInfo(Variant::STRING, "display/window/stretch/aspect", PROPERTY_HINT_ENUM, "ignore,keep,keep_width,keep_height,expand"));
|
||||
GLOBAL_DEF("display/window/stretch/shrink", 1);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/shrink", PropertyInfo(Variant::STRING, "display/window/stretch/shrink", PROPERTY_HINT_RANGE, "1,8,1"));
|
||||
sml->set_auto_accept_quit(GLOBAL_DEF("application/config/auto_accept_quit", true));
|
||||
|
|
|
@ -1181,7 +1181,7 @@ void SceneTree::_update_root_rect() {
|
|||
} else if (viewport_aspect < video_mode_aspect) {
|
||||
// screen ratio is smaller vertically
|
||||
|
||||
if (stretch_aspect == STRETCH_ASPECT_KEEP_HEIGHT) {
|
||||
if (stretch_aspect == STRETCH_ASPECT_KEEP_HEIGHT || stretch_aspect == STRETCH_ASPECT_EXPAND) {
|
||||
|
||||
//will stretch horizontally
|
||||
viewport_size.x = desired_res.y * video_mode_aspect;
|
||||
|
@ -1196,7 +1196,7 @@ void SceneTree::_update_root_rect() {
|
|||
}
|
||||
} else {
|
||||
//screen ratio is smaller horizontally
|
||||
if (stretch_aspect == STRETCH_ASPECT_KEEP_WIDTH) {
|
||||
if (stretch_aspect == STRETCH_ASPECT_KEEP_WIDTH || stretch_aspect == STRETCH_ASPECT_EXPAND) {
|
||||
|
||||
//will stretch horizontally
|
||||
viewport_size.x = desired_res.x;
|
||||
|
@ -1217,12 +1217,11 @@ void SceneTree::_update_root_rect() {
|
|||
Size2 margin;
|
||||
Size2 offset;
|
||||
//black bars and margin
|
||||
if (screen_size.x < video_mode.x) {
|
||||
if (stretch_aspect != STRETCH_ASPECT_EXPAND && screen_size.x < video_mode.x) {
|
||||
margin.x = Math::round((video_mode.x - screen_size.x) / 2.0);
|
||||
VisualServer::get_singleton()->black_bars_set_margins(margin.x, 0, margin.x, 0);
|
||||
offset.x = Math::round(margin.x * viewport_size.y / screen_size.y);
|
||||
} else if (screen_size.y < video_mode.y) {
|
||||
|
||||
} else if (stretch_aspect != STRETCH_ASPECT_EXPAND && screen_size.y < video_mode.y) {
|
||||
margin.y = Math::round((video_mode.y - screen_size.y) / 2.0);
|
||||
VisualServer::get_singleton()->black_bars_set_margins(0, margin.y, 0, margin.y);
|
||||
offset.y = Math::round(margin.y * viewport_size.x / screen_size.x);
|
||||
|
|
|
@ -90,6 +90,7 @@ public:
|
|||
STRETCH_ASPECT_KEEP,
|
||||
STRETCH_ASPECT_KEEP_WIDTH,
|
||||
STRETCH_ASPECT_KEEP_HEIGHT,
|
||||
STRETCH_ASPECT_EXPAND,
|
||||
};
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue