Add ui::expandWindow() to change the size of a window dynamically

This commit is contained in:
David Capello 2021-03-02 08:38:53 -03:00
parent b163b7be48
commit f70e8d3ae7
5 changed files with 21 additions and 20 deletions

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2019-2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -903,10 +903,7 @@ private:
}
void resize() {
gfx::Size reqSize = sizeHint();
moveWindow(gfx::Rect(origin(), reqSize));
layout();
invalidate();
expandWindow(sizeHint());
}
void updateExportButton() {

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2019-2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -352,10 +352,7 @@ private:
}
void resize() {
gfx::Size reqSize = sizeHint();
moveWindow(gfx::Rect(origin(), reqSize));
layout();
invalidate();
expandWindow(sizeHint());
}
Context* m_context;

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2018-2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -154,13 +154,8 @@ void NewFileCommand::onExecute(Context* ctx)
window.advancedCheck()->setSelected(advanced);
window.advancedCheck()->Click.connect(
[&]{
gfx::Rect bounds = window.bounds();
window.advanced()->setVisible(window.advancedCheck()->isSelected());
window.setBounds(gfx::Rect(window.bounds().origin(),
window.sizeHint()));
window.layout();
window.manager()->invalidateRect(bounds);
window.expandWindow(window.sizeHint());
});
window.advanced()->setVisible(advanced);
if (advanced)

View File

@ -285,11 +285,10 @@ void Window::remapWindow()
{
if (m_isAutoRemap) {
m_isAutoRemap = false;
this->setVisible(true);
setVisible(true);
}
setBounds(Rect(Point(bounds().x, bounds().y),
sizeHint()));
expandWindow(sizeHint());
// load layout
loadLayout();
@ -323,6 +322,16 @@ void Window::moveWindow(const gfx::Rect& rect)
moveWindow(rect, true);
}
void Window::expandWindow(const gfx::Size& size)
{
const gfx::Rect oldBounds = bounds();
setBounds(gfx::Rect(bounds().origin(), size));
layout();
manager()->invalidateRect(oldBounds);
}
void Window::openWindow()
{
if (!parent()) {

View File

@ -44,6 +44,9 @@ namespace ui {
void positionWindow(int x, int y);
void moveWindow(const gfx::Rect& rect);
// Expands or shrink the window to the given side (generally sizeHint())
void expandWindow(const gfx::Size& size);
void openWindow();
void openWindowInForeground();
void closeWindow(Widget* closer);