#include "GuiGraphicsCompositionBase.h"
#include "../Controls/GuiWindowControls.h"
#include "../GraphicsHost/GuiGraphicsHost.h"
namespace
{
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
controls
;
using
namespace
elements
;
void
InvokeOnCompositionStateChanged
(
compositions
::
*
)
{
->
InvokeOnCompositionStateChanged
();
}
void
::
(
controls
::
*
)
{
if
(
&&
!=
)
{
if
(
->
())
{
->
()->
(
);
}
if
(
)
{
->
(
);
}
}
else
{
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
);
}
}
}
void
::
(
*
)
{
->
(
());
}
void
::
(
*
)
{
->
(
0
);
}
void
::
(
*
,
*
)
{
();
}
void
::
()
{
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
();
}
}
void
::
()
{
}
void
::
(
*
)
{
=
;
auto
=
();
if
(
)
{
if
(
auto
=
())
{
renderer
->
(
renderTarget
);
}
}
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
);
}
if
(
())
{
()->
.
(
(
this
));
}
if
(
)
{
->
(
renderTarget
);
}
();
}
void
::
(
controls
::
*
)
{
if
(
)
{
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
0
);
}
}
=
;
if
(
)
{
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
);
}
}
}
void
::
InvokeOnCompositionStateChanged
()
{
if
(
)
{
->
->
();
}
}
bool
::
(
*
,
bool
)
{
*
=
dynamic_cast
<
*>(
);
if
(
value
->
)
{
if
(!
)
return
false
;
}
(
value
);
return
true
;
}
::
()
{
= &
::
;
}
::
()
{
for
(
=
0
;
i
<
.
();
i
++)
{
delete
i
];
}
}
bool
::
()
{
return
;
}
*
::
()
{
return
;
}
const
::
&
::
()
{
return
;
}
bool
::
(
*
)
{
return
(
.
(),
);
}
bool
::
(
,
*
)
{
CHECK_ERROR(!isRendering, L"GuiGraphicsComposition::InsertChild(vint, GuiGraphicsComposition*)#Cannot modify composition tree during rendering.");
do
{
if
(!(!
))
throw
(
L"GuiGraphicsComposition::InsertChild(vint, GuiGraphicsComposition*)#Cannot modify composition tree during rendering."
);}
while
(
0
);
if
(!
)
return
false
;
if
(
->
())
return
false
;
.
(
,
);
->
=
this
;
->
(
nullptr
,
this
);
(
);
->
(
);
InvokeOnCompositionStateChanged
();
return
true
;
}
bool
::
(
*
)
{
CHECK_ERROR(!isRendering, L"GuiGraphicsComposition::InsertChild(vint, GuiGraphicsComposition*)#Cannot modify composition tree during rendering.");
do
{
if
(!(!
))
throw
(
L"GuiGraphicsComposition::InsertChild(vint, GuiGraphicsComposition*)#Cannot modify composition tree during rendering."
);}
while
(
0
);
if
(!
)
return
false
;
=
.
(
);
if
(
index
== -
1
)
return
false
;
->
=
nullptr
;
->
(
this
,
nullptr
);
(
);
->
(
nullptr
);
*
=
();
if
(
host
)
{
host
->
(
);
}
.
(
index
);
InvokeOnCompositionStateChanged
();
return
true
;
}
bool
::
(
*
,
)
{
if
(!
)
return
false
;
=
.
(
);
if
(
index
==-
1
)
return
false
;
.
(
index
);
.
(
,
);
InvokeOnCompositionStateChanged
();
return
true
;
}
<
>
::
()
{
return
;
}
void
::
(
<
>
)
{
if
(
)
{
if
(
)
{
if
(
auto
=
())
{
renderer
->
(
nullptr
);
}
(
nullptr
);
}
;
if
(
)
{
if
(
auto
=
())
{
renderer
->
(
());
}
(
this
);
}
InvokeOnCompositionStateChanged
();
}
}
bool
::
()
{
return
;
}
void
::
(
bool
)
{
=
;
InvokeOnCompositionStateChanged
();
}
::
::
()
{
return
;
}
void
::
(
)
{
=
;
InvokeOnCompositionStateChanged
();
}
elements
::
*
::
()
{
return
?
->
:
nullptr
;
}
void
::
(
)
{
auto
=
();
if
(
&&
renderTarget
&& !
renderTarget
->
IsClipperCoverWholeTarget
())
{
=
();
bounds
.
+=
.
;
bounds
.
+=
.
;
bounds
.
-=
.
;
bounds
.
-=
.
;
if
(
bounds
.
<=
bounds
.
&&
bounds
.
<=
bounds
.
)
{
bounds
.
+=
.
;
bounds
.
+=
.
;
bounds
.
+=
.
;
bounds
.
+=
.
;
=
true
;
if
(
)
{
*
=
();
if
(
renderer
)
{
renderer
->
(
bounds
);
}
}
if
(
.
() >
0
)
{
bounds
.
+=
.
;
bounds
.
+=
.
;
bounds
.
-=
.
;
bounds
.
-=
.
;
if
(
bounds
.
<=
bounds
.
&&
bounds
.
<=
bounds
.
)
{
bounds
.
();
renderTarget
->
(
bounds
);
if
(!
renderTarget
->
IsClipperCoverWholeTarget
())
{
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
(
(
bounds
.
,
bounds
.
));
}
}
renderTarget
->
();
}
}
=
false
;
}
}
}
*
::
()
{
if
(!
)
{
new
(
this
);
}
return
.
();
}
bool
::
()
{
return
;
}
*
::
(
,
bool
)
{
if
(!
)
return
0
;
=
();
=
(
(
0
,
0
),
bounds
.
());
if
(
relativeBounds
.
(
))
{
=
();
for
(
=
.
() -
1
;
i
>=
0
;
i
--)
{
*
=
i
];
=
child
->
();
=
childBounds
.
+ (
clientArea
.
-
bounds
.
);
=
childBounds
.
+ (
clientArea
.
-
bounds
.
);
=
(
offsetX
,
offsetY
);
*
=
child
->
(
newLocation
,
);
if
(
childResult
)
{
return
childResult
;
}
}
if
(!
|| !
)
{
return
this
;
}
}
return
nullptr
;
}
bool
::
()
{
return
;
}
void
::
(
bool
)
{
=
;
}
::
()
{
=
();
*
=
;
while
(
composition
)
{
=
composition
->
();
=
composition
->
();
bounds
.
+=
clientArea
.
;
bounds
.
+=
clientArea
.
;
bounds
.
+=
clientArea
.
;
bounds
.
+=
clientArea
.
;
composition
=
composition
->
;
}
return
bounds
;
}
controls
::
*
::
()
{
return
;
}
*
::
()
{
if
(
&&
->
->
() ==
this
)
{
return
->
;
}
else
{
return
nullptr
;
}
}
*
::
()
{
return
;
}
void
::
(
*
)
{
=
;
}
::
::
GetAssociatedHitTestResult
()
{
return
;
}
void
::
SetAssociatedHitTestResult
(
::
)
{
=
;
}
controls
::
*
::
()
{
*
=
this
;
while
(
composition
)
{
if
(
composition
->
())
{
return
composition
->
();
}
else
{
composition
=
composition
->
();
}
}
return
nullptr
;
}
*
::
()
{
return
?
->
:
nullptr
;
}
controls
::
*
::
()
{
if
(
auto
=
())
{
return
control
->
();
}
return
nullptr
;
}
*
::
()
{
*
=
this
;
while
(
composition
)
{
if
(
composition
->
())
{
return
composition
->
();
}
else
{
composition
=
composition
->
();
}
}
return
nullptr
;
}
::
()
{
return
;
}
void
::
(
)
{
;
InvokeOnCompositionStateChanged
();
}
::
()
{
return
;
}
void
::
(
)
{
;
InvokeOnCompositionStateChanged
();
}
::
()
{
return
;
}
void
::
(
)
{
;
InvokeOnCompositionStateChanged
();
}
::
()
{
=
();
bounds
.
+=
.
+
.
;
bounds
.
+=
.
+
.
;
bounds
.
-=
.
+
.
;
bounds
.
-=
.
+
.
;
return
bounds
;
}
void
::
()
{
=
true
;
for
(
=
0
;
i
<
.
();
i
++)
{
i
]->
ForceCalculateSizeImmediately
();
}
=
false
;
InvokeOnCompositionStateChanged
();
}
::
(
)
{
=
GetMinPreferredClientSize
();
if
(
minSize
.
<
.
)
minSize
.
=
.
;
if
(
minSize
.
<
.
)
minSize
.
=
.
;
minSize
.
+=
.
+
.
+
.
+
.
;
minSize
.
+=
.
+
.
+
.
+
.
;
=
.
();
=
.
();
if
(
minSize
.
<
w
)
minSize
.
=
w
;
if
(
minSize
.
<
h
)
minSize
.
=
h
;
return
(
.
(),
minSize
);
}
void
::
(
)
{
if
(
)
{
;
.
(
(
this
));
InvokeOnCompositionStateChanged
();
}
}
::
()
{
.
(
this
);
}
::
()
{
}
bool
::
()
{
return
true
;
}
::
GetMinPreferredClientSize
()
{
;
if
(
!=
::
)
{
if
(
)
{
*
=
();
if
(
renderer
)
{
minSize
renderer
->
();
}
}
}
if
(
==
::
LimitToElementAndChildren
)
{
=
().
();
for
(
=
0
;
i
<
childCount
;
i
++)
{
*
=
i
];
if
(
child
->
())
{
=
child
->
();
if
(
minSize
.
<
childBounds
.
)
minSize
.
=
childBounds
.
;
if
(
minSize
.
<
childBounds
.
)
minSize
.
=
childBounds
.
;
}
}
}
return
minSize
;
}
::
()
{
return
(
(
(
0
,
0
),
GetMinPreferredClientSize
()));
}
void
(
controls
::
*
)
{
if
(
)
{
(
->
());
}
}
void
(
*
)
{
if
(
)
{
bool
=
false
;
if
(
auto
=
dynamic_cast
<
*>(
))
{
if
(
root
->
())
{
finalized
=
true
;
}
else
{
root
->
();
}
}
if
(
auto
=
->
())
{
if
(
auto
=
dynamic_cast
<
*>(
control
))
{
if
(
root
->
())
{
finalized
=
true
;
}
else
{
root
->
();
}
}
}
if
(!
finalized
)
{
=
->
().
();
for
(
=
0
;
i
<
count
;
i
++)
{
(
->
()
i
]);
}
}
}
}
void
SafeDeleteControlInternal
(
controls
::
*
)
{
if
(
)
{
if
(
->
() !=
)
{
*
=
->
();
if
(
bounds
->
())
{
bounds
->
()->
(
bounds
);
}
}
delete
;
}
}
void
SafeDeleteCompositionInternal
(
*
)
{
if
(
)
{
if
(
->
())
{
->
()->
(
);
}
if
(
->
())
{
SafeDeleteControlInternal
(
->
());
}
else
{
for
(
=
->
().
() -
1
;
i
>=
0
;
i
--)
{
SafeDeleteCompositionInternal
(
->
().
(
i
));
}
delete
;
}
}
}
void
(
controls
::
*
)
{
if
(
auto
=
dynamic_cast
<
controls
::
*>(
))
{
controlHost
->
DeleteAfterProcessingAllEvents
();
}
else
{
(
);
SafeDeleteControlInternal
(
);
}
}
void
(
*
)
{
(
);
SafeDeleteCompositionInternal
(
);
}
}
}
}