WebCFace 2.9.0
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 template <WEBCFACE_COMPLETE(Func)>
135 std::optional<Func_> onClick() const;
136};
137extern template std::optional<Func> Canvas2DComponent::onClick<Func, true>() const;
138
140 std::unique_ptr<internal::TemporalCanvas2DComponentData> msg_data;
141
142 public:
147 explicit TemporalCanvas2DComponent(std::nullptr_t = nullptr);
155 operator=(const TemporalCanvas2DComponent &other);
158 operator=(TemporalCanvas2DComponent &&other) noexcept;
160
169 std::unique_ptr<internal::TemporalCanvas2DComponentData>
170 lockTmp(const std::shared_ptr<internal::ClientData> &data,
171 const SharedString &view_name,
172 std::unordered_map<Canvas2DComponentType, int> *idx_next = nullptr);
173
178 TemporalCanvas2DComponent &id(std::string_view id);
183 TemporalCanvas2DComponent &id(std::wstring_view id);
188 TemporalCanvas2DComponent &origin(const Transform &origin) &;
193 this->origin(origin);
194 return std::move(*this);
195 }
203 TemporalCanvas2DComponent &color(const ViewColor &color) &;
208 this->color(color);
209 return std::move(*this);
210 }
218 TemporalCanvas2DComponent &fillColor(const ViewColor &color) &;
223 this->fillColor(color);
224 return std::move(*this);
225 }
235 TemporalCanvas2DComponent &strokeWidth(double s) &;
240 this->strokeWidth(s);
241 return std::move(*this);
242 }
253 TemporalCanvas2DComponent &textSize(double s) & { return strokeWidth(s); }
258 this->textSize(s);
259 return std::move(*this);
260 }
268 TemporalCanvas2DComponent &text(std::string_view text) &;
272 TemporalCanvas2DComponent &&text(std::string_view text) && {
273 this->text(text);
274 return std::move(*this);
275 }
280 TemporalCanvas2DComponent &text(std::wstring_view text) &;
285 TemporalCanvas2DComponent &&text(std::wstring_view text) && {
286 this->text(text);
287 return std::move(*this);
288 }
298 this->geometry(g);
299 return std::move(*this);
300 }
307 TemporalCanvas2DComponent &onClick(const Func &func) &;
313 this->onClick(func);
314 return std::move(*this);
315 }
321 TemporalCanvas2DComponent &onClick(const FuncListener &func) &;
327 this->onClick(func);
328 return std::move(*this);
329 }
339 template <typename T, decltype(std::declval<T>()(), nullptr) = nullptr>
341 return onClick(std::make_shared<std::function<void WEBCFACE_CALL_FP()>>(
342 std::move(func)));
343 }
348 template <typename T, decltype(std::declval<T>()(), nullptr) = nullptr>
350 this->onClick(std::move(func));
351 return std::move(*this);
352 }
353
355 const std::shared_ptr<std::function<void WEBCFACE_CALL_FP()>> &func);
356};
357
Canvas2Dの各要素を表すクラス。
Definition component_canvas2d.h:33
std::optional< Func_ > onClick() const
クリック時に実行される関数を取得
double textSize() const
文字の大きさ(高さ)
Definition component_canvas2d.h:114
bool operator!=(const Canvas2DComponent &other) const
Definition component_canvas2d.h:80
Definition func.h:619
関数1つを表すクラス
Definition func.h:95
u8stringとstringとwstringをshared_ptrで持ち共有する
Definition encoding.h:67
Definition component_canvas2d.h:139
TemporalCanvas2DComponent & onClick(T func) &
クリック時に実行される関数を設定
Definition component_canvas2d.h:340
TemporalCanvas2DComponent && fillColor(const ViewColor &color) &&
Definition component_canvas2d.h:222
TemporalCanvas2DComponent && origin(const Transform &origin) &&
Definition component_canvas2d.h:192
TemporalCanvas2DComponent && strokeWidth(double s) &&
Definition component_canvas2d.h:239
TemporalCanvas2DComponent && onClick(T func) &&
クリック時に実行される関数を設定
Definition component_canvas2d.h:349
TemporalCanvas2DComponent && onClick(const FuncListener &func) &&
クリック時に実行される関数を設定 (FuncListener)
Definition component_canvas2d.h:326
TemporalCanvas2DComponent && text(std::string_view text) &&
Definition component_canvas2d.h:272
TemporalCanvas2DComponent && textSize(double s) &&
Definition component_canvas2d.h:257
TemporalCanvas2DComponent & textSize(double s) &
文字の大きさ(高さ)
Definition component_canvas2d.h:253
TemporalCanvas2DComponent && text(std::wstring_view text) &&
表示する文字列を設定 (wstring)
Definition component_canvas2d.h:285
TemporalCanvas2DComponent && onClick(const Func &func) &&
クリック時に実行される関数を設定 (Funcオブジェクト)
Definition component_canvas2d.h:312
TemporalCanvas2DComponent && color(const ViewColor &color) &&
Definition component_canvas2d.h:207
TemporalCanvas2DComponent && geometry(const Geometry &g) &&
Definition component_canvas2d.h:297
3次元の平行移動と回転
Definition transform.h:652
Canvas2DComponentType
Definition component_canvas2d.h:22
bool operator==(const T &other, const InputRef &ref)
Definition text.h:574
ViewColor
Definition component_view.h:40
Definition geometry.h:26
#define WEBCFACE_DLL
Definition webcface-config.h:69
#define WEBCFACE_NS_END
Definition webcface-config.h:118
#define WEBCFACE_NS_BEGIN
Definition webcface-config.h:117
#define WEBCFACE_CALL_FP
Definition webcface-config.h:107