Skip to content

Commit

Permalink
Added element hiding capability
Browse files Browse the repository at this point in the history
Giving labels multiline capabilities
  • Loading branch information
ZILtoid1991 committed Jan 29, 2024
1 parent 277a027 commit 84f1492
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 7 deletions.
12 changes: 12 additions & 0 deletions assets/test3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ETML>
<etml>
<text id="multilinedialog">
This is a multiline dialog. <br />
This dialog has multiple lines. <br />
</text>
<text id="multilinelabel">
This is a multiline label. <br />
This label has multiple lines.
</text>
</etml>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public enum ElementState : ubyte {
Enabled = 0, ///Means the element is enabled.
DisabledWOGray = 1, ///Disabled without grayout, should be only used by elements contained within other elements.
Disabled = 2, ///Means the element is disabled.
Hidden = 3, ///Element isn't drawn on the screen.
}
/**
* All Window elements inherit from this class. Provides basic interfacing with containers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class Button : WindowElement {
//output = new BitmapDrawer(coordinates.width, coordinates.height);
}
public override void draw() {
if (parent is null) return;
if (parent is null || state == ElementState.Hidden) return;
StyleSheet ss = getStyleSheet();
parent.clearArea(position);
if (isPressed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class CheckBox : WindowElement, ISmallButton {
isChecked = checked;
}
public override void draw() {
if (parent is null || state == ElementState.Hidden) return;
parent.clearArea(position);
StyleSheet ss = getStyleSheet;
Bitmap8Bit icon = isChecked ? ss.getImage(iconChecked) : ss.getImage(iconUnchecked);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class SlidingEncoder : WindowElement {
return _value;
}
override public void draw() {
if (parent is null || state == ElementState.Hidden) return;
parent.bitBLT(position.cornerUL, background);
const Point sliderpos = Point(position.left + track.left, position.top + track.top + cast(uint)(valRatio * _value));
parent.bitBLT(sliderpos, slider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ public class Label : WindowElement {
this.source = source;
}
public override void draw() {
if (parent is null || state == ElementState.Hidden) return;
StyleSheet ss = getStyleSheet();
parent.drawFilledBox(position, ss.getColor("window"));
parent.drawTextSL(position, text, Point(0,0));
//parent.drawTextSL(position, text, Point(0,0));
parent.drawTextML(position, text, Point(0,0));
if (isFocused) {
const int textPadding = ss.drawParameters["horizTextPadding"];
parent.drawBoxPattern(position - textPadding, ss.pattern["blackDottedLine"]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public class ListView : WindowElement, ElementContainer, TextInputListener {
return value;
}
override public void draw() {
if (parent is null) return;
if (parent is null || state == ElementState.Hidden) return;
StyleSheet ss = getStyleSheet;
if (flags & TEXTINPUT_EN) { //only redraw the editing cell in this case
const int textPadding = ss.drawParameters["TextSpacingSides"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class MenuBar : WindowElement {
}
}
public override void draw() {
if (parent is null || state == ElementState.Hidden) return;
StyleSheet ss = getStyleSheet();
with (parent) {
drawFilledBox(position, ss.getColor("window"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ public class Panel : WindowElement, ElementContainer {
}
return super.state(state);
}
public override ElementState state() @property @nogc @safe const pure nothrow {
return super.state();
}
public override void draw() {
if (parent is null || state() == ElementState.Hidden) return;
foreach (key; subElems) {
key.draw;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class RadioButton : WindowElement, IRadioButton, ISmallButton {
group.add(this);
}
override public void draw() {
if (parent is null || state == ElementState.Hidden) return;
parent.clearArea(position);
StyleSheet ss = getStyleSheet();
Bitmap8Bit icon = isChecked ? ss.getImage(iconLatched) : ss.getImage(iconUnlatched);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public class VertScrollBar : ScrollBar {
this.maxValue = maxValue;
}
public override void draw(){
if (parent is null) return;
if (parent is null || state == ElementState.Hidden) return;
StyleSheet ss = getStyleSheet();
//draw background
parent.drawFilledBox(position, ss.getColor("SliderBackground"));
Expand Down Expand Up @@ -190,7 +190,7 @@ public class HorizScrollBar : ScrollBar {
this.maxValue = maxValue;
}
public override void draw(){
if (parent is null) return;
if (parent is null || state == ElementState.Hidden) return;
StyleSheet ss = getStyleSheet();
//draw background
parent.drawFilledBox(position, ss.getColor("SliderBackground"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class SmallButton : WindowElement, ISmallButton {

}
public override void draw() {
if (parent is null) return;
if (parent is null || state == ElementState.Hidden) return;
StyleSheet ss = getStyleSheet();
Bitmap8Bit icon = isPressed ? ss.getImage(iconPressed) : ss.getImage(iconUnpressed);
parent.bitBLT(position.cornerUL, icon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class TextBox : WindowElement, TextInputListener {
super.passMCE(mec, mce);
}
public override void draw(){
if (parent is null) return;
if (parent is null || state == ElementState.Hidden) return;
StyleSheet ss = getStyleSheet();
const int textPadding = ss.drawParameters["TextSpacingSides"];
with (parent) {
Expand Down

0 comments on commit 84f1492

Please sign in to comment.