WebCFace 2.5.2
Web-based Communication Framework & Dashboard-like UI
Loading...
Searching...
No Matches
component_canvas2d.h
Go to the documentation of this file.
1#pragma once
2#include <unordered_map>
3#include <optional>
4#ifdef WEBCFACE_MESON
5#include "webcface-config.h"
6#else
7#include "webcface/common/webcface-config.h"
8#endif
9#include "transform.h"
10#include "field.h"
12#include "webcface/geometry.h"
13
15namespace message {
16struct Canvas2DComponentData;
17}
18namespace internal {
19struct TemporalCanvas2DComponentData;
20}
21
23 geometry = 0,
24 text = 3,
25};
34 std::shared_ptr<message::Canvas2DComponentData> msg_data;
35 std::weak_ptr<internal::ClientData> data_w;
36 SharedString id_;
37
38 void checkData() const;
39
40 public:
46
48 const std::shared_ptr<message::Canvas2DComponentData> &msg_data,
49 const std::weak_ptr<internal::ClientData> &data_w,
50 const SharedString &id);
51
61 std::string id() const;
71 std::wstring idW() const;
72
76 bool operator==(const Canvas2DComponent &other) const;
80 bool operator!=(const Canvas2DComponent &other) const {
81 return !(*this == other);
82 }
83
88 Canvas2DComponentType type() const;
93 Transform origin() const;
98 ViewColor color() const;
103 ViewColor fillColor() const;
104
109 double strokeWidth() const;
114 double textSize() const { return strokeWidth(); }
119 std::string text() const;
124 std::wstring textW() const;
129 std::optional<Geometry> geometry() const;
134 std::optional<Func> onClick() const;
135};
136
138 std::unique_ptr<internal::TemporalCanvas2DComponentData> msg_data;
139
140 public:
145 explicit TemporalCanvas2DComponent(std::nullptr_t = nullptr);
153 operator=(const TemporalCanvas2DComponent &other);
156 operator=(TemporalCanvas2DComponent &&other) noexcept;
158
167 std::unique_ptr<internal::TemporalCanvas2DComponentData>
168 lockTmp(const std::shared_ptr<internal::ClientData> &data,
169 const SharedString &view_name,
170 std::unordered_map<Canvas2DComponentType, int> *idx_next = nullptr);
171
176 TemporalCanvas2DComponent &id(std::string_view id);
181 TemporalCanvas2DComponent &id(std::wstring_view id);
186 TemporalCanvas2DComponent &origin(const Transform &origin) &;
191 this->origin(origin);
192 return std::move(*this);
193 }
201 TemporalCanvas2DComponent &color(const ViewColor &color) &;
206 this->color(color);
207 return std::move(*this);
208 }
216 TemporalCanvas2DComponent &fillColor(const ViewColor &color) &;
221 this->fillColor(color);
222 return std::move(*this);
223 }
233 TemporalCanvas2DComponent &strokeWidth(double s) &;
238 this->strokeWidth(s);
239 return std::move(*this);
240 }
251 TemporalCanvas2DComponent &textSize(double s) & { return strokeWidth(s); }
256 this->textSize(s);
257 return std::move(*this);
258 }
266 TemporalCanvas2DComponent &text(std::string_view text) &;
270 TemporalCanvas2DComponent &&text(std::string_view text) && {
271 this->text(text);
272 return std::move(*this);
273 }
278 TemporalCanvas2DComponent &text(std::wstring_view text) &;
283 TemporalCanvas2DComponent &&text(std::wstring_view text) && {
284 this->text(text);
285 return std::move(*this);
286 }
296 this->geometry(g);
297 return std::move(*this);
298 }
305 TemporalCanvas2DComponent &onClick(const Func &func) &;
311 this->onClick(func);
312 return std::move(*this);
313 }
319 TemporalCanvas2DComponent &onClick(const FuncListener &func) &;
325 this->onClick(func);
326 return std::move(*this);
327 }
337 template <typename T, decltype(std::declval<T>()(), nullptr) = nullptr>
339 return onClick(std::make_shared<std::function<void WEBCFACE_CALL_FP()>>(
340 std::move(func)));
341 }
346 template <typename T, decltype(std::declval<T>()(), nullptr) = nullptr>
348 this->onClick(std::move(func));
349 return std::move(*this);
350 }
351
353 const std::shared_ptr<std::function<void WEBCFACE_CALL_FP()>> &func);
354};
355
Canvas2Dの各要素を表すクラス。
Definition component_canvas2d.h:33
double textSize() const
文字の大きさ(高さ)
Definition component_canvas2d.h:114
bool operator!=(const Canvas2DComponent &other) const
Definition component_canvas2d.h:80
Definition func.h:590
関数1つを表すクラス
Definition func.h:95
u8stringとstringとwstringをshared_ptrで持ち共有する
Definition encoding.h:69
Definition component_canvas2d.h:137
TemporalCanvas2DComponent & onClick(T func) &
クリック時に実行される関数を設定
Definition component_canvas2d.h:338
TemporalCanvas2DComponent && fillColor(const ViewColor &color) &&
Definition component_canvas2d.h:220
TemporalCanvas2DComponent && origin(const Transform &origin) &&
Definition component_canvas2d.h:190
TemporalCanvas2DComponent && strokeWidth(double s) &&
Definition component_canvas2d.h:237
TemporalCanvas2DComponent && onClick(T func) &&
クリック時に実行される関数を設定
Definition component_canvas2d.h:347
TemporalCanvas2DComponent && onClick(const FuncListener &func) &&
クリック時に実行される関数を設定 (FuncListener)
Definition component_canvas2d.h:324
TemporalCanvas2DComponent && text(std::string_view text) &&
Definition component_canvas2d.h:270
TemporalCanvas2DComponent && textSize(double s) &&
Definition component_canvas2d.h:255
TemporalCanvas2DComponent & textSize(double s) &
文字の大きさ(高さ)
Definition component_canvas2d.h:251
TemporalCanvas2DComponent && text(std::wstring_view text) &&
表示する文字列を設定 (wstring)
Definition component_canvas2d.h:283
TemporalCanvas2DComponent && onClick(const Func &func) &&
クリック時に実行される関数を設定 (Funcオブジェクト)
Definition component_canvas2d.h:310
TemporalCanvas2DComponent && color(const ViewColor &color) &&
Definition component_canvas2d.h:205
TemporalCanvas2DComponent && geometry(const Geometry &g) &&
Definition component_canvas2d.h:295
3次元の平行移動と回転
Definition transform.h:615
Canvas2DComponentType
Definition component_canvas2d.h:22
bool operator==(const T &other, const InputRef &ref)
Definition text.h:566
ViewColor
Definition component_view.h:40
Definition geometry.h:26
#define WEBCFACE_DLL
Definition webcface-config.h:60
#define WEBCFACE_NS_END
Definition webcface-config.h:104
#define WEBCFACE_NS_BEGIN
Definition webcface-config.h:103
#define WEBCFACE_CALL_FP
Definition webcface-config.h:98