Custom theme (from Blend 2015) problem with rendering and colors in Noesis.
I want test my theme created with Blend 2015, after some fails finally I load everything and it looks same as from Blend. But not 100%.
In Blend everything looks same as from vector graphic editor, which I use for create graphics. Noesis render everything little bigger . Like there is some thikness added for everything. For example I have gaps with 1px which Blend render it, but in Noesis there are no gaps. (btw I use completly vector graphic). And I discover when I turn off antialiasing, the thikness is gone and everything have right size. But I am not sure if then graphic is antialiased or not, or if it is GLFW responsibility? And maybe good to mention I use GLFW not AppFramework.
Another problem is, when mouse is over buttons, it don't change to desired color. All colors are set up to black. I use colors from main theme, not from xaml file with buttons. Here is my theme structure file: (btw. buttons from main theme are completly ok, if mouse is over, except graphic thikness as I described above)
In Blend everything looks same as from vector graphic editor, which I use for create graphics. Noesis render everything little bigger . Like there is some thikness added for everything. For example I have gaps with 1px which Blend render it, but in Noesis there are no gaps. (btw I use completly vector graphic). And I discover when I turn off antialiasing, the thikness is gone and everything have right size. But I am not sure if then graphic is antialiased or not, or if it is GLFW responsibility? And maybe good to mention I use GLFW not AppFramework.
Another problem is, when mouse is over buttons, it don't change to desired color. All colors are set up to black. I use colors from main theme, not from xaml file with buttons. Here is my theme structure file: (btw. buttons from main theme are completly ok, if mouse is over, except graphic thikness as I described above)
Code: Select all
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Zalohovaci_Program_GUI_2"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
>
<!-- MergedDictionaries is copied from App.xaml in to DarkFlatTheme.xaml -->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="DakFlatT_button_tg_select.xaml"/>
<ResourceDictionary Source="DarkFlatT_button_add.xaml"/>
<ResourceDictionary Source="DarkFlatT_button_delete.xaml"/>
<!-- and lot of other buttons etc.. -->
</ResourceDictionary.MergedDictionaries>
<Color x:Key="White">White</Color>
<Color x:Key="Grey_Light_Dark">#FF999999</Color>
<Color x:Key="Grey_Dark_Light">#FF323232</Color>
<Color x:Key="Grey_Dark_Mz">#FF1F1F1F</Color>
<!-- Colors ... -->
<Style x:Key="button_window_close" TargetType="{x:Type Button}">
<!-- Lot of Code an this button colors is ok if mouse is over -->
</Style>
</ResourceDictionary>
Re: Custom theme (from Blend 2015) problem with rendering and colors in Noesis.
I have this code in DarkFlatT_button_add.xaml:
After change from
is working and color is changed if mouse is over button.
Can I use StaticResource with Noesis with some workaround without rewrite all documents in to DynamicResource?
And here is full code for button
Code: Select all
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="path3">
<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Geen_Light}"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="path5">
<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Geen_Light}"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="rectangle">
<EasingColorKeyFrame KeyTime="0" Value="#19F4F4F5"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
Code: Select all
<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Geen_Light}"/>
to
<EasingColorKeyFrame KeyTime="0" Value="{DynamicResource Geen_Light}"/>
Can I use StaticResource with Noesis with some workaround without rewrite all documents in to DynamicResource?
And here is full code for button
Code: Select all
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Zalohovaci_Program_GUI_2">
<Style x:Key="button_add" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="path3">
<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Geen_Light}"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="path5">
<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Geen_Light}"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="rectangle">
<EasingColorKeyFrame KeyTime="0" Value="#19F4F4F5"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="path3">
<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Green_Dark_Mz}"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="path5">
<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Green_Dark_Mz}"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="path3">
<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Grey_Mz_Dark}"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="path5">
<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Grey_Mz_Dark}"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Rectangle x:Name="rectangle" Fill="#00F4F4F5"/>
<Viewbox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Name="svg8" mc:Ignorable="d" Height="20" Stretch="Fill" Width="20" >
<!--Unknown tag: sodipodi:namedview-->
<Canvas x:Name="pridaj" Width="20" Height="20" d:LayoutOverrides="LeftPosition, RightPosition, TopPosition, BottomPosition">
<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="path3" StrokeThickness="2" StrokeMiterLimit="1.41421" StrokeLineJoin="Round" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Data="M10 4L10 16">
<Path.Stroke>
<SolidColorBrush Color="{DynamicResource Green_Grey_Mz}"/>
</Path.Stroke>
</Path>
<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="path5" StrokeThickness="2" StrokeMiterLimit="1.41421" StrokeLineJoin="Round" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Data="M16 10L4 10">
<Path.Stroke>
<SolidColorBrush Color="{DynamicResource Green_Grey_Mz}"/>
</Path.Stroke>
</Path>
</Canvas>
</Viewbox>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="True"/>
<Trigger Property="IsDefaulted" Value="True"/>
<Trigger Property="IsMouseOver" Value="True"/>
<Trigger Property="IsPressed" Value="True"/>
<Trigger Property="IsEnabled" Value="False"/>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
-
-
sfernandez
Site Admin
- Posts: 2534
- Joined:
Re: Custom theme (from Blend 2015) problem with rendering and colors in Noesis.
The unexpected thickness you are seeing is due to PPAA. It is our custom antialiasing technique that doesn't needs MSAA to work, but it extrudes edges of the geometry (<1px) to smooth them.
If that is a problem but your game/app can afford MSAA, then you can disable PPAA to get better results.
About the use of StaticResources you have to take into account that they can only be resolved if they are defined before they are used.
So if you reference any color resource in a button template, that color must be defined in that same xaml (or in a merged one) before.
You should be getting parsing errors if this is not the case. Looking at the attached xamls the colors you define are not available to the button xamls you are merging.
If that is a problem but your game/app can afford MSAA, then you can disable PPAA to get better results.
About the use of StaticResources you have to take into account that they can only be resolved if they are defined before they are used.
So if you reference any color resource in a button template, that color must be defined in that same xaml (or in a merged one) before.
You should be getting parsing errors if this is not the case. Looking at the attached xamls the colors you define are not available to the button xamls you are merging.
Re: Custom theme (from Blend 2015) problem with rendering and colors in Noesis.
Thanks.The unexpected thickness you are seeing is due to PPAA. It is our custom antialiasing technique that doesn't needs MSAA to work, but it extrudes edges of the geometry (<1px) to smooth them.
If that is a problem but your game/app can afford MSAA, then you can disable PPAA to get better results.
That means I must use DynamicResource instead Static, if I use mergedDictionaries? I was think it is working same as Blend. And I don't get any errors from Noesis and everything is loaded.About the use of StaticResources you have to take into account that they can only be resolved if they are defined before they are used.
So if you reference any color resource in a button template, that color must be defined in that same xaml (or in a merged one) before.
You should be getting parsing errors if this is not the case.
Colors are there, but I not copy all code and colors.Looking at the attached xamls the colors you define are not available to the button xamls you are merging.
-
-
sfernandez
Site Admin
- Posts: 2534
- Joined:
Re: Custom theme (from Blend 2015) problem with rendering and colors in Noesis.
Noesis regarding to StaticResource should work the same as in WPF.
Resources.xaml
If Buttons.xaml uses RedBrush as a StaticResource, both Blend and Noesis will raise an error because that resource is not defined for that xaml.
In that case you need to define these brush resources in another dictionary and reference it from the Buttons.xaml.
Resources.xaml
Brushes.xaml
Buttons.xaml
Resources.xaml
Code: Select all
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Buttons.xaml"/>
...
</ResourceDictionary.MergedDictionaries>
<SolidColorBrush x:Key="RedBrush" Color="Red"/>
...
</ResourceDictionary>
In that case you need to define these brush resources in another dictionary and reference it from the Buttons.xaml.
Resources.xaml
Code: Select all
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Buttons.xaml"/>
...
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Code: Select all
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="RedBrush" Color="Red"/>
...
</ResourceDictionary>
Code: Select all
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Brushes.xaml"/>
</ResourceDictionary.MergedDictionaries>
<ControlTemplate x:Key="ButtonTemplate" TargetType="Button">
<Grid Background="{StaticResource RedBrush}">
...
</ControlTemplate>
</ResourceDictionary>
Re: Custom theme (from Blend 2015) problem with rendering and colors in Noesis.
But "problem" is, I have it done (this dictionary structure) exactly as you describe it inside Blend (ok, not exactly because everything is under App.xaml and for noesis I only exctract mergedDictionaries and paste it in ResourceDictionary DarkTheme.xaml) and it working without any error. Even with Noesis, except that, everything with StaticResource have black color.Noesis regarding to StaticResource should work the same as in WPF.
Resources.xamlIf Buttons.xaml uses RedBrush as a StaticResource, both Blend and Noesis will raise an error because that resource is not defined for that xaml.Code: Select all<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Buttons.xaml"/> ... </ResourceDictionary.MergedDictionaries> <SolidColorBrush x:Key="RedBrush" Color="Red"/> ... </ResourceDictionary>
In that case you need to define these brush resources in another dictionary and reference it from the Buttons.xaml.
I add inside my DarkFlatT_button_add.xamlButtons.xamlCode: Select all<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Brushes.xaml"/> </ResourceDictionary.MergedDictionaries> <ControlTemplate x:Key="ButtonTemplate" TargetType="Button"> <Grid Background="{StaticResource RedBrush}"> ... </ControlTemplate> </ResourceDictionary>
Code: Select all
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="DarkFlatTheme.xaml"/>
</ResourceDictionary.MergedDictionaries>
<ControlTemplate x:Key="ButtonTemplate" TargetType="Button">
<Grid Background="{StaticResource Geen_Light}">
...
</ControlTemplate>
Is there option to set up dictionary in this way (maybe then button_add take colors from Theme)? pseudo code:
Code: Select all
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="DarkFlatTheme.xaml"/>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="DarkFlatT_button_add.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary.MergedDictionaries>
-
-
sfernandez
Site Admin
- Posts: 2534
- Joined:
Re: Custom theme (from Blend 2015) problem with rendering and colors in Noesis.
Are you using C++ SDK? In that case the error handler you pass on Noesis::GUI::Init() should be called everytime a StaticResource cannot be resolved.it working without any error
In case of using Unity or C# SDK it should be throwing a NoesisException. In Unity you can see messages about parsing errors in the console.
This occurs when StaticResource is not found, so a null is set in the property.Even with Noesis, except that, everything with StaticResource have black color
Because as I explained before, a StaticResource can only be resolved if the xaml include a previous definition of that resource, directly or via a MergedDictionary.I add inside my DarkFlatT_button_add.xaml... and now add button set correct color when mouse is over button.
There is an option if you want to avoid referencing several times the same xaml, but is kind of a hack.Is there option to set up dictionary in this way (maybe then button_add take colors from Theme)?
You can create an empty ResourceDictionary and call Noesis::GUI::SetApplicationResources().
Then you can load the Brushes (and other common resources) dictionary and add it as merged to the application dictionary you created.
Then load the rest of dictionaries depending on Brushes dictionary and add them as merged to the application dictionary too. You can also group all these dictionaries into one to simplify the code.
This will work without errors because StaticResources will be able to find brushes this time in the global Application Resources dictionary.
Re: Custom theme (from Blend 2015) problem with rendering and colors in Noesis.
Yes, I mention it in first post, but maybe not clear as I meant.Are you using C++ SDK?it working without any error
Can you please provide example? I can not find any function how to do this with codebehind with Noesis.There is an option if you want to avoid referencing several times the same xaml, but is kind of a hack.Is there option to set up dictionary in this way (maybe then button_add take colors from Theme)?
You can create an empty ResourceDictionary and call Noesis::GUI::SetApplicationResources().
Then you can load the Brushes (and other common resources) dictionary and add it as merged to the application dictionary you created.
Then load the rest of dictionaries depending on Brushes dictionary and add them as merged to the application dictionary too. You can also group all these dictionaries into one to simplify the code.
This will work without errors because StaticResources will be able to find brushes this time in the global Application Resources dictionary.
I tried something but every time I get crash:
Code: Select all
//Theme->SetSource("Themes/DarkFlat/DarkFlatTheme.xaml"); // is comented and didn't load xaml for Theme, // Theme is Noesis::ResourceDictionary as member.
Noesis::GUI::SetApplicationResources(Theme.GetPtr());
Noesis::Ptr<Noesis::ResourceKeyType> rkey = Noesis::GUI::LoadXaml<Noesis::ResourceKeyType>("Themes/DarkFlat/DarkFlatTheme.xaml");
Noesis::Ptr<Noesis::ResourceDictionary> rd = Noesis::GUI::LoadXaml<Noesis::ResourceDictionary>("Themes/DarkFlat/others.xaml"); // I add all buttons etc.. in to one others.xaml as merged dictionary
Noesis::Ptr<Noesis::ResourceDictionaryCollection> rdc = *new Noesis::ResourceDictionaryCollection;
rdc->Add("Themes/DarkFlat/others.xaml");
Theme->Add(rkey.GetPtr(), rdc.GetPtr()); // or Theme->Add(rkey.GetPtr(), rd.GetPtr()); allways I get crash on this
Re: Custom theme (from Blend 2015) problem with rendering and colors in Noesis.
Program load all xaml files and then crash.I tried something but every time I get crash:Code: Select all//Theme->SetSource("Themes/DarkFlat/DarkFlatTheme.xaml"); // is comented and didn't load xaml for Theme, // Theme is Noesis::ResourceDictionary as member. Noesis::GUI::SetApplicationResources(Theme.GetPtr()); Noesis::Ptr<Noesis::ResourceKeyType> rkey = Noesis::GUI::LoadXaml<Noesis::ResourceKeyType>("Themes/DarkFlat/DarkFlatTheme.xaml"); Noesis::Ptr<Noesis::ResourceDictionary> rd = Noesis::GUI::LoadXaml<Noesis::ResourceDictionary>("Themes/DarkFlat/others.xaml"); // I add all buttons etc.. in to one others.xaml as merged dictionary Noesis::Ptr<Noesis::ResourceDictionaryCollection> rdc = *new Noesis::ResourceDictionaryCollection; rdc->Add("Themes/DarkFlat/others.xaml"); Theme->Add(rkey.GetPtr(), rdc.GetPtr()); // or Theme->Add(rkey.GetPtr(), rd.GetPtr()); allways I get crash on this
EDIT:: I wanted edit post and mistakenly I click on Quote.
-
-
sfernandez
Site Admin
- Posts: 2534
- Joined:
Re: Custom theme (from Blend 2015) problem with rendering and colors in Noesis.
The code I was talking about should look like this:
Code: Select all
// Noesis::GUI::Init() ...
// Noesis::GUI::SetXamlProvider/SetFontProvider/SetTextureProvider...
Ptr<Noesis::ResourceDictionary> appResources = *new ResourceDictionary();
Noesis::GUI::SetApplicationResources(appResources);
Ptr<Noesis::ResourceDictionary> commonResources =
Noesis::GUI::LoadXaml<Noesis::ResourceDictionary>(
"Themes/DarkFlat/DarkFlatTheme.xaml");
appResources->GetMergedDictionaries()->Add(commonResources);
Ptr<Noesis::ResourceDictionary> otherResources =
Noesis::GUI::LoadXaml<Noesis::ResourceDictionary>(
"Themes/DarkFlat/others.xaml");
appResources->GetMergedDictionaries()->Add(otherResources);
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot], Semrush [Bot] and 2 guests