diff options
| -rw-r--r-- | share/icons/hicolor/symbolic/actions/text_outer_style-symbolic.svg | 89 | ||||
| -rw-r--r-- | share/ui/style.css | 6 | ||||
| -rw-r--r-- | src/ui/toolbar/text-toolbar.cpp | 166 | ||||
| -rw-r--r-- | src/ui/toolbar/text-toolbar.h | 20 | ||||
| -rw-r--r-- | src/ui/widget/combo-tool-item.cpp | 3 |
5 files changed, 189 insertions, 95 deletions
diff --git a/share/icons/hicolor/symbolic/actions/text_outer_style-symbolic.svg b/share/icons/hicolor/symbolic/actions/text_outer_style-symbolic.svg index 675007e8e..3f095d41f 100644 --- a/share/icons/hicolor/symbolic/actions/text_outer_style-symbolic.svg +++ b/share/icons/hicolor/symbolic/actions/text_outer_style-symbolic.svg @@ -1,41 +1,78 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://web.resource.org/cc/" + xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" - xmlns:xlink="http://www.w3.org/1999/xlink" - xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" id="svg1" width="28" height="28" - > + version="1.1" + sodipodi:docname="text_outer_style-symbolic.svg" + inkscape:version="1.0alpha2 (7029881c03, 2019-06-24, custom)"> + <metadata + id="metadata94"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> <sodipodi:namedview id="base" showgrid="true" - gridspacingy="1pt" - gridspacingx="1pt" - gridoriginy="0pt" - gridoriginx="0pt" - /> - <defs id="defs3"> - - </defs> -<g id="text_outer_style" transform="translate(0,0)"> - <rect height="28" id="text_outer_style_rect" style="fill:none" width="28" x="0" y="0"/> - <g aria-label="T" style="font-weight:bold;font-size:20px;font-family:sans-serif;text-anchor:middle;fill:#4d4d4d;stroke:#000000;stroke-width:0.75"> - <path d="m 2.28125,2.4199219 h 13.4375 V 5.2617187 H 10.884766 V 17 H 7.125 V 5.2617187 H 2.28125 Z" id="BigT"/> + inkscape:document-rotation="0" + inkscape:zoom="5.6" + inkscape:cx="7.046511" + inkscape:cy="44.985506" + inkscape:window-width="1360" + inkscape:window-height="704" + inkscape:window-x="0" + inkscape:window-y="27" + inkscape:window-maximized="1" + inkscape:current-layer="svg1"> + <inkscape:grid + id="GridFromPre046Settings" + type="xygrid" + originx="0pt" + originy="0pt" + spacingx="1pt" + spacingy="1pt" + color="#3f3fff" + empcolor="#3f3fff" + opacity="0.15" + empopacity="0.38" + empspacing="5" /> + </sodipodi:namedview> + <defs + id="defs3" /> + <g + id="text_outer_style" + transform="translate(0,0)"> + <rect + height="28" + id="text_outer_style_rect" + style="opacity:0" + width="28" + x="0" + y="0" /> + <g + aria-label="T" + style="font-weight:bold;font-size:20px;font-family:sans-serif;text-anchor:middle;fill:#4d4d4d;stroke:#000000;stroke-width:0.75" + id="g82" /> + <g + aria-label="T" + style="font-weight:bold;font-size:12px;font-family:sans-serif;text-anchor:middle;fill:#4d4d4d;stroke:#000000;stroke-width:0.75" + id="g85" /> + <path + id="path921" + d="M 20,1.25 A 0.75,0.75 0 0 0 19.25,2 0.75,0.75 0 0 0 20,2.75 h 5.25 v 22.5 H 2.75 V 10 A 0.75,0.75 0 0 0 2,9.25 0.75,0.75 0 0 0 1.25,10 V 26 A 0.750075,0.750075 0 0 0 2,26.75 H 26 A 0.750075,0.750075 0 0 0 26.75,26 V 2 A 0.750075,0.750075 0 0 0 26,1.25 Z m -6.03125,12.001953 h 8.0625 v 1.705078 H 19.130859 V 22 H 16.875 V 14.957031 H 13.96875 Z M 2.28125,2.4199219 h 13.4375 V 5.2617187 H 10.884766 V 17 H 7.125 V 5.2617187 H 2.28125 Z" /> </g> - <g aria-label="T" style="font-weight:bold;font-size:12px;font-family:sans-serif;text-anchor:middle;fill:#4d4d4d;stroke:#000000;stroke-width:0.75"> - <path d="m 13.96875,13.251953 h 8.0625 v 1.705078 H 19.130859 V 22 H 16.875 v -7.042969 h -2.90625 z" id="LittleT"/> - </g> - <path d="m 20,2 h 6 V 26 H 2 V 10" id="text_outer_style_path1" style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round"/> - <path d="M 3,3 H 15" id="text_outer_style_path2" style="fill:none;stroke:#999999;stroke-width:0.75;stroke-linecap:round"/> - <path d="M 7.8,5.5 V 16.25" id="text_outer_style_path3" style="fill:none;stroke:#999999;stroke-width:0.75;stroke-linecap:round"/> - <path d="m 14.6,13.75 h 6.8" id="text_outer_style_path4" style="fill:#4d4d4d;stroke:#999999;stroke-width:0.5;stroke-linecap:round"/> - <path d="m 17.5,14.85 v 6.5" id="text_outer_style_path5" style="fill:#4d4d4d;stroke:#999999;stroke-width:0.5;stroke-linecap:round"/> -</g> - </svg> diff --git a/share/ui/style.css b/share/ui/style.css index cb3f3aaee..84aec2223 100644 --- a/share/ui/style.css +++ b/share/ui/style.css @@ -328,6 +328,12 @@ spinbutton undershoot { font-size: 7pt; } +#line_spacing_menu > box *{ + margin:1px; +} + + + /* The actual canvas (Inkscape's drawing area). */ SPCanvas { diff --git a/src/ui/toolbar/text-toolbar.cpp b/src/ui/toolbar/text-toolbar.cpp index 8b0698c06..364333311 100644 --- a/src/ui/toolbar/text-toolbar.cpp +++ b/src/ui/toolbar/text-toolbar.cpp @@ -267,10 +267,12 @@ TextToolbar::TextToolbar(SPDesktop *desktop) _tracker->addUnit(unit_table.getUnit("em")); _tracker->addUnit(unit_table.getUnit("ex")); _tracker->setActiveUnit(unit_table.getUnit("%")); - _hamburger_menu = Gtk::manage(new Gtk::Popover()); - - _hamburger_menu_content = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); - _hamburger_menu->add(*_hamburger_menu_content); + _line_spacing_menu = Gtk::manage(new Gtk::Popover()); + _line_spacing_menu->set_modal(false); + _line_spacing_menu->signal_closed().connect(sigc::mem_fun(*this, &TextToolbar::line_height_popover_closed)); + _line_spacing_menu->set_name("line_spacing_advanced"); + _line_spacing_menu_content = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); + _line_spacing_menu->add(*_line_spacing_menu_content); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -343,17 +345,6 @@ TextToolbar::TextToolbar(SPDesktop *desktop) add_separator(); - /* Text outer style */ - { - _outer_style_item = Gtk::manage(new Gtk::ToggleToolButton()); - _outer_style_item->set_label(_("Show outer style")); - _outer_style_item->set_tooltip_text(_("Show style of outermost text element. The 'font-size' and 'line-height' values of the outermost text element determine the minimum line spacing in the block.")); - _outer_style_item->set_icon_name(INKSCAPE_ICON("text_outer_style")); - _hamburger_menu_content->pack_start(*_outer_style_item, 10, false, false); - _outer_style_item->signal_toggled().connect(sigc::mem_fun(*this, &TextToolbar::outer_style_changed)); - // need to set_active status *after* a bunch of other widgets. See end of this function. - } - /* Font size */ { // List of font sizes for drop-down menu @@ -379,6 +370,53 @@ TextToolbar::TextToolbar(SPDesktop *desktop) _font_size_item->signal_changed().connect(sigc::mem_fun(*this, &TextToolbar::fontsize_value_changed)); add(*_font_size_item); } + /* line_spacing Menu */ + { + _line_spacing_menu_launcher = Gtk::manage(new Gtk::ToggleToolButton()); + _line_spacing_menu_launcher->set_label(_("Line height options")); + _line_spacing_menu_launcher->set_tooltip_text(_("Show line height options")); + _line_spacing_menu_launcher->set_icon_name(INKSCAPE_ICON("text_line_spacing")); + _line_spacing_menu_launcher->set_name("line_spacing_menu_launcher"); + _line_spacing_menu->set_relative_to(*_line_spacing_menu_launcher); + _line_spacing_menu->set_name("line_spacing_menu"); + _line_spacing_menu->set_default_widget(*_line_spacing_menu_launcher); + _line_spacing_menu_launcher->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &TextToolbar::poptoggle), _line_spacing_menu_launcher)); + add(*_line_spacing_menu_launcher); + } + /* Line height */ + { + // Drop down menu + std::vector<Glib::ustring> labels = {_("Smaller spacing"), "", "", "", "", C_("Text tool", "Normal"), "", "", "", "", "", _("Larger spacing")}; + std::vector<double> values = { 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 2.0}; + + auto line_height_val = prefs->getDouble("/tools/text/lineheight", 1.15); + _line_height_adj = Gtk::Adjustment::create(line_height_val, 0.0, 1000.0, 0.1, 1.0); + _line_height_item = Gtk::manage(new UI::Widget::SpinButtonToolItem("text-line-height", "", _line_height_adj, 0.1, 2)); + _line_height_item->set_tooltip_text(_("Spacing between baselines")); + _line_height_item->set_custom_numeric_menu_data(values, labels); + _line_height_item->set_focus_widget(Glib::wrap(GTK_WIDGET(desktop->canvas))); + _line_height_adj->signal_value_changed().connect(sigc::mem_fun(*this, &TextToolbar::lineheight_value_changed)); + //_tracker->addAdjustment(_line_height_adj->gobj()); // (Alex V) Why is this commented out? + add(*_line_height_item); + _line_height_item->set_sensitive(true); + } + /* Line height units */ + { + _line_height_units_item = _tracker->create_tool_item( _("Units"), ("") ); + _line_spacing_menu_content->pack_start(*_line_height_units_item, 10, false, false); + _line_height_units_item->signal_changed_after().connect(sigc::mem_fun(*this, &TextToolbar::lineheight_unit_changed)); + } + + /* Text outer style */ + { + _outer_style_item = Gtk::manage(new Gtk::ToggleToolButton()); + _outer_style_item->set_label(_("Show outer style")); + _outer_style_item->set_tooltip_text(_("Show style of outermost text element. The 'font-size' and 'line-height' values of the outermost text element determine the minimum line spacing in the block.")); + _outer_style_item->set_icon_name(INKSCAPE_ICON("text_outer_style")); + _line_spacing_menu_content->pack_start(*_outer_style_item, 10, false, false); + _outer_style_item->signal_toggled().connect(sigc::mem_fun(*this, &TextToolbar::outer_style_changed)); + // need to set_active status *after* a bunch of other widgets. See end of this function. + } /* Text line height unset */ { @@ -386,7 +424,7 @@ TextToolbar::TextToolbar(SPDesktop *desktop) _line_height_unset_item->set_label(_("Unset line height")); _line_height_unset_item->set_tooltip_text(_("If enabled, line height is set on part of selection. Click to unset.")); _line_height_unset_item->set_icon_name(INKSCAPE_ICON("paint-unknown")); - _hamburger_menu_content->pack_start(*_line_height_unset_item, 10, false, false); + _line_spacing_menu_content->pack_start(*_line_height_unset_item, 10, false, false); _line_height_unset_item->signal_toggled().connect(sigc::mem_fun(*this, &TextToolbar::lineheight_unset_changed)); _line_height_unset_item->set_active(prefs->getBool("/tools/text/line_height_unset", false)); } @@ -429,29 +467,24 @@ TextToolbar::TextToolbar(SPDesktop *desktop) store ); // Tree store _line_spacing_item->use_icon(true); _line_spacing_item->use_label(true); - std::cout << prefs->getEntry("/tools/text/default_line_spacing_mode").isValid() << "jjjjjjj" << std::endl; - if (!prefs->getEntry("/tools/text/default_line_spacing_mode").isValid()) { - prefs->setInt("/tools/text/default_line_spacing_mode",0); - } + gint mode = prefs->getInt("/tools/text/line_spacing_mode", 0); _line_spacing_item->set_active( mode ); - _hamburger_menu_content->pack_start(*_line_spacing_item,10, false, false); + _line_spacing_menu_content->pack_start(*_line_spacing_item,10, false, false); _line_spacing_item->signal_changed().connect(sigc::mem_fun(*this, &TextToolbar::line_spacing_mode_changed)); } - /* Hamburger Menu */ + Gtk::SeparatorToolItem *separator = Gtk::manage(new Gtk::SeparatorToolItem()); + _line_spacing_menu_content->pack_start(*separator, 10, false, false); + /* Line height set to defaults */ { - _hamburger_menu_launcher = Gtk::manage(new Gtk::ToggleToolButton()); - _hamburger_menu_launcher->set_label(_("More options")); - _hamburger_menu_launcher->set_tooltip_text(_("Toggle show more options")); - _hamburger_menu_launcher->set_icon_name(INKSCAPE_ICON("hamburger-menu")); - _hamburger_menu_launcher->set_name("hamburger-menu-launcher"); - _hamburger_menu->set_relative_to(*_hamburger_menu_launcher); - _hamburger_menu->set_name("hamburger-menu"); - _hamburger_menu->set_default_widget(*_hamburger_menu_launcher); - _hamburger_menu_launcher->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &TextToolbar::poptoggle), _hamburger_menu_launcher)); - add(*_hamburger_menu_launcher); + _line_spacing_defaulting = Gtk::manage(new Gtk::ToolButton()); + _line_spacing_defaulting->set_label("Press to apply the most common default values"); + _line_spacing_defaulting->set_tooltip_text(_("Press to apply the most common default values")); + _line_spacing_defaulting->set_icon_name("edit-clear"); + _line_spacing_menu_content->pack_start(*_line_spacing_defaulting, 10, false, false); + _line_spacing_defaulting->signal_clicked().connect(sigc::mem_fun(*this, &TextToolbar::lineheight_defaulting)); } /* Alignment */ @@ -525,31 +558,6 @@ TextToolbar::TextToolbar(SPDesktop *desktop) _subscript_item->set_active(prefs->getBool("/tools/text/sub", false)); } - /* Line height */ - { - // Drop down menu - std::vector<Glib::ustring> labels = {_("Smaller spacing"), "", "", "", "", C_("Text tool", "Normal"), "", "", "", "", "", _("Larger spacing")}; - std::vector<double> values = { 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 2.0}; - - auto line_height_val = prefs->getDouble("/tools/text/lineheight", 0.0); - _line_height_adj = Gtk::Adjustment::create(line_height_val, 0.0, 1000.0, 0.1, 1.0); - _line_height_item = Gtk::manage(new UI::Widget::SpinButtonToolItem("text-line-height", _("Line:"), _line_height_adj, 0.1, 2)); - _line_height_item->set_tooltip_text(_("Spacing between baselines")); - _line_height_item->set_custom_numeric_menu_data(values, labels); - _line_height_item->set_focus_widget(Glib::wrap(GTK_WIDGET(desktop->canvas))); - _line_height_adj->signal_value_changed().connect(sigc::mem_fun(*this, &TextToolbar::lineheight_value_changed)); - //_tracker->addAdjustment(_line_height_adj->gobj()); // (Alex V) Why is this commented out? - add(*_line_height_item); - _line_height_item->set_sensitive(true); - _line_height_item->set_icon(INKSCAPE_ICON("text_line_spacing")); - } - - /* Line height units */ - { - _line_height_units_item = _tracker->create_tool_item( _("Units"), ("") ); - _hamburger_menu_content->pack_start(*_line_height_units_item, 10, false, false); - _line_height_units_item->signal_changed_after().connect(sigc::mem_fun(*this, &TextToolbar::lineheight_unit_changed)); - } /* Letter spacing */ { // Drop down menu @@ -745,7 +753,7 @@ TextToolbar::TextToolbar(SPDesktop *desktop) _direction_item->use_label(false); gint mode = prefs->getInt("/tools/text/text_direction", 0); _direction_item->set_active( mode ); - _hamburger_menu_content->pack_start(*_direction_item,10, false, false); + add(*_direction_item); _direction_item->signal_changed_after().connect(sigc::mem_fun(*this, &TextToolbar::direction_changed)); } add_separator(); @@ -761,6 +769,12 @@ TextToolbar::TextToolbar(SPDesktop *desktop) desktop->connectEventContextChanged(sigc::mem_fun(*this, &TextToolbar::watch_ec)); } + +void TextToolbar::line_height_popover_closed() +{ + _line_spacing_menu_launcher->set_active(false); +} + void TextToolbar::fontfamily_value_changed() { @@ -979,9 +993,9 @@ void TextToolbar::poptoggle(Gtk::ToggleToolButton *btn) { if (btn->get_active()) { - _hamburger_menu->show_all(); + _line_spacing_menu->show_all(); } else { - _hamburger_menu->hide(); + _line_spacing_menu->hide(); } } @@ -1978,6 +1992,30 @@ TextToolbar::lineheight_unset_changed() _freeze = false; } + +// Unset line height on selection's inner text objects (tspan, etc.). +void +TextToolbar::lineheight_defaulting() +{ + // quit if run by the _changed callbacks + if (_freeze) { + return; + } + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setInt("/tools/text/line_spacing_mode", 1); + _line_spacing_item->set_active(1); + _line_height_units_item->set_active(0); + _line_height_units_item->set_sensitive(false); + _line_height_unset_item->set_active(true); + _outer_style_item->set_active(true); + _line_height_adj->set_value(1.15); + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT, + _("Text: Defaulting line height.")); + + _freeze = false; +} + // Changes selection to only text outer elements. void TextToolbar::outer_style_changed() @@ -2272,6 +2310,8 @@ TextToolbar::selection_changed(Inkscape::Selection * /*selection*/, bool subsele if (i->style->line_height.unit != SP_CSS_UNIT_NONE && !(i->style->line_height.normal)) { text_line_height_has_units = true; } + } else { + text_line_height_zero = true; } // TO DO: recursively check children std::vector<SPObject*> children = i->childList(false); @@ -2295,7 +2335,6 @@ TextToolbar::selection_changed(Inkscape::Selection * /*selection*/, bool subsele else mode[3]++; } } - int activeButtonLS = 3; if (mode[0] > 0 && mode[1] == 0 && mode[2] == 0 && mode[3] == 0) activeButtonLS = 0; if (mode[0] == 0 && mode[1] > 0 && mode[2] == 0 && mode[3] == 0) activeButtonLS = 1; @@ -2305,6 +2344,11 @@ TextToolbar::selection_changed(Inkscape::Selection * /*selection*/, bool subsele // << ", "<< mode[2] // << ", "<< mode[3] << std::endl; _line_spacing_item->set_active( activeButtonLS ); + + if (!vec.size()) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + _line_spacing_item->set_active(prefs->getInt("/tools/text/line_spacing_mode", 0)); + } // Enable/disable line height widget based on mode and Outer Style toggle. if ( (activeButtonLS == 0 && outer) || // Adaptive diff --git a/src/ui/toolbar/text-toolbar.h b/src/ui/toolbar/text-toolbar.h index 4c85d3c47..89285e9d0 100644 --- a/src/ui/toolbar/text-toolbar.h +++ b/src/ui/toolbar/text-toolbar.h @@ -32,6 +32,7 @@ #include <gtkmm/popover.h> #include <gtkmm/box.h> +#include <gtkmm/separatortoolitem.h> #include <gtkmm/adjustment.h> class SPDesktop; @@ -67,21 +68,24 @@ private: UI::Widget::ComboBoxEntryToolItem *_font_family_item; UI::Widget::ComboBoxEntryToolItem *_font_size_item; UI::Widget::ComboBoxEntryToolItem *_font_style_item; - Gtk::Popover *_hamburger_menu; - Gtk::Box *_hamburger_menu_content; - Gtk::ToggleToolButton *_hamburger_menu_launcher; + Gtk::Popover *_line_spacing_menu; + Gtk::Box *_line_spacing_menu_content; + Gtk::ToolButton *_line_spacing_defaulting; + Gtk::ToggleToolButton *_line_height_unset_item; + Gtk::ToggleToolButton *_line_spacing_menu_launcher; + UI::Widget::ComboToolItem *_line_height_units_item; + UI::Widget::SpinButtonToolItem *_line_height_item; + UI::Widget::ComboToolItem *_line_spacing_item; Gtk::ToggleToolButton *_superscript_item; Gtk::ToggleToolButton *_subscript_item; Gtk::ToggleToolButton *_outer_style_item; - Gtk::ToggleToolButton *_line_height_unset_item; + + UI::Widget::ComboToolItem *_align_item; UI::Widget::ComboToolItem *_writing_mode_item; UI::Widget::ComboToolItem *_orientation_item; UI::Widget::ComboToolItem *_direction_item; - UI::Widget::ComboToolItem *_line_height_units_item; - UI::Widget::ComboToolItem *_line_spacing_item; - UI::Widget::SpinButtonToolItem *_line_height_item; UI::Widget::SpinButtonToolItem *_word_spacing_item; UI::Widget::SpinButtonToolItem *_letter_spacing_item; UI::Widget::SpinButtonToolItem *_dx_item; @@ -113,6 +117,8 @@ private: void direction_changed(int mode); void lineheight_value_changed(); void lineheight_unit_changed(int not_used); + void lineheight_defaulting(); + void line_height_popover_closed(); void line_spacing_mode_changed(int mode); void wordspacing_value_changed(); void letterspacing_value_changed(); diff --git a/src/ui/widget/combo-tool-item.cpp b/src/ui/widget/combo-tool-item.cpp index 6adafe316..4da817131 100644 --- a/src/ui/widget/combo-tool-item.cpp +++ b/src/ui/widget/combo-tool-item.cpp @@ -54,7 +54,8 @@ ComboToolItem::ComboToolItem(Glib::ustring group_label, _use_pixbuf (true), _icon_size ( Gtk::ICON_SIZE_LARGE_TOOLBAR ), _combobox (nullptr), - _menuitem (nullptr) + _menuitem (nullptr), + _active(0) { Gtk::Box* box = Gtk::manage(new Gtk::Box()); add(*box); |
