Scroom 0.14-49-gb7ae7a6d
Loading...
Searching...
No Matches
anonymous_namespace{transparentoverlayviewinfo.cc} Namespace Reference

Functions

void setToggleButtonColor (GtkWidget *w, PresentationInterface::Ptr const &p)
 

Function Documentation

◆ setToggleButtonColor()

void anonymous_namespace{transparentoverlayviewinfo.cc}::setToggleButtonColor ( GtkWidget *  w,
PresentationInterface::Ptr const &  p 
)
22 {
23 Colormappable::Ptr const c = std::dynamic_pointer_cast<Colormappable>(p);
24 if(c && p->isPropertyDefined(MONOCHROME_COLORMAPPABLE_PROPERTY_NAME))
25 {
26 Color const col = c->getMonochromeColor();
27 GtkCssProvider* bgCssProvider = gtk_css_provider_new();
28 const std::string bgCss = "* { background-image:none; background-color: #" + col.getHex() + ";}";
29
30 // Fill the provider with the correct data bgCss string
31 gtk_css_provider_load_from_data(bgCssProvider, bgCss.c_str(), -1, nullptr);
32
33 // Get the style context
34 GtkStyleContext* bgContext = gtk_widget_get_style_context(w);
35
36 // Add the provider
37 gtk_style_context_add_provider(bgContext, GTK_STYLE_PROVIDER(bgCssProvider), GTK_STYLE_PROVIDER_PRIORITY_USER);
38
39
40 const std::string fgCss = "* { color: #" + col.getContrastingBlackOrWhite().getHex() + ";}";
41 GtkWidget* label = gtk_bin_get_child(GTK_BIN(w));
42 GtkCssProvider* fgCssProvider = gtk_css_provider_new();
43
44 // Fill the provider with the correct data fgCss string
45 gtk_css_provider_load_from_data(fgCssProvider, fgCss.c_str(), -1, nullptr);
46
47 // Get the style context
48 GtkStyleContext* fgContext = gtk_widget_get_style_context(label);
49
50 // Add the provider
51 gtk_style_context_add_provider(fgContext, GTK_STYLE_PROVIDER(fgCssProvider), GTK_STYLE_PROVIDER_PRIORITY_USER);
52 }
53 }
Definition color.hh:37
std::string getHex() const
Definition color.hh:93
Color getContrastingBlackOrWhite() const
Definition color.hh:121
std::shared_ptr< Colormappable > Ptr
Definition colormappable.hh:114
const std::string MONOCHROME_COLORMAPPABLE_PROPERTY_NAME
Definition colormappable.hh:20
PresentationInterfaceStub::Ptr const p
Definition determine-size-test.cc:172
std::pair< GSourceFunc, gpointer > const w
Definition gtkhelper-tests.cc:42
Semaphore c(0)
Here is the call graph for this function: