diff --git a/Import/GacUI.cpp b/Import/GacUI.cpp index 644c250a..7f06bd90 100644 --- a/Import/GacUI.cpp +++ b/Import/GacUI.cpp @@ -12860,21 +12860,32 @@ NodeItemProvider void NodeItemProvider::OnBeforeItemModified(INodeProvider* parentNode, vint start, vint count, vint newCount) { - offsetBeforeChildModified=0; + vint offset = 0; vint base=CalculateNodeVisibilityIndexInternal(parentNode); if(base!=-2 && parentNode->GetExpanding()) { for(vint i=0;iGetChild(start+i); - offsetBeforeChildModified+=child->CalculateTotalVisibleNodes(); + offset+=child->CalculateTotalVisibleNodes(); child->Release(); } } + offsetBeforeChildModifieds.Set(parentNode, offset); } void NodeItemProvider::OnAfterItemModified(INodeProvider* parentNode, vint start, vint count, vint newCount) { + vint offsetBeforeChildModified = 0; + { + vint index = offsetBeforeChildModifieds.Keys().IndexOf(parentNode); + if (index != -1) + { + offsetBeforeChildModified = offsetBeforeChildModifieds.Values().Get(index); + offsetBeforeChildModifieds.Remove(parentNode); + } + } + vint base=CalculateNodeVisibilityIndexInternal(parentNode); if(base!=-2 && parentNode->GetExpanding()) { diff --git a/Import/GacUI.h b/Import/GacUI.h index 47e0a42e..caed0ea2 100644 --- a/Import/GacUI.h +++ b/Import/GacUI.h @@ -12716,10 +12716,12 @@ GuiVirtualTreeListControl NodeProvider , protected virtual INodeItemView , public Description { + typedef collections::Dictionary NodeIntMap; protected: Ptr root; INodeItemPrimaryTextView* nodeItemPrimaryTextView; - vint offsetBeforeChildModified; + NodeIntMap offsetBeforeChildModifieds; + INodeProvider* GetNodeByOffset(INodeProvider* provider, vint offset); void OnAttached(INodeRootProvider* provider)override; diff --git a/Import/GacUIReflection.cpp b/Import/GacUIReflection.cpp index 4d399b9f..4a4fcef6 100644 --- a/Import/GacUIReflection.cpp +++ b/Import/GacUIReflection.cpp @@ -1867,6 +1867,8 @@ Type Declaration CLASS_MEMBER_PROPERTY_FAST(TitleBar) CLASS_MEMBER_METHOD(MoveToScreenCenter, NO_PARAMETER) + CLASS_MEMBER_METHOD(ShowModal, { L"owner" _ L"callback" }) + CLASS_MEMBER_METHOD(ShowModalAndDelete, { L"owner" _ L"callback" }) END_CLASS_MEMBER(GuiWindow) BEGIN_INTERFACE_MEMBER(GuiWindow::IStyleController) diff --git a/Tools/GacGen.exe b/Tools/GacGen.exe index 3d7d6a08..c767c999 100644 Binary files a/Tools/GacGen.exe and b/Tools/GacGen.exe differ diff --git a/Tutorial/GacUI_Controls/AddressBook/Main.cpp b/Tutorial/GacUI_Controls/AddressBook/Main.cpp index adc29575..22f2322d 100644 --- a/Tutorial/GacUI_Controls/AddressBook/Main.cpp +++ b/Tutorial/GacUI_Controls/AddressBook/Main.cpp @@ -14,8 +14,11 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi Ptr folderImage; Ptr contactImage; +class ViewModel; + class Category : public Object, public ICategory { + friend class ViewModel; protected: ICategory* parent; WString name; @@ -59,11 +62,7 @@ public: StaticCategory() :Category(nullptr) { - } - - WString GetName()override - { - return L"My Address Book"; + name = L"My Address Book"; } }; @@ -137,10 +136,21 @@ public: void AddCategory(WString name) { + if (auto current = dynamic_cast(selectedCategory.Obj())) + { + auto category = new Category(current); + category->name = name; + current->folders.Add(category); + } } void RemoveCategory() { + if (auto parent = dynamic_cast(selectedCategory->GetParent())) + { + parent->folders.Remove(selectedCategory.Obj()); + SetSelectedCategory(nullptr); + } } }; diff --git a/Tutorial/GacUI_Controls/AddressBook/UI/Resource.xml b/Tutorial/GacUI_Controls/AddressBook/UI/Resource.xml index 801c9efb..7fd8a6e3 100644 --- a/Tutorial/GacUI_Controls/AddressBook/UI/Resource.xml +++ b/Tutorial/GacUI_Controls/AddressBook/UI/Resource.xml @@ -76,7 +76,7 @@ - + @@ -85,7 +85,21 @@ ViewModel.SelectedCategory is not null - {} + + + ViewModel.SelectedCategory is null ? false : ViewModel.SelectedCategory.Parent is not null @@ -204,5 +218,52 @@ + + + + + + + textBoxName.Text + + + + composeType:MinSize + composeType:Percentage percentage:1.0 + composeType:MinSize + + + composeType:MinSize + composeType:Percentage percentage:1.0 + composeType:MinSize + composeType:MinSize + + + + + + + + + + + + + + + + + +
+
+
+
\ No newline at end of file diff --git a/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.cpp b/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.cpp index ad63d08d..47dad4f7 100644 --- a/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.cpp +++ b/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.cpp @@ -10,6 +10,34 @@ DO NOT MODIFY #include "Demo.h" +namespace demo +{ + // #region CLASS_MEMBER_GUIEVENT_HANDLER (DO NOT PUT OTHER CONTENT IN THIS #region.) + + void NewFolderWindow::OnCreate() + { + } + + void NewFolderWindow::OnDestroy() + { + } + + // #endregion CLASS_MEMBER_GUIEVENT_HANDLER + + NewFolderWindow::NewFolderWindow() + { + InitializeComponents(); + OnCreate(); + } + + NewFolderWindow::~NewFolderWindow() + { + OnDestroy(); + ClearSubscriptions(); + } +} + + namespace vl { namespace reflection @@ -20,6 +48,7 @@ namespace vl IMPL_CPP_TYPE_INFO(demo::ICategory) IMPL_CPP_TYPE_INFO(demo::IViewModel) IMPL_CPP_TYPE_INFO(demo::MainWindow) + IMPL_CPP_TYPE_INFO(demo::NewFolderWindow) BEGIN_CLASS_MEMBER(demo::ICategory) CLASS_MEMBER_BASE(vl::reflection::IDescriptable) @@ -62,6 +91,16 @@ namespace vl CLASS_MEMBER_PROPERTY_READONLY_FAST(ViewModel) END_CLASS_MEMBER(demo::MainWindow) + BEGIN_CLASS_MEMBER(demo::NewFolderWindow) + CLASS_MEMBER_BASE(vl::presentation::controls::GuiWindow) + CLASS_MEMBER_CONSTRUCTOR(demo::NewFolderWindow*(), NO_PARAMETER) + + CLASS_MEMBER_EVENT(FolderNameChanged) + CLASS_MEMBER_PROPERTY_EVENT_FAST(FolderName, FolderNameChanged) + CLASS_MEMBER_EVENT(ReadyChanged) + CLASS_MEMBER_PROPERTY_EVENT_FAST(Ready, ReadyChanged) + END_CLASS_MEMBER(demo::NewFolderWindow) + #undef _ class DemoResourceLoader : public Object, public ITypeLoader @@ -72,6 +111,7 @@ namespace vl ADD_TYPE_INFO(demo::ICategory) ADD_TYPE_INFO(demo::IViewModel) ADD_TYPE_INFO(demo::MainWindow) + ADD_TYPE_INFO(demo::NewFolderWindow) } void Unload(ITypeManager* manager) diff --git a/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.h b/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.h index e9056e2d..dd9196bd 100644 --- a/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.h +++ b/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.h @@ -18,6 +18,7 @@ namespace demo class ICategory; class IViewModel; class MainWindow; + class NewFolderWindow; class ICategory : public virtual vl::reflection::IDescriptable, public vl::reflection::Description { @@ -58,6 +59,7 @@ namespace demo vl::presentation::controls::GuiToolstripCommand* commandSmallIcon; vl::presentation::controls::GuiToolstripCommand* commandTile; vl::presentation::controls::GuiBindableListView* listViewContacts; + vl::presentation::controls::GuiWindow* self; vl::presentation::controls::GuiBindableTreeView* treeViewFolders; void InitializeComponents(Ptr ViewModel) @@ -76,6 +78,7 @@ namespace demo GUI_INSTANCE_REFERENCE(commandSmallIcon); GUI_INSTANCE_REFERENCE(commandTile); GUI_INSTANCE_REFERENCE(listViewContacts); + GUI_INSTANCE_REFERENCE(self); GUI_INSTANCE_REFERENCE(treeViewFolders); } else @@ -98,6 +101,7 @@ namespace demo ,commandSmallIcon(0) ,commandTile(0) ,listViewContacts(0) + ,self(0) ,treeViewFolders(0) { } @@ -108,6 +112,66 @@ namespace demo } }; + template + class NewFolderWindow_ : public vl::presentation::controls::GuiWindow, public vl::presentation::GuiInstancePartialClass, public vl::reflection::Description + { + friend struct vl::reflection::description::CustomTypeDescriptorSelector; + private: + vl::WString FolderName_; + bool Ready_; + protected: + vl::presentation::controls::GuiWindow* self; + vl::presentation::controls::GuiDocumentLabel* textBoxName; + + void InitializeComponents() + { + if (InitializeFromResource()) + { + GUI_INSTANCE_REFERENCE(self); + GUI_INSTANCE_REFERENCE(textBoxName); + } + else + { + } + } + public: + NewFolderWindow_() + :vl::presentation::GuiInstancePartialClass(L"demo::NewFolderWindow") + ,vl::presentation::controls::GuiWindow(vl::presentation::theme::GetCurrentTheme()->CreateWindowStyle()) + ,self(0) + ,textBoxName(0) + { + this->FolderName_ = vl::reflection::description::UnboxValue(vl::reflection::description::Value::From(L"", reflection::description::GetTypeDescriptor())); + this->Ready_ = vl::reflection::description::UnboxValue(vl::reflection::description::Value::From(L"true", reflection::description::GetTypeDescriptor())); + } + + vl::Event FolderNameChanged; + + vl::WString GetFolderName() + { + return FolderName_; + } + + void SetFolderName(vl::WString value) + { + FolderName_ = value; + FolderNameChanged(); + } + + vl::Event ReadyChanged; + + bool GetReady() + { + return Ready_; + } + + void SetReady(bool value) + { + Ready_ = value; + ReadyChanged(); + } + }; + } namespace vl { @@ -118,9 +182,29 @@ namespace vl DECL_TYPE_INFO(demo::ICategory) DECL_TYPE_INFO(demo::IViewModel) DECL_TYPE_INFO(demo::MainWindow) + DECL_TYPE_INFO(demo::NewFolderWindow) } } } +namespace demo +{ + class NewFolderWindow : public demo::NewFolderWindow_ + { + friend class demo::NewFolderWindow_; + friend struct vl::reflection::description::CustomTypeDescriptorSelector; + protected: + + // #region CLASS_MEMBER_GUIEVENT_HANDLER (DO NOT PUT OTHER CONTENT IN THIS #region.) + void OnCreate(); + void OnDestroy(); + // #endregion CLASS_MEMBER_GUIEVENT_HANDLER + public: + NewFolderWindow(); + ~NewFolderWindow(); + }; +} + + #endif diff --git a/Tutorial/GacUI_Controls/UIRes/AddressBook.bin b/Tutorial/GacUI_Controls/UIRes/AddressBook.bin index 1f015709..5f863679 100644 Binary files a/Tutorial/GacUI_Controls/UIRes/AddressBook.bin and b/Tutorial/GacUI_Controls/UIRes/AddressBook.bin differ