Skip to content

Commit

Permalink
Fixed nested layout and docking area doesn't revert children properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Neko-Box-Coder committed Sep 16, 2023
1 parent 0adfff0 commit cb30630
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
5 changes: 3 additions & 2 deletions Include/ssGUI/DataClasses/EventCallbackManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ namespace ssGUI
virtual void SetDependentComponents(ssGUI::Renderer* renderer, ssGUI::GUIObject* obj);

//function: AddEventCallback
//Adds an eventCallback to this GUI Object. If the eventCallback already exists, nothing will be modified.
//Adds an eventCallback to this GUI Object.
//If the eventCallback already exists, it will return the existing one event callback.
virtual ssGUI::EventCallback* AddEventCallback(ssGUI::Enums::EventType eventType);

//function: AddEventCallbackCopy
//Adds an eventCallback to this GUI Object by copying an already existing eventCallback.
//If an eventCallback already exists in this GUI object, nothing will be modified.
//If the eventCallback already exists, it will return the existing one event callback.
virtual ssGUI::EventCallback* AddEventCallbackCopy(ssGUI::EventCallback* copy, bool copyListeners);

//function: GetEventCallback
Expand Down
9 changes: 5 additions & 4 deletions Src/ssGUI/DataClasses/Hierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,6 @@ namespace ssGUI

//Update local position
CurrentTransform->SetGlobalPosition(CurrentTransform->GetGlobalPosition());

//Update focus status for recursive parent objects if this object is focused
if(IsFocused())
SetFocus(true);

//Send event callback if any object is subscribed to child added
if(newParent->IsEventCallbackExist(ssGUI::Enums::EventType::CHILD_ADDED))
Expand All @@ -319,6 +315,11 @@ namespace ssGUI

currentParent = currentParent->GetParent();
}

//Update focus status for recursive parent objects if this object is focused
//This will trigger position changed callback so set the focus after notifying all event callbacks
if(IsFocused())
SetFocus(true);
}

bool Hierarchy::IsCurrentChildComposite() const
Expand Down
2 changes: 1 addition & 1 deletion Src/ssGUI/Extensions/DockableV2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ namespace Extensions
containerWindow->SetParent(mainWindow);
else
containerWindow->SetParent(CurrentObjectsReferences.GetObjectReference(TopLevelParent));

containerWindow->SetGlobalPosition(posBeforeUndocking + LastDraggedDistance);
LastDraggedDistance = glm::vec2();
}
Expand Down
7 changes: 0 additions & 7 deletions Src/ssGUI/Extensions/DockingArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,15 +486,8 @@ namespace Extensions
if(lastChild != nullptr)
{
dockingAreaExt->PauseChildRemovedEventListener = true;

//Remove layout extension first since it modifiy the size when child get removed
if(info.Container->IsExtensionExist<ssGUI::Extensions::Layout>())
info.Container->RemoveExtension<ssGUI::Extensions::Layout>();

lastChild->SetParent(info.Container->GetParent());

info.Container->GetParent()->MoveChildAfterTargetChild(lastChild, info.Container);

dockingAreaExt->PauseChildRemovedEventListener = false;
}

Expand Down
3 changes: 3 additions & 0 deletions Src/ssGUI/Extensions/Layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ namespace Extensions
target->RemoveEventCallback(eventType);
};

//Revert any changes we made to the children when they got parented
SetOverrideChildrenResizeTypeAndOnTop(false);

eventCallbackCleanUp(Container, ssGUI::Enums::EventType::BEFORE_RECURSIVE_CHILD_ADD);
eventCallbackCleanUp(Container, ssGUI::Enums::EventType::RECURSIVE_CHILD_ADDED);
eventCallbackCleanUp(Container, ssGUI::Enums::EventType::RECURSIVE_CHILD_REMOVED);
Expand Down

0 comments on commit cb30630

Please sign in to comment.