mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-01 18:00:26 +00:00
Add Widget::setMinMaxSize() to set min/max size at the same time (fix #3652)
This commit is contained in:
parent
0775b0d8ba
commit
98f2964f6f
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -303,8 +303,9 @@ ColorBar::ColorBar(int align, TooltipManager* tooltipManager)
|
||||
|
||||
for (auto w : { &m_editPal, &m_buttons,
|
||||
&m_tilesButton, &m_tilesetModeButtons }) {
|
||||
w->setMinSize(gfx::Size(0, theme->dimensions.colorBarButtonsHeight()));
|
||||
w->setMaxSize(gfx::Size(std::numeric_limits<int>::max(),
|
||||
w->setMinMaxSize(
|
||||
gfx::Size(0, theme->dimensions.colorBarButtonsHeight()),
|
||||
gfx::Size(std::numeric_limits<int>::max(),
|
||||
theme->dimensions.colorBarButtonsHeight())); // TODO add resetMaxSize
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -911,9 +911,10 @@ void StatusBar::onInitTheme(ui::InitThemeEvent& ev)
|
||||
auto theme = SkinTheme::get(this);
|
||||
setBgColor(theme->colors.statusBarFace());
|
||||
setBorder(gfx::Border(6*guiscale(), 0, 6*guiscale(), 0));
|
||||
setMinSize(Size(0, textHeight()+8*guiscale()));
|
||||
setMaxSize(Size(std::numeric_limits<int>::max(),
|
||||
textHeight()+8*guiscale()));
|
||||
setMinMaxSize(
|
||||
Size(0, textHeight()+8*guiscale()),
|
||||
Size(std::numeric_limits<int>::max(),
|
||||
textHeight()+8*guiscale()));
|
||||
|
||||
m_newFrame->setStyle(theme->styles.newFrameButton());
|
||||
m_commandsBox->setBorder(gfx::Border(2, 1, 2, 2)*guiscale());
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -642,14 +642,12 @@ void WidgetLoader::fillWidgetWithXmlElementAttributes(const TiXmlElement* elem,
|
||||
const int maxh = (maxheight ? strtol(maxheight, NULL, 10): 0);
|
||||
widget->InitTheme.connect(
|
||||
[widget, minw, minh, maxw, maxh]{
|
||||
widget->setMinSize(gfx::Size(0, 0));
|
||||
widget->setMaxSize(gfx::Size(std::numeric_limits<int>::max(),
|
||||
std::numeric_limits<int>::max()));
|
||||
widget->resetMinSize();
|
||||
widget->resetMaxSize();
|
||||
const gfx::Size reqSize = widget->sizeHint();
|
||||
widget->setMinSize(
|
||||
widget->setMinMaxSize(
|
||||
gfx::Size((minw > 0 ? guiscale()*minw: reqSize.w),
|
||||
(minh > 0 ? guiscale()*minh: reqSize.h)));
|
||||
widget->setMaxSize(
|
||||
(minh > 0 ? guiscale()*minh: reqSize.h)),
|
||||
gfx::Size((maxw > 0 ? guiscale()*maxw: std::numeric_limits<int>::max()),
|
||||
(maxh > 0 ? guiscale()*maxh: std::numeric_limits<int>::max())));
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -1034,6 +1034,15 @@ void Widget::setMaxSize(const gfx::Size& sz)
|
||||
m_maxSize = sz;
|
||||
}
|
||||
|
||||
void Widget::setMinMaxSize(const gfx::Size& minSz,
|
||||
const gfx::Size& maxSz)
|
||||
{
|
||||
ASSERT(minSz.w <= maxSz.w);
|
||||
ASSERT(minSz.h <= maxSz.h);
|
||||
m_minSize = minSz;
|
||||
m_maxSize = maxSz;
|
||||
}
|
||||
|
||||
void Widget::resetMinSize()
|
||||
{
|
||||
m_minSize = gfx::Size(0, 0);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -260,6 +260,7 @@ namespace ui {
|
||||
const gfx::Size& maxSize() const { return m_maxSize; }
|
||||
void setMinSize(const gfx::Size& sz);
|
||||
void setMaxSize(const gfx::Size& sz);
|
||||
void setMinMaxSize(const gfx::Size& minSz, const gfx::Size& maxSz);
|
||||
void resetMinSize();
|
||||
void resetMaxSize();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user