mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-06 06:58:15 +00:00
Add ui::expandWindow() to change the size of a window dynamically
This commit is contained in:
parent
b163b7be48
commit
f70e8d3ae7
@ -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() {
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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()) {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user