GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Floating boxes

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
ephracis
Familiar Face


Joined: 23 Sep 2007
Posts: 5

PostPosted: Sun Sep 23, 2007 5:28 pm    Post subject: Floating boxes Reply with quote

Hi,

I am extremely new to GTK. Although I have knowledge in C, callbacks and have worked in Qt before.

My goal with this GTK project I am starting now is to create X number of boxes. These boxes are defined in an xml file, like their width, height and position (x,y).

My problem is: they should have borders unless they are near each other (no pixel between them). It would also be great if I could correct collisions (this cannot be done in the xml parser for a number of reasons).

Of course, they should not reside within a window, they should float.


I have written the same in Qt, although it was a lot of work since I had to work with QGraphicsScene and I had to implement my own "docking" algoritm and "collision detection" algoritm. Also, there was a lot of problems making the boxes floating.

I was hoping that GTK could beat Qt in this. :)

I am reading the GTK tutorial documents but I figured that this specific design would be a lot easier to create if I at least got some hints on what to read more about by you guys. :)

Thanks!
Back to top
caracal
GTK+ Geek


Joined: 21 Jun 2007
Posts: 80
Location: Wilkes Barre Pa

PostPosted: Sun Sep 23, 2007 8:41 pm    Post subject: Reply with quote

Do you have a screen shot of what you would like to do i am having a hard time visualizing what it is you want to do.

Quote:
"docking" algoritm and "collision detection"

Your most certainly going to have to write these again although
you could use a physics library

In a 2D environment "Cairo, Metacity, Openbox, Xfwm, Etc" use something like
Chipmunk http://wiki.slembcke.net/main/published/Chipmunk

In a 3D environment "Clutter, GtkGLExt, Emerald, Etc" use something like
ODE http://www.ode.org/
Back to top
ephracis
Familiar Face


Joined: 23 Sep 2007
Posts: 5

PostPosted: Mon Sep 24, 2007 7:44 pm    Post subject: Reply with quote

Sorry if it was confusing. I did my best to explain. But here is a picture.

By "floating" I mean that these boxes will not reside within a normal window, they will be put anywhere on the screen. I thought that at least the collision detection and "merging"-kinda-thing in the picture would be used frequently enough for someone to have written a good algoritm for it.
I do not want to use the one I wrote in Qt - I bet there are a hundred ways to optimize it.

I will check out the 2d library suggestion. :)
Back to top
caracal
GTK+ Geek


Joined: 21 Jun 2007
Posts: 80
Location: Wilkes Barre Pa

PostPosted: Tue Sep 25, 2007 4:40 am    Post subject: Reply with quote

gtk_window_set_decorated ()

void gtk_window_set_decorated (GtkWindow *window,
gboolean setting);

By default, windows are decorated with a title bar, resize controls, etc. Some window managers allow GTK+ to disable these decorations, creating a borderless window. If you set the decorated property to FALSE using this function, GTK+ will do its best to convince the window manager not to decorate the window. Depending on the system, this function may not have any effect when called on a window that is already visible, so you should call it before calling gtk_window_show().

On Windows, this function always works, since there's no window manager policy involved.

window : a GtkWindow
setting : TRUE to decorate the window
Back to top
ephracis
Familiar Face


Joined: 23 Sep 2007
Posts: 5

PostPosted: Tue Sep 25, 2007 9:54 am    Post subject: Reply with quote

Thanks for that tip! So this solution will require me to create a window for each box. It may be possible.

My goal is to put my application as an applet in the Gnome panel (sorry, maybe wrong terms there). FYI, if you are interested, this is why I was forced to use QGraphicsScene in Qt since this is what Plasma in KDE 4 will be using (read: all plasmoids provides a QGraphicsScene). I have not yet been able to check out how to actually write an applet for the Gnome panel but everything should clear up any time soon (when I read some docs about it). ;)

Anyway, I still have the collision problem, but I should be able to write my own algoritm if I have to. I was just hoping that someone may already have created a smart way to accomplish this.

If anyone is interested in this project we are more than happy to introduce people. Check out our project on SourceForge: raptormenu (sorry about the advertising there, but it is really a fun project and we are really short handed).
Back to top
caracal
GTK+ Geek


Joined: 21 Jun 2007
Posts: 80
Location: Wilkes Barre Pa

PostPosted: Thu Sep 27, 2007 9:55 pm    Post subject: Reply with quote

Ahhh i see you would be better off asking questions about gnome application development on the gnome developers forums.

As i have no idea how to code applets for gnomes panel.
Back to top
ephracis
Familiar Face


Joined: 23 Sep 2007
Posts: 5

PostPosted: Fri Sep 28, 2007 8:39 am    Post subject: Reply with quote

Yes, of course. But the question here was not really how to develop gnome applets, than it was how to create those boxes and a collision detection. :)
Back to top
caracal
GTK+ Geek


Joined: 21 Jun 2007
Posts: 80
Location: Wilkes Barre Pa

PostPosted: Sat Sep 29, 2007 1:41 am    Post subject: Reply with quote

Try

http://live.gnome.org/GnomeLove/PanelAppletTutorial
http://developer.gnome.org/doc/tutorials/applet/index.html
http://www.gnome.org/projects/ORBit2/appletstutorial.html
http://www.google.com/search?q=Gnome+panel+applet+tutorial&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
Back to top
caracal
GTK+ Geek


Joined: 21 Jun 2007
Posts: 80
Location: Wilkes Barre Pa

PostPosted: Sat Sep 29, 2007 1:59 am    Post subject: Reply with quote

If you develop any application for the panel your going to have to use gnome libs/apis. If you want something like kde's plasmoids then there is gdesklets or adeslets if you want some thing more custom then there is xlib and cairo.

Quote:
So this solution will require me to create a window for each box. It may be possible.


Actually if your creating floating boxes on a gnu/linux desktop there is always going to be a window for each box even with qt. What happens is each additional box after the first may be a child to the parent window there for only showing one application entry "The parent" for all windows"boxes" in a process view. This is were threading gets involved. Even the widgets in a gui toolkit in reality are separate windows Example: "A Window is the parent a button is a child & the text in the button is also a child" that would make three windows 1 parent and 2 children.

So say you want 2 boxes to collide and blend together. There are two ways to do this that i know of 1. using a canvas library and drawing your boxes on the canvas or 2. Use a 3D window manager with a 3D collision and effects plugin. I could thing of a couple other ways but there not pratical.

Besides that im still not really quit sure what your trying to do your best bet if you need any more help would be to use inkscape or xara and draw out a desktop and they application exactly as you wish it to appear in a finished state. And then upload that as a png or whatever to some free image hosting site and post back here with the link.
Back to top
ephracis
Familiar Face


Joined: 23 Sep 2007
Posts: 5

PostPosted: Sat Sep 29, 2007 8:31 am    Post subject: Reply with quote

Oh thanks for all that info! You have just tought me some very good-to-know stuff about windows and widgets. ;)

Anyway, did you see the photo I sent in a link a couple of posts ago? Here it is if you missed it:
http://picasaweb.google.com/ephracis/Raptor/photo?authkey=wDYdQIB-NH4#5113857912280998466

I also painted a photo of another setup on a desktop, showing how it would look like when it is a panel applet.
http://picasaweb.google.com/ephracis/Raptor/photo?authkey=wDYdQIB-NH4#5115538438494642770

You see, I have written a library which present the GUI with a number of boxes that should be painted. The easy way is to just paint all those boxes and then put stuff into them. But I wanted the GUI to be a little smart and detect if the boxes actually where colliding and "merge" them if they where (as shown in both pictures).

So the thing is that these boxes are dynamic, they can be changed just by changing an xml-file.

I do not want to write a superkaramba-like desktop applet, I want it to be an applet in the gnome *panel*. I was using plasmoids because that is how the KDE4 desktop will work, but there are a lot of problems there.

I have been working a whole lot on the Qt GUI and I find it really hard to do the border painting right. I am getting really tired of getting it to paint all pixels right (this is what I get for having configurable boxes, right?). That is why I was hoping that someone could ease my development a little bit by some tips on how to achieve this.

Or maybe someone here wants to join in and code with me? :P
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP