diff --git a/src/slic3r/GUI/GUI_Utils.cpp b/src/slic3r/GUI/GUI_Utils.cpp index b7d38db3d2..cb8ba45c6b 100644 --- a/src/slic3r/GUI/GUI_Utils.cpp +++ b/src/slic3r/GUI/GUI_Utils.cpp @@ -589,6 +589,58 @@ void RemoveButtonBorder(wxWindow* win) ); #endif } + +void RemoveInputBorder(wxWindow* win) +{ + GtkWidget* widget = win->GetHandle(); + if (!widget) return; + +#if GTK_CHECK_VERSION(3, 0, 0) + // GTK3+: use CSS provider + GtkCssProvider* provider = gtk_css_provider_new(); + + // Target 'entry' and its inner subnodes (like text selection areas) + const char* css = + "entry, entry text, entry undershoot {" + " border: none;" + " outline: none;" + " box-shadow: none;" + " padding: 0px;" + " margin: 0px;" + " min-height: 0px;" + " min-width: 0px;" + " background: none;" + "}"; + +#if GTK_CHECK_VERSION(4, 0, 0) + // GTK4 + gtk_css_provider_load_from_data(provider, css, -1); +#else + // GTK3 + gtk_css_provider_load_from_data(provider, css, -1, nullptr); +#endif + + GtkStyleContext* ctx = gtk_widget_get_style_context(widget); + gtk_style_context_add_provider( + ctx, + GTK_STYLE_PROVIDER(provider), + GTK_STYLE_PROVIDER_PRIORITY_USER + ); + g_object_unref(provider); + +#else + // GTK2: Target the x/y thickness of the entry widget + gtk_rc_parse_string( + "style \"no-padding-entry\" {" + " xthickness = 0" + " ythickness = 0" + " GtkEntry::inner-border = { 0, 0, 0, 0 }" + " GtkEntry::focus-line-width = 0" + "}" + "class \"GtkEntry\" style \"no-padding-entry\"" + ); +#endif +} #endif // __WXGTK__ #ifdef __linux__ diff --git a/src/slic3r/GUI/GUI_Utils.hpp b/src/slic3r/GUI/GUI_Utils.hpp index d6767d3310..ac585cd189 100644 --- a/src/slic3r/GUI/GUI_Utils.hpp +++ b/src/slic3r/GUI/GUI_Utils.hpp @@ -467,6 +467,7 @@ void staticbox_remove_margin(wxStaticBox* sb); #ifdef __WXGTK3__ void RemoveButtonBorder(wxWindow* win); +void RemoveInputBorder(wxWindow* win); #endif #if defined(__WXOSX__) || defined(__linux__) diff --git a/src/slic3r/GUI/Widgets/CheckBox.cpp b/src/slic3r/GUI/Widgets/CheckBox.cpp index 54e98887e7..c7d2a667ee 100644 --- a/src/slic3r/GUI/Widgets/CheckBox.cpp +++ b/src/slic3r/GUI/Widgets/CheckBox.cpp @@ -2,7 +2,7 @@ #include "../wxExtensions.hpp" -#ifdef __WXGTK3__ +#ifdef __WXGTK__ #include "../GUI_Utils.hpp" #endif diff --git a/src/slic3r/GUI/Widgets/SwitchButton.cpp b/src/slic3r/GUI/Widgets/SwitchButton.cpp index 9e780c0f02..44cbf6dcf9 100644 --- a/src/slic3r/GUI/Widgets/SwitchButton.cpp +++ b/src/slic3r/GUI/Widgets/SwitchButton.cpp @@ -12,7 +12,7 @@ #include "libslic3r/MacUtils.hpp" #endif -#ifdef __WXGTK3__ +#ifdef __WXGTK__ #include "../GUI_Utils.hpp" #endif diff --git a/src/slic3r/GUI/Widgets/TextInput.cpp b/src/slic3r/GUI/Widgets/TextInput.cpp index 362e4c99b3..49605e048d 100644 --- a/src/slic3r/GUI/Widgets/TextInput.cpp +++ b/src/slic3r/GUI/Widgets/TextInput.cpp @@ -6,6 +6,10 @@ #include #include +#ifdef __WXGTK__ +#include "../GUI_Utils.hpp" +#endif + BEGIN_EVENT_TABLE(TextInput, StaticBox) EVT_PAINT(TextInput::paintEvent) @@ -60,6 +64,11 @@ void TextInput::Create(wxWindow * parent, state_handler.attach({&label_color, & text_color}); state_handler.update_binds(); text_ctrl = new TextCtrl(this, wxID_ANY, text, {4, 4}, wxDefaultSize, style | wxBORDER_NONE | wxTE_PROCESS_ENTER); + +#ifdef __WXGTK__ + Slic3r::GUI::RemoveInputBorder(text_ctrl); +#endif + text_ctrl->SetFont(Label::Body_14); text_ctrl->SetInitialSize(text_ctrl->GetBestSize()); text_ctrl->SetBackgroundColour(background_color.colorForStates(state_handler.states()));