Page 1 of 1

[Solved] Cannot Set Titlebar Font via Looknfeel?

Posted: Tue Nov 02, 2010 15:16
by mithryanna
This is an interesting problem that may be a bug. I want to change the font used for my titlebars, so instead of having to change it on every layout or programmatically on every framewindow widget, I figured the best place to handle this would be in the looknfeel. Except that I've tried several different ways to set the font with no success. I am 100% sure the font I am trying to use is loaded, as I have successfully used this font elsewhere in our gui. I've even set the font property successfully elsewhere, just not on my titlebars!

Tried setting Font property in the Titlebar widget:

Code: Select all

<WidgetLook name="Immersive_Border/Titlebar">
      <PropertyDefinition name="CaptionColour" initialValue="FF000000" redrawOnWrite="true" />
      <Property name="NonClient" value="True" />
      <Property name="Font" value="MyriadPro-9" />


Tried setting Font property within the child of our FrameWindow widget:

Code: Select all

      <Child type="Immersive_Border/Titlebar" nameSuffix="__auto_titlebar__">
        <Area>
         <Dim type="LeftEdge">
           <AbsoluteDim value="0" />
         </Dim>
         <Dim type="TopEdge">
           <AbsoluteDim value="0" />
         </Dim>
         <Dim type="RightEdge">
           <UnifiedDim scale="1" type="RightEdge" />
         </Dim>
         <Dim type="Height">
           <FontDim widget="__auto_titlebar__" type="LineSpacing">
            <DimOperator op="Multiply">
              <AbsoluteDim value="1.5" />
            </DimOperator>
           </FontDim>
         </Dim>
        </Area>
                  <Property name="Font" value="MyriadPro-9" />
        <Property name="AlwaysOnTop" value="False" />
      </Child>


Tried setting the TitlebarFont property in the FrameWindow widget:

Code: Select all

      <PropertyLinkDefinition name="CaptionColour" widget="__auto_titlebar__" targetProperty="CaptionColour" initialValue="FF000000" />
      <PropertyLinkDefinition name="TitlebarFont" widget="__auto_titlebar__" targetProperty="Font" />
      <Property name="Text" value="Toolbox" />
                <Property name="TitlebarFont" value="MyriadPro-9" />


I even tried using the property tag in a way I'm not sure is correct to set the font property on the __auto_titlebar__ child widget:

Code: Select all

      <PropertyLinkDefinition name="CaptionColour" widget="__auto_titlebar__" targetProperty="CaptionColour" initialValue="FF000000" />
      <PropertyLinkDefinition name="TitlebarFont" widget="__auto_titlebar__" targetProperty="Font" />
      <Property name="Text" value="Toolbox" />
      <Property name="Font" widget="__auto_titlebar__" value="MyriadPro-9" />


Finally, my CEGUI log is mostly fine. There are a few errors that have to do with an outdated layout we use briefly at the beginning of the program for a login screen (so not relevant), as well as some object exception errors I need to take a look at, but again they shouldn't have anything to do with the titlebar.

Code: Select all

02/11/2010 11:00:51 (Std)    ---- Version 0.7.2 (Build: Aug 28 2010 Debug Microsoft Windows MSVC++ 8.0 32 bit) ----
02/11/2010 11:00:51 (Std)    ---- Renderer module is: CEGUI::OpenGLRenderer - Official OpenGL based 2nd generation renderer module.  TextureTarget support enabled via FBO extension. ----
02/11/2010 11:00:51 (Std)    ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
02/11/2010 11:00:51 (Std)    ---- Image Codec module is: SILLYImageCodec - Official SILLY based image codec ----
02/11/2010 11:00:51 (Std)    ---- Scripting module is: None ----

...

02/11/2010 11:01:13 (Error)   CEGUI::UnknownObjectException in file c:\cegui-0.7.2-vc8\cegui\src\ceguiwindowmanager.cpp(256) : WindowManager::getWindow - A Window object with the name 'ToolboxWindow__auto_closebutton__' does not exist within the system
02/11/2010 11:01:13 (Error)   CEGUI::UnknownObjectException in file c:\cegui-0.7.2-vc8\cegui\src\ceguiwindowmanager.cpp(256) : WindowManager::getWindow - A Window object with the name 'ToolboxWindow__auto_polygoncreation_btn__' does not exist within the system
02/11/2010 11:01:13 (Std)    ---- Successfully completed loading of GUI layout from 'Immersive_ToolboxWindow.layout' ----


In all of these cases my font property was ignored entirely and the font is the same big, ugly default font it was before... I am not getting any error messages printed to my console, and the windows are popping up fine, so the XML is parsed alright.

Is this a bug or am I failing to put the tag in the right spot?

Re: Cannot Set Titlebar Font via Looknfeel?

Posted: Wed Nov 03, 2010 11:30
by CrazyEddie
I think any of these solutions should work - except maybe the last one which is - as you suspected - not actually valid.

Since we have this PropertyLinkDefinition set up the same way in FrameWindow for TaharezLook I ran a couple of tests there and it all worked as expected - so I'm not quite sure what to suggest. The only difference I see is that you're on 0.7.2 and I'm on 0.7.4, but for this particular feature I don't think that is significant.

Could you test TaharezLook (either in your app or via one of the samples) and confirm you can get this working correctly there?

CE.

Re: Cannot Set Titlebar Font via Looknfeel?

Posted: Thu Nov 04, 2010 14:40
by mithryanna
I tested a TaharezLook FrameWindow in our app and the looknfeel successfully changed the titlebar font.

For the test I did the following:

Modified TaharezLook looknfeel; changed text property in addition to the titlebarfont so I could tell if the looknfeel was being recognized even if the titlebarfont property was ignored.

Code: Select all

<Property name="Text" value="Titlebar Font Test" />
<Property name="TitlebarFont" value="MyriadPro-9" />


I successfully spawned a TaharezLook/FrameWindow with titlebar text set to Titlebar Font Test and font set to MyriadPro-9. So no CEGUI bug. Unfortunately I still have to track down why the same code isn't setting the titlebar font in our custom looknfeel...

Re: Cannot Set Titlebar Font via Looknfeel?

Posted: Thu Nov 04, 2010 14:49
by mithryanna
Case closed. You're gonna laugh at this one; I know I am. :hammer: Turns out the .layout files automatically generated in the layout editor that we were using for our windows were setting the titlebar font, so anytime I set the titlebarfont property in the looknfeel it didn't matter since it was getting overridden by the layout!