Results 1 to 4 of 4

Thread: About CL_GUITheme and set_resources

  1. #1

    Default About CL_GUITheme

    Hey i just wondered why the CL_ResourceManager param in CL_GUITheme::set_resources() isn't passed as a reference one.
    Is this on purpose because it seems rather odd to me.

    And theres another thing related to a GUITheme. I have a custom created dialog in which i define a background. Therefore i do create a custom css file in which i define:
    Code:
    @import "../../theme/theme.css";
     
    window#MainMenu
    {
    	bg-image:MainMenuBg;
    }
    As i understand the gui tutorials correctely i can only set one css file to the GUIManager. This works, but is kinda wired because if my project grows i'll have more custom created dialogs and therefore have for each of 'em a css-file. So every time i wanna load a custom dialog i have to load also the standard theme cause i can only set one css file to the GUIManager. Am i right or is there another solution to archive this?

    There is more

    I have a directory structure like:
    Code:
    ../data/
    ../data/gui/
    ../data/gui/dialogs/
    ../data/gui/dialogs/MainMenu/
    ../data/gui/themes/
    ../data/gui/gfx/
    So if i load the MainMenu.xml within "../data/gui/dialogs/MainMenu/" in which the custom dialog is defined, i also load the theme.css and resources.xml files from this directory. Now as you see i import the default Luna theme within the custom theme.css. This works just fine but within the Luna theme.css are other imports like:
    Code:
    @import "window.css";
    etc.
    And here the code fails, because the css loader tries to load the window.css from the "../data/gui/dialogs/" directory and not from the directory the Luna theme.css lies in. I wondered if i have made a mistake but it seems like the loader aint resolve the relative path correctely.

    I hope you guys could help me out here


    PS: Sorry for the long post, i just didn't want to create a new thread for it, hope this is ok


    Thanks in advance.

    Imp
    Last edited by Impz0r; 06-29-2009 at 06:28 PM.

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

    Default

    Quote Originally Posted by Impz0r View Post
    There is more

    I have a directory structure like:
    Code:
    ../data/
    ../data/gui/
    ../data/gui/dialogs/
    ../data/gui/dialogs/MainMenu/
    ../data/gui/themes/
    ../data/gui/gfx/
    So if i load the MainMenu.xml within "../data/gui/dialogs/MainMenu/" in which the custom dialog is defined, i also load the theme.css and resources.xml files from this directory. Now as you see i import the default Luna theme within the custom theme.css. This works just fine but within the Luna theme.css are other imports like:
    Code:
    @import "window.css";
    etc.
    And here the code fails, because the css loader tries to load the window.css from the "../data/gui/dialogs/" directory and not from the directory the Luna theme.css lies in. I wondered if i have made a mistake but it seems like the loader aint resolve the relative path correctely.
    That was a bug in the CL_CSSDocument import (using VFS) function

    It did not keep track of the changing path.

    This is been fixed in the SVN, using
    Code:
    	CL_String fullname = CL_PathHelp::get_fullname(last_path, import_text, CL_PathHelp::path_type_file);
    	fullname = CL_PathHelp::normalize(fullname, CL_PathHelp::path_type_file);
    	load(fullname, directory);
    I tested it using the Tests/GUI/Button1 test, by changing the theme loader to:

    Code:
    	CL_VirtualFileSystem vfs("c:/clanlib-2.0");
    	CL_VirtualDirectory vdir(vfs, "");
    	gui.set_css_document("Tests/GUI/Button1/theme.css", vdir);
    Remember that any file cannot be lower than the directory in CL_VirtualDirectory. (ie, you cannot do: "../clanlib-2.0/Tests/GUI/Button1/theme.css")

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

    Default

    Quote Originally Posted by Impz0r View Post
    Hey i just wondered why the CL_ResourceManager param in CL_GUITheme::set_resources() isn't passed as a reference one.
    Is this on purpose because it seems rather odd to me.
    For the same reason as: http://www.rtsoft.com/forums/showthread.php?t=2709

    Quote Originally Posted by Impz0r View Post

    And theres another thing related to a GUITheme. I have a custom created dialog in which i define a background. Therefore i do create a custom css file in which i define:
    Code:
    @import "../../theme/theme.css";
     
    window#MainMenu
    {
    	bg-image:MainMenuBg;
    }
    As i understand the gui tutorials correctely i can only set one css file to the GUIManager. This works, but is kinda wired because if my project grows i'll have more custom created dialogs and therefore have for each of 'em a css-file. So every time i wanna load a custom dialog i have to load also the standard theme cause i can only set one css file to the GUIManager. Am i right or is there another solution to archive this?
    I can't quite understand what you are trying to achieve here.

    You can have a single global css that contains many themes.

    Use CL_Component::set_class_name()

    For example:
    Code:
    	CL_Window window(&gui, CL_GUITopLevelDescription(CL_Rect(200, 200, 540, 440), false));
    	window.set_class_name("cool");
    
    	CL_PushButton button(&window);
    	button.set_geometry(CL_Rect(10, 10, 160, 50));
    	button.set_text("Button Normal");
    	button.set_class_name("cool");
    And in the theme.css, have:
    Code:
    button.cool
    { 
    	bg-image:MainMenuBg;
    }
    window.cool
    { 
    	bg-image:MainMenuBg;
    }
    
    etc

  4. #4

    Default

    Wow thanks alot rombust for your help!

    About the single global css file. The thing is, i do use right now the Luna theme for prototyping. Later on i'll may change it to a more appropriate theme within the games context.

    Anyways, what im trying to do is to load the default Luna theme once and later, if i need to load a dialog or something else i want to load a custom css-file for that particular control. So the question i was trying to ask was, how do i achive this.

    I did something along the lines:
    Code:
    CL_CSSDocument cssDoc = get_gui_manager().get_css_document();
    cssDoc.load(sCustomCSSFile, virtualFileDir);
    get_gui_manager().set_css_document(cssDoc);
    It does work, but i was wondering if it is the way to go, or is there another, maybe better way?


    Thanks in advance!

    Imp

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
  •