Change active tracing to use correct glyph instead of dot (#890)
* Change active tracing to use correct glyph instead of dot * make the pointer on the glyph line up correctly
This commit is contained in:
parent
3b916dcec3
commit
234ac8deb3
@ -424,6 +424,18 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
|
<Border x:Name="TracePointer"
|
||||||
|
Width="16"
|
||||||
|
Height="18"
|
||||||
|
Margin="48,50,0,0"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Visibility="Collapsed">
|
||||||
|
<FontIcon Foreground="Red"
|
||||||
|
FontFamily="{StaticResource CalculatorFontFamily}"
|
||||||
|
FontSize="18"
|
||||||
|
Glyph=""/>
|
||||||
|
</Border>
|
||||||
<Border MinWidth="36"
|
<Border MinWidth="36"
|
||||||
Margin="0,0,12,12"
|
Margin="0,0,12,12"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
|
@ -67,6 +67,9 @@ GraphingCalculator::GraphingCalculator()
|
|||||||
// And when the actual trace value changes
|
// And when the actual trace value changes
|
||||||
GraphingControl->TracingValueChangedEvent += ref new TracingValueChangedEventHandler(this, &GraphingCalculator::OnTracePointChanged);
|
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
|
// OemMinus and OemAdd aren't declared in the VirtualKey enum, we can't add this accelerator XAML-side
|
||||||
auto virtualKey = ref new KeyboardAccelerator();
|
auto virtualKey = ref new KeyboardAccelerator();
|
||||||
virtualKey->Key = (VirtualKey)187; //OemMinus key
|
virtualKey->Key = (VirtualKey)187; //OemMinus key
|
||||||
@ -177,6 +180,13 @@ void GraphingCalculator::OnTracePointChanged(Windows::Foundation::Point newPoint
|
|||||||
PositionGraphPopup();
|
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()
|
GraphingCalculatorViewModel ^ GraphingCalculator::ViewModel::get()
|
||||||
{
|
{
|
||||||
return m_viewModel;
|
return m_viewModel;
|
||||||
@ -479,6 +489,8 @@ void CalculatorApp::GraphingCalculator::ActiveTracing_Checked(Platform::Object ^
|
|||||||
this, &CalculatorApp::GraphingCalculator::ActiveTracing_KeyUp);
|
this, &CalculatorApp::GraphingCalculator::ActiveTracing_KeyUp);
|
||||||
|
|
||||||
KeyboardShortcutManager::IgnoreEscape(false);
|
KeyboardShortcutManager::IgnoreEscape(false);
|
||||||
|
|
||||||
|
TracePointer->Visibility = ::Visibility::Visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalculatorApp::GraphingCalculator::ActiveTracing_Unchecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
void CalculatorApp::GraphingCalculator::ActiveTracing_Unchecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||||
@ -495,6 +507,8 @@ void CalculatorApp::GraphingCalculator::ActiveTracing_Unchecked(Platform::Object
|
|||||||
m_activeTracingKeyUpToken.Value = 0;
|
m_activeTracingKeyUpToken.Value = 0;
|
||||||
}
|
}
|
||||||
KeyboardShortcutManager::HonorEscape();
|
KeyboardShortcutManager::HonorEscape();
|
||||||
|
|
||||||
|
TracePointer->Visibility = ::Visibility::Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalculatorApp::GraphingCalculator::ActiveTracing_KeyUp(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args)
|
void CalculatorApp::GraphingCalculator::ActiveTracing_KeyUp(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args)
|
||||||
|
@ -55,6 +55,7 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo
|
|||||||
|
|
||||||
void OnShowTracePopupChanged(bool newValue);
|
void OnShowTracePopupChanged(bool newValue);
|
||||||
void OnTracePointChanged(Windows::Foundation::Point newPoint);
|
void OnTracePointChanged(Windows::Foundation::Point newPoint);
|
||||||
|
void OnPointerPointChanged(Windows::Foundation::Point newPoint);
|
||||||
private:
|
private:
|
||||||
void OnDataRequested(
|
void OnDataRequested(
|
||||||
Windows::ApplicationModel::DataTransfer::DataTransferManager ^ sender,
|
Windows::ApplicationModel::DataTransfer::DataTransferManager ^ sender,
|
||||||
|
@ -844,6 +844,7 @@ void Grapher::HandleTracingMovementTick(Object ^ sender, Object ^ e)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ActiveTraceCursorPosition = curPos;
|
ActiveTraceCursorPosition = curPos;
|
||||||
|
PointerValueChangedEvent(curPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@ public
|
|||||||
|
|
||||||
public
|
public
|
||||||
delegate void TracingValueChangedEventHandler(Windows::Foundation::Point value);
|
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
|
[Windows::UI::Xaml::Markup::ContentPropertyAttribute(Name = L"Equations")] public ref class Grapher sealed
|
||||||
: public Windows::UI::Xaml::Controls::Control,
|
: public Windows::UI::Xaml::Controls::Control,
|
||||||
@ -27,6 +29,7 @@ public
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
event TracingValueChangedEventHandler ^ TracingValueChangedEvent;
|
event TracingValueChangedEventHandler ^ TracingValueChangedEvent;
|
||||||
|
event PointerValueChangedEventHandler ^ PointerValueChangedEvent;
|
||||||
event TracingChangedEventHandler ^ TracingChangedEvent;
|
event TracingChangedEventHandler ^ TracingChangedEvent;
|
||||||
virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler ^ PropertyChanged;
|
virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler ^ PropertyChanged;
|
||||||
|
|
||||||
|
@ -1,81 +0,0 @@
|
|||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// Licensed under the MIT License.
|
|
||||||
|
|
||||||
#include "pch.h"
|
|
||||||
#include "ActiveTracingPointRenderer.h"
|
|
||||||
#include "DirectXHelper.h"
|
|
||||||
|
|
||||||
using namespace D2D1;
|
|
||||||
using namespace GraphControl::DX;
|
|
||||||
using namespace std;
|
|
||||||
using namespace Windows::Foundation;
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
const ColorF c_DefaultPointColor = ColorF::Red;
|
|
||||||
constexpr float c_ActiveTracingPointRadius = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
ActiveTracingPointRenderer::ActiveTracingPointRenderer(DeviceResources* deviceResources)
|
|
||||||
: m_deviceResources{ deviceResources }
|
|
||||||
, m_color{ c_DefaultPointColor }
|
|
||||||
|
|
||||||
{
|
|
||||||
m_RoundedRect.rect.bottom = 0;
|
|
||||||
m_RoundedRect.rect.left = 0;
|
|
||||||
m_RoundedRect.rect.right = 10;
|
|
||||||
m_RoundedRect.rect.top = 10;
|
|
||||||
m_width = (int)(m_RoundedRect.rect.right - m_RoundedRect.rect.left);
|
|
||||||
m_height = (int)(m_RoundedRect.rect.top - m_RoundedRect.rect.bottom);
|
|
||||||
m_RoundedRect.radiusX = c_ActiveTracingPointRadius;
|
|
||||||
m_RoundedRect.radiusY = c_ActiveTracingPointRadius;
|
|
||||||
|
|
||||||
CreateDeviceDependentResources();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActiveTracingPointRenderer::CreateDeviceDependentResources()
|
|
||||||
{
|
|
||||||
CreateBrush();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActiveTracingPointRenderer::ReleaseDeviceDependentResources()
|
|
||||||
{
|
|
||||||
m_brush.Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActiveTracingPointRenderer::Render(const Point& location)
|
|
||||||
{
|
|
||||||
// We want to center this around the location
|
|
||||||
if (ID2D1DeviceContext* context = m_deviceResources->GetD2DDeviceContext())
|
|
||||||
{
|
|
||||||
m_RoundedRect.rect.bottom = location.Y - m_height / 2;
|
|
||||||
m_RoundedRect.rect.left = location.X - m_width / 2;
|
|
||||||
m_RoundedRect.rect.top = m_RoundedRect.rect.bottom + m_height;
|
|
||||||
m_RoundedRect.rect.right = m_RoundedRect.rect.left + m_width;
|
|
||||||
|
|
||||||
context->BeginDraw();
|
|
||||||
context->FillRoundedRectangle(m_RoundedRect, m_brush.Get());
|
|
||||||
|
|
||||||
// Ignore D2DERR_RECREATE_TARGET here. This error indicates that the device
|
|
||||||
// is lost. It will be handled during the next call to Present.
|
|
||||||
HRESULT hr = context->EndDraw();
|
|
||||||
if (hr != D2DERR_RECREATE_TARGET)
|
|
||||||
{
|
|
||||||
ThrowIfFailed(hr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActiveTracingPointRenderer::SetColor(const ColorF& color)
|
|
||||||
{
|
|
||||||
m_color = color;
|
|
||||||
CreateBrush();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActiveTracingPointRenderer::CreateBrush()
|
|
||||||
{
|
|
||||||
m_brush.Reset();
|
|
||||||
ThrowIfFailed(
|
|
||||||
m_deviceResources->GetD2DDeviceContext()->CreateSolidColorBrush(m_color, &m_brush)
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// Licensed under the MIT License.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace GraphControl::DX
|
|
||||||
{
|
|
||||||
class DeviceResources;
|
|
||||||
|
|
||||||
class ActiveTracingPointRenderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ActiveTracingPointRenderer(DeviceResources* deviceResources);
|
|
||||||
|
|
||||||
void CreateDeviceDependentResources();
|
|
||||||
void ReleaseDeviceDependentResources();
|
|
||||||
void Render(const Windows::Foundation::Point& location);
|
|
||||||
|
|
||||||
void SetColor(const D2D1::ColorF& color);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void CreateBrush();
|
|
||||||
|
|
||||||
private:
|
|
||||||
DeviceResources* const m_deviceResources;
|
|
||||||
|
|
||||||
D2D1::ColorF m_color;
|
|
||||||
D2D1_ROUNDED_RECT m_RoundedRect;
|
|
||||||
int m_width;
|
|
||||||
int m_height;
|
|
||||||
|
|
||||||
// Resources related to rendering.
|
|
||||||
Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> m_brush;
|
|
||||||
};
|
|
||||||
}
|
|
@ -37,7 +37,6 @@ namespace GraphControl::DX
|
|||||||
, m_TraceValue(Point(0, 0))
|
, m_TraceValue(Point(0, 0))
|
||||||
, m_TraceLocation(Point(0, 0))
|
, m_TraceLocation(Point(0, 0))
|
||||||
, m_Tracing(false)
|
, m_Tracing(false)
|
||||||
, m_ActiveTracingPointRenderer{ &m_deviceResources }
|
|
||||||
{
|
{
|
||||||
// Register to be notified if the Device is lost or recreated
|
// Register to be notified if the Device is lost or recreated
|
||||||
m_deviceResources.RegisterDeviceNotify(this);
|
m_deviceResources.RegisterDeviceNotify(this);
|
||||||
@ -177,8 +176,6 @@ namespace GraphControl::DX
|
|||||||
{
|
{
|
||||||
// Active tracing takes over for draw nearest point input from the mouse pointer.
|
// Active tracing takes over for draw nearest point input from the mouse pointer.
|
||||||
trackPoint = m_activeTracingPointerLocation;
|
trackPoint = m_activeTracingPointerLocation;
|
||||||
|
|
||||||
m_ActiveTracingPointRenderer.Render(m_activeTracingPointerLocation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int formulaId;
|
int formulaId;
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "DeviceResources.h"
|
#include "DeviceResources.h"
|
||||||
#include "NearestPointRenderer.h"
|
#include "NearestPointRenderer.h"
|
||||||
#include "ActiveTracingPointRenderer.h"
|
|
||||||
#include "IGraph.h"
|
#include "IGraph.h"
|
||||||
|
|
||||||
// Renders Direct2D and 3D content on the screen.
|
// Renders Direct2D and 3D content on the screen.
|
||||||
@ -67,7 +66,6 @@ namespace GraphControl::DX
|
|||||||
if (m_activeTracingPointerLocation != newValue)
|
if (m_activeTracingPointerLocation != newValue)
|
||||||
{
|
{
|
||||||
m_activeTracingPointerLocation = newValue;
|
m_activeTracingPointerLocation = newValue;
|
||||||
m_ActiveTracingPointRenderer.Render(m_activeTracingPointerLocation);
|
|
||||||
RunRenderPass();
|
RunRenderPass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,7 +121,6 @@ namespace GraphControl::DX
|
|||||||
private:
|
private:
|
||||||
DX::DeviceResources m_deviceResources;
|
DX::DeviceResources m_deviceResources;
|
||||||
NearestPointRenderer m_nearestPointRenderer;
|
NearestPointRenderer m_nearestPointRenderer;
|
||||||
ActiveTracingPointRenderer m_ActiveTracingPointRenderer;
|
|
||||||
|
|
||||||
// Cached Graph object with Renderer property.
|
// Cached Graph object with Renderer property.
|
||||||
std::shared_ptr<Graphing::IGraph> m_graph = nullptr;
|
std::shared_ptr<Graphing::IGraph> m_graph = nullptr;
|
||||||
|
@ -285,7 +285,6 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Control\Grapher.h" />
|
<ClInclude Include="Control\Grapher.h" />
|
||||||
<ClInclude Include="DirectX\ActiveTracingPointRenderer.h" />
|
|
||||||
<ClInclude Include="DirectX\DeviceResources.h" />
|
<ClInclude Include="DirectX\DeviceResources.h" />
|
||||||
<ClInclude Include="DirectX\DirectXHelper.h" />
|
<ClInclude Include="DirectX\DirectXHelper.h" />
|
||||||
<ClInclude Include="DirectX\NearestPointRenderer.h" />
|
<ClInclude Include="DirectX\NearestPointRenderer.h" />
|
||||||
@ -299,7 +298,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Control\Grapher.cpp" />
|
<ClCompile Include="Control\Grapher.cpp" />
|
||||||
<ClCompile Include="DirectX\ActiveTracingPointRenderer.cpp" />
|
|
||||||
<ClCompile Include="DirectX\DeviceResources.cpp" />
|
<ClCompile Include="DirectX\DeviceResources.cpp" />
|
||||||
<ClCompile Include="DirectX\NearestPointRenderer.cpp" />
|
<ClCompile Include="DirectX\NearestPointRenderer.cpp" />
|
||||||
<ClCompile Include="DirectX\RenderMain.cpp" />
|
<ClCompile Include="DirectX\RenderMain.cpp" />
|
||||||
@ -326,4 +324,4 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets" />
|
<ImportGroup Label="ExtensionTargets" />
|
||||||
</Project>
|
</Project>
|
@ -28,9 +28,6 @@
|
|||||||
<ClCompile Include="DirectX\NearestPointRenderer.cpp">
|
<ClCompile Include="DirectX\NearestPointRenderer.cpp">
|
||||||
<Filter>DirectX</Filter>
|
<Filter>DirectX</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="DirectX\ActiveTracingPointRenderer.cpp">
|
|
||||||
<Filter>DirectX</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Models\KeyGraphFeaturesInfo.cpp" />
|
<ClCompile Include="Models\KeyGraphFeaturesInfo.cpp" />
|
||||||
<ClCompile Include="Models\Equation.cpp">
|
<ClCompile Include="Models\Equation.cpp">
|
||||||
<Filter>Models</Filter>
|
<Filter>Models</Filter>
|
||||||
@ -54,9 +51,6 @@
|
|||||||
<ClInclude Include="DirectX\NearestPointRenderer.h">
|
<ClInclude Include="DirectX\NearestPointRenderer.h">
|
||||||
<Filter>DirectX</Filter>
|
<Filter>DirectX</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="DirectX\ActiveTracingPointRenderer.h">
|
|
||||||
<Filter>DirectX</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Utils.h" />
|
<ClInclude Include="Utils.h" />
|
||||||
<ClInclude Include="Models\KeyGraphFeaturesInfo.h" />
|
<ClInclude Include="Models\KeyGraphFeaturesInfo.h" />
|
||||||
<ClInclude Include="Models\Equation.h">
|
<ClInclude Include="Models\Equation.h">
|
||||||
@ -77,7 +71,5 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CopyFileToFolders Include="$(GraphingImplDll)" />
|
<CopyFileToFolders Include="$(GraphingImplDll)" />
|
||||||
<CopyFileToFolders Include="$(GraphingEngineDll)" />
|
<CopyFileToFolders Include="$(GraphingEngineDll)" />
|
||||||
<CopyFileToFolders Include="$(GraphingImplDll)" />
|
|
||||||
<CopyFileToFolders Include="$(GraphingEngineDll)" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue
Block a user