Update tooltips for the Equation Button and Style Picker (#1163)

* Update EquationButton automation name and tooltips

* added tooltips to the stylepicker and fixed the issue where the color name did not update for dark mode colors

* Update src/Calculator/Resources/en-US/Resources.resw

Co-Authored-By: ItzLevvie <11600822+ItzLevvie@users.noreply.github.com>

* fixed the issue where the colors are only listed as black in the tooltip and automation name

* Add tooltips for high contrast colors

Co-authored-by: ItzLevvie <11600822+ItzLevvie@users.noreply.github.com>
This commit is contained in:
Stephanie Anderl 2020-05-07 16:36:52 -07:00 committed by GitHub
parent fd48f6ec1d
commit 0105e6b319
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 161 additions and 50 deletions

View File

@ -69,16 +69,6 @@ void EquationTextBox::OnApplyTemplate()
if (m_equationButton != nullptr)
{
m_equationButton->Click += ref new RoutedEventHandler(this, &EquationTextBox::OnEquationButtonClicked);
auto toolTip = ref new ToolTip();
auto equationButtonMessage = LocalizationStringUtil::GetLocalizedString(
IsEquationLineDisabled ? resProvider->GetResourceString(L"showEquationButtonToolTip")
: resProvider->GetResourceString(L"hideEquationButtonToolTip"), EquationButtonContentIndex);
toolTip->Content = equationButtonMessage;
ToolTipService::SetToolTip(m_equationButton, toolTip);
AutomationProperties::SetName(m_equationButton, equationButtonMessage);
}
if (m_richEditContextMenu != nullptr)
@ -237,16 +227,7 @@ void EquationTextBox::OnEquationButtonClicked(Object ^ sender, RoutedEventArgs ^
{
EquationButtonClicked(this, ref new RoutedEventArgs());
auto toolTip = ref new ToolTip();
auto resProvider = AppResourceProvider::GetInstance();
auto equationButtonMessage = LocalizationStringUtil::GetLocalizedString(
IsEquationLineDisabled ? resProvider->GetResourceString(L"showEquationButtonToolTip")
: resProvider->GetResourceString(L"hideEquationButtonToolTip"), EquationButtonContentIndex);
toolTip->Content = equationButtonMessage;
ToolTipService::SetToolTip(m_equationButton, toolTip);
AutomationProperties::SetName(m_equationButton, equationButtonMessage);
SetEquationButtonTooltipAndAutomationName();
}
void EquationTextBox::OnRemoveButtonClicked(Object ^ sender, RoutedEventArgs ^ e)
@ -485,3 +466,26 @@ void EquationTextBox::OnEquationFormatRequested(Object ^ sender, MathRichEditBox
{
EquationFormatRequested(this, args);
}
void EquationTextBox::SetEquationButtonTooltipAndAutomationName()
{
auto toolTip = ref new ToolTip();
auto resProvider = AppResourceProvider::GetInstance();
auto equationButtonMessage = LocalizationStringUtil::GetLocalizedString(
IsEquationLineDisabled ? resProvider->GetResourceString(L"showEquationButtonAutomationName")
: resProvider->GetResourceString(L"hideEquationButtonAutomationName"),
EquationButtonContentIndex);
auto equationButtonTooltip = LocalizationStringUtil::GetLocalizedString(
IsEquationLineDisabled ? resProvider->GetResourceString(L"showEquationButtonToolTip") : resProvider->GetResourceString(L"hideEquationButtonToolTip"));
toolTip->Content = equationButtonTooltip;
ToolTipService::SetToolTip(m_equationButton, toolTip);
AutomationProperties::SetName(m_equationButton, equationButtonMessage);
}
void EquationTextBox::OnEquationButtonContentIndexPropertyChanged(String ^ /*oldValue*/, String ^ newValue)
{
SetEquationButtonTooltipAndAutomationName();
}

View File

@ -22,7 +22,7 @@ namespace CalculatorApp
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::SolidColorBrush ^, EquationColor);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::SolidColorBrush ^, EquationButtonForegroundColor);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Controls::Flyout ^, ColorChooserFlyout);
DEPENDENCY_PROPERTY(Platform::String ^, EquationButtonContentIndex);
DEPENDENCY_PROPERTY_WITH_CALLBACK(Platform::String ^, EquationButtonContentIndex);
DEPENDENCY_PROPERTY(Platform::String ^, MathEquation);
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, HasError);
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, IsAddEquationMode);
@ -74,6 +74,9 @@ namespace CalculatorApp
void OnColorFlyoutClosed(Platform::Object ^ sender, Platform::Object ^ e);
void OnHasErrorPropertyChanged(bool oldValue, bool newValue);
void OnEquationButtonContentIndexPropertyChanged(Platform::String ^ /*oldValue*/, Platform::String ^ newValue);
void SetEquationButtonTooltipAndAutomationName();
CalculatorApp::Controls::MathRichEditBox ^ m_richEditBox;
Windows::UI::Xaml::Controls::Primitives::ToggleButton ^ m_equationButton;

View File

@ -80,6 +80,7 @@
Fill="{x:Bind}"
StrokeThickness="0"
AutomationProperties.Name="{x:Bind local:EquationStylePanelControl.GetColorAutomationName((Brush))}"
ToolTipService.ToolTip="{x:Bind local:EquationStylePanelControl.GetColorAutomationName((Brush))}"
UseLayoutRounding="false"/>
</DataTemplate>
</GridView.ItemTemplate>

View File

@ -145,62 +145,100 @@ String ^ EquationStylePanelControl::GetColorAutomationName(Brush ^ brush)
auto resourceLoader = AppResourceProvider::GetInstance();
auto color = static_cast<SolidColorBrush ^>(brush);
if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush1")))
auto lightDictionary = static_cast<ResourceDictionary ^>(Application::Current->Resources->ThemeDictionaries->Lookup(L"Light"));
auto darkDictionary = static_cast<ResourceDictionary ^>(Application::Current->Resources->ThemeDictionaries->Lookup(L"Default"));
auto highContrast = static_cast<ResourceDictionary ^>(Application::Current->Resources->ThemeDictionaries->Lookup(L"HighContrast"));
if (color == safe_cast<SolidColorBrush ^>(lightDictionary->Lookup(L"EquationBrush1"))
|| color == safe_cast<SolidColorBrush ^>(darkDictionary->Lookup(L"EquationBrush1")))
{
return resourceLoader->GetResourceString("equationColor1AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush2")))
else if (color == safe_cast<SolidColorBrush ^>(lightDictionary->Lookup(L"EquationBrush2"))
|| color == safe_cast<SolidColorBrush ^>(darkDictionary->Lookup(L"EquationBrush2")))
{
return resourceLoader->GetResourceString("equationColor2AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush3")))
else if (color == safe_cast<SolidColorBrush ^>(lightDictionary->Lookup(L"EquationBrush3"))
|| color == safe_cast<SolidColorBrush ^>(darkDictionary->Lookup(L"EquationBrush3")))
{
return resourceLoader->GetResourceString("equationColor3AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush4")))
else if (color == safe_cast<SolidColorBrush ^>(lightDictionary->Lookup(L"EquationBrush4"))
|| color == safe_cast<SolidColorBrush ^>(darkDictionary->Lookup(L"EquationBrush4")))
{
return resourceLoader->GetResourceString("equationColor4AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush5")))
else if (color == safe_cast<SolidColorBrush ^>(lightDictionary->Lookup(L"EquationBrush5"))
|| color == safe_cast<SolidColorBrush ^>(darkDictionary->Lookup(L"EquationBrush5")))
{
return resourceLoader->GetResourceString("equationColor5AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush6")))
else if (color == safe_cast<SolidColorBrush ^>(lightDictionary->Lookup(L"EquationBrush6"))
|| color == safe_cast<SolidColorBrush ^>(darkDictionary->Lookup(L"EquationBrush6")))
{
return resourceLoader->GetResourceString("equationColor6AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush7")))
else if (color == safe_cast<SolidColorBrush ^>(lightDictionary->Lookup(L"EquationBrush7"))
|| color == safe_cast<SolidColorBrush ^>(darkDictionary->Lookup(L"EquationBrush7")))
{
return resourceLoader->GetResourceString("equationColor7AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush8")))
else if (color == safe_cast<SolidColorBrush ^>(lightDictionary->Lookup(L"EquationBrush8"))
|| color == safe_cast<SolidColorBrush ^>(darkDictionary->Lookup(L"EquationBrush8")))
{
return resourceLoader->GetResourceString("equationColor8AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush9")))
else if (color == safe_cast<SolidColorBrush ^>(lightDictionary->Lookup(L"EquationBrush9"))
|| color == safe_cast<SolidColorBrush ^>(darkDictionary->Lookup(L"EquationBrush9")))
{
return resourceLoader->GetResourceString("equationColor9AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush10")))
else if (color == safe_cast<SolidColorBrush ^>(lightDictionary->Lookup(L"EquationBrush10"))
|| color == safe_cast<SolidColorBrush ^>(darkDictionary->Lookup(L"EquationBrush10")))
{
return resourceLoader->GetResourceString("equationColor10AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush11")))
else if (color == safe_cast<SolidColorBrush ^>(lightDictionary->Lookup(L"EquationBrush11"))
|| color == safe_cast<SolidColorBrush ^>(darkDictionary->Lookup(L"EquationBrush11")))
{
return resourceLoader->GetResourceString("equationColor11AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush12")))
else if (color == safe_cast<SolidColorBrush ^>(lightDictionary->Lookup(L"EquationBrush12"))
|| color == safe_cast<SolidColorBrush ^>(darkDictionary->Lookup(L"EquationBrush12")))
{
return resourceLoader->GetResourceString("equationColor12AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush13")))
else if (color == safe_cast<SolidColorBrush ^>(lightDictionary->Lookup(L"EquationBrush13"))
|| color == safe_cast<SolidColorBrush ^>(darkDictionary->Lookup(L"EquationBrush13")))
{
return resourceLoader->GetResourceString("equationColor13AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(darkDictionary->Lookup(L"EquationBrush14")))
{
return resourceLoader->GetResourceString("equationColor14WhiteAutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(lightDictionary->Lookup(L"EquationBrush14")))
{
return resourceLoader->GetResourceString("equationColor14BlackAutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(highContrast->Lookup(L"EquationBrush1")))
{
return resourceLoader->GetResourceString("equationHighContrastColor1AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(highContrast->Lookup(L"EquationBrush2")))
{
return resourceLoader->GetResourceString("equationHighContrastColor2AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(highContrast->Lookup(L"EquationBrush3")))
{
return resourceLoader->GetResourceString("equationHighContrastColor3AutomationName");
}
else
{
return resourceLoader->GetResourceString("equationColor14AutomationName");
return resourceLoader->GetResourceString("equationHighContrastColor4AutomationName");
}
}
String ^ EquationStylePanelControl::GetLineAutomationName(Object ^ line)

View File

@ -4323,13 +4323,22 @@
<comment>This is the text for the for the equation style context menu command</comment>
</data>
<data name="showEquationButtonToolTip" xml:space="preserve">
<value>Show equation</value>
<comment>This is the tooltip/automation name shown when visibility is set to hidden in the graphing calculator.</comment>
</data>
<data name="hideEquationButtonToolTip" xml:space="preserve">
<value>Hide equation</value>
<comment>This is the tooltip/automation name shown when visibility is set to visible in the graphing calculator.</comment>
</data>
<data name="showEquationButtonAutomationName" xml:space="preserve">
<value>Show equation %1</value>
<comment>{Locked="%1"}, This is the tooltip/automation name shown when visibility is set to hidden in the graphing calculator. %1 is the equation number.</comment>
</data>
<data name="hideEquationButtonToolTip" xml:space="preserve">
<data name="hideEquationButtonAutomationName" xml:space="preserve">
<value>Hide equation %1</value>
<comment>{Locked="%1"}, This is the tooltip/automation name shown when visibility is set to visible in the graphing calculator. %1 is the equation number.</comment>
</data>
<data name="disableTracingButtonToolTip" xml:space="preserve">
<value>Stop tracing</value>
<comment>This is the tooltip/automation name for the graphing calculator stop tracing button</comment>
@ -4582,10 +4591,30 @@
<value>Brown</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationColor14AutomationName" xml:space="preserve">
<data name="equationColor14BlackAutomationName" xml:space="preserve">
<value>Black</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationColor14WhiteAutomationName" xml:space="preserve">
<value>White</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationHighContrastColor1AutomationName" xml:space="preserve">
<value>Color 1</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationHighContrastColor2AutomationName" xml:space="preserve">
<value>Color 2</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationHighContrastColor3AutomationName" xml:space="preserve">
<value>Color 3</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationHighContrastColor4AutomationName" xml:space="preserve">
<value>Color 4</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="GraphThemeHeading.Text" xml:space="preserve">
<value>Theme</value>
<comment>Graph settings heading for the theme options</comment>
@ -4616,7 +4645,43 @@
</data>
<data name="KGFEquationTextBox.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Function Analysis Equation Box</value>
<comment>This is the automation name text for the equation box in the function analsis panel</comment>
<comment>This is the automation name text for the equation box in the function analysis panel</comment>
</data>
<data name="lessThanFlyoutButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Less than</value>
<comment>Screen reader prompt for the Less than button</comment>
</data>
<data name="lessThanOrEqualFlyoutButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Less than or equal</value>
<comment>Screen reader prompt for the Less than or equal button</comment>
</data>
<data name="equalsFlyoutButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Equal</value>
<comment>Screen reader prompt for the Equal button</comment>
</data>
<data name="greaterThanOrEqualFlyoutButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Greater than or equal</value>
<comment>Screen reader prompt for the Greater than or equal button</comment>
</data>
<data name="greaterThanFlyoutButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Greater than</value>
<comment>Screen reader prompt for the Greater than button</comment>
</data>
<data name="graphingEqualButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Equals</value>
<comment>Screen reader prompt for the equal button on the graphing calculator operator keypad</comment>
</data>
<data name="xButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>X</value>
<comment>Screen reader prompt for the X button on the graphing calculator operator keypad</comment>
</data>
<data name="yButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Y</value>
<comment>Screen reader prompt for the Y button on the graphing calculator operator keypad</comment>
</data>
<data name="submitButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Submit</value>
<comment>Screen reader prompt for the submit button on the graphing calculator operator keypad</comment>
</data>
<data name="lessThanFlyoutButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Less than</value>