From 1b3cc73d073b280f7e36e81919f52caab954c7b4 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 3 Aug 2019 13:34:56 +0200 Subject: [PATCH] Investigation: rebuild the problematic situation in this controlled environment Within the timeline drawing code, adding a class to the Gtk::StyleContext on the fly seemingly did not work. Now we're doing basically the same here in this small Gtk test application, and it does not work either :-) --- research/gtk-style-experiment.cpp | 41 ++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/research/gtk-style-experiment.cpp b/research/gtk-style-experiment.cpp index 793cd1329..8b939240f 100644 --- a/research/gtk-style-experiment.cpp +++ b/research/gtk-style-experiment.cpp @@ -39,6 +39,7 @@ #include "stage/gtk-base.hpp" #include "lib/searchpath.hpp" +#include "lib/format-cout.hpp" #include "lib/error.hpp" #include "lib/util.hpp" @@ -54,6 +55,19 @@ namespace research { const string RESOURCE_PATH{"$ORIGIN/gui"}; const string CLASS_experiment{"experiment"}; + + string + slopeClassName(int depth) + { + switch (depth) + { + case 1: return "track-slope-deep1"; + case 2: return "track-slope-deep2"; + case 3: return "track-slope-deep3"; + case 4: return "track-slope-deep4"; + default:return "track-slope-verydeep"; + } + } } using CairoC = stage::PCairoContext const&; @@ -78,6 +92,10 @@ namespace research { void adjustSize(); void enableDraw (bool); + int xBorderSiz = 1; + int xObservedSize = -1; + string xObservedPath; + private: virtual bool on_draw (Cairo::RefPtr const&) override; @@ -200,7 +218,7 @@ namespace research { StyleTestPanel::experiment_1() { frame_.set_label("Experiment 1... GROW"); - + canvas_.xBorderSiz += 1; canvas_.adjustSize(); } @@ -209,6 +227,13 @@ namespace research { StyleTestPanel::experiment_2() { frame_.set_label("Experiment 2... DUMP"); + + cout << "xBorderSize = "<get_margin().get_top(); + + if (xBorderSiz > 1) { + style_->context_save(); + style_->add_class(slopeClassName(xBorderSiz)); + } + + xObservedSize = style_->get_border().get_top(); + xObservedPath = string{style_->get_path().to_string()}; style_->render_frame (cox ,20 // left start of the rectangle ,20 // top of the rectangle ,50 // width of the area ,marT // height to fill ); + + if (xBorderSiz > 1) { + style_->context_restore(); + } } //////////////////TEST drawing via Gtk::StyleContext