mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-18 11:42:47 +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
|
// Aseprite
|
||||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
// Copyright (C) 2019-2021 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -903,10 +903,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void resize() {
|
void resize() {
|
||||||
gfx::Size reqSize = sizeHint();
|
expandWindow(sizeHint());
|
||||||
moveWindow(gfx::Rect(origin(), reqSize));
|
|
||||||
layout();
|
|
||||||
invalidate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateExportButton() {
|
void updateExportButton() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
// Copyright (C) 2019-2021 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -352,10 +352,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void resize() {
|
void resize() {
|
||||||
gfx::Size reqSize = sizeHint();
|
expandWindow(sizeHint());
|
||||||
moveWindow(gfx::Rect(origin(), reqSize));
|
|
||||||
layout();
|
|
||||||
invalidate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Context* m_context;
|
Context* m_context;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -154,13 +154,8 @@ void NewFileCommand::onExecute(Context* ctx)
|
|||||||
window.advancedCheck()->setSelected(advanced);
|
window.advancedCheck()->setSelected(advanced);
|
||||||
window.advancedCheck()->Click.connect(
|
window.advancedCheck()->Click.connect(
|
||||||
[&]{
|
[&]{
|
||||||
gfx::Rect bounds = window.bounds();
|
|
||||||
window.advanced()->setVisible(window.advancedCheck()->isSelected());
|
window.advanced()->setVisible(window.advancedCheck()->isSelected());
|
||||||
window.setBounds(gfx::Rect(window.bounds().origin(),
|
window.expandWindow(window.sizeHint());
|
||||||
window.sizeHint()));
|
|
||||||
window.layout();
|
|
||||||
|
|
||||||
window.manager()->invalidateRect(bounds);
|
|
||||||
});
|
});
|
||||||
window.advanced()->setVisible(advanced);
|
window.advanced()->setVisible(advanced);
|
||||||
if (advanced)
|
if (advanced)
|
||||||
|
@ -285,11 +285,10 @@ void Window::remapWindow()
|
|||||||
{
|
{
|
||||||
if (m_isAutoRemap) {
|
if (m_isAutoRemap) {
|
||||||
m_isAutoRemap = false;
|
m_isAutoRemap = false;
|
||||||
this->setVisible(true);
|
setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
setBounds(Rect(Point(bounds().x, bounds().y),
|
expandWindow(sizeHint());
|
||||||
sizeHint()));
|
|
||||||
|
|
||||||
// load layout
|
// load layout
|
||||||
loadLayout();
|
loadLayout();
|
||||||
@ -323,6 +322,16 @@ void Window::moveWindow(const gfx::Rect& rect)
|
|||||||
moveWindow(rect, true);
|
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()
|
void Window::openWindow()
|
||||||
{
|
{
|
||||||
if (!parent()) {
|
if (!parent()) {
|
||||||
|
@ -44,6 +44,9 @@ namespace ui {
|
|||||||
void positionWindow(int x, int y);
|
void positionWindow(int x, int y);
|
||||||
void moveWindow(const gfx::Rect& rect);
|
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 openWindow();
|
||||||
void openWindowInForeground();
|
void openWindowInForeground();
|
||||||
void closeWindow(Widget* closer);
|
void closeWindow(Widget* closer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user