[Gtk-sharp-list] A text view widget with a transparent background, and some other pure evil.
greg at vis.net.nz
Sun Mar 21 04:52:49 EDT 2010
I'm experimenting with a way to implement a simple text tool for a GTK
What I've got so far is an custom container widget which uses cairo to paint
the background on expose. When the user clicks on the container widget, a
text view widget is added on top and given keyboard focus.
When the text entry is completed, it's drawn to a cairo image surface, and
the text view widget is destroyed.
This works pretty well. The one caveat, is that the text view must have a
solid background colour. Ideally, I'd like to be able to give it a
transparent background. And that's when it starts to get tricky.
I'd like to be able to do something like:
text_view.ModifyBase (StateType.Normal, new Gdk.Color (r,g,b,_alpha_))
But the problem is that Gdk.Color doesn't support alpha.
I understand it is possible to use alpha compositing for child widgets. From
what I've read, I think I need to get the rgba colour map from the GDK
screen, and then set it on the widget. But then I also need to pass in an
alpha value for the text view's background colour, at which point I'm stuck.
So now, dear reader, you've made it this far, and it's time for the
- Is it currently possible to set the alpha channel of the text view
widget's background colour, or make the background completely transparent?
- Or, is there a better way to achieve the same effect?
- If not, are there any plans to add a function that does this to GTK (and
GtkSharp)? Is that likely to happen within the next year or so?
- If there isn't a solution at the moment, are there any good workarounds?
(For example, I could potentially use "pure evil" , and skip alpha
compositing all together, just i.e. re-render the background. Actually I
tried this in GTK#, and not only did my demo app crash, but it also took
MonoDevelop down with it. And I thought the pure evil bit was just a joke.
 http://dannipenguin.livejournal.com/283590.html )
Anyways, thanks for your time, and hopefully someone out there has cracked
this nut already... would love to hear from you!
Here's the source code for my text tool demo:
Here's some other links that I looked at while working on this:
And a related thread on the Pinta list:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Gtk-sharp-list