Skip to content

Commit

Permalink
Init ui::document.
Browse files Browse the repository at this point in the history
  • Loading branch information
crupest committed Oct 15, 2023
1 parent c34035b commit a696fed
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
19 changes: 19 additions & 0 deletions include/cru/ui/document/DocumentElement.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include "../Base.h"
#include "DocumentElementType.h"

namespace cru::ui::document {
class CRU_UI_API DocumentElement : public Object {
public:
explicit DocumentElement(DocumentElementType* type);

~DocumentElement() override;

public:
DocumentElementType* GetType() const { return type_; }

private:
DocumentElementType* type_;
};
} // namespace cru::ui::document
25 changes: 25 additions & 0 deletions include/cru/ui/document/DocumentElementType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include "cru/common/String.h"

#include "../Base.h"

namespace cru::ui::document {
class CRU_UI_API DocumentElementType : public Object {
public:
explicit DocumentElementType(String name);

~DocumentElementType() override;

public:
String GetName() const { return name_; }

private:
String name_;
};

struct CRU_UI_API DocumentElementTypes {
static DocumentElementType* const kRootElementType;
};

} // namespace cru::ui::document
2 changes: 2 additions & 0 deletions src/ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ add_library(CruUi
controls/TextHostControlService.cpp
controls/TreeView.cpp
controls/Window.cpp
document/DocumentElement.cpp
document/DocumentElementType.cpp
events/MouseEventArgs.cpp
helper/ClickDetector.cpp
helper/ShortcutHub.cpp
Expand Down
8 changes: 8 additions & 0 deletions src/ui/document/DocumentElement.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "cru/ui/document/DocumentElement.h"
#include "cru/ui/document/DocumentElementType.h"

namespace cru::ui::document {
DocumentElement::DocumentElement(DocumentElementType* type) : type_(type) {}

DocumentElement::~DocumentElement() {}
} // namespace cru::ui::document
13 changes: 13 additions & 0 deletions src/ui/document/DocumentElementType.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "cru/ui/document/DocumentElementType.h"

#include <utility>

namespace cru::ui::document {
DocumentElementType::DocumentElementType(String name)
: name_(std::move(name)) {}

DocumentElementType::~DocumentElementType() {}

DocumentElementType* const DocumentElementTypes::kRootElementType =
new DocumentElementType(u"Root");
} // namespace cru::ui::document

0 comments on commit a696fed

Please sign in to comment.