Olivier
Topic Author
Posts: 6
Joined: 22 Nov 2012, 20:41

Question with integration NoesisGUI / Ogre

06 Dec 2012, 00:07

Hello,

I currently trying NoesisGUI with Ogre3D. I have integrated NoesisGUI with the exemples.
Exemple with Time.xaml work fine, and TicTacToe too ^^.

In the provided examples, I tried to integrate all exemple and only XAML exemple which contains only vectorial design work fine (time.xaml, butterfly.xaml, tiger and tux.xaml work fine) but other exemple don't work.
If i try to integrate, for exemple, Palette.xaml, there are no error but nothing is display.

After several test, I have generate a exemple where the viewer show the content correctly and where my application bug (left the viewer, right my application) :
Image

My application can display canvas, certain type of TextBlock (with 3 Textblock, only one is displayed) and button is not display.

Can you help me to understand ?
 
User avatar
sfernandez
Site Admin
Posts: 1911
Joined: 22 Dec 2011, 19:20

Re: Question with integration NoesisGUI / Ogre

07 Dec 2012, 14:51

Hello Olivier,

As it occurs in WPF, every control needs a valid Template to get a visual representation. Our engine doesn't define a default theme (where default styles and templates are usually defined for each control) becuase sometimes there is no need for them and resources are saved.

When you are designing a XAML that includes control elements, you must provide a template for each control type. This can be done explicitly:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid.Resources>
        <ControlTemplate x:Key="ButtonTemplate" TargetType="{x:Type Button}">
            <Border Background="Silver" Padding="10,5">
                <ContentPresenter
                  HorizontalAlignment="Center"
                  VerticalAlignment="Center"/>
            </Border>
        </ControlTemplate>
    </Grid.Resources>
    <Button
      Template="{StaticResource ButtonTemplate}"
      Content="Button"
      HorizontalAlignment="Center"
      VerticalAlignment="Center"/>
</Grid>
By including an external file with all the styles and templates for the controls you use already defined:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../../Gui/Themes/NoesisStyle.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Grid.Resources>
    <Button
      Template="{StaticResource ButtonTemplate}"
      Content="Button"
      HorizontalAlignment="Center"
      VerticalAlignment="Center"/>
</Grid>
Or you can specify that external resource file directly when loading the XAML using the Ogre Bindings API:
void* uiRoot;
void* uiRenderer;
Noesis_LoadXAML(&uiRoot, &uiRenderer, "Gui/Samples/Button.xaml", "Gui/Themes/NoesisStyle.xaml");
Anyway, seeing that this behavior has caused more confusion in the past and it is not at all intuitive, in the following release we will notify by a clear error that a control does not have a valid template for rendering.
 
Olivier
Topic Author
Posts: 6
Joined: 22 Nov 2012, 20:41

Re: Question with integration NoesisGUI / Ogre

08 Dec 2012, 20:09

Thank you for your reply,

It works well !

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 0 guests