Skip to content

Commit

Permalink
Merge pull request #8 from stuerp/vNext
Browse files Browse the repository at this point in the history
v0.1.6.0
  • Loading branch information
stuerp authored Jul 9, 2024
2 parents 5d736ed + 78a9a35 commit a10454b
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 48 deletions.
19 changes: 16 additions & 3 deletions Configuration.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

/** $VER: configuration_t.cpp (2024.07.08) P. Stuer **/
/** $VER: configuration_t.cpp (2024.07.09) P. Stuer **/

#include "pch.h"

Expand Down Expand Up @@ -73,6 +73,8 @@ void configuration_t::Reset() noexcept
_WindowSize = 100; // ms
_WindowSizeUnit = WindowSizeUnit::Milliseconds;
_ReactionAlignment = 0.25;

_ClearOnStartup = ClearOnStartup::All;
}

/// <summary>
Expand All @@ -90,11 +92,13 @@ configuration_t & configuration_t::operator=(const configuration_t & other)

_ProfileName = other._ProfileName;

_ClearOnStartup = other._ClearOnStartup;

return *this;
}

/// <summary>
/// Reads this instance with the specified reader. (CUI version)
/// Reads this instance with the specified reader.
/// </summary>
void configuration_t::Read(stream_reader * reader, size_t size, abort_callback & abortHandler, bool isPreset) noexcept
{
Expand Down Expand Up @@ -131,6 +135,12 @@ void configuration_t::Read(stream_reader * reader, size_t size, abort_callback &
{
reader->read_string(UTF8String, abortHandler); _ProfileName = pfc::wideFromUTF8(UTF8String);
}

// Version 5, v0.1.6.0
if (Version >= 5)
{
uint32_t Value; reader->read_object_t(Value, abortHandler); _ClearOnStartup = (ClearOnStartup) Value;
}
}
catch (exception & ex)
{
Expand All @@ -141,7 +151,7 @@ void configuration_t::Read(stream_reader * reader, size_t size, abort_callback &
}

/// <summary>
/// Writes this instance to the specified writer. (CUI version)
/// Writes this instance to the specified writer.
/// </summary>
void configuration_t::Write(stream_writer * writer, abort_callback & abortHandler, bool isPreset) const noexcept
{
Expand All @@ -163,6 +173,9 @@ void configuration_t::Write(stream_writer * writer, abort_callback & abortHandle

// Version 4, v0.1.5.6
UTF8String = pfc::utf8FromWide(_ProfileName.c_str()); writer->write_string(UTF8String, abortHandler);

// Version 5, v0.1.6.0
Value = (uint32_t) _ClearOnStartup; writer->write_object_t(Value, abortHandler);
}
catch (exception & ex)
{
Expand Down
22 changes: 19 additions & 3 deletions Configuration.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@

/** $VER: Configuration.h (2024.07.08) P. Stuer **/
/** $VER: Configuration.h (2024.07.09) P. Stuer **/

#pragma once

#include "pch.h"

enum WindowSizeUnit
enum WindowSizeUnit : uint32_t
{
Milliseconds = 0,
Samples,

Count
};

enum ClearOnStartup : uint32_t
{
None = 0,

BrowsingHistory,
DownloadHistory,
Cookies,
Cache,
Passwords,
Autofill,
SitePermissions,

All = (uint32_t) ~0,
};

/// <summary>
/// Represents the configuration of the component.
/// </summary>
Expand Down Expand Up @@ -43,7 +58,8 @@ class configuration_t
// > 0: All samples are behind the playback (similar to VST audio analyzer plugins like Voxengo SPAN) with the last sample equal to the actual playback.

std::wstring _ProfileName;
ClearOnStartup _ClearOnStartup;

private:
const int32_t _CurrentVersion = 4;
const int32_t _CurrentVersion = 5;
};
15 changes: 13 additions & 2 deletions Preferences.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

/** $VER: Preferences.cpp (2024.07.05) P. Stuer **/
/** $VER: Preferences.cpp (2024.07.09) P. Stuer **/

#include "pch.h"

Expand Down Expand Up @@ -100,6 +100,8 @@ class Preferences : public CDialogImpl<Preferences>, public preferences_page_ins
_Configuration._ReactionAlignment = ::_wtof(Text);
}

_Configuration._ClearOnStartup = (SendDlgItemMessageW(IDC_CLEAR_BROWSING_DATA, BM_GETCHECK) == BST_CHECKED) ? ClearOnStartup::All : ClearOnStartup::None;

UIElement * CurrentElement = _UIElementTracker.GetCurrentElement();

if (CurrentElement != nullptr)
Expand Down Expand Up @@ -133,6 +135,7 @@ class Preferences : public CDialogImpl<Preferences>, public preferences_page_ins
COMMAND_CODE_HANDLER_EX(CBN_SELCHANGE, OnSelectionChanged) // This also handles LBN_SELCHANGE

COMMAND_HANDLER_EX(IDC_USER_DATA_FOLDER_PATH_SELECT, BN_CLICKED, OnButtonClicked)
COMMAND_HANDLER_EX(IDC_CLEAR_BROWSING_DATA, BN_CLICKED, OnButtonClicked)

COMMAND_HANDLER_EX(IDC_FILE_PATH_SELECT, BN_CLICKED, OnButtonClicked)
COMMAND_HANDLER_EX(IDC_FILE_PATH_EDIT, BN_CLICKED, OnButtonClicked)
Expand Down Expand Up @@ -181,6 +184,8 @@ class Preferences : public CDialogImpl<Preferences>, public preferences_page_ins
}

SetDlgItemTextW(IDC_REACTION_ALIGNMENT, pfc::wideFromUTF8(pfc::format_float(_Configuration._ReactionAlignment, 0, 2)));

SendDlgItemMessageW(IDC_CLEAR_BROWSING_DATA, BM_SETCHECK, (WPARAM) (_Configuration._ClearOnStartup == ClearOnStartup::All ? BST_CHECKED : BST_UNCHECKED));
}

/// <summary>
Expand Down Expand Up @@ -267,7 +272,10 @@ class Preferences : public CDialogImpl<Preferences>, public preferences_page_ins
}

default:
{
OnChanged();
break;
}
}
}

Expand Down Expand Up @@ -324,14 +332,17 @@ class Preferences : public CDialogImpl<Preferences>, public preferences_page_ins

auto w = (CComboBox) GetDlgItem(IDC_WINDOW_SIZE_UNIT);

if (_Configuration._WindowSizeUnit != w.GetCurSel())
if (_Configuration._WindowSizeUnit != (uint32_t) w.GetCurSel())
return true;

GetDlgItemTextW(IDC_REACTION_ALIGNMENT, Text, _countof(Text));

if (_Configuration._ReactionAlignment != ::_wtof(Text))
return true;

if (SendDlgItemMessageW(IDC_CLEAR_BROWSING_DATA, BM_GETCHECK) != (_Configuration._ClearOnStartup == ClearOnStartup::All ? BST_CHECKED : BST_UNCHECKED))
return true;

return false;
}

Expand Down
34 changes: 20 additions & 14 deletions PreferencesLayout.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@

/** $VER: PreferencesLayout.h (2024.07.03) **/
/** $VER: PreferencesLayout.h (2024.07.09) **/

#pragma once

#define W_A00 332 // Dialog width as set by foobar2000, in dialog units
#define H_A00 288 // Dialog height as set by foobar2000, in dialog units
#define W_A00 332 // Dialog width as set by foobar2000, in dialog units
#define H_A00 288 // Dialog height as set by foobar2000, in dialog units

#define H_LBL 8 // Label
#define H_LBL 8 // Label

#define W_BTN 50 // Button
#define H_BTN 14 // Button
#define W_BTN 50 // Button
#define H_BTN 14 // Button

#define H_EBX 14 // Edit box
#define H_CBX 14 // Combo box
#define H_EBX 14 // Edit box
#define H_CBX 14 // Combo box

#define W_CHB 10 // Check box
#define H_CHB 10 // Check box
#define W_CHB 10 // Check box
#define H_CHB 10 // Check box

#define DX 7
#define DY 7
#define DX 7
#define DY 7

#define IX 4 // Spacing between two related controls
#define IY 3
#define IX 4 // Spacing between two related controls
#define IY 3

#pragma region Name

Expand Down Expand Up @@ -132,3 +132,9 @@
#define H_D25 H_LBL

#pragma endregion

// Checkbox: Clear browsing data on startup
#define X_D26 0
#define Y_D26 Y_D24 + H_D24 + IY
#define W_D26 160
#define H_D26 H_LBL
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

# foo_uie_webview

[foo_uie_webview](https://github.com/stuerp/foo_uie_webview/releases) is a [foobar2000](https://www.foobar2000.org/) component that exposes the [Microsoft Edge WebView2](https://learn.microsoft.com/en-us/microsoft-edge/webview2/) control as UI panel. The component started as foo_vis_text.
[foo_uie_webview](https://github.com/stuerp/foo_uie_webview/releases) is a [foobar2000](https://www.foobar2000.org/) component that exposes the [Microsoft WebView2](https://learn.microsoft.com/en-us/microsoft-edge/webview2/) control as UI panel. The component started as foo_vis_text.

It takes an HTML file that receives playback notifications from foobar2000. The panel can react to those notifications and adjust its output using Javascript code.
It takes an HTML file that receives playback notifications from foobar2000. The panel can react to those notifications and adjust its output using JavaScript code.

## Features

Expand Down Expand Up @@ -95,6 +95,10 @@ To create the component first build the x86 configuration and next the x64 confi

## Change Log

v0.1.6.0, 2024-07-09

* New: Added a setting to clear the browsing data on startup or not.

v0.1.5.6, 2024-07-08

* New: Each instance of the component can have a name to easier distinguish between them.
Expand Down Expand Up @@ -192,7 +196,7 @@ v0.1.0.0, 2024-06-02, *"Scratchin' the itch"*
* Home page: [https://github.com/stuerp/foo_uie_webview](https://github.com/stuerp/foo_uie_webview)
* Repository: [https://github.com/stuerp/foo_uie_webview.git](https://github.com/stuerp/foo_uie_webview.git)
* Issue tracker: [https://github.com/stuerp/foo_uie_webview/issues](https://github.com/stuerp/foo_uie_webview/issues)
* Wiki: [https://wiki.hydrogenaud.io/index.php?title=Foobar2000:Components/Text_Visualizer_(foo_uie_webview)](https://wiki.hydrogenaud.io/index.php?title=Foobar2000:Components/Text_Visualizer_(foo_uie_webview)).
* Wiki: [https://wiki.hydrogenaud.io/index.php?title=Foobar2000:Components/WebView_(foo_uie_webview)](https://wiki.hydrogenaud.io/index.php?title=Foobar2000:Components/WebView_(foo_uie_webview)).

## License

Expand Down
12 changes: 7 additions & 5 deletions Resources.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

/** $VER: Resources.h (2024.07.07) P. Stuer **/
/** $VER: Resources.h (2024.07.09) P. Stuer **/

#pragma once

Expand All @@ -8,13 +8,13 @@

#define NUM_FILE_MAJOR 0
#define NUM_FILE_MINOR 1
#define NUM_FILE_PATCH 5
#define NUM_FILE_PRERELEASE 6
#define NUM_FILE_PATCH 6
#define NUM_FILE_PRERELEASE 0

#define NUM_PRODUCT_MAJOR 0
#define NUM_PRODUCT_MINOR 1
#define NUM_PRODUCT_PATCH 5
#define NUM_PRODUCT_PRERELEASE 6
#define NUM_PRODUCT_PATCH 6
#define NUM_PRODUCT_PRERELEASE 0

/** Component specific **/

Expand Down Expand Up @@ -75,4 +75,6 @@
#define IDC_REACTION_ALIGNMENT 1030
#define IDC_WINDOW_OFFSET 1032

#define IDC_CLEAR_BROWSING_DATA 1040

#define IDR_CONTEXT_MENU_ICON 2000
34 changes: 18 additions & 16 deletions Resources.rc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

/** $VER: Resources.rc (2024.07.05) P. Stuer **/
/** $VER: Resources.rc (2024.07.09) P. Stuer **/

#include "Resources.h"

Expand Down Expand Up @@ -50,25 +50,27 @@ IDD_PREFERENCES dialogex 0, 0, 0, 0
style DS_SETFONT | WS_CHILD
font 8, "Segoe UI", 400, 0, 1
{
rtext "Name:", IDC_STATIC, X_D11, Y_D11 + 2, W_D11, H_D11
edittext IDC_NAME, X_D12, Y_D12, W_D12, H_D12, ES_AUTOHSCROLL
rtext "Name:", IDC_STATIC, X_D11, Y_D11 + 2, W_D11, H_D11
edittext IDC_NAME, X_D12, Y_D12, W_D12, H_D12, ES_AUTOHSCROLL

ltext "User data folder path", IDC_STATIC, X_D13, Y_D13 + 2, W_D13, H_D13
edittext IDC_USER_DATA_FOLDER_PATH, X_D14, Y_D14, W_D14, H_D14, ES_AUTOHSCROLL
pushbutton "...", IDC_USER_DATA_FOLDER_PATH_SELECT, X_D15, Y_D15, W_D15, H_D15
ltext "User data folder path", IDC_STATIC, X_D13, Y_D13 + 2, W_D13, H_D13
edittext IDC_USER_DATA_FOLDER_PATH, X_D14, Y_D14, W_D14, H_D14, ES_AUTOHSCROLL
pushbutton "...", IDC_USER_DATA_FOLDER_PATH_SELECT, X_D15, Y_D15, W_D15, H_D15

ltext "Template file path", IDC_STATIC, X_D16, Y_D16 + 2, W_D16, H_D16
edittext IDC_FILE_PATH, X_D17, Y_D17, W_D17, H_D17, ES_AUTOHSCROLL
pushbutton "...", IDC_FILE_PATH_SELECT, X_D18, Y_D18, W_D18, H_D18
pushbutton "&Edit", IDC_FILE_PATH_EDIT, X_D19, Y_D19, W_D19, H_D19
ltext "Template file path", IDC_STATIC, X_D16, Y_D16 + 2, W_D16, H_D16
edittext IDC_FILE_PATH, X_D17, Y_D17, W_D17, H_D17, ES_AUTOHSCROLL
pushbutton "...", IDC_FILE_PATH_SELECT, X_D18, Y_D18, W_D18, H_D18
pushbutton "&Edit", IDC_FILE_PATH_EDIT, X_D19, Y_D19, W_D19, H_D19

rtext "Window size:", IDC_STATIC, X_D20, Y_D20 + 2, W_D20, H_D20
edittext IDC_WINDOW_SIZE, X_D21, Y_D21, W_D21, H_D21, ES_RIGHT | ES_AUTOHSCROLL | WS_TABSTOP
combobox IDC_WINDOW_SIZE_UNIT, X_D22, Y_D22, W_D22, H_D22, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
rtext "Window size:", IDC_STATIC, X_D20, Y_D20 + 2, W_D20, H_D20
edittext IDC_WINDOW_SIZE, X_D21, Y_D21, W_D21, H_D21, ES_RIGHT | ES_AUTOHSCROLL | WS_TABSTOP
combobox IDC_WINDOW_SIZE_UNIT, X_D22, Y_D22, W_D22, H_D22, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP

rtext "Reaction alignment:" IDC_STATIC, X_D23, Y_D23 + 2, W_D23, H_D23
edittext IDC_REACTION_ALIGNMENT X_D24, Y_D24, W_D24, H_D24, ES_RIGHT | ES_AUTOHSCROLL | WS_TABSTOP
ltext "", IDC_WINDOW_OFFSET, X_D25, Y_D25 + 2, W_D25, H_D25
rtext "Reaction alignment:" IDC_STATIC, X_D23, Y_D23 + 2, W_D23, H_D23
edittext IDC_REACTION_ALIGNMENT X_D24, Y_D24, W_D24, H_D24, ES_RIGHT | ES_AUTOHSCROLL | WS_TABSTOP
ltext "", IDC_WINDOW_OFFSET, X_D25, Y_D25 + 2, W_D25, H_D25

control "Clear browsing data on startup", IDC_CLEAR_BROWSING_DATA, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, X_D26, Y_D26, W_D26, H_D26
}

IDR_CONTEXT_MENU_ICON rcdata "Main.ico"
Expand Down
5 changes: 3 additions & 2 deletions WebView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,6 @@ HRESULT UIElement::CreateWebView()
/// </summary>
void UIElement::DeleteWebView() noexcept
{
ClearBrowserData();

if (_WebView)
{
wil::com_ptr<ICoreWebView2_11> WebView11 = _WebView.try_query<ICoreWebView2_11>();
Expand Down Expand Up @@ -596,6 +594,9 @@ HRESULT UIElement::CreateContextMenu(const wchar_t * itemLabel, const wchar_t *
/// </summary>
HRESULT UIElement::ClearBrowserData() const noexcept
{
if (_Configuration._ClearOnStartup == ClearOnStartup::None)
return S_OK;

if (_WebView == nullptr)
return E_ILLEGAL_METHOD_CALL;

Expand Down

0 comments on commit a10454b

Please sign in to comment.