PeriDyno 1.0.0
Loading...
Searching...
No Matches
WColorWidget.cpp
Go to the documentation of this file.
1#include "WColorWidget.h"
2
4{
5 layout = this->setLayout(std::make_unique<Wt::WHBoxLayout>());
6 layout->setContentsMargins(0, 0, 0, 0);
7 layout->setSpacing(0);
8
9 setValue(field);
10 mfield = field;
11 mData->colorInput().connect(this, &WColorWidget::updateField);
12}
13
15
17{
18 mData = layout->addWidget(std::make_unique<Wt::WColorPicker>());
19
20 std::string template_name = field->getTemplateName();
21 int R = 0;
22 int G = 0;
23 int B = 0;
24
25 if (template_name == std::string(typeid(dyno::Color).name()))
26 {
28 auto v = f->getData();
29
30 int r = int(v.r * 255) % 255;
31 int g = int(v.g * 255) % 255;
32 int b = int(v.b * 255) % 255;
33
34 auto color = Wt::WColor(r, g, b);
35 mData->setColor(color);
36 }
37}
38
40{
41 std::string template_name = mfield->getTemplateName();
42
43 if (template_name == std::string(typeid(dyno::Color).name()))
44 {
45 auto color = mData->color();
46 int v1 = color.red();
47 int v2 = color.green();
48 int v3 = color.blue();
49
51 float r = float(v1) / 255;
52 float g = float(v2) / 255;
53 float b = float(v3) / 255;
54
55 f->setValue(dyno::Color(r, g, b));
56 changeValue_.emit(1);
57 }
58}
WColorWidget(dyno::FBase *)
void setValue(dyno::FBase *)
Wt::Signal< int > changeValue_
Wt::WHBoxLayout * layout
dyno::FBase * mfield
Wt::WColorPicker * mData
virtual const std::string getTemplateName()
Definition FBase.h:51
DataType getData()
Definition Field.h:74
void setValue(T val)
Definition Field.h:111
TA * cast(TB *b)
Definition Typedef.inl:286