ElementBox: investigate and fix problem with label
...as it turned out, the ClipWidget did still invoke the Gtk::Frame::set_label() function, thereby deactivate our elaborate custom IDLabel and showing the label text unconditionally instead (also violating our size constraint)
This commit is contained in:
parent
15e00e01c2
commit
3953bbd5ee
5 changed files with 117 additions and 14 deletions
|
|
@ -199,7 +199,7 @@ namespace timeline {
|
|||
}
|
||||
|
||||
void
|
||||
setClipName(cuString newName) override
|
||||
setClipName(cuString& newName) override
|
||||
{
|
||||
clipName_ = newName;
|
||||
}
|
||||
|
|
@ -274,13 +274,13 @@ namespace timeline {
|
|||
cuString
|
||||
getClipName() const override
|
||||
{
|
||||
return this->get_label();
|
||||
return widget::ElementBoxWidget::getName();
|
||||
}
|
||||
|
||||
void
|
||||
setClipName(cuString newName) override
|
||||
setClipName(cuString& newName) override
|
||||
{
|
||||
this->set_label (newName);
|
||||
widget::ElementBoxWidget::setName (newName);
|
||||
}
|
||||
|
||||
uint
|
||||
|
|
@ -318,7 +318,7 @@ namespace timeline {
|
|||
establishHorizontalExtension()
|
||||
{
|
||||
int hsiz = getCanvas().getMetric().translateTimeToPixels (accessDuration());
|
||||
cout << "Clip:: hsize="<<hsiz<<endl;
|
||||
cout << "Clip:: hsize="<<hsiz<<endl; ////////////////////////////////////////////////////////TICKET #1038 : tracing -- remove this
|
||||
return hsiz;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ namespace timeline {
|
|||
|
||||
/** human readable rendering of the clip's name or identity */
|
||||
virtual cuString getClipName() const =0;
|
||||
virtual void setClipName (cuString) =0;
|
||||
virtual void setClipName (cuString&) =0;
|
||||
|
||||
virtual TimeVar& accessStartTime() =0;
|
||||
virtual TimeVar& accessDuration() =0;
|
||||
|
|
|
|||
|
|
@ -189,19 +189,47 @@ namespace widget {
|
|||
}
|
||||
|
||||
|
||||
cuString
|
||||
IDLabel::getCaption() const
|
||||
{
|
||||
return name_.get_text();
|
||||
namespace {
|
||||
inline bool
|
||||
tmpUnhide (Gtk::Widget& w)
|
||||
{
|
||||
bool was_hidden = not w.is_visible();
|
||||
w.show();
|
||||
return was_hidden;
|
||||
}
|
||||
inline void
|
||||
restoreHide (Gtk::Widget& w, bool was_hidden)
|
||||
{
|
||||
if (was_hidden)
|
||||
w.hide();
|
||||
else
|
||||
w.show();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IDLabel::setCaption(cuString& idCaption)
|
||||
{
|
||||
// can not retrieve size information from hidden widgets...
|
||||
bool hideIcon = tmpUnhide (icon_);
|
||||
bool hideMenu = tmpUnhide (menu_);
|
||||
bool hideName = tmpUnhide (name_);
|
||||
bool hideThis = tmpUnhide (*this);
|
||||
|
||||
name_.set_text(idCaption);
|
||||
show_all();
|
||||
// cache required full display size (for size constrained layout)
|
||||
queryNaturalSize (*this, labelFullSize_);
|
||||
|
||||
restoreHide (icon_, hideThis);
|
||||
restoreHide (menu_, hideName);
|
||||
restoreHide (name_, hideMenu);
|
||||
restoreHide (*this, hideIcon);
|
||||
}
|
||||
|
||||
cuString
|
||||
IDLabel::getCaption() const
|
||||
{
|
||||
return name_.get_text();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -219,10 +247,10 @@ namespace widget {
|
|||
set_label_align(0.0, 0.0);
|
||||
|
||||
set_label_widget(label_);
|
||||
label_.setCaption(config.getName());
|
||||
label_.get_style_context()->add_class(CLASS_elementbox_idlabel);
|
||||
|
||||
this->show_all();
|
||||
label_.setCaption(config.getName());
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -232,6 +260,12 @@ namespace widget {
|
|||
label_.setCaption (nameID);
|
||||
}
|
||||
|
||||
cuString
|
||||
ElementBoxWidget::getName() const
|
||||
{
|
||||
return label_.getCaption();
|
||||
}
|
||||
|
||||
/**
|
||||
* Layout trend for ElementBoxWidget is nailed down (`final`) to "height-for-width".
|
||||
* The reason is, some of the use cases entail placing the element box onto a canvas
|
||||
|
|
@ -446,6 +480,8 @@ namespace widget {
|
|||
IDLabel::adaptSize (int widthC, int heightC)
|
||||
{
|
||||
// first determine if vertical extension is problematic
|
||||
///////////////////////////////////////////////////////////////////////////////TICKET #1038 : tracing -- remove this
|
||||
cout << _Fmt{"IDLb:: adaptSize(%d,%d) i:%b m:%b l:%b"} % widthC % heightC % icon_.is_visible() % menu_.is_visible() % name_.is_visible() <<endl;
|
||||
int currH = queryNaturalHeight (*this);
|
||||
if (currH > heightC)
|
||||
{//hide all child widgets,
|
||||
|
|
|
|||
|
|
@ -169,6 +169,11 @@ namespace widget {
|
|||
// default copy acceptable
|
||||
|
||||
void setName(cuString&);
|
||||
cuString getName() const;
|
||||
|
||||
/// redirect Gtk::Frame setters to ElementBoxWidget
|
||||
void set_label(cuString& s) { setName(s); }
|
||||
cuString get_label() const { return getName(); }
|
||||
|
||||
private:/* ===== Internals ===== */
|
||||
|
||||
|
|
|
|||
|
|
@ -20924,7 +20924,7 @@
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1666286511402" ID="ID_901100748" MODIFIED="1666286681653" TEXT="Constraint-handling versagt u.U für das Label">
|
||||
<node COLOR="#435e98" CREATED="1666286511402" ID="ID_901100748" MODIFIED="1666308082637" TEXT="Constraint-handling versagt u.U für das Label">
|
||||
<icon BUILTIN="broken-line"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1666286569009" ID="ID_571211770" MODIFIED="1666286670640" TEXT="Beispiel: Clip-1 : Duration 1s">
|
||||
<icon BUILTIN="forward"/>
|
||||
|
|
@ -20938,8 +20938,70 @@
|
|||
<icon BUILTIN="broken-line"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1666286588511" ID="ID_1014622465" MODIFIED="1666286603787" TEXT="Untersuchung">
|
||||
<node COLOR="#435e98" CREATED="1666286588511" ID="ID_1014622465" MODIFIED="1666308061322" TEXT="Untersuchung">
|
||||
<icon BUILTIN="yes"/>
|
||||
<node CREATED="1666307200947" ID="ID_712219112" MODIFIED="1666307460841" TEXT="Verdacht: setCaption() manipuliert visibility">
|
||||
<icon BUILTIN="button_cancel"/>
|
||||
<node CREATED="1666307233042" ID="ID_1411306141" MODIFIED="1666307262873" TEXT="...und würde dadurch das differenzierte, partielle Verbergen stören"/>
|
||||
<node CREATED="1666307264414" ID="ID_594632089" MODIFIED="1666307445275" TEXT="⟹ sollte den tatsächlichen visibility-Status wiederherstellen">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
nach dem Setzen eines neuen Label-Texts müssen wir die Länge des IDLabel erneut ausmessen, und dazu müssen alle seine Komponenten vorrübergehend visible() gesetzt werden; hatte bisher darauf gesetzt, daß der size-constraint-Algo dann von selber wieder auf den richtigen Status kommt...
|
||||
</p>
|
||||
</body>
|
||||
</html></richcontent>
|
||||
</node>
|
||||
<node CREATED="1666307446440" ID="ID_165108662" MODIFIED="1666307458008" TEXT="aber das bewirkt rein gar nix">
|
||||
<icon BUILTIN="stop-sign"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1666307466288" ID="ID_1621773970" MODIFIED="1666307492593" TEXT="Hilfe... was passiert hier — Kontrollverlust">
|
||||
<icon BUILTIN="smily_bad"/>
|
||||
<node CREATED="1666307500030" ID="ID_999771663" MODIFIED="1666307518501" TEXT="alle Caption-Setter auskommentiert"/>
|
||||
<node CREATED="1666307519219" ID="ID_757987414" MODIFIED="1666307528695" TEXT="der komische Text ist immer noch da"/>
|
||||
<node CREATED="1666307529508" ID="ID_990701944" MODIFIED="1666307578878" TEXT="und auch der Size-Constraint ist sonderbar(falsch)">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Höhe nur 16px, obwohl doch das Icon mindestens 18px braucht (incl.Border), und das get_required_height() diesen Wert eigentlich liefern sollte
|
||||
</p>
|
||||
</body>
|
||||
</html></richcontent>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#db10ad" CREATED="1666307585634" ID="ID_1666781450" MODIFIED="1666307620469" TEXT="AUA!!">
|
||||
<icon BUILTIN="smiley-oh"/>
|
||||
<node CREATED="1666307623237" ID="ID_1740179483" MODIFIED="1666307643118" TEXT="ClipWidget ruft immer noch Frame::set_label() auf"/>
|
||||
<node CREATED="1666307644363" ID="ID_1158991887" MODIFIED="1666307653429" TEXT="ja in der Tat, die Funktion ist noch sichtbar"/>
|
||||
<node CREATED="1666307654257" ID="ID_662041930" MODIFIED="1666307709729" TEXT="sie schießt unser tolles Custom IDLabel ins Nirvana">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
und schaltet den Frame wieder zurück auf ein Text-Label, das natürlich dann in keinster Weise der size-Constraint-Kontrolle unterliegt
|
||||
</p>
|
||||
</body>
|
||||
</html></richcontent>
|
||||
</node>
|
||||
<node CREATED="1666308020848" ID="ID_1559858341" MODIFIED="1666308033677" TEXT="puh das war aber gut versteckt">
|
||||
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1666308048044" ID="ID_1668793880" MODIFIED="1666308056987" TEXT="dann besser diese Setter überdecken">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#435e98" CREATED="1666308065995" ID="ID_1843697802" MODIFIED="1666308081223" TEXT="Fazit: hat gar nicht versagt...">
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1666286684491" ID="ID_825575865" MODIFIED="1666286709542" TEXT="Clip-Dragging funktioniert nur eingeschränkt">
|
||||
|
|
|
|||
Loading…
Reference in a new issue