improve reload ui
This commit is contained in:
@@ -144,7 +144,7 @@
|
||||
</node>
|
||||
<button id="button-unfold-all" width="30" height="20" text="+" margin="0 5 0 0"/>
|
||||
</border>
|
||||
<border color=".4" pad="5" dir="col" width="100%">
|
||||
<border color=".4" pad="5" dir="col" width="100%" grow="1">
|
||||
|
||||
<!-- PREVIEW -->
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
<stroke-preview id="canvas" width="100%" height="100"/>
|
||||
</button-custom>
|
||||
|
||||
<scroll id="scroller" scroll-color=".3" margin="5 5 5 10" max-height="500" color=".4">
|
||||
<scroll id="scroller" scroll-color=".3" margin="5 5 5 10" color=".4" height="1" grow="1">
|
||||
|
||||
<!-- PRESET AND SHAPE -->
|
||||
|
||||
|
||||
@@ -238,6 +238,7 @@ void App::init_sidebar()
|
||||
fp->destroy();
|
||||
}
|
||||
layout[main_id]->add_child(stroke);
|
||||
stroke->SetSize(350, YGUndefined);
|
||||
auto tick = layout[main_id]->add_child<NodeImage>();
|
||||
tick->SetPositioning(YGPositionTypeAbsolute);
|
||||
tick->SetSize(32, 16);
|
||||
@@ -251,7 +252,7 @@ void App::init_sidebar()
|
||||
stroke->m_mouse_ignore = false;
|
||||
stroke->mouse_capture();
|
||||
auto scroll = stroke->find<NodeScroll>("scroller");
|
||||
scroll->SetMaxHeight(glm::max(100.f, screen.y - pos.y - 200.f));
|
||||
scroll->SetHeight(glm::max(100.f, screen.y - pos.y - 200.f));
|
||||
layout[main_id]->update();
|
||||
|
||||
stroke->on_popup_close = [this, tick](Node*) {
|
||||
@@ -1179,6 +1180,11 @@ void App::initLayout()
|
||||
NodeIcon::static_init();
|
||||
NodeStrokePreview::static_init();
|
||||
|
||||
layout.on_reloading = [&] {
|
||||
ui_save();
|
||||
NodeStrokePreview::empty_queue();
|
||||
};
|
||||
|
||||
layout.on_loaded = [&] {
|
||||
LOG("initializing layout updating after load");
|
||||
layout[main_id]->update(width, height, zoom);
|
||||
|
||||
@@ -32,6 +32,9 @@ bool LayoutManager::load(const char* path)
|
||||
if (m_loaded)
|
||||
return true; // already loaded
|
||||
#endif // __ANDROID__
|
||||
|
||||
if (!m_layouts.empty() && on_reloading)
|
||||
on_reloading();
|
||||
|
||||
m_path = path;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ class LayoutManager
|
||||
public:
|
||||
bool m_loaded = false;
|
||||
std::function<void()> on_loaded;
|
||||
std::function<void()> on_reloading;
|
||||
void unload();
|
||||
void create();
|
||||
bool load(const char* path);
|
||||
|
||||
@@ -92,7 +92,7 @@ enum class kWidget : uint16_t
|
||||
UserManual = const_hash("usermanual"),
|
||||
};
|
||||
|
||||
class Node
|
||||
class Node : public std::enable_shared_from_this<Node>
|
||||
{
|
||||
friend class LayoutManager;
|
||||
public:
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
std::atomic_int NodeStrokePreview::s_instances{ 0 };
|
||||
std::atomic_bool NodeStrokePreview::s_running{ false };
|
||||
std::thread NodeStrokePreview::s_renderer;
|
||||
BlockingQueue<NodeStrokePreview*> NodeStrokePreview::s_queue;
|
||||
BlockingQueue<std::shared_ptr<NodeStrokePreview>> NodeStrokePreview::s_queue;
|
||||
|
||||
RTT NodeStrokePreview::m_rtt;
|
||||
RTT NodeStrokePreview::m_rtt_mixer;
|
||||
@@ -33,6 +33,11 @@ void NodeStrokePreview::terminate_renderer()
|
||||
}
|
||||
}
|
||||
|
||||
void NodeStrokePreview::empty_queue()
|
||||
{
|
||||
s_queue.q.clear();
|
||||
}
|
||||
|
||||
Node* NodeStrokePreview::clone_instantiate() const
|
||||
{
|
||||
return new NodeStrokePreview();
|
||||
@@ -548,7 +553,7 @@ void NodeStrokePreview::draw_stroke()
|
||||
});
|
||||
}
|
||||
s_queue.mutex.unlock();
|
||||
s_queue.PostUnique(this, m_draw_first);
|
||||
s_queue.PostUnique(std::static_pointer_cast<NodeStrokePreview>(shared_from_this()), m_draw_first);
|
||||
}
|
||||
|
||||
void NodeStrokePreview::draw()
|
||||
|
||||
@@ -29,8 +29,9 @@ public:
|
||||
static std::atomic_int s_instances;
|
||||
static std::atomic_bool s_running;
|
||||
static std::thread s_renderer;
|
||||
static BlockingQueue<NodeStrokePreview*> s_queue;
|
||||
static BlockingQueue<std::shared_ptr<NodeStrokePreview>> s_queue;
|
||||
static void terminate_renderer();
|
||||
static void empty_queue();
|
||||
std::shared_ptr<Brush> m_brush;
|
||||
std::shared_ptr<Brush> m_dual_brush;
|
||||
bool m_draw_first = false;
|
||||
|
||||
Reference in New Issue
Block a user