Button foreground color (1 Viewer)

Tgx

Retired Team Member
  • Premium Supporter
  • January 22, 2008
    1,560
    1,115
    Home Country
    Italy Italy
    Hi everybody,

    I'm working at last on a real skin for MP2. I'm experimenting with all the controls. Is there a way to change the default white foreground color for buttons used in templates?

    Thanks

    Tgx
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    Buttons are defined inside buttons.xaml and they are using colors from other files (both can be theme depending). I can give more infos when I'm back home.
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    Let me describe some basic steps here, how to find the information you want. Take this as a small tour into the MP2 xaml files :)

    Let's start to investigate the "default" skin. It's defined inside the "SkinBase" plugin.

    For buttons we check the folder structure of the "SkinBase" plugin:

    Code:
    [SkinBase]
      Skin
        default (skin name)
          themes
            default (theme name)
              styles
                Buttons.xaml

    So yes, Buttons.xaml we are looking for. So next look into this xaml file:

    Code:
    ....
      <!-- ************************* Control styles for buttons ************************* -->
     
      <Style x:Key="ButtonControlStyle" TargetType="{x:Type Control}">
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate>
              <Rectangle x:Name="ButtonControlRectangle" Stroke="{ThemeResource ButtonStrokeColor}"
                  RadiusX="{ThemeResource ButtonControlRadiusX}" RadiusY="{ThemeResource ButtonControlRadiusY}">
                <Rectangle.Fill>
                  <RadialGradientBrush GradientOrigin="0.85,0.82">
                    <RadialGradientBrush.RelativeTransform>
                      <TransformGroup>
                        <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1.335" ScaleY="1.582"/>
                        <TranslateTransform X="0.027" Y="-0.006"/>
                      </TransformGroup>
                    </RadialGradientBrush.RelativeTransform>
                    <GradientStop Color="{ThemeResource ButtonGradient1Color}" Offset="0"/>
                    <GradientStop Color="{ThemeResource ButtonGradient2Color}" Offset="1"/>
                  </RadialGradientBrush>
                </Rectangle.Fill>
              </Rectangle>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
      </Style>

    This is the main definition of the button "background". Here is no content yet...
    Next:
    Code:
      <!-- ***************************** Standard buttons ******************************** -->
     
      <Style x:Key="DefaultButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate>
              <Grid x:Name="GrowControl" RenderTransformOrigin="0.5,0.5" Margin="2">
                <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                  <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid.RenderTransform>
                  <TransformGroup>
                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                  </TransformGroup>
                </Grid.RenderTransform>
                <Control Style="{ThemeResource ButtonControlStyle}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
                <ContentPresenter x:Name="ButtonContentPresenter" Margin="10,5,10,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
              </Grid>
              <ControlTemplate.Triggers>
                <Trigger Property="HasFocus" Value="True">
                  <Trigger.EnterActions>
                    <BeginStoryboard x:Name="Focused_BeginStoryboard" Storyboard="{ThemeResource FocusedButtonStoryboard}"/>
                    <SoundPlayerAction Source="button12.wav" DisableOnAudioOutput="True"/>
                  </Trigger.EnterActions>
                  <Trigger.ExitActions>
                    <StopStoryboard BeginStoryboardName="Focused_BeginStoryboard"/>
                  </Trigger.ExitActions>
                </Trigger>
                <Trigger Property="IsPressed" Value="True">
                  <Trigger.EnterActions>
                    <BeginStoryboard x:Name="Pressed_BeginStoryboard" Storyboard="{ThemeResource PressedButtonStoryboard}"
                        HandoffBehavior="TemporaryReplace"/>
                    <SoundPlayerAction Source="button7.wav" DisableOnAudioOutput="True"/>
                  </Trigger.EnterActions>
                  <Trigger.ExitActions>
                    <StopStoryboard BeginStoryboardName="Pressed_BeginStoryboard"/>
                  </Trigger.ExitActions>
                </Trigger>
                <Trigger Property="IsEnabled" Value="False">
                  <Trigger.EnterActions>
                    <BeginStoryboard x:Name="Disabled_BeginStoryBoard" Storyboard="{ThemeResource DisabledButtonStoryboard}"/>
                  </Trigger.EnterActions>
                  <Trigger.ExitActions>
                    <StopStoryboard BeginStoryboardName="Disabled_BeginStoryBoard"/>
                  </Trigger.ExitActions>
                </Trigger>
              </ControlTemplate.Triggers>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
      </Style>
     
      <!-- Implicit default style for Button controls -->
      <Style BasedOn="{ThemeResource DefaultButtonStyle}" TargetType="{x:Type Button}"/>
    The style for all generic buttons is found! There are more styles (like ButtonWideStyle, which are quite similar).

    But still no real button content, that we can change here directly. All content is replaced into this template by
    Code:
                <ContentPresenter x:Name="ButtonContentPresenter" Margin="10,5,10,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>

    Now let's check where this style get's used. Do a "find in project" and search for 'Style="{ThemeResource ButtonWideStyle}"'.

    One occurence leads to "othercontrols.xaml":
    Code:
      <!-- An item list container represented by a standard "Button", scrolling its "ItemLabel" label when focused -->
      <Style x:Key="DefaultMenuItemContainerStyle" BasedOn="{ThemeResource DefaultItemContainerStyle}">
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate TargetType="{x:Type ListViewItem}">
              <Button Style="{ThemeResource ButtonWideStyle}"
                  Command="{DynamicResource ResourceKey=Menu_Command}"
                  IsEnabled="{Binding Enabled}" SetFocus="{Binding Path=Selected,Mode=OneTime}">
                <Button.Triggers>
                  <Trigger Property="HasFocus" Value="True">
                    <Setter TargetName="ItemLabel" Property="Scroll" Value="Auto"/>
                    <Setter Property="StackPanel.ZIndex" Value="100.0"/>
                  </Trigger>
                </Button.Triggers>
              </Button>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
      </Style>
    Yes, there is a button used as a ListViewItem, in general lists (menu, media items), which uses our '<Button Style="{ThemeResource ButtonWideStyle}"...'

    There you find a first reference to the label, called '<Setter TargetName="ItemLabel" Property="Scroll" Value="Auto"/>'. Label contains the text content. Text has a color... So next question, where is this "DefaultMenuItemContainerStyle" used?

    Code:
      <!-- ListView style to be used for main menu -->
      <Style x:Key="MainMenuListViewStyle" BasedOn="{ThemeResource DefaultListViewStyle}">
        <Setter Property="ItemTemplate" Value="{ThemeResource MainMenuItemDataTemplate}"/>
        <Setter Property="DataStringProvider" Value="{ThemeResource MainMenuItemDataStringProvider}"/>
        <Setter Property="ItemContainerStyle" Value="{ThemeResource DefaultMenuItemContainerStyle}"/>
      </Style>
    Getting better, now let's check the ItemTemplate "MainMenuItemDataTemplate"...

    Well, we got it (finally!):
    Code:
      <DataTemplate x:Key="MainMenuItemDataTemplate">
        <DockPanel x:Name="ItemControl" LastChildFill="True">
          <Label x:Name="ItemLabel" DockPanel.Dock="Center" Content="{Binding [Name]}" Color="{ThemeResource TextColor}"/>
        </DockPanel>
      </DataTemplate>
    There is our label, using the Color "TextColor".

    When we now search for the definition of "TextColor" this leads us to the real color, defined inside "colors.xml"

    Code:
      <!-- White -->
      <ResourceWrapper x:Key="TextColor" Resource="White"/>

    This value you can change now to any other color, "Red", "Green", "#FFFFFF" (white), "#A0FFFFFF" (semi transparent white).

    As a rule of thumb, look into the .xaml files with suitable names, here "color.xaml" contains all definitions of main colors (or gradients).
     
    Last edited:

    Tgx

    Retired Team Member
  • Premium Supporter
  • January 22, 2008
    1,560
    1,115
    Home Country
    Italy Italy
    • Thread starter
    • Moderator
    • #4
    Thanks,

    i really appreciate your help! One thing that puzzled me is the fact that the output of Expression Blend is slightly different from the syntax which Mediaportal 2 comprehends.
    In this case i was looking for the property "foreground" produced through Blend and i could not find it in Mp2 xaml files. Later, analyzing the code, i found that every time we need to change the foreground color of a control i needed to search for the "color" property.

    There will surely be other issue to solve... i hope you can help me!

    Right now, is it possible to implement hidden menus (actionmenus) and animations like "windowopen/windowclose" like the ones used in Mp1?

    Thanks

    Tgx
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    There is a lot you can do with animations. I recently build such a hidden menu in Reflexions movie view. It slides in on key press or button click. You can check the latest version from dev branch.

    There is also the Gui TestPlugin that shows more animations. In principle you can animate all transforms: translate, rotate and scale.
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    Hi,

    did you get further in your tests? Are there any things where I can assist you?

    All questions are good to ask, I will try to put them into a "MP2-Skinning-FAQ" in the end, so other skinners can also profit from it.

    Morpheus
     

    Tgx

    Retired Team Member
  • Premium Supporter
  • January 22, 2008
    1,560
    1,115
    Home Country
    Italy Italy
    • Thread starter
    • Moderator
    • #8
    I'm a little busy at the moment. However i think i've understood how skinning works in MP2.
    At first I tried to modify your Reflexion skin, but it ended in a skin full of useless code and unoptimized.
    Then i realized that every skin depends on the default MP2 skin in every part.
    I'm now rebuilding from ground up my skin starting from the default MP2 skin and adding my own code. It will take a while!

    I'd like to add hidden menus like the ones from MP1, but i cannot find the branch you mentioned in the previous post. I'm not good with Git.

    Thanks

    Tgx
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    Hi,

    the slide menu I have implemented is already merged into dev branch. So you find a fully working version in my Reflexion skin https://github.com/MediaPortal/Medi.../Skin/Reflexion/screens/master_slidemenu.xaml

    In principle it does use RenderTransformations to Translate (x) the menu out of screen. On trigger ("menu" button click, or Key.Info) it slides in, sets the focus to menu.

    Morpheus
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    Any news on the skinning front? Questions are welcome, I think they will help others as well :)
     

    Users who are viewing this thread

    Similar threads

    Before you create this bug report: Make sure that your system (Windows, codecs and drivers) is up to date, matching the Requirements and you've filled in your System Specs. Have a look at our MediaPortal Wiki! Maybe the solution is already there. Have a look at our Jira (Bug and Issue Tracker)and the threads in this section, maybe...
    Before you create this bug report: Make sure that your system (Windows, codecs and drivers) is up to date, matching the...
    Before you create this bug report: Make sure that your system (Windows, codecs and drivers) is up to date, matching the...
    Replies
    0
    Views
    288
    This is one of the top search results for WMC having stopped working; thanks everyone for the useful information! My shell scripting skills are very rusty these days, so for those like me who are still rocking Windows 7's (or some later version of) WMC, I thought I'd post the (rather hacky) Python script I'm using as a drop-in...
    This is one of the top search results for WMC having stopped working; thanks everyone for the useful information! My shell...
    NOT A MEDIAPORTAL ISSUE. Using MediaPortal1, Kodi for TV viewing. Today I noticed the TV Guide in Kodi stopped updating. A Google...
    Replies
    32
    Views
    4K
    I should point out that the developers have not formally left the project, and development has not formally stopped. The developers have instead simply "faded away", gradually spending less and less time on MP2 until the present, when they spend no time on MP2. But one or more of the developers might return next week! It is impossible...
    I should point out that the developers have not formally left the project, and development has not formally stopped. The developers...
    Hi Folks, I need some help with fixing the Problem that MP2 doesn't keep the sorted Order of Channels in TV-Configuraiton. I am...
    Replies
    10
    Views
    449
    MP1 MP2 Design questions. DE
    No No
    No No
    Is there an xml display utility that will allow graphically checking of dialog and osd text and graphics element placement? or Is...
    Replies
    1
    Views
    204
    Hi CyberSimian (and others) just a bit along the coast from me (near Exeter) - I know you are very long-standing! Not going to make this long winded or anything, but just to point out over the @15 years I've overall donated several hundred quid. And I begrduge NONE of it, not a penny - I do wish MP well - 100%. It is an awesome...
    Hi CyberSimian (and others) just a bit along the coast from me (near Exeter) - I know you are very long-standing! Not going to...
    ONGGGG term MP user (and donator - why wouldn't you?) and leaving somewhat reluctantly. Few reasons, some that just seem...
    Replies
    4
    Views
    1K
    Top Bottom