Merge from main and fix merge conflicts

This commit is contained in:
Lam Wei Lun
2026-08-19 16:16:21 +08:00
79 changed files with 2567 additions and 655 deletions
+9 -18
View File
@@ -96,21 +96,18 @@ void Button::SetIcon(const wxString& icon)
}
}
void Button::SetBitmap(const wxBitmap& bitmap)
void Button::SetIcon(const wxBitmap& icon)
{
custom_icon = bitmap;
this->active_icon = ScalableBitmap();
this->active_icon.bmp() = icon;
messureSize();
Refresh();
}
void Button::SetInactiveIcon(const wxString &icon)
void Button::SetBitmap(const wxBitmap& bitmap)
{
if (!icon.IsEmpty()) {
// BBS set button icon default size to 20
this->inactive_icon = ScalableBitmap(this, icon.ToStdString(), this->active_icon.px_cnt());
} else {
this->inactive_icon = ScalableBitmap();
}
custom_icon = bitmap;
messureSize();
Refresh();
}
@@ -265,12 +262,10 @@ void Button::SetStyle(const ButtonStyle style, const ButtonType type)
void Button::Rescale()
{
if (this->active_icon.bmp().IsOk())
// Only a named icon can be re-rasterized; one set from a wxBitmap has no source file,
if (!this->active_icon.name().empty())
this->active_icon.msw_rescale();
if (this->inactive_icon.bmp().IsOk())
this->inactive_icon.msw_rescale();
messureSize();
if(m_has_style)
@@ -301,11 +296,7 @@ void Button::render(wxDC& dc)
wxSize szIcon;
wxSize textSize = this->textSize.GetSize();
ScalableBitmap icon;
if (m_selected || ((states & (int)StateColor::State::Hovered) != 0))
icon = active_icon;
else
icon = inactive_icon;
const ScalableBitmap& icon = active_icon;
wxSize padding = this->paddingSize;
int spacing = 5;
// Wrap text
+24 -24
View File
@@ -7,24 +7,25 @@
class ButtonProps
{
public:
static int ChoiceButtonGap(){return 10;};
static int WindowButtonGap(){return 10;};
static int ChoiceButtonGap() { return 10; };
static int WindowButtonGap() { return 10; };
};
enum class ButtonStyle{
enum class ButtonStyle {
Regular,
Confirm,
Alert,
Disabled,
};
enum class ButtonType{
Compact , // Font10 FullyRounded For spaces with less areas
Window , // Font12 FullyRounded For regular buttons in windows and not related with parameter boxes
Choice , // Font14 Semi-Rounded For dialog/window choice buttons
enum class ButtonType {
Compact, // Font10 FullyRounded For spaces with less areas
Window, // Font12 FullyRounded For regular buttons in windows and not related with parameter boxes
Choice, // Font14 Semi-Rounded For dialog/window choice buttons
Parameter, // Font14 Semi-Rounded For buttons that near parameter boxes
Icon , // ------ Semi-Rounded For buttons that only has icons. icons should be 16x16 and iconSize has to be defined as 16 while creation of button
Expanded , // Font14 Semi-Rounded For full length buttons. ex. buttons in static box
Icon, // ------ Semi-Rounded For buttons that only has icons. icons should be 16x16 and iconSize has to be defined as 16 while
// creation of button
Expanded, // Font14 Semi-Rounded For full length buttons. ex. buttons in static box
};
class wxTipWindow;
@@ -34,20 +35,19 @@ class Button : public StaticBox
wxSize minSize; // set by outer
wxSize paddingSize;
ScalableBitmap active_icon;
ScalableBitmap inactive_icon;
wxBitmap custom_icon;
StateColor text_color;
StateColor text_color;
bool pressedDown = false;
bool m_selected = true;
bool canFocus = true;
bool canFocus = true;
bool isCenter = true;
bool vertical = false;
wxTipWindow* tipWindow = nullptr;
static const int buttonWidth = 200;
static const int buttonWidth = 200;
static const int buttonHeight = 50;
public:
@@ -62,9 +62,9 @@ public:
bool SetFont(const wxFont& font) override;
void SetIcon(const wxString& icon);
void SetBitmap(const wxBitmap& bitmap);
void SetIcon(const wxBitmap& icon);
void SetInactiveIcon(const wxString& icon);
void SetBitmap(const wxBitmap& bitmap);
void SetMinSize(const wxSize& size) override;
void SetMaxSize(const wxSize& size) override;
@@ -73,19 +73,19 @@ public:
void SetStyle(const ButtonStyle style /*= ButtonStyle::Regular*/, const ButtonType type /*= ButtonType::None*/);
void SetTextColor(StateColor const &color);
void SetTextColor(StateColor const& color);
void SetTextColorNormal(wxColor const &color);
void SetTextColorNormal(wxColor const& color);
void SetSelected(bool selected = true) { m_selected = selected; }
// Only meant to be used by inspector, not public API
ButtonStyle GetStyle() const { return m_style; }
ButtonType GetType() const { return m_type; }
bool IsSelected() const { return m_selected; }
ButtonType GetType() const { return m_type; }
bool IsSelected() const { return m_selected; }
bool Enable(bool enable = true) override;
void EnableTooltipEvenDisabled();// The tip will be shown even if the button is disabled
void EnableTooltipEvenDisabled(); // The tip will be shown even if the button is disabled
void SetCanFocus(bool canFocus) override;
@@ -109,7 +109,7 @@ protected:
private:
bool m_has_style = false;
ButtonStyle m_style;
ButtonType m_type;
ButtonType m_type;
void paintEvent(wxPaintEvent& evt);
@@ -120,10 +120,10 @@ private:
// some useful events
void mouseDown(wxMouseEvent& event);
void mouseReleased(wxMouseEvent& event);
void mouseCaptureLost(wxMouseCaptureLostEvent &event);
void keyDownUp(wxKeyEvent &event);
void mouseCaptureLost(wxMouseCaptureLostEvent& event);
void keyDownUp(wxKeyEvent& event);
//
//
void sendButtonEvent();
// parent motion
+41 -13
View File
@@ -57,18 +57,6 @@ std::string host_theme_vars_css()
return s;
}
// Document-start user script: injects the contract <style>, stamps data-orca-theme before
// first paint, and raises a JS flag so the legacy globalapi.js dark.css poll stands down for
// host-themed pages. The WebView2 timing guard lives in document_start_injector().
std::string host_theme_user_script()
{
const std::string style = "<style id=\"orca-host-theme-vars\">" + host_theme_vars_css() + "</style>";
return WebViewHostDialog::document_start_injector(
style, "orca-host-theme-vars", "afterbegin",
"window.__orcaHostThemed=true;var theme=\"" + host_theme_name() + "\";",
"if(document.documentElement)document.documentElement.setAttribute('data-orca-theme',theme);");
}
// JS to re-theme an already-loaded document live (no reload): replace the injected
// style's contents and update data-orca-theme. Everything downstream (theme.css
// tokens, plugin element defaults, page layout) re-cascades from these values.
@@ -87,6 +75,46 @@ if(document.documentElement)
} // namespace
// Document-start user script: injects the contract <style>, stamps data-orca-theme before
// first paint, and raises a JS flag so the legacy globalapi.js dark.css poll stands down for
// host-themed pages. The WebView2 timing guard lives in document_start_injector().
std::string WebViewHostDialog::theme_user_script()
{
const std::string style = "<style id=\"orca-host-theme-vars\">" + host_theme_vars_css() + "</style>";
return document_start_injector(
style, "orca-host-theme-vars", "afterbegin",
"window.__orcaHostThemed=true;var theme=\"" + host_theme_name() + "\";",
"if(document.documentElement)document.documentElement.setAttribute('data-orca-theme',theme);");
}
std::string WebViewHostDialog::plugin_defaults_user_script()
{
std::string css;
css += "<style id=\"orca-plugin-defaults\">";
css += "html,body{background:var(--orca-bg);color:var(--orca-fg);"
"font-family:var(--orca-font);font-size:13px;}";
css += "body{margin:0;}";
css += "h1,h2,h3,h4,h5,h6{color:var(--orca-fg);font-weight:600;}";
css += "a{color:var(--orca-accent);}";
css += "hr{border:0;border-top:1px solid var(--orca-border);}";
css += "button{font:inherit;color:var(--orca-accent-fg);background:var(--orca-accent);"
"border:1px solid var(--orca-accent);border-radius:4px;padding:5px 14px;cursor:pointer;}";
css += "button:hover{filter:brightness(1.1);}";
css += "button:disabled{opacity:.5;cursor:default;}";
css += "input,select,textarea{font:inherit;color:var(--orca-fg);"
"background:var(--orca-bg);border:1px solid var(--orca-border);"
"border-radius:4px;padding:4px 8px;}";
css += "input:focus,select:focus,textarea:focus{outline:none;border-color:var(--orca-accent);}";
css += "table{border-collapse:collapse;}";
css += "th,td{text-align:left;padding:6px 10px;border-bottom:1px solid var(--orca-border);}";
css += "th{color:var(--orca-muted);font-weight:600;}";
css += "::-webkit-scrollbar{width:12px;height:12px;}";
css += "::-webkit-scrollbar-thumb{background:var(--orca-border);border-radius:6px;}";
css += "::-webkit-scrollbar-track{background:transparent;}";
css += "</style>";
return document_start_injector(css, "orca-plugin-defaults", "beforeend");
}
std::string WebViewHostDialog::document_start_injector(const std::string& markup,
const char* dom_id,
const char* position,
@@ -244,7 +272,7 @@ void WebViewHostDialog::register_theme_user_scripts()
// script message handler is registered separately (AddScriptMessageHandler), but on
// some backends RemoveAllUserScripts() drops it too, which would break
// window.wx.postMessage / HandleStudio. Live re-theme goes through apply_theme_live().
m_browser->AddUserScript(wxString::FromUTF8(host_theme_user_script()));
m_browser->AddUserScript(wxString::FromUTF8(theme_user_script()));
add_user_scripts();
}
@@ -49,6 +49,10 @@ public:
const std::string& prelude = {},
const std::string& on_inject = {});
// Shared by modeless Pages tabs and PluginWebDialog.
static std::string theme_user_script();
static std::string plugin_defaults_user_script();
protected:
wxWebView* browser() const { return m_browser; }