mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-01-24 13:58:00 -05:00
Reduce firmware size by refactoring global data defined in public headers. Each global variable which require runtime initialization adds initialization code to every translation unit which includes the header where the variable is defined and declared.
48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#include "Alignment.hpp"
|
|
|
|
namespace gui
|
|
{
|
|
|
|
bool Alignment::operator==(const Alignment &alignment) const
|
|
{
|
|
return !(horizontal != alignment.horizontal || vertical != alignment.vertical);
|
|
}
|
|
|
|
bool Alignment::operator!=(const Alignment &alignment) const
|
|
{
|
|
return (horizontal != alignment.horizontal || vertical != alignment.vertical);
|
|
}
|
|
|
|
Position Alignment::calculateHAlignment(Length parentSize, Length childSize) const
|
|
{
|
|
switch (horizontal) {
|
|
case Alignment::Horizontal::Left:
|
|
return 0;
|
|
case (Alignment::Horizontal::Center):
|
|
return (parentSize - childSize) / 2;
|
|
case Alignment::Horizontal::Right:
|
|
return parentSize - childSize;
|
|
default:
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
Position Alignment::calculateVAlignment(Length parentSize, Length childSize) const
|
|
{
|
|
switch (vertical) {
|
|
case Alignment::Vertical::Top:
|
|
return 0;
|
|
case (Alignment::Vertical::Center):
|
|
return (parentSize - childSize) / 2;
|
|
case Alignment::Vertical::Bottom:
|
|
return parentSize - childSize;
|
|
default:
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
} /* namespace gui */
|