Results 1 to 9 of 9

Thread: [GUI] It's the little things...

  1. #1
    Lesser Wizard
    Join Date
    Jun 2007
    Posts
    109

    Default [GUI] It's the little things...

    EDIT: Solved, see post #7.


    That make me pull my hair out

    In the GUI example, when you use a drop down menu in the menubar window, it continues to animate while the drop down is active... so if you move the mouse around it properly animates new drop downs, and the hilight color of the items you select.

    On my app, oddly, it doesn't animate, but it'll select menus based on where my mouse is. So it's "working" input-wise but it is not "animating" drawing-wise (just kinda stuck there on the same menu until I click out of the area).

    Can't seem to see the difference in my usage of the menu bar, it's identical to the example as far as I can tell.

    I'm doing a similar thing with the gui_manager.exec(false); per cycle (similar to how the example does it).

    Some code.

    GUIComponentWhoseNameDoesntMatter.cpp
    Code:
                    ... this is the CL_Window constructor ...
    		menu = new CL_MenuBar(this);
    		menu->set_geometry(CL_Rect(client_area.left, client_area.top, client_area.right, client_area.top+25));
    
    		menu_file.insert_item("New...");
    		menu_file.insert_item("Open...");
    		menu_file.insert_item("Save");
    		menu_file.insert_separator();
    		menu_file.insert_item("Properties");
    		menu_file.insert_separator();
    		menu_file.insert_item("Exit");
    		menu->add_menu("File",menu_file);
    
                   ... more menus here, same style code ...
    main.cpp
    Code:
                    ...
    
    		CL_OpenGLWindowDescription win_desc;
    		win_desc.set_allow_resize(false);
    		win_desc.set_title("GUI Example Application");
    		win_desc.set_size(CL_Size( SCREEN_WIDTH, SCREEN_HEIGHT ), false);
    
    		CL_DisplayWindow wind(win_desc);
    		window = &wind;
    
    		// Short cut to GC
    		CL_GraphicContext gc = window->get_gc();
    
    		// Setup GUI
    		wm = new CL_GUIWindowManagerTexture(*window);
    		wm->func_repaint().set(this, &App::gui_repaint);
    		resources = CL_ResourceManager("Resources/GUIThemeAeroPacked/resources.xml"); 
    		theme.set_resources(resources);
    		gui.set_window_manager(*wm);
    		gui.set_theme(theme);
    		gui.set_css_document("Resources/GUIThemeAeroPacked/theme.css");
    
                    tool_window = new GUIThingWhoseNameDoesntMatter(gc, &gui);
    
    		while(!quit)
    		{
    			timer();
    
    			gc.clear(CL_Colorf(0.0f,0.0f,0.0f));
    			gc.set_map_mode(CL_MapMode(cl_map_2d_upper_left));
    
    			area.update(micro_second);
    			area.draw(gc);
    
    			// GUI
    			gui.exec(false);
    
    			CL_System::sleep(10);
    		}
    
                   ...
    Idears? Not much here, but I'm not doing much beyond this (I don't think?)

    Many thanks for any input!
    Last edited by catch22; 07-05-2009 at 05:51 PM.

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    We're not animating anything in ClanGUI. So if you use the Texture Manager, it will not animate. Maybe the other example is using the System Manager, which uses OS windows for the popups, and that makes it animate?

    Could also be that I totally misunderstand your issue

  3. #3
    Lesser Wizard
    Join Date
    Jun 2007
    Posts
    109

    Default

    Ah the GUI example works both ways.

    Maybe slightly misunderstood. I mean drawing. It draws when I initially do the drop down, but after, it does not. So if I have 3 menus.

    File Edit View

    For example. And I click file. It drops down, but when I mouseover the various items, they do not hilight. Also, if I mouseover Edit or View, they do not drop down. Instead, file stays dropped down. It's like stuck there. But if I click, it properly detects the menu item (even if they are under Edit or View, they just don't draw).

    It's like it's not updating, you know? But far as I can tell, the GUI example does no extra work to update the menu bar.

    I've tried setting constant repaint and running the menu bar itself in modal mode, but the results are the same. So I must be missing some mundane detail somewhere.

  4. #4
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Can you do a screen grab containing the affected area.

    There may be components under the menu that are incorrectly getting input.

    What version of ClanLib are you using? From SVN or V2.0.2 ? The GUI has had lots of fixes since the release.

    What target are you using? GL, GL1 or GDI

    I have noticed, that you are using the Texture WM, and letting the ClanGUI draw the texture. I can't remember if the GUI example draws the textures manually. If so, then it is possible that clanGUI texture redraw is broken (when there is more than 1 top-level windows) - again, if so, you could try drawing the windows manually, to see if that helps

  5. #5
    Lesser Wizard
    Join Date
    Jun 2007
    Posts
    109

    Default

    Quote Originally Posted by rombust View Post
    Can you do a screen grab containing the affected area.

    There may be components under the menu that are incorrectly getting input.

    What version of ClanLib are you using? From SVN or V2.0.2 ? The GUI has had lots of fixes since the release.

    What target are you using? GL, GL1 or GDI

    I have noticed, that you are using the Texture WM, and letting the ClanGUI draw the texture. I can't remember if the GUI example draws the textures manually. If so, then it is possible that clanGUI texture redraw is broken (when there is more than 1 top-level windows) - again, if so, you could try drawing the windows manually, to see if that helps
    I'm using the SVN version (rebuilt recently). GL is the target.

    I am drawing them manually, here's the function (sorry forgot to paste it before):

    Code:
    void App::gui_repaint()
    {
    	std::vector<CL_GUIWindowManagerTextureWindow> windows = wm->get_windows();
    	std::vector<CL_GUIWindowManagerTextureWindow>::size_type index, size;
    	size = windows.size();
    
    	for (index = 0; index < size; index++)
    	{
    		CL_GUIWindowManagerTextureWindow wnd = windows[index];
    		CL_Subtexture texture = wnd.get_texture();
    		CL_Image image(window->get_gc(), texture);
    		image.draw(window->get_gc(), (float)wnd.get_geometry().left, (float)wnd.get_geometry().top);
    	}
    
    	window->flip(1);		// TODO: V-sync as option
    }
    I double checked to see if anything was under it. All there is now is a CL_Window and the menu bar, and the problem persists.

    I'm really unsure what is causing it. I'll upload a screen cap so you can see more what I mean.

    EDIT: Well, windows does not seem to capture the mouse location in screen shots, so it's not very useful for illustration. At this point I think I'll zip up my app so you can have a look at it.

    EDIT2: Attached executable of the little program for your review. Let me know what ya think. One thing to try: notice the console window outputs menu selections, so click on say file, then move over to where a layer drop down would be and click under it a ways. You'll notice the menu selection will be from the other menu. So the click locations work and what not, but the drawing just doesnt seem to update.
    Last edited by catch22; 07-05-2009 at 04:38 PM.

  6. #6
    Lesser Wizard
    Join Date
    Jun 2007
    Posts
    109

    Default

    When run as system window, it works fine. So I thought maybe there's some issue with my texture repaint function. However, it's identical to the one in the GUI example

    Still stumped, heh!

  7. #7
    Lesser Wizard
    Join Date
    Jun 2007
    Posts
    109

    Default

    Alright, I figured it out.

    The difference was I was connecting a custom repaint function. The GUI example simply called it's repaint function from the main loop.

    I'm not sure if this is a bug or not, or just the order of events I was using. But perhaps the slot to call the custom repaint function gets stopped up when a drop down is clicked and running.

    Just a theory, I'm not sure. The fix (for me) is the leave the repaint callback (which is blank), and do the manual texture redraws from the game loop, after calling exec. So it looks like this.

    Code:
                    // Setup GUI
    		wm = new CL_GUIWindowManagerTexture(*window);
    		wm->func_repaint().set(this, &App::gui_repaint);
    		resources = CL_ResourceManager("Resources/GUIThemeLunaPacked/resources.xml"); 
    		theme.set_resources(resources);
    		gui.set_window_manager(*wm);
    		gui.set_theme(theme);
    		gui.set_css_document("Resources/GUIThemeLunaPacked/theme.css");
    
    
                    while(!quit)
    		{
    			timer();
    			
    			gc.clear(CL_Colorf(0.0f,0.0f,0.0f));
    			gc.set_map_mode(CL_MapMode(cl_map_2d_upper_left));
    
    			area.update(micro_second);
    			area.draw(gc);
    			
    			gc.pop_modelview();
    		
    			// GUI
    			gui.exec(false);
    
    			std::vector<CL_GUIWindowManagerTextureWindow> windows = wm->get_windows();
    			std::vector<CL_GUIWindowManagerTextureWindow>::size_type index, size;
    			size = windows.size();
    			for (index = 0; index < size; index++)
    			{
    				CL_GUIWindowManagerTextureWindow wnd = windows[index];
    				CL_Subtexture texture = wnd.get_texture();
    				CL_Image image(window->get_gc(), texture);
    				image.draw(window->get_gc(), (float)wnd.get_geometry().left, (float)wnd.get_geometry().top);
    			}
    		
    			window->get_gc().set_translate(-area.get_camera().x, -area.get_camera().y);
    
    			window->flip(1);		// TODO: V-sync as option
    			CL_System::sleep(10);
    		}
    
    
    void App::gui_repaint()
    {
    	
    }
    Now, it's strange, but if I don't set a custom repaint func, drawing looks messy. I have to leave it as an empty function, though. Any other way, and it doesn't draw right.

    This is just what I've done for now to continue on with my project. If anyone more knowing about the GUI system could explain this stuff, it'd be cool to know
    Last edited by catch22; 07-05-2009 at 05:46 PM.

  8. #8
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Yes, that's it.

    The GUI example does call "wm->func_repaint().set(this, &App::gui_repaint);" will an empty gui_repaint.

    The GUI example has it's own draw loop. First to draw the background gradient, then the windows and the finally the FPS.

    Maybe an additional "wm->func_predraw()" and "wm->func_postdraw()" functions would be a better solution for the GUI example (to avoid this confusion happening again).

  9. #9
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Changed my mind, it's better to fix ClanGUI instead to make it clearer

Similar Threads

  1. You can do interesting things with ClanLib 0.9 GUI
    By rombust in forum Official ClanLib SDK Forums
    Replies: 8
    Last Post: 03-24-2009, 07:46 PM
  2. What things be developing?
    By quickflash in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 09-26-2006, 10:28 PM
  3. Some requested things to implement
    By SLATE in forum Funeral Quest
    Replies: 6
    Last Post: 09-27-2004, 04:59 PM
  4. the little things
    By brandan in forum Dink Smallwood HD
    Replies: 5
    Last Post: 08-14-2004, 10:51 PM
  5. Fun things to do with Toolfish Web Compare
    By in forum Other RTsoft Games
    Replies: 0
    Last Post: 10-20-2002, 08:26 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •