fix mixer rect, textures popup, parallel abr import
This commit is contained in:
@@ -93,23 +93,23 @@ public class MainActivity extends NativeActivity {
|
|||||||
Log.v("PanoPainterJava", "create path failed: " + brush_thumbs.getAbsolutePath());
|
Log.v("PanoPainterJava", "create path failed: " + brush_thumbs.getAbsolutePath());
|
||||||
|
|
||||||
}
|
}
|
||||||
// patterns
|
// textures
|
||||||
File patterns = new File(pano_dir.getAbsolutePath(), "patterns");
|
File textures = new File(pano_dir.getAbsolutePath(), "textures");
|
||||||
if (!patterns.exists())
|
if (!textures.exists())
|
||||||
{
|
{
|
||||||
if (patterns.mkdirs())
|
if (textures.mkdirs())
|
||||||
Log.v("PanoPainterJava", "create path " + patterns.getAbsolutePath());
|
Log.v("PanoPainterJava", "create path " + textures.getAbsolutePath());
|
||||||
else
|
else
|
||||||
Log.v("PanoPainterJava", "create path failed: " + patterns.getAbsolutePath());
|
Log.v("PanoPainterJava", "create path failed: " + textures.getAbsolutePath());
|
||||||
|
|
||||||
}
|
}
|
||||||
File patterns_thumbs = new File(patterns.getAbsolutePath(), "thumbs");
|
File textures_thumbs = new File(textures.getAbsolutePath(), "thumbs");
|
||||||
if (!patterns_thumbs.exists())
|
if (!textures_thumbs.exists())
|
||||||
{
|
{
|
||||||
if (patterns_thumbs.mkdirs())
|
if (textures_thumbs.mkdirs())
|
||||||
Log.v("PanoPainterJava", "create path " + patterns_thumbs.getAbsolutePath());
|
Log.v("PanoPainterJava", "create path " + textures_thumbs.getAbsolutePath());
|
||||||
else
|
else
|
||||||
Log.v("PanoPainterJava", "create path failed: " + patterns_thumbs.getAbsolutePath());
|
Log.v("PanoPainterJava", "create path failed: " + textures_thumbs.getAbsolutePath());
|
||||||
|
|
||||||
}
|
}
|
||||||
// settings
|
// settings
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 806 B After Width: | Height: | Size: 806 B |
|
Before Width: | Height: | Size: 388 B After Width: | Height: | Size: 388 B |
@@ -286,17 +286,17 @@
|
|||||||
<node dir="row">
|
<node dir="row">
|
||||||
<node width="30%" dir="col">
|
<node width="30%" dir="col">
|
||||||
<!--labels-->
|
<!--labels-->
|
||||||
<node height="30" justify="center">
|
<node height="40" justify="center">
|
||||||
<text text="Stencil"/>
|
<text text="Pattern"/>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node dir="col" align="center" grow="1" width="1">
|
<node dir="col" align="center" grow="1" width="1">
|
||||||
<!--controls-->
|
<!--controls-->
|
||||||
<node height="30" pad="1" width="100%" dir="row">
|
<node height="40" width="100%" dir="row">
|
||||||
<slider-h id="tip-stencil" width="1" grow="1"/>
|
<slider-h id="tip-stencil" width="1" grow="1" height="30" margin="5 5 5 0"/>
|
||||||
<node width="50" pad="0" margin="0 0 0 5">
|
<button-custom id="texture-change" width="40" height="40" dir="row" pad="4">
|
||||||
<button id="tip-stencil-load" text="Load" height="28"></button>
|
<image id="texture-change-thumb" width="32" height="100%"/>
|
||||||
</node>
|
</button-custom>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
|
|||||||
26
src/app.cpp
26
src/app.cpp
@@ -143,14 +143,14 @@ void App::initLog()
|
|||||||
{
|
{
|
||||||
LOG("error creating brushes thumbs path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
LOG("error creating brushes thumbs path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
||||||
}
|
}
|
||||||
// patterns
|
// textures
|
||||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/patterns"] withIntermediateDirectories:YES attributes:nil error:&err])
|
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/textures"] withIntermediateDirectories:YES attributes:nil error:&err])
|
||||||
{
|
{
|
||||||
LOG("error creating patterns path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
LOG("error creating textures path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
||||||
}
|
}
|
||||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/patterns /thumbs"] withIntermediateDirectories:YES attributes:nil error:&err])
|
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/textures/thumbs"] withIntermediateDirectories:YES attributes:nil error:&err])
|
||||||
{
|
{
|
||||||
LOG("error creating patterns thumbs path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
LOG("error creating textures thumbs path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
||||||
}
|
}
|
||||||
// settings
|
// settings
|
||||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/settings"] withIntermediateDirectories:YES attributes:nil error:&err])
|
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/settings"] withIntermediateDirectories:YES attributes:nil error:&err])
|
||||||
@@ -184,14 +184,14 @@ void App::initLog()
|
|||||||
{
|
{
|
||||||
LOG("error creating brushes thumbs path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
LOG("error creating brushes thumbs path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
||||||
}
|
}
|
||||||
// patterns
|
// textures
|
||||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/patterns"] withIntermediateDirectories:YES attributes:nil error:&err])
|
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/textures"] withIntermediateDirectories:YES attributes:nil error:&err])
|
||||||
{
|
{
|
||||||
LOG("error creating brushes path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
LOG("error creating brushes path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
||||||
}
|
}
|
||||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/patterns/thumbs"] withIntermediateDirectories:YES attributes:nil error:&err])
|
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/textures/thumbs"] withIntermediateDirectories:YES attributes:nil error:&err])
|
||||||
{
|
{
|
||||||
LOG("error creating patterns thumbs path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
LOG("error creating textures thumbs path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
||||||
}
|
}
|
||||||
// settings
|
// settings
|
||||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/settings"] withIntermediateDirectories:YES attributes:nil error:&err])
|
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/settings"] withIntermediateDirectories:YES attributes:nil error:&err])
|
||||||
@@ -237,10 +237,10 @@ void App::initLog()
|
|||||||
if (!PathFileExistsA((data_path + "\\brushes\\thumbs").c_str()))
|
if (!PathFileExistsA((data_path + "\\brushes\\thumbs").c_str()))
|
||||||
CreateDirectoryA((data_path + "\\brushes\\thumbs").c_str(), NULL);
|
CreateDirectoryA((data_path + "\\brushes\\thumbs").c_str(), NULL);
|
||||||
|
|
||||||
if (!PathFileExistsA((data_path + "\\patterns").c_str()))
|
if (!PathFileExistsA((data_path + "\\textures").c_str()))
|
||||||
CreateDirectoryA((data_path + "\\patterns").c_str(), NULL);
|
CreateDirectoryA((data_path + "\\textures").c_str(), NULL);
|
||||||
if (!PathFileExistsA((data_path + "\\patterns\\thumbs").c_str()))
|
if (!PathFileExistsA((data_path + "\\textures\\thumbs").c_str()))
|
||||||
CreateDirectoryA((data_path + "\\patterns\\thumbs").c_str(), NULL);
|
CreateDirectoryA((data_path + "\\textures\\thumbs").c_str(), NULL);
|
||||||
|
|
||||||
if (!PathFileExistsA((data_path + "\\settings").c_str()))
|
if (!PathFileExistsA((data_path + "\\settings").c_str()))
|
||||||
CreateDirectoryA((data_path + "\\settings").c_str(), NULL);
|
CreateDirectoryA((data_path + "\\settings").c_str(), NULL);
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ void App::init_sidebar()
|
|||||||
Canvas::I->m_current_brush->load_texture(path, thumb);
|
Canvas::I->m_current_brush->load_texture(path, thumb);
|
||||||
stroke->m_preview->draw_stroke();
|
stroke->m_preview->draw_stroke();
|
||||||
};
|
};
|
||||||
stroke->on_stencil_changed = [this](Node*target, const std::string& path, const std::string& thumb) {
|
stroke->on_texture_changed = [this](Node*target, const std::string& path, const std::string& thumb) {
|
||||||
Canvas::I->m_current_brush->load_stencil(path, thumb);
|
Canvas::I->m_current_brush->load_stencil(path, thumb);
|
||||||
stroke->m_preview->draw_stroke();
|
stroke->m_preview->draw_stroke();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ void Stroke::add_point(glm::vec3 pos, float pressure)
|
|||||||
float dist = m_keypoints.empty() ? m_step :
|
float dist = m_keypoints.empty() ? m_step :
|
||||||
m_keypoints.back().dist + glm::distance(m_keypoints.back().pos, pos);
|
m_keypoints.back().dist + glm::distance(m_keypoints.back().pos, pos);
|
||||||
if (m_keypoints.empty())
|
if (m_keypoints.empty())
|
||||||
m_prev_sample.origin = pos;
|
m_prev_sample = randomize_sample(pos, pressure, 0);
|
||||||
else if (m_keypoints.back().pos == pos)
|
else if (m_keypoints.back().pos == pos)
|
||||||
return; // skip same point, leading to black samples (NaN values)
|
return; // skip same point, leading to black samples (NaN values)
|
||||||
Keypoint kp;
|
Keypoint kp;
|
||||||
|
|||||||
@@ -444,7 +444,7 @@ std::vector<Canvas::StrokeFrame> Canvas::stroke_draw_compute(Stroke& stroke) con
|
|||||||
B[j].uvs2 = p / mixer_sz;
|
B[j].uvs2 = p / mixer_sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
f.m_mixer_rect = { mixer_bb_min, mixer_bb_max - mixer_bb_min };
|
f.m_mixer_rect = { glm::floor(mixer_bb_min), glm::ceil(mixer_bb_max - mixer_bb_min) };
|
||||||
f.col = glm::vec4(s.col, 1);
|
f.col = glm::vec4(s.col, 1);
|
||||||
f.pressure = s.flow;
|
f.pressure = s.flow;
|
||||||
f.shapes = stroke_draw_project(B);
|
f.shapes = stroke_draw_project(B);
|
||||||
|
|||||||
@@ -73,8 +73,11 @@ void NodePanelBrush::init()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& samp : abr.m_samples)
|
parallel_for(abr.m_samples.size(), [&](size_t i)
|
||||||
{
|
{
|
||||||
|
auto ii = abr.m_samples.begin();
|
||||||
|
std::advance(ii, i);
|
||||||
|
const auto& samp = *ii;
|
||||||
std::string path_high = App::I.data_path + "/brushes/" + samp.first + ".png";
|
std::string path_high = App::I.data_path + "/brushes/" + samp.first + ".png";
|
||||||
std::string path_thumb = App::I.data_path + "/brushes/thumbs/" + samp.first + ".png";
|
std::string path_thumb = App::I.data_path + "/brushes/thumbs/" + samp.first + ".png";
|
||||||
auto padded = samp.second->resize_squared(glm::u8vec4(255));
|
auto padded = samp.second->resize_squared(glm::u8vec4(255));
|
||||||
@@ -83,29 +86,32 @@ void NodePanelBrush::init()
|
|||||||
auto thumb = padded.resize(64, 64);
|
auto thumb = padded.resize(64, 64);
|
||||||
thumb.save(path_thumb);
|
thumb.save(path_thumb);
|
||||||
|
|
||||||
async_start();
|
//async_start();
|
||||||
NodeButtonBrush* brush = new NodeButtonBrush;
|
//NodeButtonBrush* brush = new NodeButtonBrush;
|
||||||
m_container->add_child(brush);
|
//m_container->add_child(brush);
|
||||||
brush->init();
|
//brush->init();
|
||||||
brush->create();
|
//brush->create();
|
||||||
brush->loaded();
|
//brush->loaded();
|
||||||
brush->set_icon(path_thumb.c_str());
|
//brush->set_icon(path_thumb.c_str());
|
||||||
brush->thumb_path = path_thumb;
|
//brush->thumb_path = path_thumb;
|
||||||
brush->high_path = path_high;
|
//brush->high_path = path_high;
|
||||||
brush->brush_name = name;
|
//brush->brush_name = name;
|
||||||
brush->m_user_brush = true;
|
//brush->m_user_brush = true;
|
||||||
brush->on_click = std::bind(&NodePanelBrush::handle_click, this, std::placeholders::_1);
|
//brush->on_click = std::bind(&NodePanelBrush::handle_click, this, std::placeholders::_1);
|
||||||
app_redraw();
|
//app_redraw();
|
||||||
async_end();
|
//async_end();
|
||||||
}
|
});
|
||||||
for (const auto& patt : abr.m_patterns)
|
parallel_for(abr.m_patterns.size(), [&](size_t i)
|
||||||
{
|
{
|
||||||
std::string path_high = App::I.data_path + "/patterns/" + patt.first + ".png";
|
auto ii = abr.m_patterns.begin();
|
||||||
std::string path_thumb = App::I.data_path + "/patterns/thumbs/" + patt.first + ".png";
|
std::advance(ii, i);
|
||||||
|
const auto& patt = *ii;
|
||||||
|
std::string path_high = App::I.data_path + "/textures/" + patt.first + ".png";
|
||||||
|
std::string path_thumb = App::I.data_path + "/textures/thumbs/" + patt.first + ".png";
|
||||||
patt.second->save(path_high);
|
patt.second->save(path_high);
|
||||||
auto thumb = patt.second->resize(64, 64);
|
auto thumb = patt.second->resize(64, 64);
|
||||||
thumb.save(path_thumb);
|
thumb.save(path_thumb);
|
||||||
}
|
});
|
||||||
auto brushes = abr.compute_brushes(App::I.data_path);
|
auto brushes = abr.compute_brushes(App::I.data_path);
|
||||||
for (const auto& pr : brushes)
|
for (const auto& pr : brushes)
|
||||||
{
|
{
|
||||||
@@ -120,10 +126,10 @@ void NodePanelBrush::init()
|
|||||||
}
|
}
|
||||||
//save();
|
//save();
|
||||||
}
|
}
|
||||||
else if (img.load_file(path))
|
else if (!m_dir_name.empty() && img.load_file(path))
|
||||||
{
|
{
|
||||||
std::string path_high = App::I.data_path + "/brushes/" + name + ".png";
|
std::string path_high = App::I.data_path + "/" + m_dir_name + "/" + name + ".png";
|
||||||
std::string path_thumb = App::I.data_path + "/brushes/thumbs/" + name + ".png";
|
std::string path_thumb = App::I.data_path + "/" + m_dir_name + "/thumbs/" + name + ".png";
|
||||||
|
|
||||||
img = img.resize_squared(glm::u8vec4(255));
|
img = img.resize_squared(glm::u8vec4(255));
|
||||||
//img.gayscale_alpha();
|
//img.gayscale_alpha();
|
||||||
@@ -204,13 +210,13 @@ void NodePanelBrush::init()
|
|||||||
|
|
||||||
m_container = find<NodeScroll>("brushes");
|
m_container = find<NodeScroll>("brushes");
|
||||||
restore();
|
restore();
|
||||||
if (m_container->m_children.empty())
|
if (m_container->m_children.empty() && !m_dir_name.empty())
|
||||||
{
|
{
|
||||||
auto icons = Asset::list_files("data/brushes", true, ".*\\.png$");
|
auto icons = Asset::list_files("data/" + m_dir_name, true, ".*\\.png$");
|
||||||
for (auto& i : icons)
|
for (auto& i : icons)
|
||||||
{
|
{
|
||||||
std::string path = "data/thumbs/" + i;
|
std::string path = "data/" + m_dir_name + "/thumbs/" + i;
|
||||||
std::string path_hi = "data/brushes/" + i;
|
std::string path_hi = "data/" + m_dir_name + "/" + i;
|
||||||
NodeButtonBrush* brush = new NodeButtonBrush;
|
NodeButtonBrush* brush = new NodeButtonBrush;
|
||||||
m_container->add_child(brush);
|
m_container->add_child(brush);
|
||||||
brush->init();
|
brush->init();
|
||||||
@@ -224,11 +230,11 @@ void NodePanelBrush::init()
|
|||||||
brush->on_click = std::bind(&NodePanelBrush::handle_click, this, std::placeholders::_1);
|
brush->on_click = std::bind(&NodePanelBrush::handle_click, this, std::placeholders::_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto custom_icons = Asset::list_files(App::I.data_path + "/brushes", true, ".*\\.png$");
|
auto custom_icons = Asset::list_files(App::I.data_path + "/" + m_dir_name, true, ".*\\.png$");
|
||||||
for (auto& i : custom_icons)
|
for (auto& i : custom_icons)
|
||||||
{
|
{
|
||||||
std::string path_thumb = App::I.data_path + "/brushes/thumbs/" + i;
|
std::string path_thumb = App::I.data_path + "/" + m_dir_name + "/thumbs/" + i;
|
||||||
std::string path_high = App::I.data_path + "/brushes/" + i;
|
std::string path_high = App::I.data_path + "/" + m_dir_name + "/" + i;
|
||||||
NodeButtonBrush* brush = new NodeButtonBrush;
|
NodeButtonBrush* brush = new NodeButtonBrush;
|
||||||
m_container->add_child(brush);
|
m_container->add_child(brush);
|
||||||
brush->init();
|
brush->init();
|
||||||
@@ -290,17 +296,21 @@ int NodePanelBrush::find_brush(const std::string & name) const
|
|||||||
|
|
||||||
std::string NodePanelBrush::get_texture_path(int index) const
|
std::string NodePanelBrush::get_texture_path(int index) const
|
||||||
{
|
{
|
||||||
|
if (index < 0 || index >= m_container->m_children.size())
|
||||||
|
return "";
|
||||||
return ((NodeButtonBrush*)m_container->m_children[index].get())->high_path;
|
return ((NodeButtonBrush*)m_container->m_children[index].get())->high_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string NodePanelBrush::get_thumb_path(int index) const
|
std::string NodePanelBrush::get_thumb_path(int index) const
|
||||||
{
|
{
|
||||||
|
if (index < 0 || index >= m_container->m_children.size())
|
||||||
|
return "";
|
||||||
return ((NodeButtonBrush*)m_container->m_children[index].get())->thumb_path;
|
return ((NodeButtonBrush*)m_container->m_children[index].get())->thumb_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NodePanelBrush::save()
|
bool NodePanelBrush::save()
|
||||||
{
|
{
|
||||||
auto path = App::I.data_path + "/settings/brushes.bin";
|
auto path = App::I.data_path + "/settings/" + m_dir_name + ".bin";
|
||||||
if (FILE* fp = fopen(path.c_str(), "wb"))
|
if (FILE* fp = fopen(path.c_str(), "wb"))
|
||||||
{
|
{
|
||||||
header_t h;
|
header_t h;
|
||||||
@@ -334,7 +344,7 @@ bool NodePanelBrush::save()
|
|||||||
|
|
||||||
bool NodePanelBrush::restore()
|
bool NodePanelBrush::restore()
|
||||||
{
|
{
|
||||||
auto path = App::I.data_path + "/settings/brushes.bin";
|
auto path = App::I.data_path + "/settings/" + m_dir_name + ".bin";
|
||||||
if (FILE* fp = fopen(path.c_str(), "rb"))
|
if (FILE* fp = fopen(path.c_str(), "rb"))
|
||||||
{
|
{
|
||||||
header_t h;
|
header_t h;
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class NodePanelBrush : public Node
|
|||||||
bool m_user_brush = false;
|
bool m_user_brush = false;
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
|
std::string m_dir_name;
|
||||||
std::function<void(Node* target, int index)> on_brush_changed;
|
std::function<void(Node* target, int index)> on_brush_changed;
|
||||||
std::function<void(Node* target)> on_popup_close;
|
std::function<void(Node* target)> on_popup_close;
|
||||||
virtual Node* clone_instantiate() const override;
|
virtual Node* clone_instantiate() const override;
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ void NodePanelStroke::init_controls()
|
|||||||
{
|
{
|
||||||
m_brush_popup = std::make_shared<NodePanelBrush>();
|
m_brush_popup = std::make_shared<NodePanelBrush>();
|
||||||
m_brush_popup->m_manager = m_manager;
|
m_brush_popup->m_manager = m_manager;
|
||||||
|
m_brush_popup->m_dir_name = "brushes";
|
||||||
m_brush_popup->init();
|
m_brush_popup->init();
|
||||||
m_brush_popup->create();
|
m_brush_popup->create();
|
||||||
m_brush_popup->loaded();
|
m_brush_popup->loaded();
|
||||||
@@ -86,6 +87,18 @@ void NodePanelStroke::init_controls()
|
|||||||
m_brush_popup->m_flood_events = true;
|
m_brush_popup->m_flood_events = true;
|
||||||
m_brush_popup->m_capture_children = false;
|
m_brush_popup->m_capture_children = false;
|
||||||
|
|
||||||
|
m_texture_popup = std::make_shared<NodePanelBrush>();
|
||||||
|
m_texture_popup->m_manager = m_manager;
|
||||||
|
m_texture_popup->m_dir_name = "textures";
|
||||||
|
m_texture_popup->init();
|
||||||
|
m_texture_popup->create();
|
||||||
|
m_texture_popup->loaded();
|
||||||
|
m_texture_popup->SetPositioning(YGPositionTypeAbsolute);
|
||||||
|
m_texture_popup->SetSize(300, 400);
|
||||||
|
m_texture_popup->m_mouse_ignore = false;
|
||||||
|
m_texture_popup->m_flood_events = true;
|
||||||
|
m_texture_popup->m_capture_children = false;
|
||||||
|
|
||||||
m_presets_popup = std::make_shared<NodePanelBrushPreset>();
|
m_presets_popup = std::make_shared<NodePanelBrushPreset>();
|
||||||
m_presets_popup->m_manager = m_manager;
|
m_presets_popup->m_manager = m_manager;
|
||||||
m_presets_popup->init();
|
m_presets_popup->init();
|
||||||
@@ -98,6 +111,7 @@ void NodePanelStroke::init_controls()
|
|||||||
m_presets_popup->m_capture_children = false;
|
m_presets_popup->m_capture_children = false;
|
||||||
|
|
||||||
int br_idx = std::max(m_brush_popup->find_brush("Round-Hard"), 0);
|
int br_idx = std::max(m_brush_popup->find_brush("Round-Hard"), 0);
|
||||||
|
|
||||||
// init main brush
|
// init main brush
|
||||||
auto b = std::make_shared<Brush>();
|
auto b = std::make_shared<Brush>();
|
||||||
b->load_texture(m_brush_popup->get_texture_path(br_idx), m_brush_popup->get_thumb_path(br_idx));
|
b->load_texture(m_brush_popup->get_texture_path(br_idx), m_brush_popup->get_thumb_path(br_idx));
|
||||||
@@ -219,11 +233,45 @@ void NodePanelStroke::init_controls()
|
|||||||
if (on_dual_changed)
|
if (on_dual_changed)
|
||||||
on_dual_changed(this, m_brush_popup->get_texture_path(index), m_brush_popup->get_thumb_path(index));
|
on_dual_changed(this, m_brush_popup->get_texture_path(index), m_brush_popup->get_thumb_path(index));
|
||||||
m_dual_brush_thumb->set_image(m_brush_popup->get_thumb_path(index));
|
m_dual_brush_thumb->set_image(m_brush_popup->get_thumb_path(index));
|
||||||
//m_brush_popup->mouse_release();
|
|
||||||
//m_brush_popup->parent->remove_child(m_brush_popup.get());
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// TEXTURE IMAGE
|
||||||
|
|
||||||
|
m_texture_thumb = find<NodeImage>("texture-change-thumb");
|
||||||
|
m_texture_thumb->set_image(m_texture_popup->get_thumb_path(0));
|
||||||
|
m_texture_button = find<NodeButtonCustom>("texture-change");
|
||||||
|
m_texture_button->on_click = [this](Node*) {
|
||||||
|
auto screen = root()->m_size;
|
||||||
|
glm::vec2 pos = m_texture_button->m_pos + glm::vec2(m_texture_button->m_size.x, 0);
|
||||||
|
root()->add_child(m_texture_popup);
|
||||||
|
auto tick = root()->add_child<NodeImage>();
|
||||||
|
tick->SetPositioning(YGPositionTypeAbsolute);
|
||||||
|
tick->SetSize(16, 32);
|
||||||
|
tick->SetPosition(pos.x, pos.y + (m_texture_button->m_size.y - 32) * 0.5f);
|
||||||
|
tick->set_image("data/ui/popup-tick.png");
|
||||||
|
root()->update();
|
||||||
|
if ((pos.y + m_texture_popup->m_size.y) > screen.y)
|
||||||
|
pos.y = screen.y - m_texture_popup->m_size.y;
|
||||||
|
if (pos.y < 0)
|
||||||
|
pos.y = 0;
|
||||||
|
m_texture_popup->SetPosition(pos.x + 16, pos.y);
|
||||||
|
m_texture_popup->mouse_capture();
|
||||||
|
root()->update();
|
||||||
|
|
||||||
|
m_texture_popup->on_popup_close = [this, tick](Node*) {
|
||||||
|
tick->destroy();
|
||||||
|
};
|
||||||
|
|
||||||
|
m_texture_popup->on_brush_changed = [this](Node*, int index) {
|
||||||
|
if (on_texture_changed)
|
||||||
|
on_texture_changed(this, m_texture_popup->get_texture_path(index), m_texture_popup->get_thumb_path(index));
|
||||||
|
m_texture_thumb->set_image(m_texture_popup->get_thumb_path(index));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
m_preview = find<NodeStrokePreview>("canvas");
|
m_preview = find<NodeStrokePreview>("canvas");
|
||||||
m_blend_mode = find<NodeComboBox>("blend-mode");
|
m_blend_mode = find<NodeComboBox>("blend-mode");
|
||||||
m_blend_mode->on_select = [this](Node*, int index) {
|
m_blend_mode->on_select = [this](Node*, int index) {
|
||||||
@@ -308,19 +356,21 @@ void NodePanelStroke::init_controls()
|
|||||||
m_preview->m_brush = Canvas::I->m_current_brush;
|
m_preview->m_brush = Canvas::I->m_current_brush;
|
||||||
m_preview->draw_stroke();
|
m_preview->draw_stroke();
|
||||||
|
|
||||||
|
/*
|
||||||
auto load_stencil = find<NodeButton>("tip-stencil-load");
|
auto load_stencil = find<NodeButton>("tip-stencil-load");
|
||||||
load_stencil->on_click = [this](Node*) {
|
load_stencil->on_click = [this](Node*) {
|
||||||
App::I.pick_image([this](std::string path) {
|
App::I.pick_image([this](std::string path) {
|
||||||
App::I.async_start();
|
App::I.async_start();
|
||||||
if (TextureManager::load(path.c_str()))
|
if (TextureManager::load(path.c_str()))
|
||||||
{
|
{
|
||||||
if (on_stencil_changed)
|
if (on_texture_changed)
|
||||||
on_stencil_changed(this, path, "");
|
on_texture_changed(this, path, "");
|
||||||
}
|
}
|
||||||
App::I.async_redraw();
|
App::I.async_redraw();
|
||||||
App::I.async_end();
|
App::I.async_end();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
update_controls();
|
update_controls();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,10 @@ public:
|
|||||||
NodeCheckBox* m_tip_size_pressure;
|
NodeCheckBox* m_tip_size_pressure;
|
||||||
NodeButtonCustom* m_brush_button;
|
NodeButtonCustom* m_brush_button;
|
||||||
NodeButtonCustom* m_dual_brush_button;
|
NodeButtonCustom* m_dual_brush_button;
|
||||||
|
NodeButtonCustom* m_texture_button;
|
||||||
NodeImage* m_brush_thumb;
|
NodeImage* m_brush_thumb;
|
||||||
NodeImage* m_dual_brush_thumb;
|
NodeImage* m_dual_brush_thumb;
|
||||||
|
NodeImage* m_texture_thumb;
|
||||||
NodeImage* m_preset_thumb;
|
NodeImage* m_preset_thumb;
|
||||||
NodeButtonCustom* m_preset_button;
|
NodeButtonCustom* m_preset_button;
|
||||||
NodeStrokePreview* m_preset_preview;
|
NodeStrokePreview* m_preset_preview;
|
||||||
@@ -68,9 +70,10 @@ public:
|
|||||||
NodeButtonCustom* m_tip_aspect_reset;
|
NodeButtonCustom* m_tip_aspect_reset;
|
||||||
|
|
||||||
std::shared_ptr<NodePanelBrush> m_brush_popup;
|
std::shared_ptr<NodePanelBrush> m_brush_popup;
|
||||||
|
std::shared_ptr<NodePanelBrush> m_texture_popup;
|
||||||
std::shared_ptr<NodePanelBrushPreset> m_presets_popup;
|
std::shared_ptr<NodePanelBrushPreset> m_presets_popup;
|
||||||
std::function<void(Node* target)> on_stroke_change;
|
std::function<void(Node* target)> on_stroke_change;
|
||||||
std::function<void(Node* target, const std::string& path, const std::string& thumb)> on_stencil_changed;
|
std::function<void(Node* target, const std::string& path, const std::string& thumb)> on_texture_changed;
|
||||||
std::function<void(Node* target, const std::string& path, const std::string& thumb)> on_brush_changed;
|
std::function<void(Node* target, const std::string& path, const std::string& thumb)> on_brush_changed;
|
||||||
std::function<void(Node* target, const std::string& path, const std::string& thumb)> on_dual_changed;
|
std::function<void(Node* target, const std::string& path, const std::string& thumb)> on_dual_changed;
|
||||||
std::map<NodeSliderH*, std::function<float(float)>> m_curves;
|
std::map<NodeSliderH*, std::function<float(float)>> m_curves;
|
||||||
|
|||||||
Reference in New Issue
Block a user