[Approved] GUICheckButton implementation (1 Viewer)

ajp8164

Portal Pro
January 9, 2008
575
1,166
Atlanta, GA
Home Country
United States of America United States of America
This patch provides for an implementation of the GUICheckButton control (type=checkbutton). This control had a partial implementation and was not exposed through the control factory. I have completed the implementation (based on some of my previous patches) and exposed it for use. This patch affects only GUICheckButton.cs and GUIControlFactory.cs (to expose the control for interpretation from the skin xml). Skin designers and plugin developers can make use of this new control.

This control offers a high degree of flexibility for both rendering and behavior. The "on click" logic for this button toggles the "selected" value for the control and then considers hyperlink and action.

Control attributes for this control are:

textureFocus - the button image when this control is in focus. Default is no texture.
textureNoFocus - the button image when this control is not in focus. Default is no texture.
font - the label font for the button. Default is no font.
label - the button label. Default is "".
textcolor - the label text color when the control is in focus. Default is 0xFFFFFFFF.
textcolorNoFocus - the label text color when the control is not in focus. Default is 0xFFFFFFFF.
disabledcolor - the label text color when the control is disabled. Default is 0xFF606060.
hyperlink - the window id of the window to go to when the button is clicked. Default is stay on same page.
action - the action id to perform when the button is clicked. Default is to perform no action.
script - the script to run when the button is clicked. Default is no script to run.
textXOff - the text X position offset from it's calculated position (see textalign and textvalign). Default is 0.
textYOff - the text Y position offset from it's calculated position (see textalign and textvalign). Default is 0.
application - the application to run when the button is clicked. Default is no application to run.
arguments - arguments to the "application" attributes.
textureCheckmarkNoFocus - the image to use to render the checkmark when the control is not in focus. Default is no image.
textureCheckmark - the image to use to render the checkmark when the control is in focus. Default is no image.
markWidth - The width of the checkmark. Default is to use the native width of the specified texture.
markHeight - The height of the checkmark. Default is to use the native height of the specified texture.
markXOff - the checkmark X position offset from it's calculated position (see markalign and markvalign). Default is 0.
markYOff - the checkmark Y position offset from it's calculated position (see markalign and markvalign). Default is 0.
markalign - the horizontal alignment of the checkmark; "left","right","center". Default is "left".
markvalign - the vertical alignment of the checkmark; "top","middle","bottom". Default is "top".
shadowAngle - the integral angle, in degrees, of the shadow text. Zero degrees is along the x-axis, increasing positive values from zero will rotate the shadow clockwise.
shadowDistance - the number of pixels the shadow is offset from the normal (foreground) text.
shadowColor - the color of the shadow. Default is 0xFFFFFFFF.
textalign - the horizontal alignment of the label; "left","right","center". Default is "left".
textvalign - the vertical alignment of the label; "top","middle","bottom". Default is "top".

The following border attributes apply to both textureFocus and textureNoFocus.

border - specifies a comma separated list of border edge thickness for each side of the border. The order of values is left, right, top, bottom. This field accepts either four integer values separated by commas or a single integer value which is then used for all four sides. Examples: "10" -or- "10,10,1,1"
position - specifies the position of the border relative to the image edges. Valid values are "outside", "inside", "center". The default value is "outside".
textureRepeat - specifies whether the texture used for the border should repeat or stretch inside each of the four rectangles that compose the overall border. The default value is "no".
textureRotate - specifies whether or not the texture used for the border should be rotated for each of the border rectangles. If the texture should rotate then the texture will be rotated 90 deg for the right border rectangle, 180 deg for the bottom, and 270 deg for the left. The default value is "no".
border, texture - specifies the tetxure filename for the border rectangles. A single file is used for all four of the border rectangles. Based on the value of textureRepeat, the entire texture extent is either stretched (scaled up/down) to fill the border rectangles or is scaled (up/down) to fit inside the border rectangle at its native aspect ratio and repeatedly drawn until the border rectangle is filled. The default value is "image_border.png". This texture file must exist in the skin media directory otherwise no border will be drawn. Example: <border texture="my_border.png">10</border>
border, colorKey - specfies the color key for the border texture. The default value is 0xFFFFFFFF. Example: <border colorKey="0x66FFFFFF">10</border>

Below is a complete example of usage along with a picture of the result. Notice the (unselected) circular checkmark at the right side of the control.

Code:
			<control>
				<description>auto delete recordings</description>
				<type>checkbutton</type>
				<id>401</id>
				<label>6016</label>
				<onleft>13</onleft>
				<onright>13</onright>
				<onup>43</onup>
				<ondown>402</ondown>
				<textureCheckmark>check-box.png</textureCheckmark>
				<textureCheckmarkNoFocus>check-boxNF.png</textureCheckmarkNoFocus>
				<markWidth>16</markWidth>
				<markHeight>16</markHeight>
				<markXOff>20</markXOff>
				<markalign>right</markalign>
				<markvalign>middle</markvalign>
				<height>34</height>
				<width>995</width>
				<font>menu</font>
				<textcolor>#buttonTextColor</textcolor>
				<textalign>left</textalign>
				<textvalign>middle</textvalign>
				<textXOff>10</textXOff>
				<textureFocus border="1" position="inside" colorKey="66FFFFFF">list-focus.png</textureFocus>
				<textureNoFocus>list-nofocus.png</textureNoFocus>
			</control>

attachment.php
 

Attachments

  • Picture 1.png
    Picture 1.png
    28.4 KB
  • check_button_impl.patch
    30.7 KB

ajp8164

Portal Pro
January 9, 2008
575
1,166
Atlanta, GA
Home Country
United States of America United States of America
Question ...

I am also working on a control called a SpinButton that works in much the same way as this one except if uses the characteristics of a SpinControl rather than a CheckMarkControl. In the SpinButton I have removed the implementation of the following attributes since they make no sense in the usability of the control. The questions is: should I also remove these attributes and implementation from this CheckButton? Would anyone ever use these in combination?

hyperlink - the window id of the window to go to when the button is clicked. Default is stay on same page.
action - the action id to perform when the button is clicked. Default is to perform no action.
script - the script to run when the button is clicked. Default is no script to run.
application - the application to run when the button is clicked. Default is no application to run.
arguments - arguments to the "application" attributes.

Thanks for feedback.

Please PM me so we can keep this thread clean. :D
 

DieBagger

Retired Team Member
  • Premium Supporter
  • September 11, 2007
    2,516
    1,276
    41
    Austria
    Home Country
    Austria Austria
    Hi,

    could you please explain the difference between the checkbutton control and togglebutton as well as spinbutton vs. updownbutton? Is this meant as a replacement or do they have a different range of application?

    Also in your xml example you have:

    <textureCheckmarkFocus>check-box.png</textureCheckmarkFocus>

    while according to the sourcecode the property is called "textureCheckmark".

    Thx
     

    catavolt

    Design Group Manager
  • Team MediaPortal
  • August 13, 2007
    14,791
    11,609
    Königstein (Taunus)
    Home Country
    Germany Germany
    ^ You´re right! With <textureCheckmarkFocus>check-box.png</textureCheckmarkFocus> nothing is shown, but with <textureCheckmark>check-box.png</textureCheckmark> the green checkmark is finally shown. :D
     

    catavolt

    Design Group Manager
  • Team MediaPortal
  • August 13, 2007
    14,791
    11,609
    Königstein (Taunus)
    Home Country
    Germany Germany
    Just tested the GUICheckControl with latest SVN 24047. It seems that the activated checkmarks are not stored. When closing and re-opening the respective settings screen, all checkmarks are again deactivated. Any clue?
     

    ajp8164

    Portal Pro
    January 9, 2008
    575
    1,166
    Atlanta, GA
    Home Country
    United States of America United States of America
    The spinbutton is a combination of updownbutton and button. It allows for the spin control to appear embedded inside the button easily. Focus between the up/down arrows is made possible while the whole button is in focus. You can, for example, use the up/down arrows to make a choice and use the buttons select capability to consume that choice in some way.

    The checkbutton was implemented from an existing, unfinished implementation. It offers similar capability to the togglebutton but adds all the base button capability as well.

    At the time I created both of these controls I realized that there was too much risk in modifying the updown and toggle buttons (I might break every skin out there) - so creating these was the best way to go -- I consume these buttons in my skin plugin.

    These controls are only useful for plugin developers at the moment since their behavior is not inherited from any of their constituent controls.

    See the Focus skin thread for examples of how these button are used. I use them on my settings screens.

    Perhaps not the whole story... but close :D


    Hi,

    could you please explain the difference between the checkbutton control and togglebutton as well as spinbutton vs. updownbutton? Is this meant as a replacement or do they have a different range of application?

    Also in your xml example you have:

    <textureCheckmarkFocus>check-box.png</textureCheckmarkFocus>

    while according to the sourcecode the property is called "textureCheckmark".

    Thx
     

    ajp8164

    Portal Pro
    January 9, 2008
    575
    1,166
    Atlanta, GA
    Home Country
    United States of America United States of America
    @Catavolt -

    There may indeed be a bug in the svn trunk. Try the ajp_stage version and let me know if you experience the problem there. I have been using the builds of the stage branch since it was created and have not seen any issues.
    :D

    Just tested the GUICheckControl with latest SVN 24047. It seems that the activated checkmarks are not stored. When closing and re-opening the respective settings screen, all checkmarks are again deactivated. Any clue?
     

    Users who are viewing this thread

    Top Bottom