From c0129350ac393ac4361555a43f5b5435c33c3685 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Tue, 22 Nov 2022 19:22:20 +0100 Subject: [PATCH] ... --- src/live_effects/parameter/bool.cpp | 2 +- src/live_effects/parameter/colorpicker.cpp | 1 + src/live_effects/parameter/enum.h | 2 +- src/live_effects/parameter/fontbutton.cpp | 1 + src/live_effects/parameter/originalpath.cpp | 2 +- .../parameter/originalsatellite.cpp | 2 +- src/live_effects/parameter/parameter.cpp | 2 +- src/live_effects/parameter/path.cpp | 2 +- src/live_effects/parameter/patharray.cpp | 2 +- src/live_effects/parameter/point.cpp | 1 + src/live_effects/parameter/random.cpp | 2 +- src/live_effects/parameter/satellite.cpp | 2 +- src/live_effects/parameter/satellitearray.cpp | 2 +- src/live_effects/parameter/text.cpp | 1 + src/live_effects/parameter/togglebutton.cpp | 1 + .../parameter/transformedpoint.cpp | 2 +- src/live_effects/parameter/unit.cpp | 2 +- src/live_effects/parameter/vector.cpp | 2 +- src/ui/dialog/livepatheffect-add.cpp | 8 +++--- src/ui/dialog/livepatheffect-editor.cpp | 28 +++++++++---------- src/ui/dialog/livepatheffect-editor.h | 2 ++ 21 files changed, 38 insertions(+), 31 deletions(-) diff --git a/src/live_effects/parameter/bool.cpp b/src/live_effects/parameter/bool.cpp index 96d655ab5b..a47e67233e 100644 --- a/src/live_effects/parameter/bool.cpp +++ b/src/live_effects/parameter/bool.cpp @@ -82,7 +82,7 @@ BoolParam::param_newWidget() false, param_effect->getRepr(), param_effect->getSPDoc()) ); - + checkwdg->get_style_context()->add_class("lpeparam"); checkwdg->setActive(value); checkwdg->setProgrammatically = false; checkwdg->set_undo_parameters(_("Change bool parameter"), INKSCAPE_ICON("dialog-path-effects")); diff --git a/src/live_effects/parameter/colorpicker.cpp b/src/live_effects/parameter/colorpicker.cpp index 3c8d35032a..29388d665e 100644 --- a/src/live_effects/parameter/colorpicker.cpp +++ b/src/live_effects/parameter/colorpicker.cpp @@ -120,6 +120,7 @@ ColorPickerParam::param_newWidget() *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ); + colorpickerwdg->get_style_context()->add_class("lpeparam"); SPDocument *document = param_effect->getSPDoc(); { DocumentUndo::ScopedInsensitive _no_undo(document); diff --git a/src/live_effects/parameter/enum.h b/src/live_effects/parameter/enum.h index 91af18ccfa..56c6cb79f2 100644 --- a/src/live_effects/parameter/enum.h +++ b/src/live_effects/parameter/enum.h @@ -48,7 +48,7 @@ public: Inkscape::UI::Widget::RegisteredEnum *regenum = Gtk::manage ( new Inkscape::UI::Widget::RegisteredEnum( param_label, param_tooltip, param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc(), sorted ) ); - + regenum->get_style_context()->add_class("lpeparam"); regenum->set_active_by_id(value); regenum->combobox()->setProgrammatically = false; regenum->combobox()->signal_changed().connect(sigc::mem_fun (*this, &EnumParam::_on_change_combo)); diff --git a/src/live_effects/parameter/fontbutton.cpp b/src/live_effects/parameter/fontbutton.cpp index 441f14e6c5..9804c21e70 100644 --- a/src/live_effects/parameter/fontbutton.cpp +++ b/src/live_effects/parameter/fontbutton.cpp @@ -76,6 +76,7 @@ FontButtonParam::param_newWidget() *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) ); + fontbuttonwdg->get_style_context()->add_class("lpeparam"); Glib::ustring fontspec = param_getSVGValue(); fontbuttonwdg->setValue( fontspec); fontbuttonwdg->set_undo_parameters(_("Change font button parameter"), INKSCAPE_ICON("dialog-path-effects")); diff --git a/src/live_effects/parameter/originalpath.cpp b/src/live_effects/parameter/originalpath.cpp index c4d582dfc7..a3005e180e 100644 --- a/src/live_effects/parameter/originalpath.cpp +++ b/src/live_effects/parameter/originalpath.cpp @@ -45,7 +45,7 @@ Gtk::Widget * OriginalPathParam::param_newWidget() { Gtk::Box *_widget = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); - + _widget->get_style_context()->add_class("lpeparam"); { // Label Gtk::Label *pLabel = Gtk::manage(new Gtk::Label(param_label)); _widget->pack_start(*pLabel, true, true); diff --git a/src/live_effects/parameter/originalsatellite.cpp b/src/live_effects/parameter/originalsatellite.cpp index 4ddd1c37d7..d6f07eae93 100644 --- a/src/live_effects/parameter/originalsatellite.cpp +++ b/src/live_effects/parameter/originalsatellite.cpp @@ -38,7 +38,7 @@ OriginalSatelliteParam::~OriginalSatelliteParam() = default; Gtk::Widget *OriginalSatelliteParam::param_newWidget() { Gtk::Box *_widget = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); - + _widget->get_style_context()->add_class("lpeparam"); { // Label Gtk::Label *pLabel = Gtk::manage(new Gtk::Label(param_label)); _widget->pack_start(*pLabel, true, true); diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index a3aea93009..a695e5eb1c 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -336,7 +336,7 @@ Gtk::Widget *ScalarParam::param_newWidget() if (widget_is_visible) { Inkscape::UI::Widget::RegisteredScalar *rsu = Gtk::manage(new Inkscape::UI::Widget::RegisteredScalar( param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc())); - + rsu->get_style_context()->add_class("lpeparam"); rsu->setValue(value); rsu->setDigits(digits); rsu->setIncrements(inc_step, inc_page); diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index d28b4d36b2..80972f14a6 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -259,7 +259,7 @@ Gtk::Widget * PathParam::param_newWidget() { Gtk::Box * _widget = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); - + _widget->get_style_context()->add_class("lpeparam"); Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(param_label)); _widget->pack_start(*pLabel, true, true); pLabel->set_tooltip_text(param_tooltip); diff --git a/src/live_effects/parameter/patharray.cpp b/src/live_effects/parameter/patharray.cpp index aa7f34a6dd..2938ee7458 100644 --- a/src/live_effects/parameter/patharray.cpp +++ b/src/live_effects/parameter/patharray.cpp @@ -219,7 +219,7 @@ Gtk::Widget *PathArrayParam::param_newWidget() vbox->pack_end(*hbox, Gtk::PACK_SHRINK); vbox->show_all_children(true); - + vbox->get_style_context()->add_class("lpeparam"); return vbox; } diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp index dd390dd18c..20c3780179 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -166,6 +166,7 @@ PointParam::param_newWidget() Gtk::Box * hbox = Gtk::manage( new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL) ); hbox->pack_start(*pointwdg, true, true); hbox->show_all_children(); + hbox->get_style_context()->add_class("lpeparam"); return dynamic_cast (hbox); } diff --git a/src/live_effects/parameter/random.cpp b/src/live_effects/parameter/random.cpp index 42f50656f4..f88855cf1e 100644 --- a/src/live_effects/parameter/random.cpp +++ b/src/live_effects/parameter/random.cpp @@ -171,7 +171,7 @@ RandomParam::param_newWidget() regrandom->signal_button_release_event().connect(sigc::mem_fun (*this, &RandomParam::on_button_release)); regrandom->set_undo_parameters(_("Change random parameter"), INKSCAPE_ICON("dialog-path-effects")); - + regrandom->get_style_context()->add_class("lpeparam"); return dynamic_cast (regrandom); } diff --git a/src/live_effects/parameter/satellite.cpp b/src/live_effects/parameter/satellite.cpp index 8481f642ff..b69baa51ed 100644 --- a/src/live_effects/parameter/satellite.cpp +++ b/src/live_effects/parameter/satellite.cpp @@ -285,7 +285,7 @@ Gtk::Widget *SatelliteParam::param_newWidget() pButton->set_tooltip_text(_("Link to item on clipboard")); _widget->show_all_children(); - + _widget->get_style_context()->add_class("lpeparam"); return dynamic_cast(_widget); } diff --git a/src/live_effects/parameter/satellitearray.cpp b/src/live_effects/parameter/satellitearray.cpp index b678bc171f..4c03cf64b4 100644 --- a/src/live_effects/parameter/satellitearray.cpp +++ b/src/live_effects/parameter/satellitearray.cpp @@ -390,7 +390,7 @@ Gtk::Widget *SatelliteArrayParam::param_newWidget() vbox->pack_end(*hbox, Gtk::PACK_SHRINK); vbox->show_all_children(true); - + vbox->get_style_context()->add_class("lpeparam"); return vbox; } diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp index ea0171dc2e..42b677e7d3 100644 --- a/src/live_effects/parameter/text.cpp +++ b/src/live_effects/parameter/text.cpp @@ -153,6 +153,7 @@ TextParam::param_newWidget() text_container->pack_start(*set, false, false, 2); Gtk::Widget *return_widg = dynamic_cast (text_container); return_widg->set_halign(Gtk::ALIGN_END); + return_widg->get_style_context()->add_class("lpeparam"); return return_widg; } diff --git a/src/live_effects/parameter/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp index 6b8550730a..58f1953e2e 100644 --- a/src/live_effects/parameter/togglebutton.cpp +++ b/src/live_effects/parameter/togglebutton.cpp @@ -141,6 +141,7 @@ ToggleButtonParam::param_newWidget() checkwdg->set_undo_parameters(_("Change togglebutton parameter"), INKSCAPE_ICON("dialog-path-effects")); _toggled_connection = checkwdg->signal_toggled().connect(sigc::mem_fun(*this, &ToggleButtonParam::toggled)); + checkwdg->get_style_context()->add_class("lpeparam"); return checkwdg; } diff --git a/src/live_effects/parameter/transformedpoint.cpp b/src/live_effects/parameter/transformedpoint.cpp index 21e090ea84..e1753f5bbd 100644 --- a/src/live_effects/parameter/transformedpoint.cpp +++ b/src/live_effects/parameter/transformedpoint.cpp @@ -123,7 +123,7 @@ TransformedPointParam::param_newWidget() Gtk::Box * hbox = Gtk::manage( new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL) ); hbox->pack_start(*pointwdg, true, true); hbox->show_all_children(); - + hbox->get_style_context()->add_class("lpeparam"); return dynamic_cast (hbox); } diff --git a/src/live_effects/parameter/unit.cpp b/src/live_effects/parameter/unit.cpp index 7be0fc20b3..cd712af190 100644 --- a/src/live_effects/parameter/unit.cpp +++ b/src/live_effects/parameter/unit.cpp @@ -92,7 +92,7 @@ UnitParam::param_newWidget() unit_menu->setUnit(unit->abbr); unit_menu->set_undo_parameters(_("Change unit parameter"), INKSCAPE_ICON("dialog-path-effects")); - + unit_menu->get_style_context()->add_class("lpeparam"); return dynamic_cast (unit_menu); } diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp index f421f4d56d..dc5ec2b2f5 100644 --- a/src/live_effects/parameter/vector.cpp +++ b/src/live_effects/parameter/vector.cpp @@ -120,7 +120,7 @@ VectorParam::param_newWidget() Gtk::Box * hbox = Gtk::manage( new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL) ); hbox->pack_start(*pointwdg, true, true); hbox->show_all_children(); - + hbox->get_style_context()->add_class("lpeparam"); return dynamic_cast (hbox); } diff --git a/src/ui/dialog/livepatheffect-add.cpp b/src/ui/dialog/livepatheffect-add.cpp index 150aada2c6..5105d93ee6 100644 --- a/src/ui/dialog/livepatheffect-add.cpp +++ b/src/ui/dialog/livepatheffect-add.cpp @@ -450,7 +450,7 @@ bool LivePathEffectAdd::fav_toggler(GdkEventButton *evt, Glib::RefPtrget_text()); LPESelectorEffect->get_parent()->get_style_context()->remove_class("lpefav"); LPESelectorEffect->get_parent()->get_style_context()->add_class("lpenormal"); - LPESelectorEffect->get_parent()->get_style_context()->add_class("lpe"); + LPESelectorEffect->get_parent()->get_style_context()->add_class("lpeparam"); if (_showfavs) { reload_effect_list(); } @@ -462,7 +462,7 @@ bool LivePathEffectAdd::fav_toggler(GdkEventButton *evt, Glib::RefPtrget_text()); LPESelectorEffect->get_parent()->get_style_context()->add_class("lpefav"); LPESelectorEffect->get_parent()->get_style_context()->remove_class("lpenormal"); - LPESelectorEffect->get_parent()->get_style_context()->add_class("lpe"); + LPESelectorEffect->get_parent()->get_style_context()->add_class("lpeparam"); } } return true; @@ -786,7 +786,7 @@ int LivePathEffectAdd::on_sort(Gtk::FlowBoxChild *child1, Gtk::FlowBoxChild *chi LPESelectorEffectEventFavTop->set_halign(Gtk::ALIGN_END); LPESelectorEffectEventFavTop->set_valign(Gtk::ALIGN_START); } - child1->get_style_context()->add_class("lpe"); + child1->get_style_context()->add_class("lpeparam"); } } } @@ -903,7 +903,7 @@ int LivePathEffectAdd::on_sort(Gtk::FlowBoxChild *child1, Gtk::FlowBoxChild *chi LPESelectorEffectEventFavTop->set_halign(Gtk::ALIGN_END); LPESelectorEffectEventFavTop->set_valign(Gtk::ALIGN_START); } - child2->get_style_context()->add_class("lpe"); + child2->get_style_context()->add_class("lpeparam"); } } } diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 0771722d58..95d7e1d939 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -27,6 +27,7 @@ #include "object/sp-tspan.h" #include "object/sp-item-group.h" #include "object/sp-text.h" +#include "svg/css-ostringstream.h" #include "ui/tools/node-tool.h" #include "ui/widget/custom-tooltip.h" #include "util/optstr.h" @@ -181,7 +182,7 @@ LivePathEffectEditor::is_appliable(LivePathEffect::EffectType etype, Glib::ustri return appliable; } -void align(Gtk::Widget* top) { +void align(Gtk::Widget* top, Glib::RefPtr _lpewidgetsprovider) { auto box = dynamic_cast(top); if (!box) return; @@ -210,13 +211,6 @@ void align(Gtk::Widget* top) { } } }); - // align - for_child_n(0, [=](Gtk::Widget* child) { - if (auto label = dynamic_cast(child)) { - label->set_size_request(max_width); - } - }); - // column 1 - align spin buttons, if any int button_width = 0; for_child_n(1, [&](Gtk::Widget* child) { @@ -229,11 +223,17 @@ void align(Gtk::Widget* top) { }); // set min size for comboboxes, if any int combo_size = button_width > 0 ? button_width : 50; // match with spinbuttons, or just min of 50px - for_child_n(1, [=](Gtk::Widget* child) { - if (auto combo = dynamic_cast(child)) { - combo->set_size_request(combo_size); - } - }); + auto screen = Gdk::Screen::get_default(); + Gtk::StyleContext::remove_provider_for_screen(screen,_lpewidgetsprovider); + std::cout << max_width << "AA" << combo_size << std::endl; + Inkscape::CSSOStringStream os; + os.precision(0); + os << ""; //".lpeparam label { min-width: " << max_width << "px; } .lpeparam box label ~ * box label { min-width:1px;} .lpeparam box label ~ * box label + label { /*margin-left:-40px;*/} .lpeparam combo { min-width: " << combo_size << "px; }"; + _lpewidgetsprovider->load_from_data(os.str()); + + // note: priority set to APP - 1 to make sure styles.css take precedence over generic font-size + Gtk::StyleContext::add_provider_for_screen(screen, _lpewidgetsprovider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION - 1); + } void @@ -616,7 +616,7 @@ LivePathEffectEditor::showParams(std::pairadd(*effectwidget); expanderdata.first->show_all_children(); - align(effectwidget); + align(effectwidget, _lpewidgetsprovider); // fixme: add resizing of dialog lpe->refresh_widgets = false; ensure_size(); diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h index bc54e255d8..858b888746 100644 --- a/src/ui/dialog/livepatheffect-editor.h +++ b/src/ui/dialog/livepatheffect-editor.h @@ -17,6 +17,7 @@ #include "ui/widget/completion-popup.h" #include "ui/column-menu-builder.h" #include +#include namespace Inkscape { namespace UI { @@ -102,6 +103,7 @@ private: bool _has_mask; bool _frezee = false; sigc::connection *resize_connection = nullptr; + Glib::RefPtr _lpewidgetsprovider = Gtk::CssProvider::create(); }; } // namespace Dialog -- GitLab