Page 1 of 1

Padding between buttons

Posted: 20 Sep 2013, 20:48
by golgepapaz
I am programmatically adding buttons to a Stackpanel.All is well but there are spaces between
buttons as shown in the image below.
Image

I've tried using SnaptoDevicePixels instead of UseLayoutRounding property at GUIRoot after a Google search as a remedy to the problem but it seem Noesis does not respect to the property.

Also how can I set dependency properties in unity script? I am guessing it's done with SetValue() but I was unable to use it for SnaptoDevicePixels property. Should I define it myself? will it work in that case?

Re: Padding between buttons

Posted: 21 Sep 2013, 02:10
by sfernandez
Hi, I will try to explain what is happening.

The visual aspect of a control is determined by its Template. The buttons in your attached image are using our default style, which is designed to have a space around the button for the focus border (just click on a button and you will see a blue border around the button indicating which control has the focus).

You can modify that default appearance by defining your own ControlTemplate:
<ControlTemplate x:Key="MyButtonTemplate" TargetType="{x:Type ButtonBase}">
    <Grid UseLayoutRounding="True">
        <Border x:Name="Bg"
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            BorderThickness="{TemplateBinding BorderThickness}"
            CornerRadius="1"/>
        <Grid Margin="{TemplateBinding BorderThickness}">
            <ContentPresenter
                RecognizesAccessKey="True"
                Margin="{TemplateBinding Padding}"
                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                UseLayoutRounding="{TemplateBinding UseLayoutRounding}"/>
        </Grid>
    </Grid>
    <ControlTemplate.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter TargetName="Bg" Property="Background" Value="Yellow"/>
        </Trigger>
        <Trigger Property="IsPressed" Value="True">
            <Setter TargetName="Bg" Property="Background" Value="Gold"/>
        </Trigger>
    </ControlTemplate.Triggers>
</ControlTemplate>
Then you can apply that template to any button:
<Button Template="{StaticResource MyButtonTemplate}" Content="Button"/>
About SnapsToDevicePixels, we didn't implement it, in favor of UseLayoutRounding because of performance reasons.

Re: Padding between buttons

Posted: 21 Sep 2013, 10:47
by golgepapaz
alright, thank you. Also added a bug to mantis tracker about noesis crashing seeing it was empty I was not sure whether you are checking it.

Re: Padding between buttons

Posted: 21 Sep 2013, 17:58
by sfernandez
Bug tracker is the appropriate place to post bugs.
And you see it empty because visibility is limited to only your own reported bugs.

;)

Re: Padding between buttons

Posted: 21 Sep 2013, 18:12
by sfernandez
Also how can I set dependency properties in unity script? I am guessing it's done with SetValue() but I was unable to use it for SnaptoDevicePixels property. Should I define it myself? will it work in that case?
All dependency properties are wrapped with the corresponding Getter and Setter functions. For example, to set the Text dependency property in a TextBlock, you can use the SetText function:
NoesisGUIPanel gui = GetComponent<NoesisGUIPanel>();
FrameworkElement root = gui.GetRoot<FrameworkElement>();
TextBlock tb = root.FindName<TextBlock>("tb");
tb.SetText("Some text");

Re: Padding between buttons

Posted: 21 Sep 2013, 19:00
by golgepapaz
All dependency properties are wrapped with the corresponding Getter and Setter functions. For example, to set the Text dependency property in a TextBlock, you can use the SetText function:
NoesisGUIPanel gui = GetComponent<NoesisGUIPanel>();
FrameworkElement root = gui.GetRoot<FrameworkElement>();
TextBlock tb = root.FindName<TextBlock>("tb");
tb.SetText("Some text");
So if I don't see it in the intellisense that means it's not implemented is that right?

As for the mantis, you could at the very least make user issues visible (if that's at all possible) this would prevent duplicate entries and help refining bugs.Surely you can use another tracker for your own internal use in any case.

Re: Padding between buttons

Posted: 22 Sep 2013, 01:41
by jsantos
So if I don't see it in the intellisense that means it's not implemented is that right?
Yes, probably. But if you miss anything just tell us.
As for the mantis, you could at the very least make user issues visible (if that's at all possible) this would prevent duplicate entries and help refining bugs.Surely you can use another tracker for your own internal use in any case.
Yes, we have our own internal tracker (with hundreds of tickets). The one found at bugs.noesisengine.com is for clients. We made it private on purpose because many times we need resources (scenes, xamls) to track the bug and we think that data must remain private, not visible for the rest of the users.