Update release

This commit is contained in:
vczh
2024-11-09 06:28:18 -08:00
parent 34ed13b84a
commit 1ee765cff9
7 changed files with 232 additions and 65 deletions
+202 -60
View File
@@ -2726,15 +2726,6 @@ GuiWindow
TypedControlTemplateObject(true)->SetMaximized(IsRenderedAsMaximized());
}
void GuiWindow::Opened()
{
GuiControlHost::Opened();
if (auto ct = TypedControlTemplateObject(false))
{
UpdateIcon(GetNativeWindow(), ct);
}
}
void GuiWindow::DpiChanged(bool preparing)
{
if (!preparing)
@@ -2746,6 +2737,54 @@ GuiWindow
}
}
void GuiWindow::Opened()
{
GuiControlHost::Opened();
if (auto ct = TypedControlTemplateObject(false))
{
UpdateIcon(GetNativeWindow(), ct);
}
}
void GuiWindow::BeforeClosing(bool& cancel)
{
if (GetHostedApplication() && this == GetApplication()->GetMainWindow())
{
GuiWindow* pickedWindow = nullptr;
if (showModalRecord)
{
pickedWindow = showModalRecord->current;
}
else
{
for (auto window : From(GetApplication()->GetWindows()))
{
if (window->GetVisible() && window->showModalRecord)
{
pickedWindow = window->showModalRecord->current;
break;
}
}
}
if (pickedWindow && pickedWindow != this)
{
if (pickedWindow->GetFocused())
{
pickedWindow->Hide();
}
else
{
pickedWindow->SetFocused();
}
cancel = true;
return;
}
}
GuiControlHost::BeforeClosing(cancel);
}
void GuiWindow::AssignFrameConfig(const NativeWindowFrameConfig& config)
{
frameConfig = &config;
@@ -2915,7 +2954,6 @@ GuiWindow
void GuiWindow::ShowWithOwner(GuiWindow* owner)
{
#define ERROR_MESSAGE_PREFIX L"vl::presentation::controls::GuiWindow::ShowWithOwner(GuiWindow*)#"
auto ownerNativeWindow = owner->GetNativeWindow();
auto nativeWindow = GetNativeWindow();
auto previousParent = nativeWindow->GetParent();
@@ -2928,21 +2966,40 @@ GuiWindow
});
}
Show();
#undef ERROR_MESSAGE_PREFIX
}
void GuiWindow::ShowModal(GuiWindow* owner, const Func<void()>& callback)
{
#define ERROR_MESSAGE_PREFIX L"vl::presentation::controls::GuiWindow::ShowModal(GuiWindow*, const Func<void()>&)#"
CHECK_ERROR(!showModalRecord, ERROR_MESSAGE_PREFIX L"Cannot call this function nestedly.");
CHECK_ERROR(owner && owner->GetEnabled(), ERROR_MESSAGE_PREFIX L"The owner should not have been disabled.");
if (!owner->showModalRecord)
{
owner->showModalRecord = Ptr(new ShowModalRecord{ owner,owner });
}
showModalRecord = owner->showModalRecord;
showModalRecord->current = this;
owner->SetEnabled(false);
GetNativeWindow()->SetParent(owner->GetNativeWindow());
auto container = Ptr(new IGuiGraphicsEventHandler::Container);
auto disposeFlag = GetDisposedFlag();
container->handler = WindowReadyToClose.AttachLambda([=](GuiGraphicsComposition* sender, GuiEventArgs& arguments)
{
GetNativeWindow()->SetParent(nullptr);
callback();
GetNativeWindow()->SetParent(nullptr);
owner->SetEnabled(true);
owner->SetFocused();
showModalRecord = nullptr;
owner->showModalRecord->current = owner;
if (owner->showModalRecord->current == owner->showModalRecord->origin)
{
owner->showModalRecord = nullptr;
}
GetApplication()->InvokeInMainThread(this, [=]()
{
if (!disposeFlag->IsDisposed())
@@ -2953,6 +3010,7 @@ GuiWindow
});
});
Show();
#undef ERROR_MESSAGE_PREFIX
}
void GuiWindow::ShowModalAndDelete(GuiWindow* owner, const Func<void()>& callback)
@@ -7328,6 +7386,7 @@ GuiDateComboBox
void GuiDateComboBox::SetSelectedDate(const DateTime& value)
{
selectedDate=value;
datePicker->SetDate(selectedDate);
NotifyUpdateSelectedDate();
}
@@ -9099,10 +9158,23 @@ DataColumn
void DataColumn::SetFilter(Ptr<IDataFilter> value)
{
if (associatedFilter) associatedFilter->SetCallback(nullptr);
associatedFilter = value;
if (associatedFilter) associatedFilter->SetCallback(dataProvider);
NotifyChanged(false);
if (associatedFilter != value)
{
if (associatedFilter) associatedFilter->SetCallback(nullptr);
associatedFilter = value;
if (associatedFilter) associatedFilter->SetCallback(dataProvider);
if (dataProvider)
{
vint index = dataProvider->columns.IndexOf(this);
if (index != -1)
{
dataProvider->OnProcessorChanged();
return;
}
}
NotifyChanged(false);
}
}
Ptr<IDataSorter> DataColumn::GetSorter()
@@ -9112,10 +9184,23 @@ DataColumn
void DataColumn::SetSorter(Ptr<IDataSorter> value)
{
if (associatedSorter) associatedSorter->SetCallback(nullptr);
associatedSorter = value;
if (associatedSorter) associatedSorter->SetCallback(dataProvider);
NotifyChanged(false);
if (associatedSorter != value)
{
if (associatedSorter) associatedSorter->SetCallback(nullptr);
associatedSorter = value;
if (associatedSorter) associatedSorter->SetCallback(dataProvider);
if (dataProvider)
{
vint index = dataProvider->columns.IndexOf(this);
if (index == dataProvider->GetSortedColumn())
{
dataProvider->SortByColumn(index, sortingState == ColumnSortingState::Ascending);
return;
}
}
NotifyChanged(false);
}
}
Ptr<IDataVisualizerFactory> DataColumn::GetVisualizerFactory()
@@ -9403,43 +9488,47 @@ DataProvider
void DataProvider::ReorderRows(bool invokeCallback)
{
vint oldRowCount = virtualRowToSourceRow.Count();
virtualRowToSourceRow.Clear();
vint oldRowCount = Count();
vint rowCount = itemSource ? itemSource->GetCount() : 0;
virtualRowToSourceRow = nullptr;
if (currentFilter)
{
virtualRowToSourceRow = Ptr(new List<vint>);
for (vint i = 0; i < rowCount; i++)
{
if (currentFilter->Filter(itemSource->Get(i)))
{
virtualRowToSourceRow.Add(i);
virtualRowToSourceRow->Add(i);
}
}
}
else
else if (currentSorter)
{
virtualRowToSourceRow = Ptr(new List<vint>);
for (vint i = 0; i < rowCount; i++)
{
virtualRowToSourceRow.Add(i);
virtualRowToSourceRow->Add(i);
}
}
if (currentSorter && virtualRowToSourceRow.Count() > 0)
if (currentSorter && virtualRowToSourceRow->Count() > 0)
{
IDataSorter* sorter = currentSorter.Obj();
SortLambda(
&virtualRowToSourceRow[0],
virtualRowToSourceRow.Count(),
&virtualRowToSourceRow->operator[](0),
virtualRowToSourceRow->Count(),
[=](vint a, vint b)
{
return sorter->Compare(itemSource->Get(a), itemSource->Get(b)) <=> 0;
auto ordering = sorter->Compare(itemSource->Get(a), itemSource->Get(b)) <=> 0;
return ordering == 0 ? a <=> b : ordering;
});
}
if (invokeCallback)
{
RebuildAllItems();
vint newRowCount = Count();
InvokeOnItemModified(0, oldRowCount, newRowCount, true);
}
}
@@ -9468,15 +9557,28 @@ DataProvider
void DataProvider::SetAdditionalFilter(Ptr<IDataFilter> value)
{
additionalFilter = value;
RebuildFilter();
ReorderRows(true);
OnProcessorChanged();
}
// ===================== GuiListControl::IItemProvider =====================
vint DataProvider::Count()
{
return virtualRowToSourceRow.Count();
if (itemSource)
{
if (virtualRowToSourceRow)
{
return virtualRowToSourceRow->Count();
}
else
{
return itemSource->GetCount();
}
}
else
{
return 0;
}
}
WString DataProvider::GetTextValue(vint itemIndex)
@@ -9486,7 +9588,21 @@ DataProvider
description::Value DataProvider::GetBindingValue(vint itemIndex)
{
return itemSource ? itemSource->Get(virtualRowToSourceRow[itemIndex]) : Value();
if (itemSource)
{
if (virtualRowToSourceRow)
{
return itemSource->Get(virtualRowToSourceRow->Get(itemIndex));
}
else
{
return itemSource->Get(itemIndex);
}
}
else
{
return Value();
}
}
IDescriptable* DataProvider::RequestView(const WString& identifier)
@@ -11642,7 +11758,11 @@ GuiVirtualDataGrid (Editor)
if (!skipOnSelectionChanged && !triggeredByItemContentModified)
{
vint row = GetSelectedItemIndex();
if (row != -1)
if (row == selectedCell.row)
{
// do nothing
}
else if (row != -1)
{
if (selectedCell.row != row && selectedCell.column != -1)
{
@@ -11956,6 +12076,11 @@ GuiVirtualDataGrid
return selectedCell;
}
Ptr<list::IDataEditor> GuiVirtualDataGrid::GetOpenedEditor()
{
return currentEditor;
}
bool GuiVirtualDataGrid::SelectCell(const GridPos& value, bool openEditor)
{
bool validPos = 0 <= value.row && value.row < GetItemProvider()->Count() && 0 <= value.column && value.column < listViewItemView->GetColumnCount();
@@ -11984,10 +12109,12 @@ GuiVirtualDataGrid
{
ClearSelection();
}
skipOnSelectionChanged = true;
SetSelected(value.row, true);
skipOnSelectionChanged = false;
}
skipOnSelectionChanged = true;
SetSelected(value.row, true);
skipOnSelectionChanged = false;
if (openEditor)
{
return StartEdit(value.row, value.column);
}
}
@@ -13521,27 +13648,32 @@ GuiSelectableListControl
void GuiSelectableListControl::SetSelected(vint itemIndex, bool value)
{
if(value)
if (0 <= itemIndex && itemIndex < itemProvider->Count())
{
if(!selectedItems.Contains(itemIndex))
if (value)
{
if(!multiSelect)
if (!selectedItems.Contains(itemIndex))
{
selectedItems.Clear();
OnItemSelectionCleared();
if (!multiSelect)
{
selectedItems.Clear();
OnItemSelectionCleared();
}
selectedItems.Add(itemIndex);
OnItemSelectionChanged(itemIndex, value);
NotifySelectionChanged(false);
}
selectedItems.Add(itemIndex);
OnItemSelectionChanged(itemIndex, value);
NotifySelectionChanged(false);
}
}
else
{
if(selectedItems.Remove(itemIndex))
else
{
OnItemSelectionChanged(itemIndex, value);
NotifySelectionChanged(false);
if (selectedItems.Remove(itemIndex))
{
OnItemSelectionChanged(itemIndex, value);
NotifySelectionChanged(false);
}
}
selectedItemIndexStart = itemIndex;
selectedItemIndexEnd = itemIndex;
}
}
@@ -14068,6 +14200,16 @@ ListViewColumnItemArranger
TBase::DetachListControl();
}
const ListViewColumnItemArranger::ColumnHeaderButtonList& ListViewColumnItemArranger::GetColumnButtons()
{
return columnHeaderButtons;
}
const ListViewColumnItemArranger::ColumnHeaderSplitterList& ListViewColumnItemArranger::GetColumnSplitters()
{
return columnHeaderSplitters;
}
/***********************************************************************
ListViewSubItems
***********************************************************************/
@@ -23509,12 +23651,6 @@ GuiMenuButton
hostMouseEnterHandler = host->GetBoundsComposition()->GetEventReceiver()->mouseEnter.AttachMethod(this, &GuiMenuButton::OnMouseEnter);
}
GuiButton* GuiMenuButton::GetSubMenuHost()
{
GuiButton* button = TypedControlTemplateObject(true)->GetSubMenuHost();
return button ? button : this;
}
bool GuiMenuButton::OpenSubMenuInternal()
{
if (!GetSubMenuOpening())
@@ -23650,6 +23786,12 @@ GuiMenuButton
}
}
GuiButton* GuiMenuButton::GetSubMenuHost()
{
GuiButton* button = TypedControlTemplateObject(true)->GetSubMenuHost();
return button ? button : this;
}
Ptr<GuiImageData> GuiMenuButton::GetLargeImage()
{
return largeImage;
@@ -51280,7 +51422,7 @@ View Model (IMessageBoxDialogViewModel)
FakeDialogServiceBase
***********************************************************************/
FakeDialogServiceBase::MessageBoxButtonsOutput FakeDialogServiceBase::ShowMessageBox(
FakeDialogServiceBase::MessageBoxButtonsOutput FakeDialogServiceBase::ShowMessageBox(
INativeWindow* window,
const WString& text,
const WString& title,
+24 -3
View File
@@ -10771,7 +10771,14 @@ Window
GUI_SPECIFY_CONTROL_TEMPLATE_TYPE(WindowTemplate, GuiControlHost)
friend class GuiApplication;
protected:
struct ShowModalRecord
{
GuiWindow* origin = nullptr;
GuiWindow* current = nullptr;
};
bool registeredInApplication = false;
Ptr<ShowModalRecord> showModalRecord;
protected:
compositions::IGuiAltActionHost* previousAltHost = nullptr;
@@ -10793,8 +10800,9 @@ Window
void ApplyFrameConfig();
void Moved()override;
void Opened()override;
void DpiChanged(bool preparing)override;
void Opened()override;
void BeforeClosing(bool& cancel)override;
void AssignFrameConfig(const NativeWindowFrameConfig& config)override;
void OnNativeWindowChanged()override;
void OnVisualStatusChanged()override;
@@ -18156,7 +18164,6 @@ MenuButton
IGuiMenuService* ownerMenuService;
bool cascadeAction;
GuiButton* GetSubMenuHost();
bool OpenSubMenuInternal();
void OnParentLineChanged()override;
compositions::IGuiAltActionHost* GetActivatingAltHost()override;
@@ -18190,6 +18197,10 @@ MenuButton
compositions::GuiNotifyEvent ImageChanged;
/// <summary>Shortcut text changed event.</summary>
compositions::GuiNotifyEvent ShortcutTextChanged;
/// <summary>Get the button control that used to interact and popup the sub menu.</summary>
/// <returns>The button for the sub menu, it could be the menu button itself.</returns>
GuiButton* GetSubMenuHost();
/// <summary>Get the large image for the menu button.</summary>
/// <returns>The large image for the menu button.</returns>
@@ -18765,6 +18776,13 @@ ListViewColumnItemArranger
Size GetTotalSize()override;
void AttachListControl(GuiListControl* value)override;
void DetachListControl()override;
/// <summary>Get all column buttons for the Detail view.</summary>
/// <returns>All column buttons</returns>
const ColumnHeaderButtonList& GetColumnButtons();
/// <summary>Get all column splitters for the Detail view.</summary>
/// <returns>All column spitters</returns>
const ColumnHeaderSplitterList& GetColumnSplitters();
};
}
@@ -20159,6 +20177,9 @@ GuiVirtualDataGrid
/// <summary>Get the row index and column index of the selected cell.</summary>
/// <returns>The row index and column index of the selected cell.</returns>
GridPos GetSelectedCell();
/// <summary>Get the opened editor for the selected cell.</summary>
/// <returns>The opened editor for the selected cell. If there is no editor, or the editor is not activated, it returns null.</returns>
Ptr<list::IDataEditor> GetOpenedEditor();
/// <summary>Select a cell.</summary>
/// <returns>Returns true if the editor is opened.</returns>
@@ -20522,7 +20543,7 @@ DataProvider
Ptr<IDataFilter> additionalFilter;
Ptr<IDataFilter> currentFilter;
Ptr<IDataSorter> currentSorter;
collections::List<vint> virtualRowToSourceRow;
Ptr<collections::List<vint>> virtualRowToSourceRow;
bool NotifyUpdate(vint start, vint count, bool itemReferenceUpdated);
void RebuildAllItems() override;
+6 -2
View File
@@ -1958,6 +1958,8 @@ Type Declaration (Extra)
BEGIN_CLASS_MEMBER(ListViewColumnItemArranger)
CLASS_MEMBER_BASE(FixedHeightItemArranger)
CLASS_MEMBER_CONSTRUCTOR(Ptr<ListViewColumnItemArranger>(), NO_PARAMETER)
CLASS_MEMBER_PROPERTY_READONLY_FAST(ColumnButtons)
CLASS_MEMBER_PROPERTY_READONLY_FAST(ColumnSplitters)
END_CLASS_MEMBER(ListViewColumnItemArranger)
BEGIN_CLASS_MEMBER(ListViewColumnItemArranger::IColumnItemViewCallback)
@@ -2713,7 +2715,8 @@ Type Declaration (Class)
CLASS_MEMBER_GUIEVENT(BeforeSubMenuOpening)
CLASS_MEMBER_GUIEVENT(AfterSubMenuOpening)
CLASS_MEMBER_PROPERTY_READONLY_FAST(SubMenuHost)
CLASS_MEMBER_PROPERTY_GUIEVENT_FAST(LargeImage)
CLASS_MEMBER_PROPERTY_GUIEVENT_FAST(Image)
CLASS_MEMBER_PROPERTY_GUIEVENT_FAST(ShortcutText)
@@ -3053,8 +3056,9 @@ Type Declaration (Class)
CLASS_MEMBER_BASE(GuiVirtualListView)
CONTROL_CONSTRUCTOR_CONTROLT_TEMPLATE_INHERITANCE_2(GuiVirtualDataGrid, list::IItemProvider*, itemProvider)
CLASS_MEMBER_PROPERTY_GUIEVENT_READONLY_FAST(SelectedCell)
CLASS_MEMBER_PROPERTY_READONLY_FAST(ItemProvider)
CLASS_MEMBER_PROPERTY_GUIEVENT_READONLY_FAST(SelectedCell)
CLASS_MEMBER_PROPERTY_READONLY_FAST(OpenedEditor)
CLASS_MEMBER_METHOD(SetViewToDefault, NO_PARAMETER)
CLASS_MEMBER_METHOD(SelectCell, { L"value" _ L"openEditor" })
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.