Update release

This commit is contained in:
Zihan Chen
2017-04-11 02:21:46 -07:00
parent ce6e7ac14a
commit 7c1db8d19f
8 changed files with 526 additions and 264 deletions
+67 -26
View File
@@ -8890,6 +8890,11 @@ namespace vl
GuiListControl::ItemCallback GuiListControl::ItemCallback
***********************************************************************/ ***********************************************************************/
void GuiListControl::ItemCallback::OnStyleBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments)
{
listControl->CalculateView();
}
GuiListControl::ItemCallback::ItemCallback(GuiListControl* _listControl) GuiListControl::ItemCallback::ItemCallback(GuiListControl* _listControl)
:listControl(_listControl) :listControl(_listControl)
{ {
@@ -8908,7 +8913,10 @@ GuiListControl::ItemCallback
} }
for (vint i = 0; i < installedStyles.Count(); i++) for (vint i = 0; i < installedStyles.Count(); i++)
{ {
listControl->itemStyleProvider->DestroyItemStyle(installedStyles[i]); auto style = installedStyles.Keys()[i];
auto handler = installedStyles.Values()[i];
style->GetBoundsComposition()->BoundsChanged.Detach(handler);
listControl->itemStyleProvider->DestroyItemStyle(style);
} }
cachedStyles.Clear(); cachedStyles.Clear();
installedStyles.Clear(); installedStyles.Clear();
@@ -8943,7 +8951,8 @@ GuiListControl::ItemCallback
} }
listControl->itemStyleProvider->Install(style, itemIndex); listControl->itemStyleProvider->Install(style, itemIndex);
style->OnInstalled(); style->OnInstalled();
installedStyles.Add(style); auto handler = style->GetBoundsComposition()->BoundsChanged.AttachMethod(this, &ItemCallback::OnStyleBoundsChanged);
installedStyles.Add(style, handler);
listControl->GetContainerComposition()->AddChild(style->GetBoundsComposition()); listControl->GetContainerComposition()->AddChild(style->GetBoundsComposition());
listControl->OnStyleInstalled(itemIndex, style); listControl->OnStyleInstalled(itemIndex, style);
return style; return style;
@@ -8951,12 +8960,14 @@ GuiListControl::ItemCallback
void GuiListControl::ItemCallback::ReleaseItem(IItemStyleController* style) void GuiListControl::ItemCallback::ReleaseItem(IItemStyleController* style)
{ {
vint index=installedStyles.IndexOf(style); vint index = installedStyles.Keys().IndexOf(style);
if (index != -1) if (index != -1)
{ {
listControl->OnStyleUninstalled(style); listControl->OnStyleUninstalled(style);
listControl->GetContainerComposition()->RemoveChild(style->GetBoundsComposition()); listControl->GetContainerComposition()->RemoveChild(style->GetBoundsComposition());
installedStyles.RemoveAt(index); auto handler = installedStyles.Values()[index];
style->GetBoundsComposition()->BoundsChanged.Detach(handler);
installedStyles.Remove(style);
style->OnUninstalled(); style->OnUninstalled();
if (style->IsCacheable()) if (style->IsCacheable())
{ {
@@ -9923,15 +9934,20 @@ FixedHeightItemArranger
for (vint i = newStartIndex; i <= newEndIndex && i < itemCount; i++) for (vint i = newStartIndex; i <= newEndIndex && i < itemCount; i++)
{ {
GuiListControl::IItemStyleController* style = nullptr;
if (startIndex <= i && i <= endIndex) if (startIndex <= i && i <= endIndex)
{ {
GuiListControl::IItemStyleController* style=visibleStyles[i-startIndex]; style = visibleStyles[i - startIndex];
visibleStyles.Add(style); visibleStyles.Add(style);
} }
else else
{ {
GuiListControl::IItemStyleController* style=callback->RequestItem(i); style = callback->RequestItem(i);
visibleStyles.Add(style); visibleStyles.Add(style);
}
if (style)
{
vint styleHeight = callback->GetStylePreferredSize(style).y; vint styleHeight = callback->GetStylePreferredSize(style).y;
if (newRowHeight < styleHeight) if (newRowHeight < styleHeight)
{ {
@@ -10152,14 +10168,15 @@ FixedSizeMultiColumnItemArranger
{ {
for (vint i = newStartIndex; i <= newEndIndex; i++) for (vint i = newStartIndex; i <= newEndIndex; i++)
{ {
GuiListControl::IItemStyleController* style = nullptr;
if (startIndex <= i && i <= endIndex) if (startIndex <= i && i <= endIndex)
{ {
GuiListControl::IItemStyleController* style=visibleStyles[i-startIndex]; style = visibleStyles[i - startIndex];
visibleStyles.Add(style); visibleStyles.Add(style);
} }
else if (i<previousStartIndex || i>previousEndIndex) else if (i<previousStartIndex || i>previousEndIndex)
{ {
GuiListControl::IItemStyleController* style=callback->RequestItem(i); style = callback->RequestItem(i);
if (i < previousStartIndex) if (i < previousStartIndex)
{ {
@@ -10169,7 +10186,10 @@ FixedSizeMultiColumnItemArranger
{ {
visibleStyles.Add(style); visibleStyles.Add(style);
} }
}
if (style)
{
Size styleSize = callback->GetStylePreferredSize(style); Size styleSize = callback->GetStylePreferredSize(style);
if (newItemSize.x < styleSize.x) newItemSize.x = styleSize.x; if (newItemSize.x < styleSize.x) newItemSize.x = styleSize.x;
if (newItemSize.y < styleSize.y) newItemSize.y = styleSize.y; if (newItemSize.y < styleSize.y) newItemSize.y = styleSize.y;
@@ -10352,8 +10372,6 @@ FixedHeightMultiColumnItemArranger
currentWidth=0; currentWidth=0;
} }
GuiListControl::IItemStyleController* style=visibleStyles[i]; GuiListControl::IItemStyleController* style=visibleStyles[i];
vint itemWidth=callback->GetStylePreferredSize(style).x;
if(currentWidth<itemWidth) currentWidth=itemWidth;
callback->SetStyleBounds(style, Rect(Point(totalWidth, itemHeight*column), Size(0, 0))); callback->SetStyleBounds(style, Rect(Point(totalWidth, itemHeight*column), Size(0, 0)));
} }
} }
@@ -10427,14 +10445,15 @@ FixedHeightMultiColumnItemArranger
} }
newEndIndex = i; newEndIndex = i;
GuiListControl::IItemStyleController* style = nullptr;
if (startIndex <= i && i <= endIndex) if (startIndex <= i && i <= endIndex)
{ {
GuiListControl::IItemStyleController* style=visibleStyles[i-startIndex]; style = visibleStyles[i - startIndex];
visibleStyles.Add(style); visibleStyles.Add(style);
} }
else if (i<previousStartIndex || i>previousEndIndex) else if (i<previousStartIndex || i>previousEndIndex)
{ {
GuiListControl::IItemStyleController* style=callback->RequestItem(i); style = callback->RequestItem(i);
if (i < previousStartIndex) if (i < previousStartIndex)
{ {
@@ -10444,7 +10463,10 @@ FixedHeightMultiColumnItemArranger
{ {
visibleStyles.Add(style); visibleStyles.Add(style);
} }
}
if (style)
{
Size styleSize = callback->GetStylePreferredSize(style); Size styleSize = callback->GetStylePreferredSize(style);
if (currentWidth < styleSize.x) currentWidth = styleSize.x; if (currentWidth < styleSize.x) currentWidth = styleSize.x;
if (newItemHeight < styleSize.y) newItemHeight = styleSize.y; if (newItemHeight < styleSize.y) newItemHeight = styleSize.y;
@@ -33743,12 +33765,12 @@ GuiGraphicsComposition
{ {
associatedControl->OnRenderTargetChanged(renderTarget); associatedControl->OnRenderTargetChanged(renderTarget);
} }
OnRenderContextChanged();
for (vint i = 0; i < children.Count(); i++) for (vint i = 0; i < children.Count(); i++)
{ {
children[i]->UpdateRelatedHostRecord(record); children[i]->UpdateRelatedHostRecord(record);
} }
OnRenderContextChanged();
} }
void GuiGraphicsComposition::SetAssociatedControl(controls::GuiControl* control) void GuiGraphicsComposition::SetAssociatedControl(controls::GuiControl* control)
@@ -35754,6 +35776,7 @@ GuiTableComposition
{ {
previousContentMinSize = tableContentMinSize; previousContentMinSize = tableContentMinSize;
UpdateCellBoundsInternal(); UpdateCellBoundsInternal();
InvokeOnCompositionStateChanged();
} }
} }
@@ -35938,8 +35961,8 @@ GuiTableComposition
if (previousBounds != result || cellMinSizeModified) if (previousBounds != result || cellMinSizeModified)
{ {
previousBounds = result;
UpdateCellBounds(); UpdateCellBounds();
UpdatePreviousBounds(result);
} }
return result; return result;
} }
@@ -38495,6 +38518,13 @@ GuiGraphicsHost
} }
} }
void GuiGraphicsHost::RefreshRelatedHostRecord(INativeWindow* nativeWindow)
{
hostRecord.nativeWindow = nativeWindow;
hostRecord.renderTarget = nativeWindow ? GetGuiGraphicsResourceManager()->GetRenderTarget(nativeWindow) : nullptr;
windowComposition->UpdateRelatedHostRecord(&hostRecord);
}
void GuiGraphicsHost::DisconnectCompositionInternal(GuiGraphicsComposition* composition) void GuiGraphicsHost::DisconnectCompositionInternal(GuiGraphicsComposition* composition)
{ {
for(vint i=0;i<composition->Children().Count();i++) for(vint i=0;i<composition->Children().Count();i++)
@@ -38737,7 +38767,7 @@ GuiGraphicsHost
{ {
previousClientSize = size; previousClientSize = size;
minSize = windowComposition->GetPreferredBounds().GetSize(); minSize = windowComposition->GetPreferredBounds().GetSize();
Render(true); needRender = true;
} }
} }
@@ -39041,8 +39071,8 @@ GuiGraphicsHost
{ {
hostRecord.host = this; hostRecord.host = this;
windowComposition=new GuiWindowComposition; windowComposition=new GuiWindowComposition;
windowComposition->UpdateRelatedHostRecord(&hostRecord);
windowComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); windowComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
RefreshRelatedHostRecord(nullptr);
} }
GuiGraphicsHost::~GuiGraphicsHost() GuiGraphicsHost::~GuiGraphicsHost()
@@ -39069,18 +39099,18 @@ GuiGraphicsHost
GetCurrentController()->CallbackService()->UninstallListener(this); GetCurrentController()->CallbackService()->UninstallListener(this);
hostRecord.nativeWindow->UninstallListener(this); hostRecord.nativeWindow->UninstallListener(this);
} }
hostRecord.nativeWindow = _nativeWindow;
hostRecord.renderTarget = _nativeWindow ? GetGuiGraphicsResourceManager()->GetRenderTarget(_nativeWindow) : nullptr; if (_nativeWindow)
windowComposition->UpdateRelatedHostRecord(&hostRecord);
if (hostRecord.nativeWindow)
{ {
hostRecord.nativeWindow->InstallListener(this); _nativeWindow->InstallListener(this);
GetCurrentController()->CallbackService()->InstallListener(this); GetCurrentController()->CallbackService()->InstallListener(this);
previousClientSize = hostRecord.nativeWindow->GetClientSize(); previousClientSize = _nativeWindow->GetClientSize();
minSize = windowComposition->GetPreferredBounds().GetSize(); minSize = windowComposition->GetPreferredBounds().GetSize();
hostRecord.nativeWindow->SetCaretPoint(caretPoint); _nativeWindow->SetCaretPoint(caretPoint);
needRender = true; needRender = true;
} }
RefreshRelatedHostRecord(_nativeWindow);
} }
} }
@@ -39102,17 +39132,28 @@ GuiGraphicsHost
supressPaint = true; supressPaint = true;
hostRecord.renderTarget->StartRendering(); hostRecord.renderTarget->StartRendering();
windowComposition->Render(Size()); windowComposition->Render(Size());
bool success = hostRecord.renderTarget->StopRendering(); auto result = hostRecord.renderTarget->StopRendering();
hostRecord.nativeWindow->RedrawContent(); hostRecord.nativeWindow->RedrawContent();
supressPaint = false; supressPaint = false;
if (!success) switch (result)
{
case RenderTargetFailure::ResizeWhileRendering:
{
GetGuiGraphicsResourceManager()->ResizeRenderTarget(hostRecord.nativeWindow);
needRender = true;
}
break;
case RenderTargetFailure::LostDevice:
{ {
windowComposition->UpdateRelatedHostRecord(nullptr); windowComposition->UpdateRelatedHostRecord(nullptr);
GetGuiGraphicsResourceManager()->RecreateRenderTarget(hostRecord.nativeWindow); GetGuiGraphicsResourceManager()->RecreateRenderTarget(hostRecord.nativeWindow);
windowComposition->UpdateRelatedHostRecord(&hostRecord); RefreshRelatedHostRecord(hostRecord.nativeWindow);
needRender = true; needRender = true;
} }
break;
default:;
}
} }
} }
+17 -3
View File
@@ -813,6 +813,13 @@ Basic Construction
virtual IGuiGraphicsRenderer* Create()=0; virtual IGuiGraphicsRenderer* Create()=0;
}; };
enum RenderTargetFailure
{
None,
ResizeWhileRendering,
LostDevice,
};
/// <summary> /// <summary>
/// This is the interface for graphics renderer targets. /// This is the interface for graphics renderer targets.
/// </summary> /// </summary>
@@ -827,7 +834,7 @@ Basic Construction
/// Notify the target to stop rendering. /// Notify the target to stop rendering.
/// </summary> /// </summary>
/// <returns>Returns false to recreate render target.</returns> /// <returns>Returns false to recreate render target.</returns>
virtual bool StopRendering()=0; virtual RenderTargetFailure StopRendering()=0;
/// <summary> /// <summary>
/// Apply a clipper to the render target. /// Apply a clipper to the render target.
/// The result clipper is combined by all clippers in the clipper stack maintained by the render target. /// The result clipper is combined by all clippers in the clipper stack maintained by the render target.
@@ -2981,6 +2988,11 @@ Resource Manager
/// <param name="window">The specified window.</param> /// <param name="window">The specified window.</param>
virtual void RecreateRenderTarget(INativeWindow* window) = 0; virtual void RecreateRenderTarget(INativeWindow* window) = 0;
/// <summary> /// <summary>
/// Resize the render target to fit the current window size.
/// </summary>
/// <param name="window">The specified window.</param>
virtual void ResizeRenderTarget(INativeWindow* window) = 0;
/// <summary>
/// Get the renderer awared rich text document layout engine provider object. /// Get the renderer awared rich text document layout engine provider object.
/// </summary> /// </summary>
/// <returns>Returns the layout provider.</returns> /// <returns>Returns the layout provider.</returns>
@@ -6888,7 +6900,6 @@ Table Compositions
collections::Array<vint> rowSizes; collections::Array<vint> rowSizes;
collections::Array<vint> columnSizes; collections::Array<vint> columnSizes;
Rect previousBounds;
Size previousContentMinSize; Size previousContentMinSize;
Size tableContentMinSize; Size tableContentMinSize;
@@ -8019,6 +8030,7 @@ Host
vint FilterTitles(); vint FilterTitles();
void ClearAltHost(); void ClearAltHost();
void CloseAltHost(); void CloseAltHost();
void RefreshRelatedHostRecord(INativeWindow* nativeWindow);
void DisconnectCompositionInternal(GuiGraphicsComposition* composition); void DisconnectCompositionInternal(GuiGraphicsComposition* composition);
void MouseCapture(const NativeWindowMouseInfo& info); void MouseCapture(const NativeWindowMouseInfo& info);
@@ -10807,12 +10819,14 @@ List Control
class ItemCallback : public IItemProviderCallback, public IItemArrangerCallback class ItemCallback : public IItemProviderCallback, public IItemArrangerCallback
{ {
typedef collections::List<IItemStyleController*> StyleList; typedef collections::List<IItemStyleController*> StyleList;
typedef collections::Dictionary<IItemStyleController*, Ptr<compositions::IGuiGraphicsEventHandler>> InstalledStyleMap;
protected: protected:
GuiListControl* listControl; GuiListControl* listControl;
IItemProvider* itemProvider; IItemProvider* itemProvider;
StyleList cachedStyles; StyleList cachedStyles;
StyleList installedStyles; InstalledStyleMap installedStyles;
void OnStyleBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments);
public: public:
ItemCallback(GuiListControl* _listControl); ItemCallback(GuiListControl* _listControl);
~ItemCallback(); ~ItemCallback();
+163 -29
View File
@@ -2915,21 +2915,29 @@ GuiInstanceContext
errors.Add(GuiResourceError({ {resource},element->codeRange.start }, L"ref.Parameter requires the following attributes existing at the same time: Name, Class.")); errors.Add(GuiResourceError({ {resource},element->codeRange.start }, L"ref.Parameter requires the following attributes existing at the same time: Name, Class."));
} }
} }
else if (element->name.value == L"ref.Members")
{ #define COLLECT_SCRIPT(NAME, SCRIPT, POSITION)\
if (element->subNodes.Count() == 1) (element->name.value == L"ref." #NAME)\
{ {\
if (auto cdata = element->subNodes[0].Cast<XmlCData>()) if (element->subNodes.Count() == 1)\
{ {\
context->memberScript = cdata->content.value; if (auto cdata = element->subNodes[0].Cast<XmlCData>())\
context->memberPosition = { {resource},cdata->codeRange.start }; {\
context->memberPosition.column += 9; // <![CDATA[ context->SCRIPT = cdata->content.value;\
goto MEMBERSCRIPT_SUCCESS; context->POSITION = { {resource},cdata->codeRange.start };\
} context->POSITION.column += 9; /* <![CDATA[ */\
} goto NAME##_SCRIPT_SUCCESS;\
errors.Add(GuiResourceError({ {resource},element->codeRange.start }, L"Script should be contained in a CDATA section.")); }\
MEMBERSCRIPT_SUCCESS:; }\
} errors.Add(GuiResourceError({ {resource},element->codeRange.start }, L"Script should be contained in a CDATA section."));\
NAME##_SCRIPT_SUCCESS:;\
}\
else if COLLECT_SCRIPT(Members, memberScript, memberPosition)
else if COLLECT_SCRIPT(Ctor, ctorScript, ctorPosition)
else if COLLECT_SCRIPT(Dtor, dtorScript, dtorPosition)
#undef COLLECT_SCRIPT
else if (!context->instance) else if (!context->instance)
{ {
context->instance = LoadCtor(resource, element, errors); context->instance = LoadCtor(resource, element, errors);
@@ -3002,16 +3010,22 @@ GuiInstanceContext
xmlParameter->attributes.Add(attClass); xmlParameter->attributes.Add(attClass);
} }
if (memberScript != L"") #define SERIALIZE_SCRIPT(NAME, SCRIPT)\
{ if (SCRIPT != L"")\
auto xmlMembers = MakePtr<XmlElement>(); {\
xmlMembers->name.value = L"ref.Members"; auto xmlScript = MakePtr<XmlElement>();\
xmlInstance->subNodes.Add(xmlMembers); xmlScript->name.value = L"ref." #NAME;\
xmlInstance->subNodes.Add(xmlScript);\
auto text = MakePtr<XmlCData>();\
text->content.value = SCRIPT;\
xmlScript->subNodes.Add(text);\
}\
auto text = MakePtr<XmlCData>(); SERIALIZE_SCRIPT(Members, memberScript)
text->content.value = memberScript; SERIALIZE_SCRIPT(Ctpr, ctorScript)
xmlMembers->subNodes.Add(text); SERIALIZE_SCRIPT(Dtor, dtorScript)
}
#undef SERIALIZE_SCRIPT
if (stylePaths.Count() > 0) if (stylePaths.Count() > 0)
{ {
@@ -7271,6 +7285,10 @@ Workflow_GenerateInstanceClass
return nullptr; return nullptr;
} }
///////////////////////////////////////////////////////////////
// Instance Class
///////////////////////////////////////////////////////////////
auto module = Workflow_CreateModuleWithUsings(context); auto module = Workflow_CreateModuleWithUsings(context);
auto instanceClass = Workflow_InstallClass(context->className, module); auto instanceClass = Workflow_InstallClass(context->className, module);
{ {
@@ -7291,6 +7309,11 @@ Workflow_GenerateInstanceClass
instanceClass->attributes.Add(att); instanceClass->attributes.Add(att);
} }
} }
///////////////////////////////////////////////////////////////
// Inherit from Constructor Class
///////////////////////////////////////////////////////////////
if (!beforePrecompile) if (!beforePrecompile)
{ {
auto baseType = MakePtr<WfReferenceType>(); auto baseType = MakePtr<WfReferenceType>();
@@ -7310,6 +7333,10 @@ Workflow_GenerateInstanceClass
} }
} }
///////////////////////////////////////////////////////////////
// Helpers
///////////////////////////////////////////////////////////////
auto parseClassMembers = [&](const WString& code, const WString& name, List<Ptr<WfDeclaration>>& memberDecls, GuiResourceTextPos position) auto parseClassMembers = [&](const WString& code, const WString& name, List<Ptr<WfDeclaration>>& memberDecls, GuiResourceTextPos position)
{ {
WString wrappedCode = L"module parse_members; class Class {\r\n" + code + L"\r\n}"; WString wrappedCode = L"module parse_members; class Class {\r\n" + code + L"\r\n}";
@@ -7340,6 +7367,10 @@ Workflow_GenerateInstanceClass
return block; return block;
}; };
///////////////////////////////////////////////////////////////
// ref.Members
///////////////////////////////////////////////////////////////
if (context->memberScript != L"") if (context->memberScript != L"")
{ {
List<Ptr<WfDeclaration>> memberDecls; List<Ptr<WfDeclaration>> memberDecls;
@@ -7360,6 +7391,10 @@ Workflow_GenerateInstanceClass
CopyFrom(instanceClass->declarations, memberDecls, true); CopyFrom(instanceClass->declarations, memberDecls, true);
} }
///////////////////////////////////////////////////////////////
// Constructor Declaration
///////////////////////////////////////////////////////////////
auto ctor = MakePtr<WfConstructorDeclaration>(); auto ctor = MakePtr<WfConstructorDeclaration>();
ctor->constructorType = WfConstructorType::RawPtr; ctor->constructorType = WfConstructorType::RawPtr;
auto ctorBlock = (beforePrecompile ? notImplemented() : MakePtr<WfBlockStatement>()); auto ctorBlock = (beforePrecompile ? notImplemented() : MakePtr<WfBlockStatement>());
@@ -7393,6 +7428,10 @@ Workflow_GenerateInstanceClass
} }
} }
///////////////////////////////////////////////////////////////
// ref.Parameter (Variable, Getter, CtorArgument)
///////////////////////////////////////////////////////////////
FOREACH(Ptr<GuiInstanceParameter>, param, context->parameters) FOREACH(Ptr<GuiInstanceParameter>, param, context->parameters)
{ {
if (auto type = Workflow_ParseType(precompileContext, { resolvingResult.resource }, param->className.ToString() + L"^", param->classPosition, errors)) if (auto type = Workflow_ParseType(precompileContext, { resolvingResult.resource }, param->className.ToString() + L"^", param->classPosition, errors))
@@ -7476,13 +7515,22 @@ Workflow_GenerateInstanceClass
} }
} }
///////////////////////////////////////////////////////////////
// Event Handlers
///////////////////////////////////////////////////////////////
if (needEventHandler) if (needEventHandler)
{ {
WorkflowEventNamesVisitor visitor(precompileContext, resolvingResult, instanceClass, errors); WorkflowEventNamesVisitor visitor(precompileContext, resolvingResult, instanceClass, errors);
context->instance->Accept(&visitor); context->instance->Accept(&visitor);
} }
addDecl(ctor); addDecl(ctor);
///////////////////////////////////////////////////////////////
// Calling Constructor Class
///////////////////////////////////////////////////////////////
if (!beforePrecompile) if (!beforePrecompile)
{ {
{ {
@@ -7574,13 +7622,97 @@ Workflow_GenerateInstanceClass
} }
} }
///////////////////////////////////////////////////////////////
// ref.Ctor
///////////////////////////////////////////////////////////////
if (context->ctorScript != L"")
{
if (auto stat = Workflow_ParseStatement(precompileContext, { resolvingResult.resource }, context->ctorScript, context->ctorPosition, errors))
{
if (!beforePrecompile)
{
if (!stat.Cast<WfBlockStatement>())
{ {
auto dtor = MakePtr<WfDestructorDeclaration>();
addDecl(dtor);
auto block = MakePtr<WfBlockStatement>(); auto block = MakePtr<WfBlockStatement>();
dtor->statement = block; block->statements.Add(stat);
stat = block;
}
auto decl = MakePtr<WfFunctionDeclaration>();
decl->anonymity = WfFunctionAnonymity::Named;
decl->name.value = L"<instance-ctor>";
decl->returnType = GetTypeFromTypeInfo(TypeInfoRetriver<void>::CreateTypeInfo().Obj());
decl->statement = stat;
addDecl(decl);
{
auto refCtor = MakePtr<WfReferenceExpression>();
refCtor->name.value = L"<instance-ctor>";
auto callExpr = MakePtr<WfCallExpression>();
callExpr->function = refCtor;
auto exprStat = MakePtr<WfExpressionStatement>();
exprStat->expression = callExpr;
ctorBlock->statements.Add(exprStat);
}
}
}
}
///////////////////////////////////////////////////////////////
// Destructor
///////////////////////////////////////////////////////////////
auto dtor = MakePtr<WfDestructorDeclaration>();
auto dtorBlock = MakePtr<WfBlockStatement>();
dtor->statement = dtorBlock;
///////////////////////////////////////////////////////////////
// ref.Dtor
///////////////////////////////////////////////////////////////
if (context->dtorScript != L"")
{
if (auto stat = Workflow_ParseStatement(precompileContext, { resolvingResult.resource }, context->dtorScript, context->dtorPosition, errors))
{
if (!beforePrecompile)
{
if (!stat.Cast<WfBlockStatement>())
{
auto block = MakePtr<WfBlockStatement>();
block->statements.Add(stat);
stat = block;
}
auto decl = MakePtr<WfFunctionDeclaration>();
decl->anonymity = WfFunctionAnonymity::Named;
decl->name.value = L"<instance-dtor>";
decl->returnType = GetTypeFromTypeInfo(TypeInfoRetriver<void>::CreateTypeInfo().Obj());
decl->statement = stat;
addDecl(decl);
{
auto refDtor = MakePtr<WfReferenceExpression>();
refDtor->name.value = L"<instance-dtor>";
auto callExpr = MakePtr<WfCallExpression>();
callExpr->function = refDtor;
auto exprStat = MakePtr<WfExpressionStatement>();
exprStat->expression = callExpr;
dtorBlock->statements.Add(exprStat);
}
}
}
}
///////////////////////////////////////////////////////////////
// Clear Binding Subscriptions
///////////////////////////////////////////////////////////////
{
auto ref = MakePtr<WfReferenceExpression>(); auto ref = MakePtr<WfReferenceExpression>();
ref->name.value = L"ClearSubscriptions"; ref->name.value = L"ClearSubscriptions";
@@ -7589,9 +7721,11 @@ Workflow_GenerateInstanceClass
auto stat = MakePtr<WfExpressionStatement>(); auto stat = MakePtr<WfExpressionStatement>();
stat->expression = call; stat->expression = call;
block->statements.Add(stat); dtorBlock->statements.Add(stat);
} }
addDecl(dtor);
return module; return module;
} }
+4
View File
@@ -362,11 +362,15 @@ Instance Context
ParameterList parameters; ParameterList parameters;
WString memberScript; WString memberScript;
WString ctorScript;
WString dtorScript;
GuiResourceTextPos tagPosition; GuiResourceTextPos tagPosition;
GuiResourceTextPos classPosition; GuiResourceTextPos classPosition;
GuiResourceTextPos stylePosition; GuiResourceTextPos stylePosition;
GuiResourceTextPos memberPosition; GuiResourceTextPos memberPosition;
GuiResourceTextPos ctorPosition;
GuiResourceTextPos dtorPosition;
bool appliedStyles = false; bool appliedStyles = false;
StyleContextList styles; StyleContextList styles;
+132 -63
View File
@@ -1627,6 +1627,13 @@ Windows Platform Native Controller
void EnableCrossKernelCrashing() void EnableCrossKernelCrashing()
{ {
/*
"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options"
DWORD DisableUserModeCallbackFilter = 1
"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\TestCppCodegen.exe"
DWORD DisableUserModeCallbackFilter = 1
*/
typedef BOOL (WINAPI *tGetPolicy)(LPDWORD lpFlags); typedef BOOL (WINAPI *tGetPolicy)(LPDWORD lpFlags);
typedef BOOL (WINAPI *tSetPolicy)(DWORD dwFlags); typedef BOOL (WINAPI *tSetPolicy)(DWORD dwFlags);
const DWORD EXCEPTION_SWALLOWING = 0x1; const DWORD EXCEPTION_SWALLOWING = 0x1;
@@ -1660,6 +1667,8 @@ namespace vl
{ {
namespace presentation namespace presentation
{ {
using namespace elements;
namespace windows namespace windows
{ {
using namespace vl::collections; using namespace vl::collections;
@@ -1673,6 +1682,8 @@ WindowListener
protected: protected:
ID2D1Factory* d2dFactory; ID2D1Factory* d2dFactory;
INativeWindow* window; INativeWindow* window;
bool rendering = false;
bool movedWhileRendering = false;
virtual void RebuildCanvas(Size size) = 0; virtual void RebuildCanvas(Size size) = 0;
public: public:
@@ -1683,10 +1694,39 @@ WindowListener
} }
void Moved() void Moved()
{
if (rendering)
{
movedWhileRendering = true;
}
else
{
ResizeRenderTarget();
}
}
void ResizeRenderTarget()
{ {
RebuildCanvas(window->GetClientSize()); RebuildCanvas(window->GetClientSize());
} }
void StartRendering()
{
rendering = true;
}
void StopRendering()
{
rendering = false;
}
bool RetrieveAndResetMovedWhileRendering()
{
bool result = movedWhileRendering;
movedWhileRendering = false;
return result;
}
virtual ID2D1RenderTarget* GetDirect2DRenderTarget() = 0; virtual ID2D1RenderTarget* GetDirect2DRenderTarget() = 0;
virtual void RecreateRenderTarget() = 0; virtual void RecreateRenderTarget() = 0;
virtual bool PresentRenderTarget() = 0; virtual bool PresentRenderTarget() = 0;
@@ -2067,40 +2107,6 @@ ControllerListener
Direct2DWindowsNativeControllerListener* direct2DListener=0; Direct2DWindowsNativeControllerListener* direct2DListener=0;
Direct2DWindowsNativeWindowListener* GetNativeWindowListener(INativeWindow* window)
{
vint index = direct2DListener->nativeWindowListeners.Keys().IndexOf(window);
return index == -1
? 0
: direct2DListener->nativeWindowListeners.Values().Get(index).Obj();
}
ID2D1RenderTarget* GetNativeWindowDirect2DRenderTarget(INativeWindow* window)
{
if (auto listener = GetNativeWindowListener(window))
{
return listener->GetDirect2DRenderTarget();
}
return 0;
}
void RecreateNativeWindowDirect2DRenderTarget(INativeWindow* window)
{
if (auto listener = GetNativeWindowListener(window))
{
return listener->RecreateRenderTarget();
}
}
bool PresentNativeWindowDirect2DRenderTarget(INativeWindow* window)
{
if (auto listener = GetNativeWindowListener(window))
{
return listener->PresentRenderTarget();
}
return true;
}
ID2D1Factory* GetDirect2DFactory() ID2D1Factory* GetDirect2DFactory()
{ {
return direct2DListener->d2dFactory.Obj(); return direct2DListener->d2dFactory.Obj();
@@ -2125,48 +2131,107 @@ OS Supporting
class WinDirect2DApplicationDirect2DObjectProvider : public IWindowsDirect2DObjectProvider class WinDirect2DApplicationDirect2DObjectProvider : public IWindowsDirect2DObjectProvider
{ {
protected:
windows::Direct2DWindowsNativeWindowListener* GetNativeWindowListener(INativeWindow* window)
{
vint index = windows::direct2DListener->nativeWindowListeners.Keys().IndexOf(window);
return index == -1
? nullptr
: windows::direct2DListener->nativeWindowListeners.Values().Get(index).Obj();
}
public: public:
void RecreateRenderTarget(INativeWindow* window) void RecreateRenderTarget(INativeWindow* window)override
{ {
vl::presentation::windows::RecreateNativeWindowDirect2DRenderTarget(window); if (auto listener = GetNativeWindowListener(window))
{
return listener->RecreateRenderTarget();
}
} }
bool PresentRenderTarget(INativeWindow* window) void ResizeRenderTarget(INativeWindow* window)override
{ {
return vl::presentation::windows::PresentNativeWindowDirect2DRenderTarget(window); if (auto listener = GetNativeWindowListener(window))
{
return listener->ResizeRenderTarget();
}
} }
ID2D1RenderTarget* GetNativeWindowDirect2DRenderTarget(INativeWindow* window) ID2D1RenderTarget* GetNativeWindowDirect2DRenderTarget(INativeWindow* window)override
{ {
return vl::presentation::windows::GetNativeWindowDirect2DRenderTarget(window); if (auto listener = GetNativeWindowListener(window))
{
return listener->GetDirect2DRenderTarget();
}
return nullptr;
} }
ID2D1Factory* GetDirect2DFactory() void StartRendering(INativeWindow* window)override
{
if (auto listener = GetNativeWindowListener(window))
{
listener->StartRendering();
if (auto renderTarget = listener->GetDirect2DRenderTarget())
{
renderTarget->BeginDraw();
renderTarget->Clear(D2D1::ColorF(D2D1::ColorF::Black));
}
}
}
RenderTargetFailure StopRenderingAndPresent(INativeWindow* window)override
{
if (auto listener = GetNativeWindowListener(window))
{
listener->StopRendering();
bool moved = listener->RetrieveAndResetMovedWhileRendering();
if (auto renderTarget = listener->GetDirect2DRenderTarget())
{
HRESULT hr = renderTarget->EndDraw();
if (hr == S_OK)
{
if (moved)
{
return RenderTargetFailure::ResizeWhileRendering;
}
else if (listener->PresentRenderTarget())
{
return RenderTargetFailure::None;
}
}
}
}
return RenderTargetFailure::LostDevice;
}
ID2D1Factory* GetDirect2DFactory()override
{ {
return vl::presentation::windows::GetDirect2DFactory(); return vl::presentation::windows::GetDirect2DFactory();
} }
IDWriteFactory* GetDirectWriteFactory() IDWriteFactory* GetDirectWriteFactory()override
{ {
return vl::presentation::windows::GetDirectWriteFactory(); return vl::presentation::windows::GetDirectWriteFactory();
} }
IWindowsDirect2DRenderTarget* GetBindedRenderTarget(INativeWindow* window) IWindowsDirect2DRenderTarget* GetBindedRenderTarget(INativeWindow* window)override
{ {
return dynamic_cast<IWindowsDirect2DRenderTarget*>(vl::presentation::windows::GetWindowsForm(window)->GetGraphicsHandler()); return dynamic_cast<IWindowsDirect2DRenderTarget*>(vl::presentation::windows::GetWindowsForm(window)->GetGraphicsHandler());
} }
void SetBindedRenderTarget(INativeWindow* window, IWindowsDirect2DRenderTarget* renderTarget) void SetBindedRenderTarget(INativeWindow* window, IWindowsDirect2DRenderTarget* renderTarget)override
{ {
vl::presentation::windows::GetWindowsForm(window)->SetGraphicsHandler(renderTarget); vl::presentation::windows::GetWindowsForm(window)->SetGraphicsHandler(renderTarget);
} }
IWICImagingFactory* GetWICImagingFactory() IWICImagingFactory* GetWICImagingFactory()override
{ {
return vl::presentation::windows::GetWICImagingFactory(); return vl::presentation::windows::GetWICImagingFactory();
} }
IWICBitmap* GetWICBitmap(INativeImageFrame* frame) IWICBitmap* GetWICBitmap(INativeImageFrame* frame)override
{ {
return vl::presentation::windows::GetWICBitmap(frame); return vl::presentation::windows::GetWICBitmap(frame);
} }
@@ -9778,10 +9843,10 @@ WindowsGDIRenderTarget
dc=GetWindowsGDIObjectProvider()->GetNativeWindowDC(window); dc=GetWindowsGDIObjectProvider()->GetNativeWindowDC(window);
} }
bool StopRendering()override RenderTargetFailure StopRendering()override
{ {
dc = 0; dc = 0;
return true; return RenderTargetFailure::None;
} }
void PushClipper(Rect clipper)override void PushClipper(Rect clipper)override
@@ -10053,6 +10118,10 @@ WindowsGDIResourceManager
{ {
} }
void ResizeRenderTarget(INativeWindow* window)override
{
}
IGuiGraphicsLayoutProvider* GetLayoutProvider()override IGuiGraphicsLayoutProvider* GetLayoutProvider()override
{ {
return layoutProvider.Obj(); return layoutProvider.Obj();
@@ -13051,9 +13120,9 @@ WindowsDirect2DRenderTarget
typedef SortedList<Ptr<WindowsDirect2DImageFrameCache>> ImageCacheList; typedef SortedList<Ptr<WindowsDirect2DImageFrameCache>> ImageCacheList;
protected: protected:
INativeWindow* window; INativeWindow* window;
ID2D1RenderTarget* d2dRenderTarget; ID2D1RenderTarget* d2dRenderTarget = nullptr;
List<Rect> clippers; List<Rect> clippers;
vint clipperCoverWholeTargetCounter; vint clipperCoverWholeTargetCounter = 0;
CachedSolidBrushAllocator solidBrushes; CachedSolidBrushAllocator solidBrushes;
CachedLinearBrushAllocator linearBrushes; CachedLinearBrushAllocator linearBrushes;
@@ -13089,8 +13158,6 @@ WindowsDirect2DRenderTarget
public: public:
WindowsDirect2DRenderTarget(INativeWindow* _window) WindowsDirect2DRenderTarget(INativeWindow* _window)
:window(_window) :window(_window)
,d2dRenderTarget(0)
,clipperCoverWholeTargetCounter(0)
{ {
solidBrushes.SetRenderTarget(this); solidBrushes.SetRenderTarget(this);
linearBrushes.SetRenderTarget(this); linearBrushes.SetRenderTarget(this);
@@ -13173,20 +13240,17 @@ WindowsDirect2DRenderTarget
void StartRendering()override void StartRendering()override
{ {
d2dRenderTarget = GetWindowsDirect2DObjectProvider()->GetNativeWindowDirect2DRenderTarget(window); d2dRenderTarget = GetWindowsDirect2DObjectProvider()->GetNativeWindowDirect2DRenderTarget(window);
d2dRenderTarget->BeginDraw(); CHECK_ERROR(d2dRenderTarget, L"vl::presentation::elements_windows_d2d::WindowsDirect2DRenderTarget::StartRendering()#Invalid render target.");
d2dRenderTarget->Clear(D2D1::ColorF(D2D1::ColorF::Black));
GetWindowsDirect2DObjectProvider()->StartRendering(window);
} }
bool StopRendering()override RenderTargetFailure StopRendering()override
{ {
auto result = d2dRenderTarget->EndDraw(); CHECK_ERROR(d2dRenderTarget, L"vl::presentation::elements_windows_d2d::WindowsDirect2DRenderTarget::StartRendering()#Invalid render target.");
bool deviceAvailable = false; auto result = GetWindowsDirect2DObjectProvider()->StopRenderingAndPresent(window);
if (result == S_OK) d2dRenderTarget = nullptr;
{ return result;
deviceAvailable = GetWindowsDirect2DObjectProvider()->PresentRenderTarget(window);
}
d2dRenderTarget = 0;
return deviceAvailable;
} }
void PushClipper(Rect clipper)override void PushClipper(Rect clipper)override
@@ -13301,6 +13365,11 @@ WindowsGDIResourceManager
NativeWindowCreated(window); NativeWindowCreated(window);
} }
void ResizeRenderTarget(INativeWindow* window)
{
GetWindowsDirect2DObjectProvider()->ResizeRenderTarget(window);
}
IGuiGraphicsLayoutProvider* GetLayoutProvider()override IGuiGraphicsLayoutProvider* GetLayoutProvider()override
{ {
return layoutProvider.Obj(); return layoutProvider.Obj();
+4 -4
View File
@@ -650,9 +650,6 @@ namespace vl
{ {
namespace windows namespace windows
{ {
extern ID2D1RenderTarget* GetNativeWindowDirect2DRenderTarget(INativeWindow* window);
extern void RecreateNativeWindowDirect2DRenderTarget(INativeWindow* window);
extern bool PresentNativeWindowDirect2DRenderTarget(INativeWindow* window);
extern ID2D1Factory* GetDirect2DFactory(); extern ID2D1Factory* GetDirect2DFactory();
extern IDWriteFactory* GetDirectWriteFactory(); extern IDWriteFactory* GetDirectWriteFactory();
extern ID3D11Device* GetD3D11Device(); extern ID3D11Device* GetD3D11Device();
@@ -1936,8 +1933,11 @@ OS Supporting
{ {
public: public:
virtual void RecreateRenderTarget(INativeWindow* window) = 0; virtual void RecreateRenderTarget(INativeWindow* window) = 0;
virtual bool PresentRenderTarget(INativeWindow* window)=0; virtual void ResizeRenderTarget(INativeWindow* window) = 0;
virtual ID2D1RenderTarget* GetNativeWindowDirect2DRenderTarget(INativeWindow* window) = 0; virtual ID2D1RenderTarget* GetNativeWindowDirect2DRenderTarget(INativeWindow* window) = 0;
virtual void StartRendering(INativeWindow* window) = 0;
virtual elements::RenderTargetFailure StopRenderingAndPresent(INativeWindow* window) = 0;
virtual ID2D1Factory* GetDirect2DFactory() = 0; virtual ID2D1Factory* GetDirect2DFactory() = 0;
virtual IDWriteFactory* GetDirectWriteFactory() = 0; virtual IDWriteFactory* GetDirectWriteFactory() = 0;
virtual IWindowsDirect2DRenderTarget* GetBindedRenderTarget(INativeWindow* window) = 0; virtual IWindowsDirect2DRenderTarget* GetBindedRenderTarget(INativeWindow* window) = 0;
BIN
View File
Binary file not shown.
Binary file not shown.