mirror of
https://github.com/minetest/irrlicht.git
synced 2025-07-01 15:50:27 +02:00
Reformat the code, using:
find -type f | # list all regular files grep -E '\.(h|cpp|mm)$' | # filter for source files grep -v '/mt_' | # filter out generated files grep -v '/vendor/' | # and vendored GL grep -v '/test/image_loader_test.cpp' | # and this file (has giant literals arrays) xargs -n 1 -P $(nproc) clang-format -i # reformat everything Co-authored-by: numzero <numzer0@yandex.ru>
This commit is contained in:
@ -16,47 +16,35 @@ namespace gui
|
||||
{
|
||||
|
||||
//! constructor
|
||||
CGUICheckBox::CGUICheckBox(bool checked, IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
|
||||
: IGUICheckBox(environment, parent, id, rectangle), CheckTime(0), Pressed(false), Checked(checked)
|
||||
, Border(false), Background(false)
|
||||
CGUICheckBox::CGUICheckBox(bool checked, IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect<s32> rectangle) :
|
||||
IGUICheckBox(environment, parent, id, rectangle), CheckTime(0), Pressed(false), Checked(checked), Border(false), Background(false)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CGUICheckBox");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// this element can be tabbed into
|
||||
setTabStop(true);
|
||||
setTabOrder(-1);
|
||||
}
|
||||
|
||||
|
||||
//! called if an event happened.
|
||||
bool CGUICheckBox::OnEvent(const SEvent& event)
|
||||
bool CGUICheckBox::OnEvent(const SEvent &event)
|
||||
{
|
||||
if (isEnabled())
|
||||
{
|
||||
switch(event.EventType)
|
||||
{
|
||||
if (isEnabled()) {
|
||||
switch (event.EventType) {
|
||||
case EET_KEY_INPUT_EVENT:
|
||||
if (event.KeyInput.PressedDown &&
|
||||
(event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE))
|
||||
{
|
||||
(event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE)) {
|
||||
Pressed = true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (Pressed && event.KeyInput.PressedDown && event.KeyInput.Key == KEY_ESCAPE)
|
||||
{
|
||||
} else if (Pressed && event.KeyInput.PressedDown && event.KeyInput.Key == KEY_ESCAPE) {
|
||||
Pressed = false;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (!event.KeyInput.PressedDown && Pressed &&
|
||||
(event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE))
|
||||
{
|
||||
} else if (!event.KeyInput.PressedDown && Pressed &&
|
||||
(event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE)) {
|
||||
Pressed = false;
|
||||
if (Parent)
|
||||
{
|
||||
if (Parent) {
|
||||
SEvent newEvent;
|
||||
newEvent.EventType = EET_GUI_EVENT;
|
||||
newEvent.GUIEvent.Caller = this;
|
||||
@ -69,29 +57,22 @@ bool CGUICheckBox::OnEvent(const SEvent& event)
|
||||
}
|
||||
break;
|
||||
case EET_GUI_EVENT:
|
||||
if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST)
|
||||
{
|
||||
if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) {
|
||||
if (event.GUIEvent.Caller == this)
|
||||
Pressed = false;
|
||||
}
|
||||
break;
|
||||
case EET_MOUSE_INPUT_EVENT:
|
||||
if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
|
||||
{
|
||||
if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) {
|
||||
Pressed = true;
|
||||
CheckTime = os::Timer::getTime();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP)
|
||||
{
|
||||
} else if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) {
|
||||
bool wasPressed = Pressed;
|
||||
Pressed = false;
|
||||
|
||||
if (wasPressed && Parent)
|
||||
{
|
||||
if ( !AbsoluteClippingRect.isPointInside( core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y) ) )
|
||||
{
|
||||
if (wasPressed && Parent) {
|
||||
if (!AbsoluteClippingRect.isPointInside(core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y))) {
|
||||
Pressed = false;
|
||||
return true;
|
||||
}
|
||||
@ -116,29 +97,25 @@ bool CGUICheckBox::OnEvent(const SEvent& event)
|
||||
return IGUIElement::OnEvent(event);
|
||||
}
|
||||
|
||||
|
||||
//! draws the element and its children
|
||||
void CGUICheckBox::draw()
|
||||
{
|
||||
if (!IsVisible)
|
||||
return;
|
||||
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
if (skin)
|
||||
{
|
||||
video::IVideoDriver* driver = Environment->getVideoDriver();
|
||||
IGUISkin *skin = Environment->getSkin();
|
||||
if (skin) {
|
||||
video::IVideoDriver *driver = Environment->getVideoDriver();
|
||||
core::rect<s32> frameRect(AbsoluteRect);
|
||||
|
||||
// draw background
|
||||
if (Background)
|
||||
{
|
||||
if (Background) {
|
||||
video::SColor bgColor = skin->getColor(gui::EGDC_3D_FACE);
|
||||
driver->draw2DRectangle(bgColor, frameRect, &AbsoluteClippingRect);
|
||||
}
|
||||
|
||||
// draw the border
|
||||
if (Border)
|
||||
{
|
||||
if (Border) {
|
||||
skin->draw3DSunkenPane(this, 0, true, false, frameRect, &AbsoluteClippingRect);
|
||||
frameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X);
|
||||
frameRect.LowerRightCorner.X -= skin->getSize(EGDS_TEXT_DISTANCE_X);
|
||||
@ -148,34 +125,31 @@ void CGUICheckBox::draw()
|
||||
|
||||
// the rectangle around the "checked" area.
|
||||
core::rect<s32> checkRect(frameRect.UpperLeftCorner.X,
|
||||
((frameRect.getHeight() - height) / 2) + frameRect.UpperLeftCorner.Y,
|
||||
0, 0);
|
||||
((frameRect.getHeight() - height) / 2) + frameRect.UpperLeftCorner.Y,
|
||||
0, 0);
|
||||
|
||||
checkRect.LowerRightCorner.X = checkRect.UpperLeftCorner.X + height;
|
||||
checkRect.LowerRightCorner.Y = checkRect.UpperLeftCorner.Y + height;
|
||||
|
||||
EGUI_DEFAULT_COLOR col = EGDC_GRAY_EDITABLE;
|
||||
if ( isEnabled() )
|
||||
if (isEnabled())
|
||||
col = Pressed ? EGDC_FOCUSED_EDITABLE : EGDC_EDITABLE;
|
||||
skin->draw3DSunkenPane(this, skin->getColor(col),
|
||||
false, true, checkRect, &AbsoluteClippingRect);
|
||||
false, true, checkRect, &AbsoluteClippingRect);
|
||||
|
||||
// the checked icon
|
||||
if (Checked)
|
||||
{
|
||||
if (Checked) {
|
||||
skin->drawIcon(this, EGDI_CHECK_BOX_CHECKED, checkRect.getCenter(),
|
||||
CheckTime, os::Timer::getTime(), false, &AbsoluteClippingRect);
|
||||
CheckTime, os::Timer::getTime(), false, &AbsoluteClippingRect);
|
||||
}
|
||||
|
||||
// associated text
|
||||
if (Text.size())
|
||||
{
|
||||
if (Text.size()) {
|
||||
checkRect = frameRect;
|
||||
checkRect.UpperLeftCorner.X += height + 5;
|
||||
|
||||
IGUIFont* font = skin->getFont();
|
||||
if (font)
|
||||
{
|
||||
IGUIFont *font = skin->getFont();
|
||||
if (font) {
|
||||
font->draw(Text.c_str(), checkRect,
|
||||
skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), false, true, &AbsoluteClippingRect);
|
||||
}
|
||||
@ -184,14 +158,12 @@ void CGUICheckBox::draw()
|
||||
IGUIElement::draw();
|
||||
}
|
||||
|
||||
|
||||
//! set if box is checked
|
||||
void CGUICheckBox::setChecked(bool checked)
|
||||
{
|
||||
Checked = checked;
|
||||
}
|
||||
|
||||
|
||||
//! returns if box is checked
|
||||
bool CGUICheckBox::isChecked() const
|
||||
{
|
||||
@ -222,6 +194,5 @@ bool CGUICheckBox::isDrawBorderEnabled() const
|
||||
return Border;
|
||||
}
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
Reference in New Issue
Block a user