You are not logged in.

#1 2013-02-16 18:19:47

anur
Member
Registered: 2012-10-18
Posts: 7

awesome 3.5, cairo drawing in widget

Hi all
may be sombody know how to pass cairo surface to widget in awesome 3.5?
I did:

cairo= wibox.widget.imagebox()
cs =  Cairo.image_surface_create("argb32", 50, 14)
cr = Cairo.context_create(cs)
  cr:new_path()
  cr:move_to(10, 10)
  cr:line_to(40, 0)
  cr:set_source_rgb(0, 0, 0)
  cr:set_line_width(3)
  cr:stroke()
  img = capi.image.argb32(50, 14, cs:get_data()) --don't work (old way)
  cs:write_to_png("/tmp/simple-example.png") -- work
  cairo:draw(wibox,cr, 50,14)   --don't work

thanks

Last edited by anur (2013-02-16 18:21:30)

Offline

#2 2013-04-18 19:26:26

Phasme
Member
Registered: 2011-07-10
Posts: 16
Website

Re: awesome 3.5, cairo drawing in widget

Hi anur,

it seems that you are using the "old way" for awesome v < 3.5 which was to create an image widget, create an image with cairo and update the widget image with the generated cairo context.

For awesome WM 3.5 you have to create a new widget with: wibox.widget.base.make_widget() and create a draw function for this widget where you set the cairo instructions
see here for the basics:

http://awesome.naquadah.org/wiki/Writing_own_widgets

If you want to include this in a more advanced way, you should create an object in a module. I have written a "template" for this see:
https://github.com/cedlemo/blingbling/b … mplate.lua.
Even if it 's not a functionnal example, it can give you an overview on how to write your own widget that you can fill with vicious for example.

Have a looks to the code of my graphicals widgets, it could help you too ( line_graph, progress_bar ...):
https://github.com/cedlemo/blingbling.

One of my best source of informations are of course:

/usr/share/awesome/lib/awful/widget/graph.lua
/usr/share/awesome/lib/awful/widget/progressbar.lua

Offline

#3 2013-05-03 22:03:44

anur
Member
Registered: 2012-10-18
Posts: 7

Re: awesome 3.5, cairo drawing in widget

O, thanks! your points to read are excellent. Thanks. I solved my small issue.

Offline

#4 2013-06-30 09:27:05

anur
Member
Registered: 2012-10-18
Posts: 7

Re: awesome 3.5, cairo drawing in widget

Phasme,
Thanks again, may be you know why while drawing with cairo I got flustarting line between drawings
pIGDMXP.png
Color of these lines are different.
Thnaks

Offline

#5 2013-06-30 11:55:13

Trent
Member
From: Baltimore, MD (US)
Registered: 2009-04-16
Posts: 987

Re: awesome 3.5, cairo drawing in widget

anur wrote:

flustarting line between drawings

Do you mean "frustrating"?

Since this seems unrelated to your original post, it would be good to start a new thread.

Offline

Board footer

Powered by FluxBB