Skip to content

Commit 5754d8b

Browse files
committed
chore: 更新 SettingsControls
主要修复了圆角问题
1 parent 84d30c9 commit 5754d8b

10 files changed

+79
-7
lines changed

‎src/Magpie.App/App.idl‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace Magpie.App {
44

55
#include "BoolNegationConverter.idl"
66
#include "BoolToNegativeVisibilityConverter.idl"
7+
#include "SettingsExpanderCornerRadiusConverter.idl"
78
#include "ControlSizeTrigger.idl"
89
#include "IsEqualStateTrigger.idl"
910
#include "IsNullStateTrigger.idl"

‎src/Magpie.App/Magpie.App.vcxproj‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@
129129
<DependentUpon>SettingsExpander.idl</DependentUpon>
130130
<SubType>Code</SubType>
131131
</ClInclude>
132+
<ClInclude Include="SettingsExpanderCornerRadiusConverter.h">
133+
<DependentUpon>SettingsExpanderCornerRadiusConverter.idl</DependentUpon>
134+
<SubType>Code</SubType>
135+
</ClInclude>
132136
<ClInclude Include="ShortcutService.h" />
133137
<ClInclude Include="Shortcut.h" />
134138
<ClInclude Include="IconHelper.h" />
@@ -299,6 +303,10 @@
299303
<DependentUpon>SettingsExpander.idl</DependentUpon>
300304
<SubType>Code</SubType>
301305
</ClCompile>
306+
<ClCompile Include="SettingsExpanderCornerRadiusConverter.cpp">
307+
<DependentUpon>SettingsExpanderCornerRadiusConverter.idl</DependentUpon>
308+
<SubType>Code</SubType>
309+
</ClCompile>
302310
<ClCompile Include="ShortcutService.cpp" />
303311
<ClCompile Include="Shortcut.cpp" />
304312
<ClCompile Include="IconHelper.cpp" />
@@ -403,6 +411,9 @@
403411
</ClCompile>
404412
</ItemGroup>
405413
<ItemGroup>
414+
<None Include="SettingsExpanderCornerRadiusConverter.idl">
415+
<SubType>Designer</SubType>
416+
</None>
406417
<None Include="Magpie.App.def" />
407418
<None Include="SimpleStackPanel.idl">
408419
<SubType>Designer</SubType>

‎src/Magpie.App/Magpie.App.vcxproj.filters‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@
231231
<None Include="ScalingModesViewModel.idl">
232232
<Filter>ViewModels</Filter>
233233
</None>
234+
<None Include="SettingsExpanderCornerRadiusConverter.idl">
235+
<Filter>Converters</Filter>
236+
</None>
234237
</ItemGroup>
235238
<ItemGroup>
236239
<Page Include="RootPage.xaml" />
@@ -332,6 +335,9 @@
332335
<PRIResource Include="Resources.language-vi.resw">
333336
<Filter>Strings</Filter>
334337
</PRIResource>
338+
<PRIResource Include="Resources.language-pl.resw">
339+
<Filter>Strings</Filter>
340+
</PRIResource>
335341
</ItemGroup>
336342
<ItemGroup>
337343
<Text Include="conanfile.txt" />

‎src/Magpie.App/SettingsCard.Resource.xaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- 移植自 https://github.com/CommunityToolkit/Windows/blob/bef863ca70bb1edf8c940198dd5cc74afa5d2aab/components/SettingsControls/src/SettingsCard/SettingsCard.xaml -->
1+
<!-- 移植自 https://github.com/CommunityToolkit/Windows/blob/efbaf965029806fe29e02a6421af3c8f434e1460/components/SettingsControls/src/SettingsCard/SettingsCard.xaml -->
22
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
33
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

‎src/Magpie.App/SettingsCard.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// 移植自 https://github.com/CommunityToolkit/Windows/tree/bef863ca70bb1edf8c940198dd5cc74afa5d2aab/components/SettingsControls/src/SettingsCard
1+
// 移植自 https://github.com/CommunityToolkit/Windows/tree/efbaf965029806fe29e02a6421af3c8f434e1460/components/SettingsControls/src/SettingsCard
22

33
#include "pch.h"
44
#include "SettingsCard.h"
@@ -262,7 +262,7 @@ void SettingsCard::_CheckVerticalSpacingState(VisualState const& s) {
262262

263263
const hstring stateName = s ? s.Name() : hstring();
264264
if (!stateName.empty() && (stateName == RightWrappedState || stateName == RightWrappedNoIconState ||
265-
stateName == VerticalState) && Content() && (Header() || IsNotEmpty(Description()))) {
265+
stateName == VerticalState) && Content() && (IsNotEmpty(Header()) || IsNotEmpty(Description()))) {
266266
VisualStateManager::GoToState(*this, ContentSpacingState, true);
267267
} else {
268268
VisualStateManager::GoToState(*this, NoContentSpacingState, true);

‎src/Magpie.App/SettingsExpander.Resource.xaml‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- 移植自 https://github.com/CommunityToolkit/Windows/blob/main/components/SettingsControls/src/SettingsExpander/SettingsExpander.xaml -->
1+
<!-- 移植自 https://github.com/CommunityToolkit/Windows/blob/efbaf965029806fe29e02a6421af3c8f434e1460/components/SettingsControls/src/SettingsExpander/SettingsExpander.xaml -->
22
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
33
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -15,6 +15,8 @@
1515
<x:Double x:Key="SettingsExpanderChevronButtonWidth">32</x:Double>
1616
<x:Double x:Key="SettingsExpanderChevronButtonHeight">32</x:Double>
1717

18+
<local:SettingsExpanderCornerRadiusConverter x:Key="SettingsExpanderCornerRadiusConverter" />
19+
1820
<Style x:Key="DefaultSettingsExpanderItemStyle"
1921
BasedOn="{StaticResource DefaultSettingsCardStyle}"
2022
TargetType="local:SettingsCard">
@@ -76,12 +78,14 @@
7678
BorderThickness="0"
7779
Content="{TemplateBinding Content}"
7880
Description="{TemplateBinding Description}"
81+
FontFamily="{TemplateBinding FontFamily}"
7982
Header="{TemplateBinding Header}"
8083
HeaderIcon="{TemplateBinding HeaderIcon}"
8184
IsClickEnabled="False" />
8285
</muxc:Expander.Header>
8386
<muxc:Expander.Content>
84-
<local:SimpleStackPanel ChildrenTransitions="{StaticResource SettingsCardsAnimations}">
87+
<StackPanel ChildrenTransitions="{StaticResource SettingsCardsAnimations}"
88+
CornerRadius="{Binding CornerRadius, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource SettingsExpanderCornerRadiusConverter}}">
8589
<ContentPresenter Content="{TemplateBinding ItemsHeader}" />
8690
<!-- ItemsRepeater 无法在 XAML Islands 中使用,见 https://github.com/microsoft/microsoft-ui-xaml/issues/2349 -->
8791
<ItemsControl x:Name="PART_ItemsContainer"
@@ -90,7 +94,7 @@
9094
ItemTemplate="{Binding ItemTemplate, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
9195
<ContentPresenter Grid.Row="2"
9296
Content="{TemplateBinding ItemsFooter}" />
93-
</local:SimpleStackPanel>
97+
</StackPanel>
9498
</muxc:Expander.Content>
9599
</muxc:Expander>
96100
</ControlTemplate>

‎src/Magpie.App/SettingsExpander.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// 移植自 https://github.com/CommunityToolkit/Windows/tree/bef863ca70bb1edf8c940198dd5cc74afa5d2aab/components/SettingsControls/src/SettingsExpander
1+
// 移植自 https://github.com/CommunityToolkit/Windows/tree/efbaf965029806fe29e02a6421af3c8f434e1460/components/SettingsControls/src/SettingsExpander
22

33
#include "pch.h"
44
#include "SettingsExpander.h"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include "pch.h"
2+
#include "SettingsExpanderCornerRadiusConverter.h"
3+
#if __has_include("SettingsExpanderCornerRadiusConverter.g.cpp")
4+
#include "SettingsExpanderCornerRadiusConverter.g.cpp"
5+
#endif
6+
7+
using namespace winrt;
8+
using namespace Windows::UI::Xaml::Interop;
9+
10+
namespace winrt::Magpie::App::implementation {
11+
12+
IInspectable SettingsExpanderCornerRadiusConverter::Convert(IInspectable const& value, TypeName const&, IInspectable const&, hstring const&) {
13+
auto cornerRadius = value.try_as<CornerRadius>();
14+
if (!cornerRadius) {
15+
return value;
16+
}
17+
18+
cornerRadius->TopLeft = 0;
19+
cornerRadius->TopRight = 0;
20+
return box_value(*cornerRadius);
21+
}
22+
23+
IInspectable SettingsExpanderCornerRadiusConverter::ConvertBack(IInspectable const& value, TypeName const&, IInspectable const&, hstring const&) {
24+
return value;
25+
}
26+
27+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma once
2+
#include "SettingsExpanderCornerRadiusConverter.g.h"
3+
4+
namespace winrt::Magpie::App::implementation {
5+
6+
struct SettingsExpanderCornerRadiusConverter : SettingsExpanderCornerRadiusConverterT<SettingsExpanderCornerRadiusConverter> {
7+
IInspectable Convert(IInspectable const& value, Interop::TypeName const&, IInspectable const&, hstring const&);
8+
IInspectable ConvertBack(IInspectable const& value, Interop::TypeName const&, IInspectable const&, hstring const&);
9+
};
10+
11+
}
12+
13+
namespace winrt::Magpie::App::factory_implementation {
14+
15+
struct SettingsExpanderCornerRadiusConverter : SettingsExpanderCornerRadiusConverterT<SettingsExpanderCornerRadiusConverter, implementation::SettingsExpanderCornerRadiusConverter> {
16+
};
17+
18+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace Magpie.App {
2+
runtimeclass SettingsExpanderCornerRadiusConverter : [default] Windows.UI.Xaml.Data.IValueConverter {
3+
SettingsExpanderCornerRadiusConverter();
4+
}
5+
}

0 commit comments

Comments
 (0)