Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
element-box-widget.hpp
Go to the documentation of this file.
1/*
2 ELEMENT-BOX-WIDGET.hpp - fundamental UI building block to represent a placed element
3
4 Copyright (C)
5 2018, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
14
40#ifndef STAGE_WIDGET_ELEMENT_BOX_WIDGET_H
41#define STAGE_WIDGET_ELEMENT_BOX_WIDGET_H
42
43#include "stage/gtk-base.hpp"
46
47#include "lib/format-string.hpp"
48#include "lib/symbol.hpp"
49
50#include <functional>
51#include <utility>
52#include <string>
53#include "lib/format-cout.hpp"
54
55
56
57namespace stage {
58namespace widget {
59
60 using std::move;
61 using lib::Literal;
62 using std::string;
63 using util::_Fmt;
64
71
84
85 using SizeGetter = std::function<int()>;
86
87
88
99 class IDLabel
100 : public Gtk::Box
101 {
102 Gtk::Image imgIcon_;
103 Gtk::Image imgMenu_;
104 Gtk::Button icon_;
105 Gtk::Button menu_;
106 Gtk::Label name_;
107
108 public:
109 ~IDLabel();
110 IDLabel(Literal iconID, Literal menuSymb, Gtk::IconSize);
111
112 cuString getCaption() const;
113 void setCaption(cuString&);
114
115 void imposeSizeConstraint(int, int);
116
117 private:
118 Gtk::Requisition labelFullSize_{};
119 void adaptSize (int, int);
120 };
121
122
123
124 /*************************************************************************/
135 : public Gtk::EventBox
136 {
137 using _Base = Gtk::EventBox;
138 struct Strategy
139 {
142
143 bool is_size_constrained() const { return bool(getWidth); }
144 bool shall_control_height() const { return bool(getHeight); }
145 };
146
149
151 Gtk::Frame frame_;
152
153 public:
154 class Config;
155
156 template<class... QS>
157 ElementBoxWidget (Kind kind, Type type, QS ...qualifiers);
158
161
162 // default copy acceptable
163
164 void setName(cuString&);
165 cuString getName() const;
166
168 void set_label(cuString& s) { setName(s); }
169 cuString get_label() const { return getName(); }
170
171 private:/* ===== Internals ===== */
172
173 Gtk::SizeRequestMode get_request_mode_vfunc() const final;
174 void get_preferred_width_vfunc (int&, int&) const override;
175 void get_preferred_height_vfunc (int&, int&) const override;
176 void get_preferred_height_for_width_vfunc (int, int&,int&) const override;
177 void on_size_allocate (Gtk::Allocation&) override;
178
179 void imposeSizeConstraint(int, int);
180 };
181
182
184 : lib::BuilderQualifierSupport<Config>
185 {
187 uString nameID_{"∅"};
190 string logTODO_{nameID_};
191
192 friend Qualifier kind(Kind);
193 friend Qualifier name(string id);
194 friend Qualifier expander(model::Expander&);
195 friend Qualifier constrained(SizeGetter);
196 friend Qualifier constrained(SizeGetter,SizeGetter);
197
198 public:
199 template<class... QS>
200 Config(Type type, Qualifier qual, QS... qs)
201 : type_{type}
202 {
203 qualify(*this, qual, qs...);
204 }
205
207 Strategy buildLayoutStrategy(ElementBoxWidget&);
208
209 Literal getIconID() const;
210 Literal getMenuSymb() const;
211 Gtk::IconSize getIconSize() const;
212
214 getName() const
215 {
216 return nameID_;
217 }
218 };
219
220
222 inline ElementBoxWidget::Config::Qualifier
224 {
225 return ElementBoxWidget::Config::Qualifier{
226 [=](ElementBoxWidget::Config& config)
227 {
228 config.logTODO_ += util::_Fmt{"+kind(%s)"} % kind;
229 }};
230 }
231
233 inline ElementBoxWidget::Config::Qualifier
234 name(string id)
235 {
236 return ElementBoxWidget::Config::Qualifier{
237 [=](ElementBoxWidget::Config& config)
238 {
239 config.nameID_ = id;
240 }};
241 }
242
244 inline ElementBoxWidget::Config::Qualifier
246 {
247 return ElementBoxWidget::Config::Qualifier{
248 [&](ElementBoxWidget::Config& config)
249 {
250 config.logTODO_ += util::_Fmt{"+expander(%s)"} % &expander;
251 }};
252 }
253
259 inline ElementBoxWidget::Config::Qualifier
260 constrained(SizeGetter widthConstraint)
261 {
262 return ElementBoxWidget::Config::Qualifier{
263 [wC=move(widthConstraint)](ElementBoxWidget::Config& config) -> void
264 {
265 config.widthConstraint_ = move(wC);
266 }};
267 }
268
273 inline ElementBoxWidget::Config::Qualifier
274 constrained(SizeGetter widthConstraint, SizeGetter heightConstraint)
275 {
276 return ElementBoxWidget::Config::Qualifier{
277 [wC=move(widthConstraint),hC=move(heightConstraint)]
278 (ElementBoxWidget::Config& config) -> void
279 {
280 config.widthConstraint_ = move(wC);
281 config.heightConstraint_ = move(hC);
282 }};
283 }
284
285
286
292 template<class... QS>
293 inline ElementBoxWidget::ElementBoxWidget (Kind widgetKind, Type type, QS ...qualifiers)
294 : ElementBoxWidget{Config(type, kind(widgetKind), qualifiers...)}
295 { }
296
297
298}}// namespace stage::widget
299#endif /*STAGE_WIDGET_ELEMENT_BOX_WIDGET_H*/
Mix-in to support builder functions to accept optional qualifier terms.
Inline string literal.
Definition symbol.hpp:78
Functor component to support the default implementation of expanding/collapsing.
Config(Type type, Qualifier qual, QS... qs)
A basic building block of the Lumiera UI.
void get_preferred_height_for_width_vfunc(int, int &, int &) const override
void get_preferred_width_vfunc(int &, int &) const override
Layout preferences are delegated through the Strategy.
void on_size_allocate(Gtk::Allocation &) override
Tap into the notification of screen space allocation to possibly enforce size constraints.
ElementBoxWidget(Kind kind, Type type, QS ...qualifiers)
setup an ElementBoxWidget with suitable presentation style.
void imposeSizeConstraint(int, int)
Ensure the child widgets can be represented and possibly adjust or hide content, in case the extensio...
Strategy strategy_
actual layout strategy binding for this widget
Gtk::SizeRequestMode get_request_mode_vfunc() const final
Layout trend for ElementBoxWidget is nailed down (final) to "height-for-width".
void set_label(cuString &s)
redirect Gtk::Frame setters to ElementBoxWidget
void get_preferred_height_vfunc(int &, int &) const override
Widget arrangement to represent an entity for manipulation.
void adaptSize(int, int)
Multi-step procedure to keep this IDLabel widget within the given screen size constraints.
void imposeSizeConstraint(int, int)
Ensure the IDLabel stays within a given size constraint.
A front-end for using printf-style formatting.
Helper components to implement some standard UI-element actions by installing a functor.
Automatically use custom string conversion in C++ stream output.
Front-end for printf-style string template interpolation.
A set of basic GTK includes for the UI.
Implementation namespace for support and library code.
Type
the type of content object to derive suitable styling (background colour, icon)
@ EVENT
represents event streams or live connections
@ VIDEO
represents moving (or still) image data
@ LABEL
represents a label or descriptor
@ EFFECT
represents a processor or transformer
@ RULER
represents an overview ruler or TOC
@ META
represents some meta entity
@ TEXT
represents text content
@ GROUP
represents a container to group other entities
@ AUDIO
represents sound data
@ AUTO
represents automation
std::function< int()> SizeGetter
ElementBoxWidget::Config::Qualifier kind(Kind kind)
qualify the basic use case for the new ElementBoxWidget
ElementBoxWidget::Config::Qualifier name(string id)
define the name-ID displayed in the caption
Kind
the presentation intent for the ElementBoxWidget
@ ITEM
Widget represents an entity within a collection (Bin)
@ SPAN
Widget spans a time range.
@ CONTENT
Widget serves to represent a piece of content (Clip)
@ MARK
Widget is a pin or marks a position.
ElementBoxWidget::Config::Qualifier constrained(SizeGetter widthConstraint)
switch in to size-constrained layout mode.
ElementBoxWidget::Config::Qualifier expander(model::Expander &expander)
provide an expand/collapse button, wired with the given Expander
Lumiera GTK UI implementation root.
Definition guifacade.cpp:37
const uString cuString
Definition gtk-base.hpp:93
Glib::ustring uString
Definition gtk-base.hpp:92
Marker types to indicate a literal string and a Symbol.