MCPcopy Create free account
hub / github.com/TranslucentTB/TranslucentTB / ColorRequested

Method ColorRequested

TranslucentTB/mainappwindow.cpp:132–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132void MainAppWindow::ColorRequested(const txmp::TaskbarState &state)
133{
134 std::unique_lock lock(m_PickerMutex);
135 auto &pickerHost = m_ColorPickers.at(static_cast<std::size_t>(state));
136 if (!pickerHost)
137 {
138 auto &appearance = GetConfigForState(state);
139
140 using winrt::TranslucentTB::Xaml::Pages::ColorPickerPage;
141 m_App.CreateXamlWindow<ColorPickerPage>(xaml_startup_position::mouse,
142 [this, &appearance, &pickerHost, state, inner_lock = std::move(lock)](const ColorPickerPage &picker, BaseXamlPageHost *host) mutable
143 {
144 pickerHost = host;
145 inner_lock.unlock();
146
147 auto closeRevoker = picker.Closed(winrt::auto_revoke, [this, state, &pickerHost]
148 {
149 m_App.DispatchToMainThread([this, state, &pickerHost]() mutable
150 {
151 m_App.GetWorker().RemoveColorPreview(state);
152
153 std::scoped_lock guard(m_PickerMutex);
154 pickerHost = nullptr;
155 });
156 });
157
158 picker.ChangesCommitted([this, state, &appearance, &pickerHost, revoker = std::move(closeRevoker)](const winrt::Windows::UI::Color &color) mutable
159 {
160 revoker.revoke(); // we're already doing this.
161
162 m_App.DispatchToMainThread([this, state, color, &appearance, &pickerHost]() mutable
163 {
164 appearance.Color = color;
165 m_App.GetWorker().RemoveColorPreview(state); // remove color preview implicitly refreshes config
166
167 std::scoped_lock guard(m_PickerMutex);
168 pickerHost = nullptr;
169 });
170 });
171
172 picker.ColorChanged([this, state](const winrt::Windows::UI::Color &color)
173 {
174 m_App.DispatchToMainThread([this, state, color]
175 {
176 m_App.GetWorker().ApplyColorPreview(state, color);
177 });
178 });
179 },
180 state,
181 appearance.Color);
182 }
183 else
184 {
185 SetForegroundWindow(pickerHost->handle());
186 }
187}
188
189void MainAppWindow::OpenLogFileRequested()

Callers 1

RegisterMenuHandlersMethod · 0.80

Calls 5

unlockMethod · 0.80
DispatchToMainThreadMethod · 0.80
RemoveColorPreviewMethod · 0.80
ApplyColorPreviewMethod · 0.80
handleMethod · 0.80

Tested by

no test coverage detected