add xml attributes for combobox node and add resolution selection for new doc
This commit is contained in:
@@ -159,7 +159,7 @@
|
|||||||
</node>
|
</node>
|
||||||
<border dir="col" align="center" grow="1" width="1" flood-events="1">
|
<border dir="col" align="center" grow="1" width="1" flood-events="1">
|
||||||
<node height="30" pad="1" width="100%" dir="row">
|
<node height="30" pad="1" width="100%" dir="row">
|
||||||
<combobox id="blend-mode" text="Normal" width="100%" height="30"/>
|
<combobox id="blend-mode" text="Normal" width="100%" height="30" combo-list="Normal,Multiply,Screen,Color Dodge" default="0"/>
|
||||||
</node>
|
</node>
|
||||||
<node height="20" pad="1" width="100%" dir="row">
|
<node height="20" pad="1" width="100%" dir="row">
|
||||||
<slider-h id="tip-size" width="1" grow="1" value=".25"/>
|
<slider-h id="tip-size" width="1" grow="1" value=".25"/>
|
||||||
@@ -387,6 +387,7 @@
|
|||||||
<border dir="row" align="center" height="30" color=".2 .2 .2 1">
|
<border dir="row" align="center" height="30" color=".2 .2 .2 1">
|
||||||
<text text="Project name: " font-face="arial" font-size="11" margin="0 5 0 5"/>
|
<text text="Project name: " font-face="arial" font-size="11" margin="0 5 0 5"/>
|
||||||
<text-input id="txt-input" justify="center" pad="5" grow="1" height="30" color=".3"/>
|
<text-input id="txt-input" justify="center" pad="5" grow="1" height="30" color=".3"/>
|
||||||
|
<combobox id="resolution" width="100" height="30" text="1024" combo-list="512px,1024px,1536px,2048px" default="1"/>
|
||||||
</border>
|
</border>
|
||||||
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">
|
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">
|
||||||
<button id="btn-ok" text="Create Project" width="100" height="30" margin="0 10 0 0"/>
|
<button id="btn-ok" text="Create Project" width="100" height="30" margin="0 10 0 0"/>
|
||||||
|
|||||||
@@ -235,7 +235,7 @@
|
|||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="engine\node_combobox.cpp">
|
<ClCompile Include="engine\node_combobox.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files\ui</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -30,9 +30,11 @@ void App::dialog_newdoc()
|
|||||||
if (auto docname = layout[main_id]->find<NodeText>("txt-docname"))
|
if (auto docname = layout[main_id]->find<NodeText>("txt-docname"))
|
||||||
docname->set_text(("Panodoc: " + doc_name).c_str());
|
docname->set_text(("Panodoc: " + doc_name).c_str());
|
||||||
|
|
||||||
|
int res = atoi(dialog->m_resolution->labels[dialog->m_resolution->m_current_index].c_str());
|
||||||
layers->clear();
|
layers->clear();
|
||||||
canvas->m_canvas->m_layers.clear();
|
canvas->m_canvas->m_layers.clear();
|
||||||
canvas->m_canvas->m_order.clear();
|
canvas->m_canvas->m_order.clear();
|
||||||
|
canvas->m_canvas->resize(res, res);
|
||||||
canvas->reset_camera();
|
canvas->reset_camera();
|
||||||
ActionManager::clear();
|
ActionManager::clear();
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ enum class kAttribute : uint16_t
|
|||||||
Value = const_hash("value"),
|
Value = const_hash("value"),
|
||||||
Range = const_hash("range"),
|
Range = const_hash("range"),
|
||||||
AspectRatio = const_hash("aspect-ratio"),
|
AspectRatio = const_hash("aspect-ratio"),
|
||||||
|
ComboList = const_hash("combo-list"),
|
||||||
|
Default = const_hash("default"),
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class kWidget : uint16_t
|
enum class kWidget : uint16_t
|
||||||
|
|||||||
@@ -8,11 +8,18 @@ Node* NodeComboBox::clone_instantiate() const
|
|||||||
return new NodeComboBox;
|
return new NodeComboBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodeComboBox::clone_copy(Node* dest) const
|
||||||
|
{
|
||||||
|
NodeButton::clone_copy(dest);
|
||||||
|
NodeComboBox* n = static_cast<NodeComboBox*>(dest);
|
||||||
|
n->labels = labels;
|
||||||
|
n->m_current_index = m_current_index;
|
||||||
|
}
|
||||||
|
|
||||||
void NodeComboBox::loaded()
|
void NodeComboBox::loaded()
|
||||||
{
|
{
|
||||||
NodeButton::loaded();
|
NodeButton::loaded();
|
||||||
on_click = [this](Node* target) {
|
on_click = [this](Node* target) {
|
||||||
LOG("ComboBox");
|
|
||||||
NodePopupMenu* popup = new NodePopupMenu;
|
NodePopupMenu* popup = new NodePopupMenu;
|
||||||
popup->init();
|
popup->init();
|
||||||
popup->create();
|
popup->create();
|
||||||
@@ -51,8 +58,19 @@ void NodeComboBox::loaded()
|
|||||||
popup->m_capture_children = false;
|
popup->m_capture_children = false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
void NodeComboBox::clone_copy(Node* dest) const
|
|
||||||
|
void NodeComboBox::parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr)
|
||||||
{
|
{
|
||||||
NodeButton::clone_copy(dest);
|
NodeButton::parse_attributes(ka, attr);
|
||||||
NodeComboBox* n = static_cast<NodeComboBox*>(dest);
|
switch (ka)
|
||||||
}
|
{
|
||||||
|
case kAttribute::ComboList:
|
||||||
|
{
|
||||||
|
labels = split(attr->Value(), ',');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case kAttribute::Default:
|
||||||
|
m_current_index = attr->IntValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,9 +5,10 @@ class NodeComboBox : public NodeButton
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::function<void(Node* target, int index)> on_select;
|
std::function<void(Node* target, int index)> on_select;
|
||||||
std::array<std::string, 4> labels{ "Normal", "Multiply", "Screen", "Color Dodge" };
|
std::vector<std::string> labels;
|
||||||
int m_current_index = 0;
|
int m_current_index = 0;
|
||||||
virtual Node* clone_instantiate() const override;
|
virtual Node* clone_instantiate() const override;
|
||||||
virtual void clone_copy(Node* dest) const override;
|
virtual void clone_copy(Node* dest) const override;
|
||||||
virtual void loaded() override;
|
virtual void loaded() override;
|
||||||
|
virtual void parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr) override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,23 +43,6 @@ void NodeDialogCloud::loaded()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> split(const std::string& subject, char d, int max_split = 0)
|
|
||||||
{
|
|
||||||
std::vector<std::string> ret;
|
|
||||||
int start = 0;
|
|
||||||
int n = subject.find_first_of(d);
|
|
||||||
while (n != std::string::npos)
|
|
||||||
{
|
|
||||||
ret.push_back(subject.substr(start, n - start));
|
|
||||||
start = n + 1;
|
|
||||||
if (max_split && ret.size() == max_split)
|
|
||||||
break;
|
|
||||||
n = subject.find_first_of(d, start);
|
|
||||||
}
|
|
||||||
ret.push_back(subject.substr(start));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NodeDialogCloud::load_thumbs_thread()
|
void NodeDialogCloud::load_thumbs_thread()
|
||||||
{
|
{
|
||||||
CURL *curl = curl_easy_init();
|
CURL *curl = curl_easy_init();
|
||||||
|
|||||||
@@ -222,6 +222,7 @@ void NodeDialogNewDoc::init()
|
|||||||
void NodeDialogNewDoc::init_controls()
|
void NodeDialogNewDoc::init_controls()
|
||||||
{
|
{
|
||||||
btn_ok = find<NodeButton>("btn-ok");
|
btn_ok = find<NodeButton>("btn-ok");
|
||||||
|
m_resolution = find<NodeComboBox>("resolution");
|
||||||
btn_cancel = find<NodeButton>("btn-cancel");
|
btn_cancel = find<NodeButton>("btn-cancel");
|
||||||
btn_cancel->on_click = [this](Node*) {
|
btn_cancel->on_click = [this](Node*) {
|
||||||
destroy();
|
destroy();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "node_image_texture.h"
|
#include "node_image_texture.h"
|
||||||
#include "node_text.h"
|
#include "node_text.h"
|
||||||
#include "node_text_input.h"
|
#include "node_text_input.h"
|
||||||
|
#include "node_combobox.h"
|
||||||
|
|
||||||
class NodeDialogOpenItem : public NodeBorder
|
class NodeDialogOpenItem : public NodeBorder
|
||||||
{
|
{
|
||||||
@@ -65,6 +66,7 @@ public:
|
|||||||
NodeButton* btn_cancel;
|
NodeButton* btn_cancel;
|
||||||
NodeButton* btn_ok;
|
NodeButton* btn_ok;
|
||||||
NodeTextInput* input;
|
NodeTextInput* input;
|
||||||
|
NodeComboBox* m_resolution;
|
||||||
virtual Node* clone_instantiate() const override;
|
virtual Node* clone_instantiate() const override;
|
||||||
virtual void clone_finalize(Node* dest) const override;
|
virtual void clone_finalize(Node* dest) const override;
|
||||||
virtual void init() override;
|
virtual void init() override;
|
||||||
|
|||||||
@@ -88,6 +88,23 @@ glm::vec3 convert_rgb2hsv(const glm::vec3 c)
|
|||||||
return glm::vec3(fabs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
return glm::vec3(fabs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> split(const std::string& subject, char d, int max_split/* = 0*/)
|
||||||
|
{
|
||||||
|
std::vector<std::string> ret;
|
||||||
|
int start = 0;
|
||||||
|
int n = subject.find_first_of(d);
|
||||||
|
while (n != std::string::npos)
|
||||||
|
{
|
||||||
|
ret.push_back(subject.substr(start, n - start));
|
||||||
|
start = n + 1;
|
||||||
|
if (max_split && ret.size() == max_split)
|
||||||
|
break;
|
||||||
|
n = subject.find_first_of(d, start);
|
||||||
|
}
|
||||||
|
ret.push_back(subject.substr(start));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static const char* gl2str(GLenum err)
|
static const char* gl2str(GLenum err)
|
||||||
{
|
{
|
||||||
switch (err)
|
switch (err)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ bool segments_intersect(const glm::vec2& p0a, const glm::vec2& p0b,
|
|||||||
glm::vec4 rand_color();
|
glm::vec4 rand_color();
|
||||||
glm::vec3 convert_hsv2rgb(const glm::vec3 c);
|
glm::vec3 convert_hsv2rgb(const glm::vec3 c);
|
||||||
glm::vec3 convert_rgb2hsv(const glm::vec3 c);
|
glm::vec3 convert_rgb2hsv(const glm::vec3 c);
|
||||||
|
std::vector<std::string> split(const std::string& subject, char d, int max_split = 0);
|
||||||
|
|
||||||
size_t curl_data_handler(void *contents, size_t size, size_t nmemb, void *userp);
|
size_t curl_data_handler(void *contents, size_t size, size_t nmemb, void *userp);
|
||||||
size_t curl_data_write(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
size_t curl_data_write(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||||
|
|||||||
Reference in New Issue
Block a user