Apply clang-format to code base

This commit is contained in:
clang-format-bot 2022-09-22 21:26:05 +03:00 committed by ζeh Matt
parent f37d0be806
commit ddb0522bbf
No known key found for this signature in database
GPG key ID: 18CE582C71A225B0
2199 changed files with 118692 additions and 114392 deletions

View file

@ -9,36 +9,36 @@ namespace Gui
// If the 3.4.2 become a required minimum version, the ComboBox class may be removed.
void ComboBox::setPropertyOverride(const std::string& _key, const std::string& _value)
{
#if MYGUI_VERSION >= MYGUI_DEFINE_VERSION(3,4,2)
MyGUI::ComboBox::setPropertyOverride (_key, _value);
#if MYGUI_VERSION >= MYGUI_DEFINE_VERSION(3, 4, 2)
MyGUI::ComboBox::setPropertyOverride(_key, _value);
#else
if (_key == "AddItem")
{
const std::string value = MyGUI::LanguageManager::getInstance().replaceTags(_value);
MyGUI::ComboBox::setPropertyOverride (_key, value);
MyGUI::ComboBox::setPropertyOverride(_key, value);
}
else
{
MyGUI::ComboBox::setPropertyOverride (_key, _value);
MyGUI::ComboBox::setPropertyOverride(_key, _value);
}
#endif
}
void AutoSizedWidget::notifySizeChange (MyGUI::Widget* w)
void AutoSizedWidget::notifySizeChange(MyGUI::Widget* w)
{
MyGUI::Widget * parent = w->getParent();
MyGUI::Widget* parent = w->getParent();
if (parent != nullptr)
{
if (mExpandDirection.isLeft())
{
int hdiff = getRequestedSize ().width - w->getSize().width;
int hdiff = getRequestedSize().width - w->getSize().width;
w->setPosition(w->getPosition() - MyGUI::IntPoint(hdiff, 0));
}
w->setSize(getRequestedSize ());
w->setSize(getRequestedSize());
while (parent != nullptr)
{
Box * b = dynamic_cast<Box*>(parent);
Box* b = dynamic_cast<Box*>(parent);
if (b)
b->notifyChildrenSizeChanged();
else
@ -48,28 +48,27 @@ namespace Gui
}
}
MyGUI::IntSize AutoSizedTextBox::getRequestedSize()
{
return getCaption().empty() ? MyGUI::IntSize{0, 0} : getTextSize();
return getCaption().empty() ? MyGUI::IntSize{ 0, 0 } : getTextSize();
}
void AutoSizedTextBox::setCaption(const MyGUI::UString& _value)
{
TextBox::setCaption(_value);
notifySizeChange (this);
notifySizeChange(this);
}
void AutoSizedTextBox::setPropertyOverride(const std::string& _key, const std::string& _value)
{
if (_key == "ExpandDirection")
{
mExpandDirection = MyGUI::Align::parse (_value);
mExpandDirection = MyGUI::Align::parse(_value);
}
else
{
Gui::TextBox::setPropertyOverride (_key, _value);
Gui::TextBox::setPropertyOverride(_key, _value);
}
}
@ -80,12 +79,13 @@ namespace Gui
if (mShrink)
{
// MyGUI needs to know the widget size for wordwrapping, but we will know the widget size only after wordwrapping.
// To solve this issue, use the maximum tooltip width first for wordwrapping, then resize widget to its actual used space.
// MyGUI needs to know the widget size for wordwrapping, but we will know the widget size only after
// wordwrapping. To solve this issue, use the maximum tooltip width first for wordwrapping, then resize
// widget to its actual used space.
if (mWasResized)
{
int maxLineWidth = 0;
const MyGUI::VectorLineInfo & lines = getSubWidgetText()->castType<MyGUI::EditText>()->getLineInfo();
const MyGUI::VectorLineInfo& lines = getSubWidgetText()->castType<MyGUI::EditText>()->getLineInfo();
for (unsigned int i = 0; i < lines.size(); ++i)
maxLineWidth = std::max(maxLineWidth, lines[i].width);
@ -112,7 +112,7 @@ namespace Gui
EditBox::setCaption(_value);
mWasResized = false;
notifySizeChange (this);
notifySizeChange(this);
}
void AutoSizedEditBox::initialiseOverride()
@ -127,7 +127,7 @@ namespace Gui
{
if (_key == "ExpandDirection")
{
mExpandDirection = MyGUI::Align::parse (_value);
mExpandDirection = MyGUI::Align::parse(_value);
}
else if (_key == "Shrink")
{
@ -135,7 +135,7 @@ namespace Gui
}
else
{
Gui::EditBox::setPropertyOverride (_key, _value);
Gui::EditBox::setPropertyOverride(_key, _value);
}
}
@ -145,7 +145,7 @@ namespace Gui
if (isUserString("TextPadding"))
padding = MyGUI::IntSize::parse(getUserString("TextPadding"));
MyGUI::IntSize size = getTextSize() + MyGUI::IntSize(padding.width,padding.height);
MyGUI::IntSize size = getTextSize() + MyGUI::IntSize(padding.width, padding.height);
return size;
}
@ -153,18 +153,18 @@ namespace Gui
{
Button::setCaption(_value);
notifySizeChange (this);
notifySizeChange(this);
}
void AutoSizedButton::setPropertyOverride(const std::string& _key, const std::string& _value)
{
if (_key == "ExpandDirection")
{
mExpandDirection = MyGUI::Align::parse (_value);
mExpandDirection = MyGUI::Align::parse(_value);
}
else
{
Gui::Button::setPropertyOverride (_key, _value);
Gui::Button::setPropertyOverride(_key, _value);
}
}
Box::Box()
@ -174,7 +174,7 @@ namespace Gui
{
}
void Box::notifyChildrenSizeChanged ()
void Box::notifyChildrenSizeChanged()
{
align();
}
@ -193,19 +193,19 @@ namespace Gui
return true;
}
void HBox::align ()
void HBox::align()
{
unsigned int count = getChildCount ();
unsigned int count = getChildCount();
size_t h_stretched_count = 0;
int total_width = 0;
int total_height = 0;
std::vector< std::pair<MyGUI::IntSize, bool> > sizes;
std::vector<std::pair<MyGUI::IntSize, bool>> sizes;
sizes.resize(count);
for (unsigned int i = 0; i < count; ++i)
{
MyGUI::Widget* w = getChildAt(i);
bool hstretch = w->getUserString ("HStretch") == "true";
bool hstretch = w->getUserString("HStretch") == "true";
bool hidden = w->getUserString("Hidden") == "true";
if (hidden)
continue;
@ -213,9 +213,9 @@ namespace Gui
AutoSizedWidget* aw = dynamic_cast<AutoSizedWidget*>(w);
if (aw)
{
sizes[i] = std::make_pair(aw->getRequestedSize (), hstretch);
total_width += aw->getRequestedSize ().width;
total_height = std::max(total_height, aw->getRequestedSize ().height);
sizes[i] = std::make_pair(aw->getRequestedSize(), hstretch);
total_width += aw->getRequestedSize().width;
total_height = std::max(total_height, aw->getRequestedSize().height);
}
else
{
@ -225,19 +225,20 @@ namespace Gui
total_height = std::max(total_height, w->getSize().height);
}
if (i != count-1)
if (i != count - 1)
total_width += mSpacing;
}
if (mAutoResize && (total_width+mPadding*2 != getClientCoord().width || total_height+mPadding*2 != getClientCoord().height))
if (mAutoResize
&& (total_width + mPadding * 2 != getClientCoord().width
|| total_height + mPadding * 2 != getClientCoord().height))
{
int xmargin = getSize().width - getClientCoord().width;
int ymargin = getSize().height - getClientCoord().height;
setSize(MyGUI::IntSize(total_width+mPadding*2 + xmargin, total_height+mPadding*2 + ymargin));
setSize(MyGUI::IntSize(total_width + mPadding * 2 + xmargin, total_height + mPadding * 2 + ymargin));
return;
}
int curX = 0;
for (unsigned int i = 0; i < count; ++i)
{
@ -250,20 +251,21 @@ namespace Gui
if (hidden)
continue;
bool vstretch = w->getUserString ("VStretch") == "true";
int max_height = getClientCoord().height - mPadding*2;
bool vstretch = w->getUserString("VStretch") == "true";
int max_height = getClientCoord().height - mPadding * 2;
int height = vstretch ? max_height : sizes[i].first.height;
MyGUI::IntCoord widgetCoord;
widgetCoord.left = curX;
widgetCoord.top = mPadding + (getClientCoord().height-mPadding*2 - height) / 2;
widgetCoord.top = mPadding + (getClientCoord().height - mPadding * 2 - height) / 2;
int width = 0;
if (sizes[i].second)
{
if (h_stretched_count == 0)
throw std::logic_error("unexpected");
width = sizes[i].first.width + (getClientCoord().width-mPadding*2 - total_width)/h_stretched_count;
width
= sizes[i].first.width + (getClientCoord().width - mPadding * 2 - total_width) / h_stretched_count;
}
else
width = sizes[i].first.width;
@ -273,26 +275,26 @@ namespace Gui
w->setCoord(widgetCoord);
curX += width;
if (i != count-1)
if (i != count - 1)
curX += mSpacing;
}
}
void HBox::setPropertyOverride(const std::string& _key, const std::string& _value)
{
if (!Box::_setPropertyImpl (_key, _value))
if (!Box::_setPropertyImpl(_key, _value))
MyGUI::Widget::setPropertyOverride(_key, _value);
}
void HBox::setSize (const MyGUI::IntSize& _value)
void HBox::setSize(const MyGUI::IntSize& _value)
{
MyGUI::Widget::setSize (_value);
MyGUI::Widget::setSize(_value);
align();
}
void HBox::setCoord (const MyGUI::IntCoord& _value)
void HBox::setCoord(const MyGUI::IntCoord& _value)
{
MyGUI::Widget::setCoord (_value);
MyGUI::Widget::setCoord(_value);
align();
}
@ -309,10 +311,10 @@ namespace Gui
align();
}
MyGUI::IntSize HBox::getRequestedSize ()
MyGUI::IntSize HBox::getRequestedSize()
{
MyGUI::IntSize size(0,0);
for (unsigned int i = 0; i < getChildCount (); ++i)
MyGUI::IntSize size(0, 0);
for (unsigned int i = 0; i < getChildCount(); ++i)
{
bool hidden = getChildAt(i)->getUserString("Hidden") == "true";
if (hidden)
@ -321,39 +323,36 @@ namespace Gui
AutoSizedWidget* w = dynamic_cast<AutoSizedWidget*>(getChildAt(i));
if (w)
{
MyGUI::IntSize requested = w->getRequestedSize ();
MyGUI::IntSize requested = w->getRequestedSize();
size.height = std::max(size.height, requested.height);
size.width = size.width + requested.width;
if (i != getChildCount()-1)
if (i != getChildCount() - 1)
size.width += mSpacing;
}
else
{
MyGUI::IntSize requested = getChildAt(i)->getSize ();
MyGUI::IntSize requested = getChildAt(i)->getSize();
size.height = std::max(size.height, requested.height);
if (getChildAt(i)->getUserString("HStretch") != "true")
size.width = size.width + requested.width;
if (i != getChildCount()-1)
if (i != getChildCount() - 1)
size.width += mSpacing;
}
size.height += mPadding*2;
size.width += mPadding*2;
size.height += mPadding * 2;
size.width += mPadding * 2;
}
return size;
}
void VBox::align ()
void VBox::align()
{
unsigned int count = getChildCount ();
unsigned int count = getChildCount();
size_t v_stretched_count = 0;
int total_height = 0;
int total_width = 0;
std::vector< std::pair<MyGUI::IntSize, bool> > sizes;
std::vector<std::pair<MyGUI::IntSize, bool>> sizes;
sizes.resize(count);
for (unsigned int i = 0; i < count; ++i)
{
@ -363,14 +362,14 @@ namespace Gui
if (hidden)
continue;
bool vstretch = w->getUserString ("VStretch") == "true";
bool vstretch = w->getUserString("VStretch") == "true";
v_stretched_count += vstretch;
AutoSizedWidget* aw = dynamic_cast<AutoSizedWidget*>(w);
if (aw)
{
sizes[i] = std::make_pair(aw->getRequestedSize (), vstretch);
total_height += aw->getRequestedSize ().height;
total_width = std::max(total_width, aw->getRequestedSize ().width);
sizes[i] = std::make_pair(aw->getRequestedSize(), vstretch);
total_height += aw->getRequestedSize().height;
total_width = std::max(total_width, aw->getRequestedSize().width);
}
else
{
@ -381,22 +380,24 @@ namespace Gui
total_width = std::max(total_width, w->getSize().width);
}
if (i != count-1)
if (i != count - 1)
total_height += mSpacing;
}
if (mAutoResize && (total_width+mPadding*2 != getClientCoord().width || total_height+mPadding*2 != getClientCoord().height))
if (mAutoResize
&& (total_width + mPadding * 2 != getClientCoord().width
|| total_height + mPadding * 2 != getClientCoord().height))
{
int xmargin = getSize().width - getClientCoord().width;
int ymargin = getSize().height - getClientCoord().height;
setSize(MyGUI::IntSize(total_width+mPadding*2 + xmargin, total_height+mPadding*2 + ymargin));
setSize(MyGUI::IntSize(total_width + mPadding * 2 + xmargin, total_height + mPadding * 2 + ymargin));
return;
}
int curY = 0;
for (unsigned int i = 0; i < count; ++i)
{
if (i==0)
if (i == 0)
curY += mPadding;
MyGUI::Widget* w = getChildAt(i);
@ -405,20 +406,21 @@ namespace Gui
if (hidden)
continue;
bool hstretch = w->getUserString ("HStretch") == "true";
int maxWidth = getClientCoord().width - mPadding*2;
bool hstretch = w->getUserString("HStretch") == "true";
int maxWidth = getClientCoord().width - mPadding * 2;
int width = hstretch ? maxWidth : sizes[i].first.width;
MyGUI::IntCoord widgetCoord;
widgetCoord.top = curY;
widgetCoord.left = mPadding + (getClientCoord().width-mPadding*2 - width) / 2;
widgetCoord.left = mPadding + (getClientCoord().width - mPadding * 2 - width) / 2;
int height = 0;
if (sizes[i].second)
{
if (v_stretched_count == 0)
throw std::logic_error("unexpected");
height = sizes[i].first.height + (getClientCoord().height-mPadding*2 - total_height)/v_stretched_count;
height = sizes[i].first.height
+ (getClientCoord().height - mPadding * 2 - total_height) / v_stretched_count;
}
else
height = sizes[i].first.height;
@ -428,26 +430,26 @@ namespace Gui
w->setCoord(widgetCoord);
curY += height;
if (i != count-1)
if (i != count - 1)
curY += mSpacing;
}
}
void VBox::setPropertyOverride(const std::string& _key, const std::string& _value)
{
if (!Box::_setPropertyImpl (_key, _value))
if (!Box::_setPropertyImpl(_key, _value))
MyGUI::Widget::setPropertyOverride(_key, _value);
}
void VBox::setSize (const MyGUI::IntSize& _value)
void VBox::setSize(const MyGUI::IntSize& _value)
{
MyGUI::Widget::setSize (_value);
MyGUI::Widget::setSize(_value);
align();
}
void VBox::setCoord (const MyGUI::IntCoord& _value)
void VBox::setCoord(const MyGUI::IntCoord& _value)
{
MyGUI::Widget::setCoord (_value);
MyGUI::Widget::setCoord(_value);
align();
}
@ -459,10 +461,10 @@ namespace Gui
setWidgetClient(client);
}
MyGUI::IntSize VBox::getRequestedSize ()
MyGUI::IntSize VBox::getRequestedSize()
{
MyGUI::IntSize size(0,0);
for (unsigned int i = 0; i < getChildCount (); ++i)
MyGUI::IntSize size(0, 0);
for (unsigned int i = 0; i < getChildCount(); ++i)
{
bool hidden = getChildAt(i)->getUserString("Hidden") == "true";
if (hidden)
@ -471,25 +473,25 @@ namespace Gui
AutoSizedWidget* w = dynamic_cast<AutoSizedWidget*>(getChildAt(i));
if (w)
{
MyGUI::IntSize requested = w->getRequestedSize ();
MyGUI::IntSize requested = w->getRequestedSize();
size.width = std::max(size.width, requested.width);
size.height = size.height + requested.height;
if (i != getChildCount()-1)
if (i != getChildCount() - 1)
size.height += mSpacing;
}
else
{
MyGUI::IntSize requested = getChildAt(i)->getSize ();
MyGUI::IntSize requested = getChildAt(i)->getSize();
size.width = std::max(size.width, requested.width);
if (getChildAt(i)->getUserString("VStretch") != "true")
size.height = size.height + requested.height;
if (i != getChildCount()-1)
if (i != getChildCount() - 1)
size.height += mSpacing;
}
size.height += mPadding*2;
size.width += mPadding*2;
size.height += mPadding * 2;
size.width += mPadding * 2;
}
return size;
}