72 Gtk::Requisition minDummy;
73 widget.get_preferred_size (minDummy, natSize);
77 queryNaturalHeight (Gtk::Widget
const& widget)
79 int minDummy{0}, natHeight{0};
80 widget.get_preferred_height(minDummy, natHeight);
85 queryNaturalWidth (Gtk::Widget
const& widget)
87 int minDummy{0}, natWidth{0};
88 widget.get_preferred_width(minDummy, natWidth);
101 initIconSizeHeuristic (Gtk::Widget
const& icon)
112 IDLabel::~IDLabel() { }
113 ElementBoxWidget::~ElementBoxWidget() { }
117 ElementBoxWidget::Config::getIconID()
const 120 return ICON_placement;
124 ElementBoxWidget::Config::getMenuSymb()
const 127 return ICON_arrow_hand_menu;
131 ElementBoxWidget::Config::getIconSize()
const 134 return Gtk::ICON_SIZE_MENU;
142 if (widthConstraint_)
143 strategy.getWidth = move(widthConstraint_);
144 if (heightConstraint_)
145 strategy.getHeight = move(heightConstraint_);
150 IDLabel::IDLabel (
Literal iconID,
Literal menuSymb, Gtk::IconSize siz)
151 : Gtk::Box{Gtk::ORIENTATION_HORIZONTAL}
152 , imgIcon_{Gtk::StockID{iconID}, siz}
153 , imgMenu_{Gtk::StockID{menuSymb}, siz}
155 icon_.set_image(imgIcon_);
156 menu_.set_image(imgMenu_);
160 this->set_name(ID_idlabel);
162 this->get_style_context()->add_class(CLASS_idlabel);
163 icon_.get_style_context()->add_class(CLASS_idlabel_icon);
164 menu_.get_style_context()->add_class(CLASS_idlabel_menu);
165 name_.get_style_context()->add_class(CLASS_idlabel_name);
166 name_.set_hexpand(
true);
169 initIconSizeHeuristic (icon_);
174 IDLabel::setCaption(cuString& idCaption)
176 name_.set_text(idCaption);
184 IDLabel::getCaption()
const 186 return name_.get_text();
194 , label_{config.getIconID()
195 ,config.getMenuSymb()
196 ,config.getIconSize()}
199 set_name (ID_element);
201 get_style_context()->add_class (CLASS_elementbox);
204 frame_.set_label_align (0.0, 0.0);
205 frame_.set_label_widget(label_);
209 label_.setCaption (config.getName());
214 ElementBoxWidget::setName (cuString& nameID)
216 label_.setCaption (nameID);
220 ElementBoxWidget::getName()
const 222 return label_.getCaption();
234 return Gtk::SizeRequestMode::SIZE_REQUEST_HEIGHT_FOR_WIDTH;
262 if (strategy_.is_size_constrained())
263 minimum_width = natural_width = strategy_.getWidth();
265 _Base::get_preferred_width_vfunc (minimum_width,natural_width);
275 if (strategy_.shall_control_height())
276 minimum_height = natural_height = strategy_.getHeight();
278 _Base::get_preferred_height_vfunc (minimum_height,natural_height);
282 ElementBoxWidget::get_preferred_height_for_width_vfunc (
int width,
int& minimum_height,
int& natural_height)
const 284 if (strategy_.is_size_constrained() and strategy_.shall_control_height())
285 minimum_height = natural_height = strategy_.getHeight();
287 _Base::get_preferred_height_for_width_vfunc (width, minimum_height,natural_height);
304 if (strategy_.is_size_constrained())
306 _Base::on_size_allocate(availableSize);
321 label_.imposeSizeConstraint (widthC, heightC);
334 if ( labelFullSize_.width > widthC
335 or labelFullSize_.height > heightC
349 int widthReduction{0};
350 if (icon.get_visible())
352 widthReduction = queryNaturalWidth (icon);
355 return widthReduction;
364 if (label.get_visible())
366 int width = queryNaturalWidth (label);
370 if (reduction < goal)
388 maybeShow(Gtk::Button& icon,
int w,
int h, FUN& reCheck)
390 if (icon.is_visible())
return true;
395 if (not (success=reCheck()))
403 maybeShow(Gtk::Label& label,
int w,
int h, FUN& reCheck)
411 int width = queryNaturalWidth (label);
412 int goal = width - w;
415 if (not (success=reCheck()))
439 int currH = queryNaturalHeight (*
this);
450 int currW = queryNaturalWidth (*
this);
453 int goal = currW - widthC;
455 if ((goal -=
reduce(name_, goal)) <= 0)
return;
456 if ((goal -=
reduce(menu_) ) <= 0)
return;
457 if ((goal -=
reduce(icon_) ) <= 0)
return;
458 currW = queryNaturalWidth(*
this);
459 goal = currW - widthC;
460 ENSURE (goal <= 0,
"IDLabel layout management floundered. " 461 "Removed all content, yet remaining width %d > %d" 466 int headroom = widthC - currW;
467 auto reCheck = [&]() ->
bool 469 currW = queryNaturalWidth (*
this);
470 currH = queryNaturalHeight(*
this);
471 headroom = widthC - currW;
472 return currH <= heightC
476 if (not maybeShow (icon_, headroom, heightC, reCheck))
return;
477 if (not maybeShow (menu_, headroom, heightC, reCheck))
return;
478 if (not maybeShow (name_, headroom, heightC, reCheck))
return;
cuString CLASS_background
opaque backdrop
cuString CLASS_elementbox_idlabel
only present on IDLabel widget within ElementBoxWidget
inline string literal This is a marker type to indicate that
Lumiera GTK UI implementation root.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Definition of access keys for uniform UI styling.
A set of basic GTK includes for the UI.