Results 1 to 3 of 3

Thread: CL_GUIComponent not drawing properly when CL_GraphicContext is moved

  1. #1

    Question CL_GUIComponent not drawing properly when CL_GraphicContext is moved

    I'm on the early steps of creating a top down RTS game and I am trying to make it so that when the mouse hits the edges of the screen the graphics context moves. That part of the code works just fine, however when I move it the GUI does not follow.

    I can click on where the one button should be and I get the classic "Hello World" Text in the console but the button itself is being draw where is started, in other words the button can be clicked on where is should be but the part that can be seen is not moving.

    I'll explain the code that is relevant

    This is the GUI class I made, it inherits from the CL_GUIComponenet class and will be used to draw all of the GUI. obviously this is the cpp file. I didn't include the header

    Code:
    GuiApp::GuiApp(CL_GUIManager *manager, CL_GUITopLevelDescription description) : CL_GUIComponent(manager,description) {
    	MyButton = new CL_PushButton(this);
    	MyButton->set_text("Okay!");
    	MyButton->set_geometry(CL_Rect(10,10,100,80));
    	MyButton->func_clicked().set(&on_button1_clicked, MyButton);
    }
    
    
    void GuiApp::on_button1_clicked(CL_PushButton *button)
    {
    	CL_Console::write("Hello World");
    }
    I included that into my project

    Code:
    GuiApp MainGUI(&GUI,CL_GUITopLevelDescription("MyGui",CL_Size (GameResolutionWidth,GameResolutionHeight), true));
    GUI is the guimanager class. The GUI was made like in the direct render examples with the CL_GUIWindowManagerTexture class
    The last part that I believe is relevant is the main loop. Window manager is a CL_GUIWindowManagerTexture class

    Code:
    gc.clear();
    gc.set_translate(CameraX,CameraY,0);
    DrawEverything();
    
    WindowManager.process();
    WindowManager.draw_windows(gc);
    window.flip(1);
    
    
    CL_KeepAlive::process();
    CL_System::sleep(10);
    Last edited by Trollger; 08-11-2012 at 05:28 PM. Reason: [SOLVED]

  2. #2
    Squire
    Join Date
    Sep 2011
    Location
    Poland
    Posts
    16

    Default

    Try reseting the translation of gc before drawing the gui.

    Code:
    DrawEverything();
    
    gc.set_translate(0,0);
    
    WindowManager.draw_windows(gc);

  3. #3

    Default [SOLVED] Thanks, worked

    worked wonderfully, thanks.

Similar Threads

  1. CL_GraphicContext Refining
    By rombust in forum Official ClanLib SDK Forums
    Replies: 11
    Last Post: 12-20-2011, 10:56 PM
  2. CL_GUIComponent Issues
    By Fr3DBr in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 08-31-2009, 05:09 PM
  3. How to use the ClanLib GUI properly?
    By Impz0r in forum Official ClanLib SDK Forums
    Replies: 9
    Last Post: 06-30-2009, 04:54 PM
  4. Throw exception within ClanLib app is not working properly
    By alexv1 in forum Official ClanLib SDK Forums
    Replies: 8
    Last Post: 02-28-2009, 01:33 AM
  5. CL_FramerateCounter.set_fps_limit() not working properly, need assistance
    By alexv1 in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 02-18-2009, 04:56 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
  •