avoid animation panel from dropping to the side panel

This commit is contained in:
2019-10-17 21:25:38 +02:00
parent 7487feb168
commit 880eb7a406
4 changed files with 72 additions and 56 deletions

View File

@@ -428,6 +428,9 @@
</button-custom> </button-custom>
--> -->
</border> </border>
<!--<scroll id="drop-top" color="0 0 0 .5" min-height="10" mouse-capture="true" rtl="ltr"/>-->
<!-- central row --> <!-- central row -->
<node grow="1" dir="row" wrap="1" height="0" id="central-row"> <node grow="1" dir="row" wrap="1" height="0" id="central-row">
<border color="0 0 0 0.6" pad="0 5 55 0" justify="center" dir="col" wrap="1" flood-events="1" mouse-capture="true"> <border color="0 0 0 0.6" pad="0 5 55 0" justify="center" dir="col" wrap="1" flood-events="1" mouse-capture="true">
@@ -466,7 +469,7 @@
</button-custom> </button-custom>
</border> </border>
<scroll id="drop-left" color="0 0 0 .6" min-width="10" mouse-capture="true" rtl="ltr"/> <scroll id="drop-left" color="0 0 0 .5" min-width="10" mouse-capture="true" rtl="ltr"/>
<node dir="col" width="1" grow="1" height="100%"> <node dir="col" width="1" grow="1" height="100%">
<!-- timeline --> <!-- timeline -->
@@ -482,23 +485,23 @@
</button-custom> </button-custom>
</border> </border>
</node> </node>
<!--tools options--> <!--tools options-->
<border id="tools-container" color="0 0 0 0.3" dir="row" justify="center" mouse-capture="true"> <border id="tools-container" color="0 0 0 0.3" dir="row" justify="center" mouse-capture="true">
</border> </border>
<node dir="row" height="200" grow="1"> <node dir="row" height="200" grow="1">
<!--floating area-->
<node id="floatings" positioning="absolute" color="0 0 0 1" width="100%" grow="1" height="100%" rtl="ltr"/>
<!--quick bar--> <!--quick bar-->
<node justify="center" align="center" dir="col" rtl="ltr"> <node justify="center" align="center" dir="col" rtl="ltr">
<panel-quick id="panel-quick"/> <panel-quick id="panel-quick"/>
<node height="0" grow="1" max-height="50"/> <node height="0" grow="1" max-height="50"/>
</node> </node>
<!--floating area-->
<node id="floatings" color="0 0 0 1" width="1" grow="1" height="100%" rtl="ltr"/>
</node> </node>
</node> </node>
<scroll id="drop-right" color="0 0 0 .6" min-width="10" mouse-capture="true" rtl="ltr"/> <scroll id="drop-right" color="0 0 0 .5" min-width="10" mouse-capture="true" rtl="ltr"/>
<!--<node height="100%" width="1" grow="1" dir="col" align="center" justify="flex-start" rtl="ltr"> <!--<node height="100%" width="1" grow="1" dir="col" align="center" justify="flex-start" rtl="ltr">
<border border-color="0 0 0 0" thickness="2" color=".2 .2 .2 .6" pad="10" dir="row" margin="2 0 0 0"> <border border-color="0 0 0 0" thickness="2" color=".2 .2 .2 .6" pad="10" dir="row" margin="2 0 0 0">
@@ -523,8 +526,11 @@
</node>--> </node>-->
</node> </node>
<!--<scroll id="drop-bottom" color="0 0 0 .5" min-height="10" mouse-capture="true" rtl="ltr"/>-->
<!-- status bar --> <!-- status bar -->
<border height="10" color="0 0 0 .6" mouse-capture="true"/> <!--<border height="10" color="0 0 0 .6" mouse-capture="true"/>-->
<!--<border height="30" width="100%" color=".15" border-color=".3" dir="row" pad="0 0 0 10" align="center"> <!--<border height="30" width="100%" color=".15" border-color=".3" dir="row" pad="0 0 0 10" align="center">
--><!--<text-input width="100" height="100%" color=".3"/>--><!-- --><!--<text-input width="100" height="100%" color=".3"/>--><!--
<text text="Status Bar: nothing to show here."/> <text text="Status Bar: nothing to show here."/>

View File

@@ -919,6 +919,7 @@ void App::init_menu_tools()
fpanel->m_container->add_child(animation); fpanel->m_container->add_child(animation);
fpanel->SetHeight(300); fpanel->SetHeight(300);
fpanel->m_title->set_text("Animation"); fpanel->m_title->set_text("Animation");
fpanel->m_droppable = false;
grid->SetPositioning(YGPositionTypeRelative); grid->SetPositioning(YGPositionTypeRelative);
grid->SetPosition(0, 0); grid->SetPosition(0, 0);
grid->SetWidthP(100); grid->SetWidthP(100);
@@ -1626,6 +1627,7 @@ void App::ui_restore()
break; break;
case NodePanelFloating::kClass::Animation: case NodePanelFloating::kClass::Animation:
f->m_container->add_child(animation); f->m_container->add_child(animation);
f->m_droppable = false;
//grid->find("title")->SetVisibility(false); //grid->find("title")->SetVisibility(false);
animation->SetPositioning(YGPositionTypeRelative); animation->SetPositioning(YGPositionTypeRelative);
animation->SetPosition(0, 0); animation->SetPosition(0, 0);

View File

@@ -114,39 +114,42 @@ kEventResult NodePanelFloating::handle_event(Event* e)
m_outline->SetPosition(m_parent->m_pos + m_drag_start_pos + me->m_pos - m_drag_start_cur); m_outline->SetPosition(m_parent->m_pos + m_drag_start_pos + me->m_pos - m_drag_start_cur);
m_outline->SetSize(GetSize()); m_outline->SetSize(GetSize());
std::vector<std::shared_ptr<Node>> nodes;
if (auto uir = root()->find("ui-root"))
nodes = uir->get_children_at_point(me->m_pos);
bool docked = false; bool docked = false;
for (auto const& c : nodes) if (m_droppable)
{ {
if (c->m_nodeID_s.find("drop") == 0) std::vector<std::shared_ptr<Node>> nodes;
if (auto uir = root()->find("ui-root"))
nodes = uir->get_children_at_point(me->m_pos);
for (auto const& c : nodes)
{ {
m_outline->SetPosition(c->m_pos); if (c->m_nodeID_s.find("drop") == 0)
m_outline->SetSize(c->m_size);
m_drop_placeholder->remove_from_parent();
int i = 0;
float y = 0;
for (; i < c->m_children.size(); i++)
{ {
if (c->m_children[i] == m_drop_placeholder) m_outline->SetPosition(c->m_pos);
continue; m_outline->SetSize(c->m_size);
float y = c->m_children[i]->m_pos.y - c->m_pos.y + c->m_children[i]->m_size.y / 2.f; m_drop_placeholder->remove_from_parent();
float my = me->m_pos.y - c->m_pos.y; int i = 0;
if (my <= y) float y = 0;
break; for (; i < c->m_children.size(); i++)
{
if (c->m_children[i] == m_drop_placeholder)
continue;
float y = c->m_children[i]->m_pos.y - c->m_pos.y + c->m_children[i]->m_size.y / 2.f;
float my = me->m_pos.y - c->m_pos.y;
if (my <= y)
break;
}
i = std::min(i, (int)c->m_children.size());
if (/*m_parent != c.get() && */m_drop_placeholder->m_parent != c.get())
{
c->add_child(m_drop_placeholder, i);
}
else
{
c->move_child(m_drop_placeholder.get(), i);
}
docked = true;
break;
} }
i = std::min(i, (int)c->m_children.size());
if (/*m_parent != c.get() && */m_drop_placeholder->m_parent != c.get())
{
c->add_child(m_drop_placeholder, i);
}
else
{
c->move_child(m_drop_placeholder.get(), i);
}
docked = true;
break;
} }
} }
if (!docked && m_drop_placeholder->m_parent) if (!docked && m_drop_placeholder->m_parent)
@@ -183,29 +186,31 @@ kEventResult NodePanelFloating::handle_event(Event* e)
m_drop_placeholder->destroy(); m_drop_placeholder->destroy();
m_drop_placeholder->remove_from_parent(); m_drop_placeholder->remove_from_parent();
} }
std::vector<std::shared_ptr<Node>> nodes;
if (auto uir = root()->find("ui-root"))
nodes = uir->get_children_at_point(me->m_pos);
bool docked = false; bool docked = false;
auto ref = m_parent->m_children[m_parent->get_child_index(this)]; if (m_droppable)
for (auto const& c : nodes)
{ {
if (c->m_nodeID_s.find("drop") == 0) std::vector<std::shared_ptr<Node>> nodes;
if (auto uir = root()->find("ui-root"))
nodes = uir->get_children_at_point(me->m_pos);
for (auto const& c : nodes)
{ {
SetPositioning(YGPositionTypeRelative); if (c->m_nodeID_s.find("drop") == 0)
SetPosition(0, 0);
if (m_dock.lock() != c)
{ {
SetWidth(350); SetPositioning(YGPositionTypeRelative);
c->add_child(ref, drop_pos); SetPosition(0, 0);
m_dock = c; if (m_dock.lock() != c)
{
SetWidth(350);
c->add_child(shared_from_this(), drop_pos);
m_dock = c;
}
else
{
c->move_child(this, std::min((int)c->m_children.size() - 1, drop_pos));
}
docked = true;
break;
} }
else
{
c->move_child(ref.get(), std::min((int)c->m_children.size() - 1, drop_pos));
}
docked = true;
break;
} }
} }
if (!docked && !m_dock.expired()) if (!docked && !m_dock.expired())
@@ -214,7 +219,7 @@ kEventResult NodePanelFloating::handle_event(Event* e)
SetPositioning(YGPositionTypeAbsolute); SetPositioning(YGPositionTypeAbsolute);
auto newpos = glm::clamp(outline_pos - cont->m_pos, { 0, 0 }, cont->m_size - m_size); auto newpos = glm::clamp(outline_pos - cont->m_pos, { 0, 0 }, cont->m_size - m_size);
SetPosition(newpos); SetPosition(newpos);
cont->add_child(ref); cont->add_child(shared_from_this());
m_dock.reset(); m_dock.reset();
} }
m_outline = nullptr; m_outline = nullptr;

View File

@@ -15,12 +15,15 @@ class NodePanelFloating : public NodeBorder
NodeBorder* m_outline; NodeBorder* m_outline;
std::shared_ptr<NodeBorder> m_drop_placeholder; std::shared_ptr<NodeBorder> m_drop_placeholder;
public: public:
Node* m_container;
NodeText* m_title;
std::weak_ptr<Node> m_dock;
using this_class = NodePanelFloating; using this_class = NodePanelFloating;
using parent = NodeBorder; using parent = NodeBorder;
enum class kClass : uint8_t { Presets, Color, ColorAdv, Layers, Brush, Grids, Animation, Generic } m_class = kClass::Generic; enum class kClass : uint8_t { Presets, Color, ColorAdv, Layers, Brush, Grids, Animation, Generic } m_class = kClass::Generic;
Node* m_container;
NodeText* m_title;
std::weak_ptr<Node> m_dock;
bool m_droppable = true;
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 kEventResult handle_event(Event* e) override; virtual kEventResult handle_event(Event* e) override;