-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathUIElement.cpp
More file actions
773 lines (583 loc) · 20.1 KB
/
UIElement.cpp
File metadata and controls
773 lines (583 loc) · 20.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
/** $VER: UIElement.cpp (2026.01.21) P. Stuer - UIElement methods that run on the UI thread. **/
#include "pch.h"
#include "UIElement.h"
#include "StyleManager.h"
#include "Color.h"
#include "Support.h"
#include "Log.h"
#include "Error.h"
#include "PresetManager.h"
#pragma hdrstop
/// <summary>
/// Initializes a new instance.
/// </summary>
uielement_t::uielement_t(): _IsFullScreen(false), _IsVisible(true), _IsInitializing(true), _DPI(), _DisplayRefreshRate(), _hStopRendering(), _hThread(), _TrackingGraph(), _TrackingToolInfo(), _LastMousePos(), _LastBandIndex(~0U)
{
}
#pragma region User Interface
/// <summary>
/// Gets the window class definition.
/// </summary>
CWndClassInfo & uielement_t::GetWndClassInfo()
{
static ATL::CWndClassInfoW wci =
{
{
sizeof(WNDCLASSEX),
CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS,
StartWindowProc,
0, 0,
NULL, // Instance,
NULL, // Icon
NULL, // Cursor
NULL, // Background brush
NULL, // Menu
TEXT(STR_WINDOW_CLASS_NAME), // Class name
NULL // Small Icon
},
NULL, NULL, IDC_ARROW, TRUE, 0, L""
};
return wci;
}
/// <summary>
/// Creates the window.
/// </summary>
LRESULT uielement_t::OnCreate(LPCREATESTRUCT cs)
{
::SetWindowLongPtrW(m_hWnd, GWL_EXSTYLE, ::GetWindowLongPtrW(m_hWnd, GWL_EXSTYLE) | WS_EX_TRANSPARENT); // Required for alpha transparency
HRESULT hr = CreateDeviceIndependentResources();
if (FAILED(hr))
{
error_t LastError((DWORD) hr);
Log.AtFatal().Write(STR_COMPONENT_BASENAME " is unable to create DirectX device independent resources: %s", LastError.Message().c_str());
return -1;
}
(void) GetDPI(m_hWnd, _DPI);
// Create the visualisation stream.
try
{
static_api_ptr_t<visualisation_manager> VisualisationManager;
VisualisationManager->create_stream(_VisualisationStream, visualisation_manager::KStreamFlagNewFFT);
if (_VisualisationStream.is_valid())
{
_VisualisationStream->request_backlog(1.0); // Initialize the backbuffer allowing data requests up to 1s back in time.
_VisualisationStream->set_channel_mode(visualisation_stream_v2::channel_mode_default);
}
}
catch (std::exception & ex)
{
Log.AtFatal().Write(STR_COMPONENT_BASENAME " is unable to create visualisation stream: %s.", ex.what());
return -1;
}
// Get the artwork for the currently playing track (in case we get instantiated when playback is already ongoing).
{
metadb_handle_ptr CurrentTrack;
if (playback_control::get()->get_now_playing(CurrentTrack))
GetArtwork(CurrentTrack);
}
// Create the tooltip control.
CreateToolTipControl();
// Apply the initial configuration.
UpdateState(ConfigurationChanges::All);
_hStopRendering = ::CreateEventW(nullptr, TRUE, FALSE, nullptr);
StartRenderer();
return 0;
}
/// <summary>
/// Destroys the window.
/// </summary>
void uielement_t::OnDestroy()
{
StopRenderer();
::CloseHandle(_hStopRendering);
_CriticalSection.Enter();
{
for (auto & Iter : _Grid)
delete Iter._Graph;
_Grid.clear();
}
_VisualisationStream.release();
DeleteDeviceSpecificResources();
DeleteDeviceIndependentResources();
_CriticalSection.Leave();
}
/// <summary>
/// Handles the WM_ERASEBKGND message.
/// </summary>
LRESULT uielement_t::OnEraseBackground(CDCHandle hDC)
{
/*
RECT cr;
GetClientRect(&cr);
HBRUSH hBrush = color_t::CreateBrush(_UIThread._StyleManager.UserInterfaceColors[1]);
::FillRect(hDC, &cr, hBrush);
::DeleteObject((HGDIOBJ) hBrush);
*/
return 1; // Prevent GDI from erasing the background. Required for transparency.
}
/// <summary>
/// Handles the WM_PAINT message.
/// </summary>
void uielement_t::OnPaint(CDCHandle hDC)
{
ValidateRect(nullptr); // Prevent any further WM_PAINT messages.
}
/// <summary>
/// Handles the WM_SIZE message.
/// </summary>
void uielement_t::OnSize(UINT type, CSize size)
{
if ((_DeviceContext == nullptr) || (size.cx == 0) || (size.cy == 0))
return;
_CriticalSection.Enter();
// Remove the bitmap from the device context.
_DeviceContext->SetTarget(nullptr);
// Release the bitmap so that the swap chain can be resized.
_BackBuffer.Release();
// Resize the swap chain.
HRESULT hr = _SwapChain->ResizeBuffers(0, (UINT) size.cx, (UINT) size.cy, DXGI_FORMAT_B8G8R8A8_UNORM, 0);
// Recreate the back buffer.
if (SUCCEEDED(hr))
hr = CreateBackBuffer();
// Initialize the target buffer of the device context.
if (SUCCEEDED(hr))
_DeviceContext->SetTarget(_BackBuffer);
Resize();
_CriticalSection.Leave();
// ::InvalidateRect(m_hWnd, nullptr, FALSE); // Force a repaint.
}
/// <summary>
/// Handles a context menu selection.
/// </summary>
void uielement_t::OnContextMenu(CWindow wnd, CPoint position)
{
CMenu Menu;
CMenu RefreshRateLimitMenu;
CMenu PresetMenu;
std::vector<std::wstring> PresetNames;
{
Menu.CreatePopupMenu();
Menu.AppendMenu((UINT) MF_STRING, IDM_CONFIGURE, L"Configure");
Menu.AppendMenu((UINT) MF_SEPARATOR);
Menu.AppendMenu((UINT) MF_STRING, IDM_TOGGLE_FULLSCREEN, L"Toggle Full-Screen Mode");
Menu.AppendMenu((UINT) MF_STRING | (_UIState._ShowFrameCounter ? MF_CHECKED : 0), IDM_TOGGLE_FRAME_COUNTER, L"Frame Counter");
{
RefreshRateLimitMenu.CreatePopupMenu();
const int64_t RefreshRates[] = { 20, 30, 60, 100, 200 };
for (size_t i = 0; i < _countof(RefreshRates); ++i)
RefreshRateLimitMenu.AppendMenu
(
(UINT) MF_STRING | ((_UIState._RefreshRateLimit == RefreshRates[i]) ? MF_CHECKED : 0),
IDM_REFRESH_RATE_LIMIT_20 + i,
pfc::wideFromUTF8(pfc::format(RefreshRates[i], L"Hz"))
);
Menu.AppendMenu((UINT) MF_STRING, RefreshRateLimitMenu, L"Refresh Rate Limit");
}
{
PresetMenu.CreatePopupMenu();
PresetManager::GetPresetNames(_UIState._PresetsDirectoryPath, PresetNames);
UINT_PTR i = 0;
for (auto & PresetName : PresetNames)
{
PresetMenu.AppendMenu((UINT) MF_STRING | ((_UIState._ActivePresetName == PresetName) ? MF_CHECKED : 0), IDM_PRESET_NAME + i, PresetName.c_str());
i++;
}
Menu.AppendMenu((UINT) MF_STRING, PresetMenu, L"Presets");
}
Menu.AppendMenu((UINT) MF_SEPARATOR);
Menu.AppendMenu((UINT) MF_STRING | (_IsFrozen ? MF_CHECKED : 0), IDM_FREEZE, (_IsFrozen ? L"Frozen" : L"Freeze"));
Menu.SetMenuDefaultItem(IDM_CONFIGURE);
}
int CommandId = Menu.TrackPopupMenu(TPM_RETURNCMD | TPM_VERNEGANIMATION | TPM_RIGHTBUTTON | TPM_NONOTIFY, position.x, position.y, *this);
switch (CommandId)
{
case IDM_TOGGLE_FULLSCREEN:
ToggleFullScreen();
break;
case IDM_TOGGLE_FRAME_COUNTER:
ToggleFrameCounter();
break;
case IDM_TOGGLE_HARDWARE_RENDERING:
ToggleHardwareRendering();
break;
case IDM_REFRESH_RATE_LIMIT_20:
_UIState._RefreshRateLimit =
_RenderState._RefreshRateLimit = 20; // Near-atomic
break;
case IDM_REFRESH_RATE_LIMIT_30:
_UIState._RefreshRateLimit =
_RenderState._RefreshRateLimit = 30; // Near-atomic
break;
case IDM_REFRESH_RATE_LIMIT_60:
_UIState._RefreshRateLimit =
_RenderState._RefreshRateLimit = 60; // Near-atomic
break;
case IDM_REFRESH_RATE_LIMIT_100:
_UIState._RefreshRateLimit =
_RenderState._RefreshRateLimit = 100; // Near-atomic
break;
case IDM_REFRESH_RATE_LIMIT_200:
_UIState._RefreshRateLimit =
_RenderState._RefreshRateLimit = 200; // Near-atomic
break;
case IDM_CONFIGURE:
Configure();
break;
case IDM_FREEZE:
_IsFrozen = !_IsFrozen;
break;
default:
{
if (CommandId >= IDM_PRESET_NAME)
{
state_t NewState;
size_t Index = (size_t) CommandId - IDM_PRESET_NAME;
if (msc::InRange(Index, (size_t) 0, PresetNames.size() - (size_t) 1))
{
PresetManager::Load(_UIState._PresetsDirectoryPath, PresetNames[Index], &NewState);
NewState._StyleManager.DominantColor = _UIState._StyleManager.DominantColor;
NewState._StyleManager.UserInterfaceColors = _UIState._StyleManager.UserInterfaceColors;
NewState._StyleManager.UpdateCurrentColors();
NewState._ActivePresetName = PresetNames[Index];
_UIState = NewState;
UpdateState(ConfigurationChanges::All);
// Notify the configuration dialog.
if (_ConfigurationDialog.IsWindow())
{
_ConfigurationDialog.PostMessageW(UM_CONFIGURATION_CHANGED, CC_PRESET_LOADED); // Must be sent outside the critical section.
Log.AtDebug().Write(STR_COMPONENT_BASENAME " notified configuration dialog of configuration change (Preset loaded).");
}
}
}
}
}
Invalidate();
}
/// <summary>
/// Handles a left mousebutton down message.
/// </summary>
void uielement_t::OnLButtonDown(UINT flags, CPoint point)
{
if (_UIState._ShowToolTipsAlways)
return; // Already showing tooltips.
_ToolTipControl.Activate(true);
DeleteTrackingToolTip();
_UIState._ShowToolTipsNow = true;
OnMouseMove(flags, point);
}
/// <summary>
/// Handles a left mousebutton up message.
/// </summary>
void uielement_t::OnLButtonUp(UINT flags, CPoint point)
{
if (_UIState._ShowToolTipsAlways)
return; // Already showing tooltips.
_ToolTipControl.Activate(false);
DeleteTrackingToolTip();
_UIState._ShowToolTipsNow = false;
}
/// <summary>
/// Toggles between panel and full screen mode.
/// </summary>
void uielement_t::OnLButtonDblClk(UINT flags, CPoint point)
{
ToggleFullScreen();
}
/// <summary>
/// Handles a DPI change.
/// </summary>
LRESULT uielement_t::OnDPIChanged(UINT dpiX, UINT dpiY, PRECT newRect)
{
_DPI = dpiX;
DeleteDeviceSpecificResources();
return 0;
}
/// <summary>
/// Resizes all visual elements.
/// </summary>
void uielement_t::Resize()
{
if (_DeviceContext == nullptr)
return;
DeleteTrackingToolTip();
D2D1_SIZE_F SizeF = _DeviceContext->GetSize(); // Gets the size in DPIs.
// Reposition the frame counter.
_FrameCounter.Resize(SizeF.width, SizeF.height);
// Resize the grid.
{
for (auto & Iter : _Grid)
{
TTTOOLINFOW ti;
Iter._Graph->InitToolInfo(m_hWnd, ti);
_ToolTipControl.DelTool(&ti);
}
{
_CriticalSection.Enter();
_Grid.Resize(SizeF.width, SizeF.height);
_RenderState._StyleManager.DeleteGradientBrushes();
_CriticalSection.Leave();
}
for (auto & Iter : _Grid)
{
TTTOOLINFOW ti;
Iter._Graph->InitToolInfo(m_hWnd, ti);
_ToolTipControl.AddTool(&ti);
}
}
}
/// <summary>
/// Handles a change of the user interface colors.
/// </summary>
void uielement_t::OnColorsChanged()
{
GetColors();
_UIState._StyleManager.UpdateCurrentColors();
{
_CriticalSection.Enter();
_RenderState._StyleManager.UserInterfaceColors = _UIState._StyleManager.UserInterfaceColors;
::SetWindowTheme(_ToolTipControl, _DarkMode ? L"DarkMode_Explorer" : nullptr, nullptr);
// Notify the render thread.
_Event.Raise(event_t::UserInterfaceColorsChanged);
_CriticalSection.Leave();
}
// Notify the configuration dialog about the changed UI colors.
if (_ConfigurationDialog.IsWindow())
{
_ConfigurationDialog.PostMessageW(UM_CONFIGURATION_CHANGED, CC_COLORS); // Must be sent outside the critical section.
Log.AtDebug().Write(STR_COMPONENT_BASENAME " notified configuration dialog of configuration change (User interface colors).");
}
}
/// <summary>
/// Handles the UM_CONFIGURATION_CHANGED message from the configuration dialog.
/// </summary>
LRESULT uielement_t::OnConfigurationChanged(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
UpdateState((ConfigurationChanges) wParam);
return 0;
}
/// <summary>
/// Starts the render thread.
/// </summary>
void uielement_t::StartRenderer() noexcept
{
assert(_hThread == NULL);
_ThreadId = 0;
_hThread = ::CreateThread(nullptr, 0, CallRenderThreadProc, this, 0, &_ThreadId);
}
/// <summary>
/// Stops the render thread.
/// </summary>
void uielement_t::StopRenderer() noexcept
{
if (_hThread == NULL)
return;
::SetEvent(_hStopRendering);
::WaitForSingleObject(_hThread, INFINITE);
::CloseHandle(_hThread), _hThread = NULL;
}
/// <summary>
/// Toggles the frame counter display.
/// </summary>
void uielement_t::ToggleFrameCounter() noexcept
{
_UIState._ShowFrameCounter = !_UIState._ShowFrameCounter;
}
/// <summary>
/// Toggles hardware/software rendering.
/// </summary>
void uielement_t::ToggleHardwareRendering() noexcept
{
_UIState._UseHardwareRendering = !_UIState._UseHardwareRendering;
DeleteDeviceSpecificResources();
}
/// <summary>
/// Shows the configuration dialog.
/// </summary>
void uielement_t::Configure() noexcept
{
if (!_ConfigurationDialog.IsWindow())
{
dialog_parameters_t dp = { m_hWnd, &_UIState };
if (_ConfigurationDialog.Create(m_hWnd, (LPARAM) &dp) != NULL)
_ConfigurationDialog.ShowWindow(SW_SHOW);
}
else
_ConfigurationDialog.BringWindowToTop();
}
/// <summary>
/// Updates the state.
/// </summary>
void uielement_t::UpdateState(ConfigurationChanges settings) noexcept
{
if (settings == ConfigurationChanges::All)
{
DeleteTrackingToolTip();
for (auto & Iter : _Grid)
{
TTTOOLINFOW ti;
Iter._Graph->InitToolInfo(m_hWnd, ti);
_ToolTipControl.DelTool(&ti);
}
}
_CriticalSection.Enter();
{
_RenderState = _UIState; // Copies only the settings that are relevant for rendering.
if (settings == ConfigurationChanges::All)
{
_RenderState._SampleRate = 0;
_RenderState._StyleManager.DeleteDeviceSpecificResources();
// Recreate the resources that depend on the artwork.
CreateArtworkDependentResources();
// Create the graphs.
{
for (auto & Iter : _Grid)
delete Iter._Graph;
_Grid.clear();
_Grid.Initialize(_RenderState._GridRowCount, _RenderState._GridColumnCount);
for (const auto & GraphDescription : _RenderState._GraphDescriptions)
{
auto * Graph = new graph_t();
Graph->Initialize(&_RenderState, &GraphDescription, nullptr);
_Grid.push_back({ Graph, GraphDescription._HRatio, GraphDescription._VRatio });
}
}
}
}
_CriticalSection.Leave();
if (settings == ConfigurationChanges::All)
{
for (auto & Iter : _Grid)
{
TTTOOLINFOW ti;
Iter._Graph->InitToolInfo(m_hWnd, ti);
_ToolTipControl.AddTool(&ti);
}
_ToolTipControl.Activate(_RenderState._ShowToolTipsAlways);
Resize();
}
}
/// <summary>
/// Gets the graph that contains the specified point.
/// </summary>
graph_t * uielement_t::GetGraph(const CPoint & pt) noexcept
{
for (auto & Iter : _Grid)
{
if (Iter._Graph->ContainsPoint(pt))
return Iter._Graph;
}
return nullptr;
}
#pragma endregion
#pragma region play_callback_impl_base
/// <summary>
/// Playback advanced to new track.
/// </summary>
void uielement_t::on_playback_new_track(metadb_handle_ptr track)
{
UpdateState(ConfigurationChanges::All);
// Always get the album art in case the user enables the _ShowArtworkOnBackground setting while playing a track.
if (track.is_valid())
GetArtwork(track);
// Notify the render thread.
_Event.Raise(event_t::PlaybackStartedNewTrack);
}
/// <summary>
/// Playback stopped.
/// </summary>
void uielement_t::on_playback_stop(play_control::t_stop_reason reason)
{
_Artwork.DeleteWICResources();
_UIState._SampleRate = 0;
// Notify the render thread.
_Event.Raise(event_t::PlaybackStopped);
}
/// <summary>
/// Playback paused/resumed.
/// </summary>
void uielement_t::on_playback_pause(bool state)
{
// Notify the render thread.
_Event.Raise(state ? event_t::PlaybackPaused : event_t::PlaybackResumed);
}
/// <summary>
/// Called every second, for time display.
/// </summary>
void uielement_t::on_playback_time(double time)
{
_RenderState._TrackTime = time; // Near-atomic
}
#pragma endregion
/// <summary>
/// Gets the artwork for the specified track.
/// </summary>
bool uielement_t::GetArtwork(const metadb_handle_ptr & track) noexcept
{
if (_UIState._ArtworkFilePath.empty())
return GetArtworkFromTrack(track, fb2k::noAbort);
else
return GetArtworkFromScript(track, fb2k::noAbort);
}
/// <summary>
/// Gets the artwork for the specified track.
/// </summary>
bool uielement_t::GetArtworkFromTrack(const metadb_handle_ptr & track, abort_callback & abort) noexcept
{
Log.AtTrace().Write(STR_COMPONENT_BASENAME " is getting artwork for the playing track.");
GUID ArtworkGUID = GetArtworkTypeGUID(_UIState._ArtworkType);
static_api_ptr_t<album_art_manager_v2> ArtworkManager;
auto ArtworkExtractor = ArtworkManager->open(pfc::list_single_ref_t(track), pfc::list_single_ref_t(ArtworkGUID), abort);
if (!ArtworkExtractor.is_valid())
return false;
try
{
album_art_data::ptr ArtworkData;
if (!ArtworkExtractor->query(ArtworkGUID, ArtworkData, abort))
{
auto StubExtractor = ArtworkManager->open_stub(abort);
if (!StubExtractor.is_valid())
return false;
if (!StubExtractor->query(ArtworkGUID, ArtworkData, abort))
return false;
}
if (ArtworkData.is_valid())
_Artwork.CreateWICResources((uint8_t *) ArtworkData->data(), ArtworkData->size());
}
catch (const std::exception & e) // exception_aborted, exception_album_art_not_found
{
Log.AtTrace().Write(STR_COMPONENT_BASENAME " failed to get artwork for the playing track: %s", e.what());
}
return true;
}
/// <summary>
/// Gets the artwork for the specified track from a script.
/// </summary>
bool uielement_t::GetArtworkFromScript(const metadb_handle_ptr & track, abort_callback & abort) noexcept
{
Log.AtTrace().Write(STR_COMPONENT_BASENAME " is getting artwork from script \"%s\".", pfc::utf8FromWide(_UIState._ArtworkFilePath.c_str()).c_str());
titleformat_object::ptr Script;
if (!titleformat_compiler::get()->compile(Script, pfc::utf8FromWide(_UIState._ArtworkFilePath.c_str())))
return false;
if (!Script.is_valid())
return false;
pfc::string Result;
if (!track->format_title(0, Result, Script, 0))
return false;
_Artwork.CreateWICResources(pfc::wideFromUTF8(Result).c_str());
return true;
}
/// <summary>
/// Returns the API GUID for the specified artwork type.
/// </summary>
GUID uielement_t::GetArtworkTypeGUID(ArtworkType artworkType) noexcept
{
switch (artworkType)
{
default:
case ArtworkType::Front: return album_art_ids::cover_front;
case ArtworkType::Back: return album_art_ids::cover_back;
case ArtworkType::Disc: return album_art_ids::disc;
case ArtworkType::Icon: return album_art_ids::icon;
case ArtworkType::Artist: return album_art_ids::artist;
}
}