aboutsummaryrefslogtreecommitdiff
path: root/include/cru
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru')
-rw-r--r--include/cru/common/String.hpp6
-rw-r--r--include/cru/ui/mapper/Mapper.hpp5
-rw-r--r--include/cru/ui/mapper/MapperRegistry.hpp5
-rw-r--r--include/cru/ui/mapper/style/BorderStylerMapper.hpp21
-rw-r--r--include/cru/ui/style/Styler.hpp5
5 files changed, 41 insertions, 1 deletions
diff --git a/include/cru/common/String.hpp b/include/cru/common/String.hpp
index 5891e929..22d68980 100644
--- a/include/cru/common/String.hpp
+++ b/include/cru/common/String.hpp
@@ -226,6 +226,9 @@ class CRU_BASE_API String {
int Compare(const String& other) const;
int CaseInsensitiveCompare(const String& other) const;
+ bool CaseInsensitiveEqual(const String& other) const {
+ return CaseInsensitiveCompare(other) == 0;
+ }
private:
static char16_t kEmptyBuffer[1];
@@ -310,6 +313,9 @@ class CRU_BASE_API StringView {
public:
int Compare(const StringView& other) const;
int CaseInsensitiveCompare(const StringView& other) const;
+ bool CaseInsensitiveEqual(const StringView& other) const {
+ return CaseInsensitiveCompare(other) == 0;
+ }
String ToString() const { return String(ptr_, size_); }
diff --git a/include/cru/ui/mapper/Mapper.hpp b/include/cru/ui/mapper/Mapper.hpp
index 4e5499d0..5febb26e 100644
--- a/include/cru/ui/mapper/Mapper.hpp
+++ b/include/cru/ui/mapper/Mapper.hpp
@@ -1,7 +1,7 @@
#pragma once
-
#include "../Base.hpp"
+#include "cru/common/ClonablePtr.hpp"
#include "cru/common/Exception.hpp"
#include "cru/xml/XmlNode.hpp"
@@ -85,4 +85,7 @@ class CRU_UI_API BasicMapper : public MapperBase {
template <typename T>
using BasicRefMapper = BasicMapper<std::shared_ptr<T>>;
+
+template <typename T>
+using BasicPtrMapper = BasicMapper<ClonablePtr<T>>;
} // namespace cru::ui::mapper
diff --git a/include/cru/ui/mapper/MapperRegistry.hpp b/include/cru/ui/mapper/MapperRegistry.hpp
index 55051ba9..c3e5b4c4 100644
--- a/include/cru/ui/mapper/MapperRegistry.hpp
+++ b/include/cru/ui/mapper/MapperRegistry.hpp
@@ -34,6 +34,11 @@ class CRU_UI_API MapperRegistry {
return GetMapper<std::shared_ptr<T>>();
}
+ template <typename T>
+ BasicPtrMapper<T>* GetPtrMapper() const {
+ return GetMapper<ClonablePtr<T>>();
+ }
+
void RegisterMapper(MapperBase* mapper);
void UnregisterMapper(MapperBase* mapper);
diff --git a/include/cru/ui/mapper/style/BorderStylerMapper.hpp b/include/cru/ui/mapper/style/BorderStylerMapper.hpp
new file mode 100644
index 00000000..6c967bed
--- /dev/null
+++ b/include/cru/ui/mapper/style/BorderStylerMapper.hpp
@@ -0,0 +1,21 @@
+#pragma once
+#include "../Mapper.hpp"
+#include "cru/common/ClonablePtr.hpp"
+#include "cru/ui/style/Styler.hpp"
+#include "cru/xml/XmlNode.hpp"
+
+namespace cru::ui::mapper::style {
+class CRU_UI_API BorderStylerMapper
+ : public BasicPtrMapper<ui::style::BorderStyler> {
+ public:
+ CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(BorderStylerMapper)
+
+ public:
+ bool SupportMapFromXml() override { return true; }
+ bool XmlElementIsOfThisType(xml::XmlElementNode* node) override;
+
+ protected:
+ ClonablePtr<ui::style::BorderStyler> DoMapFromXml(
+ xml::XmlElementNode* node) override;
+};
+} // namespace cru::ui::mapper::style
diff --git a/include/cru/ui/style/Styler.hpp b/include/cru/ui/style/Styler.hpp
index 865cbbaf..721a3bfd 100644
--- a/include/cru/ui/style/Styler.hpp
+++ b/include/cru/ui/style/Styler.hpp
@@ -44,10 +44,15 @@ class CompoundStyler : public Styler {
class BorderStyler : public Styler {
public:
+ static ClonablePtr<BorderStyler> Create() {
+ return ClonablePtr<BorderStyler>(new BorderStyler());
+ }
+
static ClonablePtr<BorderStyler> Create(ApplyBorderStyleInfo style) {
return ClonablePtr<BorderStyler>(new BorderStyler(std::move(style)));
}
+ BorderStyler() = default;
explicit BorderStyler(ApplyBorderStyleInfo style);
void Apply(controls::Control* control) const override;