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

Change active tracing to use correct glyph instead of dot #890

Merged
merged 2 commits into from Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from all 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: 12 additions & 0 deletions src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml
Expand Up @@ -424,6 +424,18 @@
</Button>
</StackPanel>
</Border>
<Border x:Name="TracePointer"
Width="16"
Height="18"
Margin="48,50,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Visibility="Collapsed">
<FontIcon Foreground="Red"
EriWong marked this conversation as resolved.
Show resolved Hide resolved
FontFamily="{StaticResource CalculatorFontFamily}"
FontSize="18"
Glyph="&#xE3B3;"/>
</Border>
<Border MinWidth="36"
Margin="0,0,12,12"
HorizontalAlignment="Right"
Expand Down
Expand Up @@ -67,6 +67,9 @@ GraphingCalculator::GraphingCalculator()
// And when the actual trace value changes
GraphingControl->TracingValueChangedEvent += ref new TracingValueChangedEventHandler(this, &GraphingCalculator::OnTracePointChanged);

// Update where the pointer value is (ie: where the user cursor from keyboard inputs moves the point to)
GraphingControl->PointerValueChangedEvent += ref new PointerValueChangedEventHandler(this, &GraphingCalculator::OnPointerPointChanged);

// OemMinus and OemAdd aren't declared in the VirtualKey enum, we can't add this accelerator XAML-side
auto virtualKey = ref new KeyboardAccelerator();
virtualKey->Key = (VirtualKey)187; //OemMinus key
Expand Down Expand Up @@ -177,6 +180,13 @@ void GraphingCalculator::OnTracePointChanged(Windows::Foundation::Point newPoint
PositionGraphPopup();
}

void CalculatorApp::GraphingCalculator::OnPointerPointChanged(Windows::Foundation::Point newPoint)
{
// Move the pointer glyph to where it is supposed to be.
// because the glyph is centered and has some spacing, to get the point to properly line up with the glyph, move the x point over 2 px
TracePointer->Margin = Thickness(newPoint.X - 2, newPoint.Y, 0, 0);
}

GraphingCalculatorViewModel ^ GraphingCalculator::ViewModel::get()
{
return m_viewModel;
Expand Down Expand Up @@ -479,6 +489,8 @@ void CalculatorApp::GraphingCalculator::ActiveTracing_Checked(Platform::Object ^
this, &CalculatorApp::GraphingCalculator::ActiveTracing_KeyUp);

KeyboardShortcutManager::IgnoreEscape(false);

TracePointer->Visibility = ::Visibility::Visible;
}

void CalculatorApp::GraphingCalculator::ActiveTracing_Unchecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
Expand All @@ -495,6 +507,8 @@ void CalculatorApp::GraphingCalculator::ActiveTracing_Unchecked(Platform::Object
m_activeTracingKeyUpToken.Value = 0;
}
KeyboardShortcutManager::HonorEscape();

TracePointer->Visibility = ::Visibility::Collapsed;
}

void CalculatorApp::GraphingCalculator::ActiveTracing_KeyUp(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args)
Expand Down
Expand Up @@ -55,6 +55,7 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo

void OnShowTracePopupChanged(bool newValue);
void OnTracePointChanged(Windows::Foundation::Point newPoint);
void OnPointerPointChanged(Windows::Foundation::Point newPoint);
EriWong marked this conversation as resolved.
Show resolved Hide resolved
private:
void OnDataRequested(
Windows::ApplicationModel::DataTransfer::DataTransferManager ^ sender,
Expand Down
1 change: 1 addition & 0 deletions src/GraphControl/Control/Grapher.cpp
Expand Up @@ -844,6 +844,7 @@ void Grapher::HandleTracingMovementTick(Object ^ sender, Object ^ e)
else
{
ActiveTraceCursorPosition = curPos;
PointerValueChangedEvent(curPos);
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/GraphControl/Control/Grapher.h
Expand Up @@ -20,13 +20,16 @@ public

public
delegate void TracingValueChangedEventHandler(Windows::Foundation::Point value);
public
delegate void PointerValueChangedEventHandler(Windows::Foundation::Point value);

[Windows::UI::Xaml::Markup::ContentPropertyAttribute(Name = L"Equations")] public ref class Grapher sealed
: public Windows::UI::Xaml::Controls::Control,
public Windows::UI::Xaml::Data::INotifyPropertyChanged
{
public:
event TracingValueChangedEventHandler ^ TracingValueChangedEvent;
event PointerValueChangedEventHandler ^ PointerValueChangedEvent;
EriWong marked this conversation as resolved.
Show resolved Hide resolved
event TracingChangedEventHandler ^ TracingChangedEvent;
virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler ^ PropertyChanged;

Expand Down
81 changes: 0 additions & 81 deletions src/GraphControl/DirectX/ActiveTracingPointRenderer.cpp

This file was deleted.

35 changes: 0 additions & 35 deletions src/GraphControl/DirectX/ActiveTracingPointRenderer.h

This file was deleted.

3 changes: 0 additions & 3 deletions src/GraphControl/DirectX/RenderMain.cpp
Expand Up @@ -37,7 +37,6 @@ namespace GraphControl::DX
, m_TraceValue(Point(0, 0))
, m_TraceLocation(Point(0, 0))
, m_Tracing(false)
, m_ActiveTracingPointRenderer{ &m_deviceResources }
{
// Register to be notified if the Device is lost or recreated
m_deviceResources.RegisterDeviceNotify(this);
Expand Down Expand Up @@ -177,8 +176,6 @@ namespace GraphControl::DX
{
// Active tracing takes over for draw nearest point input from the mouse pointer.
trackPoint = m_activeTracingPointerLocation;

m_ActiveTracingPointRenderer.Render(m_activeTracingPointerLocation);
}

int formulaId;
Expand Down
3 changes: 0 additions & 3 deletions src/GraphControl/DirectX/RenderMain.h
Expand Up @@ -7,7 +7,6 @@

#include "DeviceResources.h"
#include "NearestPointRenderer.h"
#include "ActiveTracingPointRenderer.h"
#include "IGraph.h"

// Renders Direct2D and 3D content on the screen.
Expand Down Expand Up @@ -67,7 +66,6 @@ namespace GraphControl::DX
if (m_activeTracingPointerLocation != newValue)
{
m_activeTracingPointerLocation = newValue;
m_ActiveTracingPointRenderer.Render(m_activeTracingPointerLocation);
RunRenderPass();
}
}
Expand Down Expand Up @@ -123,7 +121,6 @@ namespace GraphControl::DX
private:
DX::DeviceResources m_deviceResources;
NearestPointRenderer m_nearestPointRenderer;
ActiveTracingPointRenderer m_ActiveTracingPointRenderer;

// Cached Graph object with Renderer property.
std::shared_ptr<Graphing::IGraph> m_graph = nullptr;
Expand Down
4 changes: 1 addition & 3 deletions src/GraphControl/GraphControl.vcxproj
Expand Up @@ -285,7 +285,6 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Control\Grapher.h" />
<ClInclude Include="DirectX\ActiveTracingPointRenderer.h" />
<ClInclude Include="DirectX\DeviceResources.h" />
<ClInclude Include="DirectX\DirectXHelper.h" />
<ClInclude Include="DirectX\NearestPointRenderer.h" />
Expand All @@ -299,7 +298,6 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="Control\Grapher.cpp" />
<ClCompile Include="DirectX\ActiveTracingPointRenderer.cpp" />
<ClCompile Include="DirectX\DeviceResources.cpp" />
<ClCompile Include="DirectX\NearestPointRenderer.cpp" />
<ClCompile Include="DirectX\RenderMain.cpp" />
Expand All @@ -326,4 +324,4 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
</Project>
</Project>
8 changes: 0 additions & 8 deletions src/GraphControl/GraphControl.vcxproj.filters
Expand Up @@ -28,9 +28,6 @@
<ClCompile Include="DirectX\NearestPointRenderer.cpp">
<Filter>DirectX</Filter>
</ClCompile>
<ClCompile Include="DirectX\ActiveTracingPointRenderer.cpp">
<Filter>DirectX</Filter>
</ClCompile>
<ClCompile Include="Models\KeyGraphFeaturesInfo.cpp" />
<ClCompile Include="Models\Equation.cpp">
<Filter>Models</Filter>
Expand All @@ -54,9 +51,6 @@
<ClInclude Include="DirectX\NearestPointRenderer.h">
<Filter>DirectX</Filter>
</ClInclude>
<ClInclude Include="DirectX\ActiveTracingPointRenderer.h">
<Filter>DirectX</Filter>
</ClInclude>
<ClInclude Include="Utils.h" />
<ClInclude Include="Models\KeyGraphFeaturesInfo.h" />
<ClInclude Include="Models\Equation.h">
Expand All @@ -77,7 +71,5 @@
<ItemGroup>
<CopyFileToFolders Include="$(GraphingImplDll)" />
<CopyFileToFolders Include="$(GraphingEngineDll)" />
<CopyFileToFolders Include="$(GraphingImplDll)" />
<CopyFileToFolders Include="$(GraphingEngineDll)" />
</ItemGroup>
</Project>