GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Oct 25, 2014 4:16 am

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Floating boxes
PostPosted: Sun Sep 23, 2007 5:28 pm 
Offline
Familiar Face

Joined: Sun Sep 23, 2007 5:13 pm
Posts: 5
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!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 23, 2007 8:41 pm 
Offline
GTK+ Guru

Joined: Thu Jun 21, 2007 1:52 pm
Posts: 198
Location: Wilkes Barre Pa
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/


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 24, 2007 7:44 pm 
Offline
Familiar Face

Joined: Sun Sep 23, 2007 5:13 pm
Posts: 5
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. :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 25, 2007 4:40 am 
Offline
GTK+ Guru

Joined: Thu Jun 21, 2007 1:52 pm
Posts: 198
Location: Wilkes Barre Pa
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 25, 2007 9:54 am 
Offline
Familiar Face

Joined: Sun Sep 23, 2007 5:13 pm
Posts: 5
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).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 27, 2007 9:55 pm 
Offline
GTK+ Guru

Joined: Thu Jun 21, 2007 1:52 pm
Posts: 198
Location: Wilkes Barre Pa
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.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 28, 2007 8:39 am 
Offline
Familiar Face

Joined: Sun Sep 23, 2007 5:13 pm
Posts: 5
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. :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 29, 2007 1:41 am 
Offline
GTK+ Guru

Joined: Thu Jun 21, 2007 1:52 pm
Posts: 198
Location: Wilkes Barre Pa
Try

http://live.gnome.org/GnomeLove/PanelAppletTutorial
http://developer.gnome.org/doc/tutorial ... index.html
http://www.gnome.org/projects/ORBit2/ap ... orial.html
http://www.google.com/search?q=Gnome+pa ... =firefox-a


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 29, 2007 1:59 am 
Offline
GTK+ Guru

Joined: Thu Jun 21, 2007 1:52 pm
Posts: 198
Location: Wilkes Barre Pa
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.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 29, 2007 8:31 am 
Offline
Familiar Face

Joined: Sun Sep 23, 2007 5:13 pm
Posts: 5
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/Ra ... 2280998466

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/Ra ... 8494642770

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group