Skip to content

Commit 7f115bf

Browse files
committed
Tidy Mile.Samples.CoreWindowApplication.
1 parent d4ca976 commit 7f115bf

1 file changed

Lines changed: 49 additions & 56 deletions

File tree

Mile.Samples.CoreWindowApplication/Mile.Samples.CoreWindowApplication.cpp

Lines changed: 49 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ struct App : winrt::implements<
5050
winrt::IFrameworkViewSource,
5151
winrt::IFrameworkView>
5252
{
53-
winrt::CompositionTarget m_target{ nullptr };
54-
winrt::VisualCollection m_visuals{ nullptr };
55-
winrt::Visual m_selected{ nullptr };
56-
winrt::float2 m_offset{};
53+
winrt::CompositionTarget m_Target = nullptr;
54+
winrt::VisualCollection m_Visuals = nullptr;
55+
winrt::Visual m_Selected = nullptr;
56+
winrt::float2 m_Offset = {};
5757

5858
winrt::IFrameworkView CreateView()
5959
{
@@ -80,115 +80,108 @@ struct App : winrt::implements<
8080
window.Activate();
8181

8282
winrt::CoreDispatcher dispatcher = window.Dispatcher();
83-
dispatcher.ProcessEvents(winrt::CoreProcessEventsOption::ProcessUntilQuit);
83+
dispatcher.ProcessEvents(
84+
winrt::CoreProcessEventsOption::ProcessUntilQuit);
8485
}
8586

8687
void SetWindow(
8788
winrt::CoreWindow const& window)
8889
{
89-
winrt::Compositor compositor;
90-
winrt::ContainerVisual root = compositor.CreateContainerVisual();
91-
m_target = compositor.CreateTargetForCurrentView();
92-
m_target.Root(root);
93-
m_visuals = root.Children();
90+
winrt::Compositor Compositor;
91+
winrt::ContainerVisual Root = Compositor.CreateContainerVisual();
92+
this->m_Target = Compositor.CreateTargetForCurrentView();
93+
this->m_Target.Root(Root);
94+
this->m_Visuals = Root.Children();
9495

9596
window.PointerPressed({ this, &App::OnPointerPressed });
9697
window.PointerMoved({ this, &App::OnPointerMoved });
9798

9899
window.PointerReleased([&](auto && ...)
99100
{
100-
m_selected = nullptr;
101+
this->m_Selected = nullptr;
101102
});
102103
}
103104

104105
void OnPointerPressed(
105106
winrt::IInspectable const&,
106107
winrt::PointerEventArgs const& args)
107108
{
108-
winrt::float2 const point = args.CurrentPoint().Position();
109+
winrt::float2 const Point = args.CurrentPoint().Position();
109110

110-
for (winrt::Visual visual : m_visuals)
111+
for (winrt::Visual Visual : this->m_Visuals)
111112
{
112-
winrt::float3 const offset = visual.Offset();
113-
winrt::float2 const size = visual.Size();
113+
winrt::float3 const Offset = Visual.Offset();
114+
winrt::float2 const Size = Visual.Size();
114115

115-
if (point.x >= offset.x &&
116-
point.x < offset.x + size.x &&
117-
point.y >= offset.y &&
118-
point.y < offset.y + size.y)
116+
if (Point.x >= Offset.x &&
117+
Point.x < Offset.x + Size.x &&
118+
Point.y >= Offset.y &&
119+
Point.y < Offset.y + Size.y)
119120
{
120-
m_selected = visual;
121-
m_offset.x = offset.x - point.x;
122-
m_offset.y = offset.y - point.y;
121+
this->m_Selected = Visual;
122+
this->m_Offset.x = Offset.x - Point.x;
123+
this->m_Offset.y = Offset.y - Point.y;
123124
}
124125
}
125126

126-
if (m_selected)
127+
if (this->m_Selected)
127128
{
128-
m_visuals.Remove(m_selected);
129-
m_visuals.InsertAtTop(m_selected);
129+
this->m_Visuals.Remove(this->m_Selected);
130+
this->m_Visuals.InsertAtTop(this->m_Selected);
130131
}
131132
else
132133
{
133-
AddVisual(point);
134+
this->AddVisual(Point);
134135
}
135136
}
136137

137138
void OnPointerMoved(
138139
winrt::IInspectable const&,
139140
winrt::PointerEventArgs const& args)
140141
{
141-
if (m_selected)
142+
if (this->m_Selected)
142143
{
143-
winrt::float2 const point = args.CurrentPoint().Position();
144-
145-
m_selected.Offset(
146-
{
147-
point.x + m_offset.x,
148-
point.y + m_offset.y,
149-
0.0f
150-
});
144+
winrt::float2 const Point = args.CurrentPoint().Position();
145+
146+
this->m_Selected.Offset(winrt::float3(
147+
Point.x + this->m_Offset.x,
148+
Point.y + this->m_Offset.y,
149+
0.0f));
151150
}
152151
}
153152

154153
void AddVisual(
155154
winrt::float2 const point)
156155
{
157-
winrt::Compositor compositor = m_visuals.Compositor();
158-
winrt::SpriteVisual visual = compositor.CreateSpriteVisual();
156+
winrt::Compositor Compositor = this->m_Visuals.Compositor();
157+
winrt::SpriteVisual Visual = Compositor.CreateSpriteVisual();
159158

160-
static winrt::Color colors[] =
159+
static winrt::Color Colors[] =
161160
{
162161
{ 0xDC, 0x5B, 0x9B, 0xD5 },
163162
{ 0xDC, 0xED, 0x7D, 0x31 },
164163
{ 0xDC, 0x70, 0xAD, 0x47 },
165164
{ 0xDC, 0xFF, 0xC0, 0x00 }
166165
};
167166

168-
static unsigned last = 0;
169-
unsigned const next = ++last % _countof(colors);
170-
visual.Brush(compositor.CreateColorBrush(colors[next]));
167+
static unsigned Last = 0;
168+
unsigned const Next = ++Last % _countof(Colors);
169+
Visual.Brush(Compositor.CreateColorBrush(Colors[Next]));
171170

172171
float const BlockSize = 100.0f;
173172

174-
visual.Size(
175-
{
176-
BlockSize,
177-
BlockSize
178-
});
173+
Visual.Size(winrt::float2(BlockSize));
179174

180-
visual.Offset(
181-
{
182-
point.x - BlockSize / 2.0f,
183-
point.y - BlockSize / 2.0f,
184-
0.0f,
185-
});
175+
Visual.Offset(winrt::float3(
176+
point.x - BlockSize / 2.0f,
177+
point.y - BlockSize / 2.0f,
178+
0.0f));
186179

187-
m_visuals.InsertAtTop(visual);
180+
this->m_Visuals.InsertAtTop(Visual);
188181

189-
m_selected = visual;
190-
m_offset.x = -BlockSize / 2.0f;
191-
m_offset.y = -BlockSize / 2.0f;
182+
this->m_Selected = Visual;
183+
this->m_Offset.x = -BlockSize / 2.0f;
184+
this->m_Offset.y = -BlockSize / 2.0f;
192185
}
193186
};
194187

0 commit comments

Comments
 (0)