Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some UI bugs in graph mode #862

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/Calculator/App.xaml
Expand Up @@ -1923,9 +1923,9 @@
</VisualState>
<VisualState x:Name="PointerOverError">
<VisualState.Setters>
<Setter Target="EquationBoxBorder.BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=EquationColor}"/>
<Setter Target="EquationBoxBorder.BorderBrush" Value="{ThemeResource EquationBoxErrorBorderBrush}"/>
<Setter Target="EquationBoxBorder.Background" Value="{ThemeResource EquationBoxErrorBackgroundBrush}"/>
<Setter Target="ColorChooserButton.Visibility" Value="Visible"/>
<Setter Target="ColorChooserButton.Visibility" Value="Collapsed"/>
<Setter Target="FunctionButton.Visibility" Value="Collapsed"/>
<Setter Target="RemoveButton.Visibility" Value="Visible"/>
<Setter Target="ErrorIcon.Visibility" Value="Collapsed"/>
Expand All @@ -1944,12 +1944,18 @@
<Setter Target="EquationBoxBorder.Background" Value="{ThemeResource TextBoxBackgroundThemeBrush}"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="FocusedError">
<VisualState.Setters>
<Setter Target="EquationBoxBorder.BorderBrush" Value="{ThemeResource EquationBoxErrorBorderBrush}"/>
<Setter Target="EquationBoxBorder.Background" Value="{ThemeResource TextBoxBackgroundThemeBrush}"/>
<Setter Target="ErrorIcon.Visibility" Value="Collapsed"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="ButtonStates">
<VisualState x:Name="ButtonVisible">
<VisualState.Setters>
<Setter Target="DeleteButton.Visibility" Value="Visible"/>
<Setter Target="ErrorIcon.Visibility" Value="Collapsed"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="ButtonHideRemove">
Expand Down
13 changes: 11 additions & 2 deletions src/Calculator/Controls/EquationTextBox.cpp
Expand Up @@ -315,7 +315,11 @@ void EquationTextBox::UpdateCommonVisualState()
{
String ^ state = nullptr;

if (m_HasFocus)
if (m_HasFocus && HasError)
{
state = "FocusedError";
}
else if (m_HasFocus)
{
state = "Focused";
}
Expand Down Expand Up @@ -390,7 +394,12 @@ void EquationTextBox::OnRichEditMenuOpening(Object ^ /*sender*/, Object ^ /*args
{
if (m_kgfEquationMenuItem != nullptr)
{
m_kgfEquationMenuItem->IsEnabled = EquationTextBox::RichEditHasContent();
m_kgfEquationMenuItem->IsEnabled = RichEditHasContent();
}

if (m_colorChooserMenuItem != nullptr)
{
m_colorChooserMenuItem->IsEnabled = !HasError;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Calculator/Resources/en-US/Resources.resw
Expand Up @@ -4096,11 +4096,11 @@
<comment>Title for KeyGraphFeatures Vertical Asymptotes Property</comment>
</data>
<data name="XIntercept" xml:space="preserve">
<value>X Intercept</value>
<value>X-Intercept</value>
<comment>Title for KeyGraphFeatures XIntercept Property</comment>
</data>
<data name="YIntercept" xml:space="preserve">
<value>Y Intercept</value>
<value>Y-Intercept</value>
<comment>Title for KeyGraphFeatures YIntercept Property</comment>
</data>
<data name="KGFAnalysisCouldNotBePerformed" xml:space="preserve">
Expand Down Expand Up @@ -4222,4 +4222,4 @@
<value>Enter an equation</value>
<comment>Used in the Graphing Calculator to indicate to users that they can enter an equation in the textbox</comment>
</data>
</root>
</root>
Expand Up @@ -700,6 +700,7 @@
<!-- Ideally the KeyGraphFeaturesPanel should be a frame so that navigation to and from the panel could be handled nicely -->
<local:KeyGraphFeaturesPanel x:Name="KeyGraphFeaturesControl"
Grid.RowSpan="2"
Margin="0,4,0,0"
KeyGraphFeaturesClosed="OnKeyGraphFeaturesClosed"
ViewModel="{x:Bind EquationInputAreaControl.EquationVM, Mode=OneWay}"
Visibility="{x:Bind IsKeyGraphFeaturesVisible, Mode=OneWay}"
Expand Down
Expand Up @@ -60,7 +60,8 @@ GraphingCalculator::GraphingCalculator()

auto toolTip = ref new ToolTip();
auto resProvider = AppResourceProvider::GetInstance();
auto tracingMessage = ActiveTracingOn ? resProvider->GetResourceString(L"disableTracingButtonToolTip") : resProvider->GetResourceString(L"enableTracingButtonToolTip");
auto tracingMessage =
ActiveTracingOn ? resProvider->GetResourceString(L"disableTracingButtonToolTip") : resProvider->GetResourceString(L"enableTracingButtonToolTip");
toolTip->Content = tracingMessage;
ToolTipService::SetToolTip(ActiveTracing, toolTip);
AutomationProperties::SetName(ActiveTracing, tracingMessage);
Expand Down Expand Up @@ -159,7 +160,12 @@ void GraphingCalculator::OnEquationsVectorChanged(IObservableVector<EquationView

void GraphingCalculator::OnTracePointChanged(Windows::Foundation::Point newPoint)
{
TraceValue->Text = "(" + newPoint.X.ToString() + ", " + newPoint.Y.ToString() + ")";
wstringstream traceValueString;

// TODO: The below precision should ideally be dynamic based on the current scale of the graph.
traceValueString << "(" << fixed << setprecision(1) << newPoint.X << "," << fixed << setprecision(1) << newPoint.Y << ")";
joseartrivera marked this conversation as resolved.
Show resolved Hide resolved

TraceValue->Text = ref new String(traceValueString.str().c_str());

auto peer = FrameworkElementAutomationPeer::FromElement(TraceValue);

Expand Down Expand Up @@ -389,9 +395,15 @@ void GraphingCalculator::OnActiveTracingClick(Object ^ sender, RoutedEventArgs ^
ActiveTracingOn = !ActiveTracingOn;
GraphingControl->ActiveTracing = ActiveTracingOn;

if (ActiveTracingOn)
{
GraphingControl->Focus(::FocusState::Programmatic);
}

auto toolTip = ref new ToolTip();
auto resProvider = AppResourceProvider::GetInstance();
auto tracingMessage = ActiveTracingOn ? resProvider->GetResourceString(L"disableTracingButtonToolTip") : resProvider->GetResourceString(L"enableTracingButtonToolTip");
auto tracingMessage =
ActiveTracingOn ? resProvider->GetResourceString(L"disableTracingButtonToolTip") : resProvider->GetResourceString(L"enableTracingButtonToolTip");
toolTip->Content = tracingMessage;
ToolTipService::SetToolTip(ActiveTracing, toolTip);
AutomationProperties::SetName(ActiveTracing, tracingMessage);
Expand Down
19 changes: 13 additions & 6 deletions src/Calculator/Views/GraphingCalculator/KeyGraphFeaturesPanel.xaml
Expand Up @@ -25,7 +25,7 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:EquationTextBox">
<Grid>
<Grid Background="{ThemeResource TextControlBackground}">

<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
Expand Down Expand Up @@ -102,7 +102,8 @@
<Setter Property="IsReadOnly" Value="True"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="IsEnabled" Value="True"/>
<Setter Property="Margin" Value="-8,0,0,0"/>
<Setter Property="Margin" Value="0,0,0,0"/>
joseartrivera marked this conversation as resolved.
Show resolved Hide resolved
<Setter Property="Padding" Value="0,3,4,0"/>
<Setter Property="UseSystemFocusVisuals" Value="True"/>
<Setter Property="TextWrapping" Value="NoWrap"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
Expand Down Expand Up @@ -169,8 +170,8 @@
<Border x:Name="BorderElement"
Grid.Row="1"
Grid.RowSpan="1"
MinWidth="{ThemeResource TextControlThemeMinWidth}"
MinHeight="{ThemeResource TextControlThemeMinHeight}"
MinWidth="0"
MinHeight="0"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Expand Down Expand Up @@ -224,6 +225,7 @@
<Style x:Name="KGF_TextBlockStyle" TargetType="TextBlock">
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="IsTextSelectionEnabled" Value="True"/>
joseartrivera marked this conversation as resolved.
Show resolved Hide resolved
<Setter Property="TextWrapping" Value="WrapWholeWords"/>
</Style>

Expand All @@ -243,6 +245,11 @@
Style="{StaticResource KGF_TitleTextBlockStyle}"
Text="{x:Bind Title, Mode=OneWay}"/>
<ItemsControl ItemsSource="{x:Bind DisplayItems, Mode=OneWay}" UseSystemFocusVisuals="True">
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Margin" Value="0"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="x:String">
<controls:MathRichEditBox HorizontalAlignment="Left"
Expand All @@ -265,7 +272,7 @@
<DataTemplate x:DataType="vm:GridDisplayItems">
<Grid VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto" MinWidth="64"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<controls:MathRichEditBox Grid.Column="0"
Expand Down Expand Up @@ -308,7 +315,7 @@
<converters:BooleanToVisibilityNegationConverter x:Name="BooleanToVisibilityNegationConverter"/>
</UserControl.Resources>

<Grid Margin="0,7,0,0" Background="Transparent">
joseartrivera marked this conversation as resolved.
Show resolved Hide resolved
<Grid Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
Expand Down
1 change: 1 addition & 0 deletions src/Calculator/pch.h
Expand Up @@ -27,6 +27,7 @@
#include <concrt.h>
#include <regex>
#include <string>
#include <iomanip>

// C++\WinRT Headers
#include "winrt/base.h"
Expand Down
9 changes: 2 additions & 7 deletions src/GraphControl/Control/Grapher.cpp
Expand Up @@ -621,10 +621,9 @@ namespace GraphControl

void Grapher::UpdateTracingChanged()
{
if (m_renderMain->Tracing || m_renderMain->ActiveTracing)
if (m_renderMain->Tracing)
{
TracingChangedEvent(true);

TracingValueChangedEvent(m_renderMain->TraceValue);
}
else
Expand All @@ -650,11 +649,7 @@ namespace GraphControl
if (m_renderMain)
{
m_renderMain->DrawNearestPoint = false;
if (ActiveTracing == false)
{
// IF we are active tracing we never want to hide the popup..
TracingChangedEvent(false);
}
TracingChangedEvent(false);
e->Handled = true;
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/GraphControl/DirectX/RenderMain.cpp
Expand Up @@ -35,7 +35,7 @@ namespace GraphControl::DX
, m_backgroundColor{ {} }
, m_swapChainPanel{ panel }
, m_TraceValue(Point(0, 0))
, m_TraceLocation(Point(0,0))
, m_TraceLocation(Point(0, 0))
, m_Tracing(false)
, m_ActiveTracingPointRenderer{ &m_deviceResources }
{
Expand Down Expand Up @@ -195,6 +195,14 @@ namespace GraphControl::DX

if (!isnan(nearestPointLocation.X) && !isnan(nearestPointLocation.Y))
{
auto lineColors = m_graph->GetOptions().GetGraphColors();

if (formulaId >= 0 && formulaId < lineColors.size())
{
auto dotColor = lineColors[formulaId];
m_nearestPointRenderer.SetColor(D2D1::ColorF(dotColor.R * 65536 + dotColor.G * 256 + dotColor.B, 1.0));
}

m_nearestPointRenderer.Render(nearestPointLocation);
m_Tracing = true;
m_TraceLocation = Point(nearestPointLocation.X, nearestPointLocation.Y);
Expand Down