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>
-->
</border>
<!--<scroll id="drop-top" color="0 0 0 .5" min-height="10" mouse-capture="true" rtl="ltr"/>-->
<!-- 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">
@@ -466,7 +469,7 @@
</button-custom>
</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%">
<!-- timeline -->
@@ -488,17 +491,17 @@
</border>
<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-->
<node justify="center" align="center" dir="col" rtl="ltr">
<panel-quick id="panel-quick"/>
<node height="0" grow="1" max-height="50"/>
</node>
<!--floating area-->
<node id="floatings" color="0 0 0 1" width="1" grow="1" height="100%" rtl="ltr"/>
</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">
<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>
<!--<scroll id="drop-bottom" color="0 0 0 .5" min-height="10" mouse-capture="true" rtl="ltr"/>-->
<!-- 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">
--><!--<text-input width="100" height="100%" color=".3"/>--><!--
<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->SetHeight(300);
fpanel->m_title->set_text("Animation");
fpanel->m_droppable = false;
grid->SetPositioning(YGPositionTypeRelative);
grid->SetPosition(0, 0);
grid->SetWidthP(100);
@@ -1626,6 +1627,7 @@ void App::ui_restore()
break;
case NodePanelFloating::kClass::Animation:
f->m_container->add_child(animation);
f->m_droppable = false;
//grid->find("title")->SetVisibility(false);
animation->SetPositioning(YGPositionTypeRelative);
animation->SetPosition(0, 0);

View File

@@ -114,10 +114,12 @@ 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->SetSize(GetSize());
bool docked = false;
if (m_droppable)
{
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;
for (auto const& c : nodes)
{
if (c->m_nodeID_s.find("drop") == 0)
@@ -149,6 +151,7 @@ kEventResult NodePanelFloating::handle_event(Event* e)
break;
}
}
}
if (!docked && m_drop_placeholder->m_parent)
m_drop_placeholder->remove_from_parent();
}
@@ -183,11 +186,12 @@ kEventResult NodePanelFloating::handle_event(Event* e)
m_drop_placeholder->destroy();
m_drop_placeholder->remove_from_parent();
}
bool docked = false;
if (m_droppable)
{
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;
auto ref = m_parent->m_children[m_parent->get_child_index(this)];
for (auto const& c : nodes)
{
if (c->m_nodeID_s.find("drop") == 0)
@@ -197,24 +201,25 @@ kEventResult NodePanelFloating::handle_event(Event* e)
if (m_dock.lock() != c)
{
SetWidth(350);
c->add_child(ref, drop_pos);
c->add_child(shared_from_this(), drop_pos);
m_dock = c;
}
else
{
c->move_child(ref.get(), std::min((int)c->m_children.size() - 1, drop_pos));
c->move_child(this, std::min((int)c->m_children.size() - 1, drop_pos));
}
docked = true;
break;
}
}
}
if (!docked && !m_dock.expired())
{
auto cont = root()->find("floatings");
SetPositioning(YGPositionTypeAbsolute);
auto newpos = glm::clamp(outline_pos - cont->m_pos, { 0, 0 }, cont->m_size - m_size);
SetPosition(newpos);
cont->add_child(ref);
cont->add_child(shared_from_this());
m_dock.reset();
}
m_outline = nullptr;

View File

@@ -15,12 +15,15 @@ class NodePanelFloating : public NodeBorder
NodeBorder* m_outline;
std::shared_ptr<NodeBorder> m_drop_placeholder;
public:
Node* m_container;
NodeText* m_title;
std::weak_ptr<Node> m_dock;
using this_class = NodePanelFloating;
using parent = NodeBorder;
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 void clone_finalize(Node* dest) const override;
virtual kEventResult handle_event(Event* e) override;