Skip to content

Commit

Permalink
Revert "Child controls are added in IContainerBase::AttachChildContro…
Browse files Browse the repository at this point in the history
…ls()"

This reverts commit 0c9444b.
  • Loading branch information
olilarkin committed May 19, 2023
1 parent d310ac2 commit c259b03
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions IGraphics/IControl.h
Expand Up @@ -595,11 +595,9 @@ class IControl
*/

/** IContainerBase allows a control to nest sub controls and it clips the drawing of those subcontrols
* Inheritors can add child controls by overriding AttachChildControls() and calling AddChildControl(), or passing in an AttachFunc lambda to the construtor.
* Inheritors can add child controls by overriding OnAttached() and calling AddChildControl(), or passing in an AttachFunc lambda to the construtor.
* Child controls should not have been added elsewhere
* OnResized() should also be overriden if the parent control bounds will change (this can also be specified in a ResizeFunc lambda)
* If you are laying out controls in OnResized() or via the ResizeFunc, you can provide an invalid rect when creating the \
* child controls, since they will be resized immediately */
* OnResized() should also be overriden if the control bounds will change (can also be specified in a ResizeFunc lambda) */
class IContainerBase : public IControl
{
public:
Expand Down Expand Up @@ -646,9 +644,12 @@ class IContainerBase : public IControl
mChildren.Empty(false);
}

virtual void OnInit() override
virtual void OnAttached() override
{
AttachChildControls();
if (mAttachFunc)
mAttachFunc(this, mRECT);

OnResize();
}

virtual void OnResize() override
Expand All @@ -657,12 +658,6 @@ class IContainerBase : public IControl
mResizeFunc(this, mRECT);
}

virtual void AttachChildControls()
{
if (mAttachFunc)
mAttachFunc(this, mRECT);
}

void SetDisabled(bool disable) override
{
ForAllChildrenFunc([disable](int childIdx, IControl* pChild) {
Expand Down

0 comments on commit c259b03

Please sign in to comment.