diff --git a/src/app/modules/gui.cpp b/src/app/modules/gui.cpp index 8dbf2b3c4..1f46f433f 100644 --- a/src/app/modules/gui.cpp +++ b/src/app/modules/gui.cpp @@ -36,6 +36,7 @@ #include "app/ui/status_bar.h" #include "app/ui/toolbar.h" #include "app/ui_context.h" +#include "base/clamp.h" #include "base/fs.h" #include "base/memory.h" #include "base/shared_ptr.h" @@ -263,7 +264,8 @@ void update_screen_for_document(const Doc* document) } } -void load_window_pos(Widget* window, const char *section) +void load_window_pos(Widget* window, const char* section, + const bool limitMinSize) { // Default position Rect orig_pos = window->bounds(); @@ -272,11 +274,17 @@ void load_window_pos(Widget* window, const char *section) // Load configurated position pos = get_config_rect(section, "WindowPos", pos); - pos.w = MID(orig_pos.w, pos.w, ui::display_w()); - pos.h = MID(orig_pos.h, pos.h, ui::display_h()); + if (limitMinSize) { + pos.w = base::clamp(pos.w, orig_pos.w, ui::display_w()); + pos.h = base::clamp(pos.h, orig_pos.h, ui::display_h()); + } + else { + pos.w = std::min(pos.w, ui::display_w()); + pos.h = std::min(pos.h, ui::display_h()); + } - pos.setOrigin(Point(MID(0, pos.x, ui::display_w()-pos.w), - MID(0, pos.y, ui::display_h()-pos.h))); + pos.setOrigin(Point(base::clamp(pos.x, 0, ui::display_w()-pos.w), + base::clamp(pos.y, 0, ui::display_h()-pos.h))); window->setBounds(pos); } diff --git a/src/app/modules/gui.h b/src/app/modules/gui.h index 29053aeaa..e7b88804c 100644 --- a/src/app/modules/gui.h +++ b/src/app/modules/gui.h @@ -1,4 +1,5 @@ // Aseprite +// Copyright (C) 2018 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -36,8 +37,9 @@ namespace app { void update_screen_for_document(const Doc* document); - void load_window_pos(ui::Widget* window, const char *section); - void save_window_pos(ui::Widget* window, const char *section); + void load_window_pos(ui::Widget* window, const char* section, + const bool limitMinSize = true); + void save_window_pos(ui::Widget* window, const char* section); ui::Widget* setup_mini_font(ui::Widget* widget); ui::Widget* setup_mini_look(ui::Widget* widget); diff --git a/src/app/ui/preview_editor.cpp b/src/app/ui/preview_editor.cpp index ff3267955..e39ecd514 100644 --- a/src/app/ui/preview_editor.cpp +++ b/src/app/ui/preview_editor.cpp @@ -1,4 +1,5 @@ // Aseprite +// Copyright (C) 2018 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -231,7 +232,7 @@ bool PreviewEditorWindow::onProcessMessage(ui::Message* msg) ui::display_h() - height - StatusBar::instance()->bounds().h - extra, width, height)); - load_window_pos(this, "MiniEditor"); + load_window_pos(this, "MiniEditor", false); invalidate(); } break;