Scroom  0.14
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 
)
26  {
27  Colormappable::Ptr const c = boost::dynamic_pointer_cast<Colormappable>(p);
28  if(c && p->isPropertyDefined(MONOCHROME_COLORMAPPABLE_PROPERTY_NAME))
29  {
30  Color const col = c->getMonochromeColor();
31  GtkCssProvider* bgCssProvider = gtk_css_provider_new();
32  const std::string bgCss = "* { background-image:none; background-color: #" + col.getHex() + ";}";
33 
34  // Fill the provider with the correct data bgCss string
35  gtk_css_provider_load_from_data(bgCssProvider, bgCss.c_str(), -1, nullptr);
36 
37  // Get the style context
38  GtkStyleContext* bgContext = gtk_widget_get_style_context(w);
39 
40  // Add the provider
41  gtk_style_context_add_provider(bgContext, GTK_STYLE_PROVIDER(bgCssProvider), GTK_STYLE_PROVIDER_PRIORITY_USER);
42 
43 
44  const std::string fgCss = "* { color: #" + col.getContrastingBlackOrWhite().getHex() + ";}";
45  GtkWidget* label = gtk_bin_get_child(GTK_BIN(w));
46  GtkCssProvider* fgCssProvider = gtk_css_provider_new();
47 
48  // Fill the provider with the correct data fgCss string
49  gtk_css_provider_load_from_data(fgCssProvider, fgCss.c_str(), -1, nullptr);
50 
51  // Get the style context
52  GtkStyleContext* fgContext = gtk_widget_get_style_context(label);
53 
54  // Add the provider
55  gtk_style_context_add_provider(fgContext, GTK_STYLE_PROVIDER(fgCssProvider), GTK_STYLE_PROVIDER_PRIORITY_USER);
56  }
57  }

Referenced by TransparentOverlayViewInfo::createToggleToolButton().

Here is the call graph for this function:
Here is the caller graph for this function:
MONOCHROME_COLORMAPPABLE_PROPERTY_NAME
const std::string MONOCHROME_COLORMAPPABLE_PROPERTY_NAME
Definition: colormappable.hh:22
Color::getHex
std::string getHex() const
Definition: color.hh:93
Colormappable::Ptr
boost::shared_ptr< Colormappable > Ptr
Definition: colormappable.hh:116
Color::getContrastingBlackOrWhite
Color getContrastingBlackOrWhite() const
Definition: color.hh:121
Color
Definition: color.hh:34