Compare commits

..
Author SHA1 Message Date
Hanif Koh 87f5aa298e Make the Unsaved Changes Dialog Header Span the Full Table Width
The grey header strip carrying the Settings/Old Value/New Value titles was
added to the tab panel without wxEXPAND, so it stayed at the width its own
sizer fitted it to. The panel, the scrolled window and every category and
value row below it are added with wxEXPAND and do follow the dialog width,
so as soon as the dialog came out wider than the table, the header stopped
short and left a bare strip of panel to the right of New Value.

The dialog takes its width from the widest child of the main sizer, which
includes the button row. In the Transfer/Discard/Save variant three Choice
buttons, each with a hard FromDIP(100) minimum, plus the gaps, the checkbox
and the margins come within a few pixels of the table width, and at higher
display scaling they overrun it.

Give the header the panel width and send the surplus to a stretch spacer
after the last column, so the columns stay put: they are hard minimum sizes
on both sides, and the rows below leave that same area empty, so header and
values remain aligned. The Settings column drops to proportion 0 so it does
not absorb the surplus and slide the other two titles out of alignment.

The header is unchanged when the dialog is not wider than its table.

Verified on Linux with a release build: with the dialog widened, the header
goes from ending at x=511 to spanning the full 749, and the pixel difference
between the two builds is confined to the strip that was previously bare. At
normal width the two builds render identically. Not verified on Windows.
2026-09-18 18:35:24 +08:00
3 changed files with 9 additions and 30 deletions
+6 -27
View File
@@ -8,7 +8,6 @@
#include <boost/filesystem.hpp>
#include <wx/event.h>
#include <wx/uri.h>
#include <utility>
@@ -56,14 +55,6 @@ wxString web_base_url()
return wxString("file://") + from_u8(dir) + "/";
}
// Whether a loaded document is the plugin HTML's own base URL. The web view reports the URL it
// parsed, so any fragment the page navigated to is ignored and the escaping it applies to what the
// resources path holds (a space, a non-ASCII character) is undone first.
bool is_content_url(const wxString& url)
{
return wxURI::Unescape(url.BeforeFirst('#')) == web_base_url();
}
} // namespace
PluginWebDialog::PluginWebDialog(wxWindow* parent,
@@ -148,31 +139,19 @@ void PluginWebDialog::destroy_for_plugin(PluginWebDialog* dialog)
void PluginWebDialog::on_bootstrap_event(wxWebViewEvent& event)
{
// The first bootstrap load (or its error) triggers the swap to plugin HTML.
if (!m_content_loaded)
load_plugin_content();
// WebKit reloads the SetPage base URL rather than the injected page, and the injected document
// reports that same URL, so a load of it that is not the swap we started is a browser reload
// and the plugin HTML has to be put back. A page the plugin linked to arrives under its own
// URL and is left alone; a post-load error only ever means a failed subresource. The Edge
// backend ignores the base URL, so the comparison never matches there, and WebView2 reloads
// SetPage content from its own history entry anyway.
else if (event.GetEventType() == wxEVT_WEBVIEW_LOADED) {
if (m_own_page_load)
m_own_page_load = false;
else if (is_content_url(event.GetURL()))
load_plugin_content();
}
// The first bootstrap load (or its error) triggers the swap to plugin HTML;
// the resulting plugin-page load is ignored (guarded by m_content_loaded).
load_plugin_content();
event.Skip();
}
void PluginWebDialog::load_plugin_content()
{
if (m_content_loaded)
return;
m_content_loaded = true;
if (wxWebView* wv = browser()) {
m_own_page_load = true;
if (wxWebView* wv = browser())
wv->SetPage(wxString::FromUTF8(m_html), web_base_url());
}
}
void PluginWebDialog::on_script_message(const nlohmann::json& payload)
-1
View File
@@ -72,7 +72,6 @@ private:
std::string m_html;
bool m_content_loaded{false};
bool m_own_page_load{false}; // a SetPage of the plugin HTML is in flight
bool m_open{true};
bool m_close_fired{false};
std::optional<nlohmann::json> m_result;
+3 -2
View File
@@ -891,7 +891,7 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection *dependent_
top_title_temp_v->Add(top_title_temp_h, 1, wxALIGN_CENTER, 0);
m_panel_temp->SetSizer(top_title_temp_v);
m_panel_temp->Layout();
m_sizer_top->Add(m_panel_temp, 1, wxALIGN_CENTER, 0);
m_sizer_top->Add(m_panel_temp, 0, wxALIGN_CENTER, 0);
title_block_middle = new wxPanel(m_table_top, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
title_block_middle->SetBackgroundColour(wxColour(172, 172, 172));
@@ -935,11 +935,12 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection *dependent_
m_panel_newv->Layout();
m_sizer_top->Add(m_panel_newv, 0, wxALIGN_CENTER, 0);
//m_sizer_top->Add(top_title_newv, 1, wxALIGN_CENTER, 0);
m_sizer_top->AddStretchSpacer();
m_table_top->SetSizer(m_sizer_top);
m_table_top->Layout();
m_sizer_top->Fit(m_table_top);
m_sizer_tab->Add(m_table_top, 1, 0, 0);
m_sizer_tab->Add(m_table_top, 0, wxEXPAND, 0);
m_scrolledWindow = new wxScrolledWindow(m_panel_tab, wxID_ANY, wxDefaultPosition, UNSAVE_CHANGE_DIALOG_SCROLL_WINDOW_SIZE, wxNO_BORDER|wxVSCROLL);
m_scrolledWindow->SetScrollRate(0, 5);