Investigation: inconclusive further research (context_save/restore)
Indeed I had missed to connect the new "free standing" StyleContext to some Gdk::Screen, typically the default screen (connected to the current top level window). But seemingly this was not really necessary, since, somehow magically, the style context must have connected itself to some screen, otherwise it wouldn't be able to access the CSS cascade. Anyhow, fixing this omission does not resolve our problem. Nor does any combination of re-connecting, invalidating etc. I poked around in the GTK (C) code a lot, but could not spot any obvious missing initialisation step. To much magic around here. Without massive debugging into GTK internals, I don't see any way to further this investigation. And, moreover there is a viable workaround (namely to set and remove the classes explicitly, which works as intended) I posted a question on Stackoverflow and for now I'll file this topic as "inconclusive" https://stackoverflow.com/q/57342478
This commit is contained in:
parent
ec3c49f612
commit
7bf7c51375
4 changed files with 65 additions and 7 deletions
|
|
@ -44,6 +44,7 @@
|
|||
#include "lib/error.hpp"
|
||||
#include "lib/util.hpp"
|
||||
|
||||
#include <gtk/gtk.h> ////////////////////TODO WIP
|
||||
#include <string>
|
||||
|
||||
using util::cStr;
|
||||
|
|
@ -218,6 +219,7 @@ namespace research {
|
|||
|
||||
Gtk::WidgetPath path = srcWidget.get_path();
|
||||
PStyleContext style = Gtk::StyleContext::create();
|
||||
style->set_screen(Gdk::Screen::get_default());
|
||||
style->set_path(path);
|
||||
// style->add_class(slopeClassName(2));
|
||||
return style;
|
||||
|
|
@ -317,8 +319,14 @@ namespace research {
|
|||
{
|
||||
int marT = style_->get_margin().get_top();
|
||||
|
||||
auto path = style_->get_path();
|
||||
|
||||
if (xBorderSiz > 1) {
|
||||
style_->context_save();
|
||||
// style_->invalidate();
|
||||
// style_->context_save();
|
||||
// style_->set_screen(Gdk::Screen::get_default());
|
||||
// style_->set_path(path);
|
||||
// style_->invalidate();
|
||||
style_->add_class(slopeClassName(xBorderSiz));
|
||||
}
|
||||
|
||||
|
|
@ -335,7 +343,8 @@ namespace research {
|
|||
);
|
||||
|
||||
if (xBorderSiz > 1) {
|
||||
style_->context_restore();
|
||||
// style_->context_restore();
|
||||
style_->remove_class(slopeClassName(xBorderSiz));
|
||||
}
|
||||
}
|
||||
//////////////////TEST drawing via Gtk::StyleContext
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ namespace timeline {
|
|||
void
|
||||
close (uint n) override
|
||||
{
|
||||
// style_->context_save();
|
||||
// style_->context_save(); // <<<---does not work. Asked on SO: https://stackoverflow.com/q/57342478
|
||||
style_->add_class (slopeClassName(n));
|
||||
style_->invalidate();
|
||||
int slopeWidth = style_->get_border().get_bottom();
|
||||
|
|
@ -235,8 +235,8 @@ namespace timeline {
|
|||
,visible_.b
|
||||
,visible_.e
|
||||
);
|
||||
// style_->context_restore(); // <<<---does not work...
|
||||
style_->remove_class (slopeClassName(n));
|
||||
// style_->context_restore();
|
||||
line_ += slopeWidth;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ namespace workspace {
|
|||
for (int i=0; i<pos; ++i) // reset any state flags accidentally set (resulting in pseudo classes like ":backdrop")
|
||||
gtk_widget_path_iter_set_state(path.gobj(), i, GTK_STATE_FLAG_NORMAL);
|
||||
PStyleContext style = Gtk::StyleContext::create(); // create a new style context and configure it according to the path defined thus far
|
||||
style->set_screen(Gdk::Screen::get_default());
|
||||
style->set_path (path);
|
||||
styleAdviceTrackBody_.setAdvice (style); // publish as Advice "style(trackBody)"
|
||||
INFO (stage, "Body-CSS: path=%s", util::cStr (path.to_string())); ////////////////////////TICKET #1201 : this yields "paned:dir-ltr.horizontal box:dir-ltr.vertical TrackScope.timeline"
|
||||
|
|
|
|||
|
|
@ -23026,10 +23026,58 @@
|
|||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1564841527588" ID="ID_1377435126" MODIFIED="1564841582490" TEXT="TODO: Untersuchung context_save() auf einem kopierten / frei konstruierten StyleContext">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1564841527588" ID="ID_1377435126" MODIFIED="1564868164039" TEXT="Untersuchung context_save() auf einem kopierten / frei konstruierten StyleContext">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node CREATED="1564868166273" ID="ID_945377761" MODIFIED="1564868267923" TEXT="kann das problematische Verhalten reproduzieren">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Wenn man einen neuen Gtk::StyleContext erzeugt,
|
||||
</p>
|
||||
<p>
|
||||
und (wie in der Doku beschrieben) den path und den screen manuell setzt,
|
||||
</p>
|
||||
<p>
|
||||
dann führt ein context_save() dazu, daß plötzlich die CSS-Werte auf Defaults zurückspringen
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1564841584180" ID="ID_1444331441" MODIFIED="1564841601195" TEXT="TODO: Untersuchung wie box-shadow gerendert wird">
|
||||
<node CREATED="1564868280687" ID="ID_593595518" MODIFIED="1564871156101" TEXT="es hilft nichts, wenn man den Screen (nochmal) setzt">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
und ja, den Screen sollte man generell setzten.<br />Steht auch so in der Doku.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
<p>
|
||||
Allerdings hat es bisher auch ohne das bei mir funktioniert.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
<icon BUILTIN="broken-line"/>
|
||||
</node>
|
||||
<node CREATED="1564868338325" ID="ID_1826179725" MODIFIED="1564871159899" TEXT="es hilft nichts, wenn man den Pfad erneut setzt">
|
||||
<icon BUILTIN="broken-line"/>
|
||||
</node>
|
||||
<node CREATED="1564868348236" ID="ID_1509661918" MODIFIED="1564871163619" TEXT="es hilft nichts, wenn man den Context invalidiert">
|
||||
<icon BUILTIN="broken-line"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1564871053125" HGAP="30" ID="ID_1611854805" LINK="https://stackoverflow.com/q/57342478/444796" MODIFIED="1564871092888" TEXT="habe auf Stackoverflow gefragt" VSHIFT="16">
|
||||
<icon BUILTIN="hourglass"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1564841584180" ID="ID_1444331441" MODIFIED="1564866024773" TEXT="TODO: Untersuchung wie box-shadow gerendert wird">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
</node>
|
||||
|
|
|
|||
Loading…
Reference in a new issue