-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
84 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,33 @@ | ||
#pragma once | ||
|
||
#include "../Base.h" | ||
#include "cru/common/String.h" | ||
|
||
#include "../Base.h" | ||
#include <vector> | ||
|
||
namespace cru::ui::document { | ||
class CRU_UI_API DocumentElementType : public Object { | ||
public: | ||
explicit DocumentElementType(String name); | ||
explicit DocumentElementType(String name, | ||
std::vector<DocumentElementType*> parents); | ||
|
||
~DocumentElementType() override; | ||
|
||
public: | ||
String GetName() const { return name_; } | ||
const std::vector<DocumentElementType*>& GetParents() const { | ||
return parents_; | ||
} | ||
|
||
private: | ||
String name_; | ||
std::vector<DocumentElementType*> parents_; | ||
}; | ||
|
||
struct CRU_UI_API DocumentElementTypes { | ||
static DocumentElementType* const kBaseElementType; | ||
static DocumentElementType* const kRootElementType; | ||
static DocumentElementType* const kTextElementType; | ||
}; | ||
|
||
} // namespace cru::ui::document |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma once | ||
|
||
#include "../Base.h" | ||
#include "DocumentElement.h" | ||
#include "cru/common/Base.h" | ||
#include "cru/common/Bitmask.h" | ||
|
||
namespace cru::ui::document { | ||
namespace details { | ||
struct TextStyleTag {}; | ||
} // namespace details | ||
|
||
using TextStyle = Bitmask<details::TextStyleTag>; | ||
|
||
struct TextStyles { | ||
static constexpr TextStyle Normal; | ||
static constexpr TextStyle Bold{0x1}; | ||
static constexpr TextStyle Italic{0x2}; | ||
}; | ||
|
||
struct IDocumentLink : virtual Interface { | ||
virtual void Open() = 0; | ||
}; | ||
|
||
class CRU_UI_API TextDocumentElement : public DocumentElement { | ||
public: | ||
TextDocumentElement(String text, TextStyle style, IDocumentLink* link); | ||
|
||
~TextDocumentElement() override; | ||
|
||
String GetText() const { return text_; } | ||
void SetText(String text); | ||
|
||
TextStyle GetStyle() const { return style_; } | ||
void SetStyle(TextStyle style); | ||
|
||
IDocumentLink* GetLink() const { return link_; } | ||
void SetLink(IDocumentLink link); | ||
|
||
private: | ||
String text_; | ||
TextStyle style_; | ||
IDocumentLink* link_; | ||
}; | ||
} // namespace cru::ui::document |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
#include "cru/ui/document/DocumentElementType.h" | ||
|
||
#include <utility> | ||
#include <vector> | ||
|
||
namespace cru::ui::document { | ||
DocumentElementType::DocumentElementType(String name) | ||
: name_(std::move(name)) {} | ||
DocumentElementType::DocumentElementType( | ||
String name, std::vector<DocumentElementType*> parents) | ||
: name_(std::move(name)), parents_(std::move(parents)) {} | ||
|
||
DocumentElementType::~DocumentElementType() {} | ||
|
||
DocumentElementType* const DocumentElementTypes::kBaseElementType = | ||
new DocumentElementType(u"Base", {}); | ||
|
||
DocumentElementType* const DocumentElementTypes::kRootElementType = | ||
new DocumentElementType(u"Root"); | ||
new DocumentElementType(u"Root", {kBaseElementType}); | ||
|
||
DocumentElementType* const DocumentElementTypes::kTextElementType = | ||
new DocumentElementType(u"Text", {kBaseElementType}); | ||
} // namespace cru::ui::document |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "cru/ui/document/TextDocumentElement.h" | ||
#include "cru/common/String.h" | ||
#include "cru/ui/document/DocumentElement.h" | ||
#include "cru/ui/document/DocumentElementType.h" | ||
|
||
namespace cru::ui::document { | ||
TextDocumentElement::TextDocumentElement(String text, TextStyle style, | ||
IDocumentLink* link) | ||
: DocumentElement(DocumentElementTypes::kTextElementType), | ||
text_(std::move(text)), | ||
style_(style), | ||
link_(link) {} | ||
|
||
TextDocumentElement::~TextDocumentElement() {} | ||
|
||
void TextDocumentElement::SetText(String text) { text_ = std::move(text); } | ||
} // namespace cru::ui::document |