Skip to content

Commit

Permalink
[ColorPicker] First Orientation implementation (#5602)
Browse files Browse the repository at this point in the history
* Add property and first template updates

* Add slider rotation (V2 styles)

* Update V1 Style

* Touch ups

* CR feedback

* CR feedback

* CR feedback

* Fix Gabby's MUXControlsTestApp issues

* CR feedback

* UI updates for horizontal design as per design

* Fix crash

* Backport changes to v1 style

* Fix small issues

* Revert some breaking name changes
  • Loading branch information
marcelwgn authored Aug 16, 2021
1 parent b49372d commit 0a2972f
Show file tree
Hide file tree
Showing 11 changed files with 855 additions and 520 deletions.
17 changes: 15 additions & 2 deletions dev/ColorPicker/ColorPicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ void ColorPicker::OnPropertyChanged(winrt::DependencyPropertyChangedEventArgs co
{
OnColorSpectrumComponentsChanged(args);
}
else if (property == s_OrientationProperty)
{
OnOrientationChanged(args);
}
}

void ColorPicker::OnColorChanged(winrt::DependencyPropertyChangedEventArgs const& args)
Expand Down Expand Up @@ -428,11 +432,17 @@ void ColorPicker::OnColorSpectrumComponentsChanged(winrt::DependencyPropertyChan
SetThirdDimensionSliderChannel();
}

void ColorPicker::OnOrientationChanged(winrt::DependencyPropertyChangedEventArgs const& args)
{
UpdateVisualState(true);
}

void ColorPicker::UpdateVisualState(bool useTransitions)
{
winrt::IReference<winrt::Color> previousColor = PreviousColor();
const bool isAlphaEnabled = IsAlphaEnabled();
const bool isColorSpectrumVisible = IsColorSpectrumVisible();
const bool isVerticalOrientation = Orientation() == winrt::Orientation::Vertical;

const wchar_t *previousColorStateName;

Expand All @@ -450,8 +460,9 @@ void ColorPicker::UpdateVisualState(bool useTransitions)
winrt::VisualStateManager::GoToState(*this, IsColorPreviewVisible() ? L"ColorPreviewVisible" : L"ColorPreviewCollapsed", useTransitions);
winrt::VisualStateManager::GoToState(*this, IsColorSliderVisible() ? L"ThirdDimensionSliderVisible" : L"ThirdDimensionSliderCollapsed", useTransitions);
winrt::VisualStateManager::GoToState(*this, isAlphaEnabled && IsAlphaSliderVisible() ? L"AlphaSliderVisible" : L"AlphaSliderCollapsed", useTransitions);
winrt::VisualStateManager::GoToState(*this, IsMoreButtonVisible() ? L"MoreButtonVisible" : L"MoreButtonCollapsed", useTransitions);
winrt::VisualStateManager::GoToState(*this, !IsMoreButtonVisible() || m_textEntryGridOpened ? L"TextEntryGridVisible" : L"TextEntryGridCollapsed", useTransitions);
// More button is disabled in horizontal orientation; only respect IsMoreButtonVisible states when switching to Vertical orientation.
winrt::VisualStateManager::GoToState(*this, IsMoreButtonVisible() && isVerticalOrientation ? L"MoreButtonVisible" : L"MoreButtonCollapsed", useTransitions);
winrt::VisualStateManager::GoToState(*this, !IsMoreButtonVisible() || m_textEntryGridOpened || !isVerticalOrientation ? L"TextEntryGridVisible" : L"TextEntryGridCollapsed", useTransitions);

if (auto&& colorRepresentationComboBox = m_colorRepresentationComboBox.get())
{
Expand All @@ -462,6 +473,8 @@ void ColorPicker::UpdateVisualState(bool useTransitions)
winrt::VisualStateManager::GoToState(*this, isAlphaEnabled && IsAlphaTextInputVisible() ? L"AlphaTextInputVisible" : L"AlphaTextInputCollapsed", useTransitions);
winrt::VisualStateManager::GoToState(*this, IsHexInputVisible() ? L"HexInputVisible" : L"HexInputCollapsed", useTransitions);
winrt::VisualStateManager::GoToState(*this, isAlphaEnabled ? L"AlphaEnabled" : L"AlphaDisabled", useTransitions);
winrt::VisualStateManager::GoToState(*this, isVerticalOrientation ? L"Vertical" : L"Horizontal", useTransitions);

}

void ColorPicker::InitializeColor()
Expand Down
1 change: 1 addition & 0 deletions dev/ColorPicker/ColorPicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ColorPicker :
void OnMinMaxSaturationChanged(winrt::DependencyPropertyChangedEventArgs const& args);
void OnMinMaxValueChanged(winrt::DependencyPropertyChangedEventArgs const& args);
void OnColorSpectrumComponentsChanged(winrt::DependencyPropertyChangedEventArgs const& args);
void OnOrientationChanged(winrt::DependencyPropertyChangedEventArgs const& args);

// ColorPicker event handlers
void OnUnloaded(winrt::IInspectable const& sender, winrt::RoutedEventArgs const& args);
Expand Down
10 changes: 10 additions & 0 deletions dev/ColorPicker/ColorPicker.idl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ unsealed runtimeclass ColorPicker : Windows.UI.Xaml.Controls.Control
ColorSpectrumComponents ColorSpectrumComponents { get; set; };
event Windows.Foundation.TypedEventHandler<ColorPicker, ColorChangedEventArgs> ColorChanged;

[MUX_PUBLIC_V2]
{
[MUX_DEFAULT_VALUE("winrt::Orientation::Vertical")]
Windows.UI.Xaml.Controls.Orientation Orientation;
}

static Windows.UI.Xaml.DependencyProperty ColorProperty { get; };
static Windows.UI.Xaml.DependencyProperty PreviousColorProperty { get; };
static Windows.UI.Xaml.DependencyProperty IsAlphaEnabledProperty { get; };
Expand All @@ -65,6 +71,10 @@ unsealed runtimeclass ColorPicker : Windows.UI.Xaml.Controls.Control
static Windows.UI.Xaml.DependencyProperty MaxValueProperty { get; };
static Windows.UI.Xaml.DependencyProperty ColorSpectrumShapeProperty { get; };
static Windows.UI.Xaml.DependencyProperty ColorSpectrumComponentsProperty { get; };
[MUX_PUBLIC_V2]
{
static Windows.UI.Xaml.DependencyProperty OrientationProperty{ get; };
}
}

}
Loading

0 comments on commit 0a2972f

Please sign in to comment.