mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-15 00:11:55 +07:00
added standart functions to label
This commit is contained in:
@@ -18,6 +18,22 @@ namespace e2d
|
||||
label() = default;
|
||||
label(str32_view text);
|
||||
|
||||
label(label&& other) noexcept;
|
||||
label& operator=(label&& other) noexcept;
|
||||
|
||||
label(const label& other);
|
||||
label& operator=(const label& other);
|
||||
|
||||
label(str32_view text, font_asset::ptr font, color32 tint);
|
||||
|
||||
label& assign(label&& other) noexcept;
|
||||
label& assign(const label& other);
|
||||
label& assign(str32_view text, font_asset::ptr font, color32 tint);
|
||||
|
||||
void swap(label& other) noexcept;
|
||||
void clear() noexcept;
|
||||
bool empty() const noexcept;
|
||||
|
||||
label& text(str32_view text);
|
||||
const str32& text() const noexcept;
|
||||
|
||||
|
||||
@@ -50,3 +50,70 @@ namespace e2d
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
label::label(label&& other) noexcept {
|
||||
assign(std::move(other));
|
||||
}
|
||||
|
||||
label& label::operator=(label&& other) noexcept {
|
||||
return assign(std::move(other));
|
||||
}
|
||||
|
||||
label::label(const label& other) {
|
||||
assign(other);
|
||||
}
|
||||
|
||||
label& label::operator=(const label& other) {
|
||||
return assign(other);
|
||||
}
|
||||
|
||||
label::label(str32_view text, font_asset::ptr font, color32 tint) {
|
||||
assign(text, font, tint);
|
||||
}
|
||||
|
||||
label& label::assign(label&& other) noexcept {
|
||||
if ( this != &other ) {
|
||||
swap(other);
|
||||
other.clear();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
label& label::assign(const label& other) {
|
||||
if ( this != &other ) {
|
||||
dirty_ = true;
|
||||
text_ = other.text_;
|
||||
font_ = other.font_;
|
||||
tint_ = other.tint_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
label& label::assign(str32_view text, font_asset::ptr font, color32 tint) {
|
||||
dirty_ = false;
|
||||
text_ = text;
|
||||
font_ = font;
|
||||
tint_ = tint;
|
||||
}
|
||||
|
||||
void label::swap(label& other) noexcept {
|
||||
using std::swap;
|
||||
swap(dirty_, other.dirty_);
|
||||
swap(text_, other.text_);
|
||||
swap(font_, other.font_);
|
||||
swap(tint_, other.tint_);
|
||||
}
|
||||
|
||||
void label::clear() noexcept {
|
||||
dirty_ = true;
|
||||
text_.clear();
|
||||
font_ = nullptr;
|
||||
tint_ = color32::white();
|
||||
}
|
||||
|
||||
bool label::empty() const noexcept {
|
||||
return text_.empty();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user