81 Gtk::Requisition minDummy;
82 widget.get_preferred_size (minDummy, natSize);
86 queryNaturalHeight (Gtk::Widget
const& widget)
88 int minDummy{0}, natHeight{0};
89 widget.get_preferred_height(minDummy, natHeight);
94 queryNaturalWidth (Gtk::Widget
const& widget)
96 int minDummy{0}, natWidth{0};
97 widget.get_preferred_width(minDummy, natWidth);
110 initIconSizeHeuristic (Gtk::Widget
const& icon)
121 IDLabel::~IDLabel() { }
122 ElementBoxWidget::~ElementBoxWidget() { }
126 ElementBoxWidget::Config::getIconID()
const 129 return ICON_placement;
133 ElementBoxWidget::Config::getMenuSymb()
const 136 return ICON_arrow_hand_menu;
140 ElementBoxWidget::Config::getIconSize()
const 143 return Gtk::ICON_SIZE_MENU;
151 if (widthConstraint_)
152 strategy.getWidth = move(widthConstraint_);
153 if (heightConstraint_)
154 strategy.getHeight = move(heightConstraint_);
159 IDLabel::IDLabel (
Literal iconID,
Literal menuSymb, Gtk::IconSize siz)
160 : Gtk::Box{Gtk::ORIENTATION_HORIZONTAL}
161 , imgIcon_{Gtk::StockID{iconID}, siz}
162 , imgMenu_{Gtk::StockID{menuSymb}, siz}
164 icon_.set_image(imgIcon_);
165 menu_.set_image(imgMenu_);
169 this->set_name(ID_idlabel);
171 this->get_style_context()->add_class(CLASS_idlabel);
172 icon_.get_style_context()->add_class(CLASS_idlabel_icon);
173 menu_.get_style_context()->add_class(CLASS_idlabel_menu);
174 name_.get_style_context()->add_class(CLASS_idlabel_name);
175 name_.set_hexpand(
true);
178 initIconSizeHeuristic (icon_);
183 IDLabel::setCaption(cuString& idCaption)
185 name_.set_text(idCaption);
193 IDLabel::getCaption()
const 195 return name_.get_text();
203 , label_{config.getIconID()
204 ,config.getMenuSymb()
205 ,config.getIconSize()}
208 set_name (ID_element);
210 get_style_context()->add_class (CLASS_elementbox);
213 frame_.set_label_align (0.0, 0.0);
214 frame_.set_label_widget(label_);
218 label_.setCaption (config.getName());
223 ElementBoxWidget::setName (cuString& nameID)
225 label_.setCaption (nameID);
229 ElementBoxWidget::getName()
const 231 return label_.getCaption();
243 return Gtk::SizeRequestMode::SIZE_REQUEST_HEIGHT_FOR_WIDTH;
271 if (strategy_.is_size_constrained())
272 minimum_width = natural_width = strategy_.getWidth();
274 _Base::get_preferred_width_vfunc (minimum_width,natural_width);
284 if (strategy_.shall_control_height())
285 minimum_height = natural_height = strategy_.getHeight();
287 _Base::get_preferred_height_vfunc (minimum_height,natural_height);
291 ElementBoxWidget::get_preferred_height_for_width_vfunc (
int width,
int& minimum_height,
int& natural_height)
const 293 if (strategy_.is_size_constrained() and strategy_.shall_control_height())
294 minimum_height = natural_height = strategy_.getHeight();
296 _Base::get_preferred_height_for_width_vfunc (width, minimum_height,natural_height);
313 if (strategy_.is_size_constrained())
315 _Base::on_size_allocate(availableSize);
330 label_.imposeSizeConstraint (widthC, heightC);
343 if ( labelFullSize_.width > widthC
344 or labelFullSize_.height > heightC
358 int widthReduction{0};
359 if (icon.get_visible())
361 widthReduction = queryNaturalWidth (icon);
364 return widthReduction;
373 if (label.get_visible())
375 int width = queryNaturalWidth (label);
379 if (reduction < goal)
397 maybeShow(Gtk::Button& icon,
int w,
int h, FUN& reCheck)
399 if (icon.is_visible())
return true;
404 if (not (success=reCheck()))
412 maybeShow(Gtk::Label& label,
int w,
int h, FUN& reCheck)
420 int width = queryNaturalWidth (label);
421 int goal = width - w;
424 if (not (success=reCheck()))
448 int currH = queryNaturalHeight (*
this);
459 int currW = queryNaturalWidth (*
this);
462 int goal = currW - widthC;
464 if ((goal -=
reduce(name_, goal)) <= 0)
return;
465 if ((goal -=
reduce(menu_) ) <= 0)
return;
466 if ((goal -=
reduce(icon_) ) <= 0)
return;
467 currW = queryNaturalWidth(*
this);
468 goal = currW - widthC;
469 ENSURE (goal <= 0,
"IDLabel layout management floundered. " 470 "Removed all content, yet remaining width %d > %d" 475 int headroom = widthC - currW;
476 auto reCheck = [&]() ->
bool 478 currW = queryNaturalWidth (*
this);
479 currH = queryNaturalHeight(*
this);
480 headroom = widthC - currW;
481 return currH <= heightC
485 if (not maybeShow (icon_, headroom, heightC, reCheck))
return;
486 if (not maybeShow (menu_, headroom, heightC, reCheck))
return;
487 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.