diff --git a/src/ui/iconview-item-factory.h b/src/ui/iconview-item-factory.h index 750d30e4c1a15ef2b84cc8d286d855442e3b7fc3..e21893692e198c7d624e3f778ac9426cb888e2da 100644 --- a/src/ui/iconview-item-factory.h +++ b/src/ui/iconview-item-factory.h @@ -20,6 +20,7 @@ class IconViewItemFactory { public: struct ItemData { Glib::ustring label_markup; + Glib::ustring name_markup; Glib::RefPtr image; Glib::ustring tooltip; }; @@ -62,10 +63,15 @@ private: box->set_start_widget(*image); // add a label below the picture if (_enable_labels) { - auto label = Gtk::make_managed(); - label->set_vexpand(); - label->set_valign(Gtk::Align::START); - box->set_end_widget(*label); + auto name_label = Gtk::make_managed(); + name_label->set_vexpand(false); + name_label->set_valign(Gtk::Align::START); + box->set_center_widget(*name_label); + + auto dim_label = Gtk::make_managed(); + dim_label->set_vexpand(false); + dim_label->set_valign(Gtk::Align::END); + box->set_end_widget(*dim_label); } list_item->set_child(*box); @@ -78,7 +84,8 @@ private: if (!box) return; auto image = dynamic_cast(box->get_start_widget()); if (!image) return; - auto label = dynamic_cast(box->get_end_widget()); + auto name_label = dynamic_cast(box->get_center_widget()); + auto dim_label = dynamic_cast(box->get_end_widget()); auto item_data = _get_item_data(item); @@ -92,14 +99,23 @@ private: auto height = tex ? tex->get_intrinsic_height() / scale : 0; image->set_size_request(width, height); - if (label) { - label->set_markup(item_data.label_markup); - label->set_max_width_chars(std::min(5 + width / 10, 12)); - label->set_wrap(); - label->set_wrap_mode(Pango::WrapMode::WORD_CHAR); - label->set_natural_wrap_mode(Gtk::NaturalWrapMode::WORD); - label->set_justify(Gtk::Justification::CENTER); - label->set_valign(Gtk::Align::START); + if (name_label) { + name_label->set_markup(item_data.name_markup); + name_label->set_max_width_chars(std::min(5 + width / 10, 12)); + name_label->set_wrap(); + name_label->set_wrap_mode(Pango::WrapMode::WORD_CHAR); + name_label->set_natural_wrap_mode(Gtk::NaturalWrapMode::WORD); + name_label->set_justify(Gtk::Justification::CENTER); + name_label->set_valign(Gtk::Align::START); + } + if (dim_label) { + dim_label->set_markup(item_data.label_markup); + dim_label->set_max_width_chars(std::min(5 + width / 10, 12)); + dim_label->set_wrap(); + dim_label->set_wrap_mode(Pango::WrapMode::WORD_CHAR); + dim_label->set_natural_wrap_mode(Gtk::NaturalWrapMode::WORD); + dim_label->set_justify(Gtk::Justification::CENTER); + dim_label->set_valign(Gtk::Align::END); } if (_use_markup) { diff --git a/src/ui/widget/template-list.cpp b/src/ui/widget/template-list.cpp index 2cc3b81fc88c83576fd15e1d3eec19d31d96e129..4aab1fe029933d4ee9713d098a87e5d1d2e9fcff 100644 --- a/src/ui/widget/template-list.cpp +++ b/src/ui/widget/template-list.cpp @@ -199,9 +199,8 @@ Glib::RefPtr> TemplateList::generate_ auto tmpl = std::dynamic_pointer_cast(ptr); if (!tmpl) return {}; - auto label = tmpl->label.empty() ? tmpl->name : - tmpl->name + "\n\n" + tmpl->label + ""; - return { .label_markup = label, .image = tmpl->icon, .tooltip = tmpl->tooltip }; + auto label = tmpl->label.empty() ? "" : tmpl->label; + return { .label_markup = "" + label + "", .name_markup = tmpl->name, .image = tmpl->icon, .tooltip = tmpl->tooltip }; }); icons.set_max_columns(30); icons.set_tab_behavior(Gtk::ListTabBehavior::ITEM); // don't steal the tab key