Skip to content

Commit

Permalink
update smallbutton.d
Browse files Browse the repository at this point in the history
  • Loading branch information
ZILtoid1991 committed Jul 5, 2023
1 parent 7301fc0 commit 6291bbb
Showing 1 changed file with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,26 @@ module pixelperfectengine.concrete.elements.smallbutton;

public import pixelperfectengine.concrete.elements.base;

/**
* SmallButton is used to implement small buttons for toolbars, on window headers, etc.
* Icons contain the frame of the buttons, etc., and are recalled from the closest
* available stylesheet.
*/
public class SmallButton : WindowElement, ISmallButton {
///Defines what icons will the button use for its states.
public string iconPressed, iconUnpressed;
private bool _isPressed;
//protected IRadioButtonGroup radioButtonGroup; //If set, the element works like a radio button

//public int brushPressed, brushNormal;


/**
* Creates an instance of SmallButton.
* Params:
* iconPressed = the string ID of the icon to be shown when the button is pressed.
* iconUnpressed = the string ID of the icon to be shown when the button is not
* pressed.
* source = the source identifier passed in the event class.
* position = the position where the button will be drawn. If the button will be
* used as a window header button, you only need to set the size, since the final
* position will be set by the window itself.
*/
public this(string iconPressed, string iconUnpressed, string source, Box position){
this.position = position;

Expand All @@ -19,7 +32,8 @@ public class SmallButton : WindowElement, ISmallButton {


}
public override void draw(){
public override void draw() {
if (parent is null) return;
StyleSheet ss = getStyleSheet();
Bitmap8Bit icon = isPressed ? ss.getImage(iconPressed) : ss.getImage(iconUnpressed);
parent.bitBLT(position.cornerUL, icon);
Expand All @@ -38,6 +52,9 @@ public class SmallButton : WindowElement, ISmallButton {
onDraw();
}
}
/**
* Returns true if the SmallButton is of size `height`, false otherwise.
*/
public bool isSmallButtonHeight(int height) {
if (position.width == height && position.height == height) return true;
else return false;
Expand Down

0 comments on commit 6291bbb

Please sign in to comment.