Skip to content

Commit

Permalink
Merge pull request #1 from ThatGravyBoat/feat/misc-changes-additions
Browse files Browse the repository at this point in the history
Misc changes and additions
  • Loading branch information
DeDiamondPro authored Jul 3, 2024
2 parents 2e827ef + 6a0bfca commit 7696ca7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/main/java/dev/dediamondpro/minemark/LayoutStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ public <T> void put(StyleType<T> styleType, T value) {
customStyles.put(styleType, value);
}

public <T> void remove(StyleType<T> styleType) {
customStyles.remove(styleType);
}

public <T> boolean has(StyleType<T> styleType) {
return customStyles.containsKey(styleType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public void endElement(String uri, String localName, String qName) {
break;
}
addText();
currentElement.complete();
currentElement = currentElement.getParent();
}

Expand Down
17 changes: 14 additions & 3 deletions src/main/java/dev/dediamondpro/minemark/elements/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,18 @@ public Element(@NotNull S style, @NotNull LayoutStyle layoutStyle, @Nullable Ele
this.attributes = attributes;
}

/**
* Called when an element is ended and all children are created.
*/
@ApiStatus.OverrideOnly
public void complete() {

}

/**
* Internal method for drawing an element, should never be used directly.
*/
@ApiStatus.Internal
@ApiStatus.OverrideOnly
public void drawInternal(float xOffset, float yOffset, float mouseX, float mouseY, R renderData){
for (Element<S, R> child : children) {
child.drawInternal(xOffset, yOffset, mouseX, mouseY, renderData);
Expand All @@ -73,7 +81,7 @@ public void drawInternal(float xOffset, float yOffset, float mouseX, float mouse
/**
* Internal method called before drawing an element, should never be used directly.
*/
@ApiStatus.Internal
@ApiStatus.OverrideOnly
public void beforeDrawInternal(float xOffset, float yOffset, float mouseX, float mouseY, R renderData) {
for (Element<S, R> child : children) {
child.beforeDrawInternal(xOffset, yOffset, mouseX, mouseY, renderData);
Expand All @@ -83,7 +91,7 @@ public void beforeDrawInternal(float xOffset, float yOffset, float mouseX, float
/**
* Internal method for called when the mouse is clicked, should never be used directly.
*/
@ApiStatus.Internal
@ApiStatus.OverrideOnly
public void onMouseClickedInternal(MouseButton button, float mouseX, float mouseY) {
for (Element<S, R> child : children) {
child.onMouseClickedInternal(button, mouseX, mouseY);
Expand Down Expand Up @@ -131,7 +139,10 @@ public void close() {

/**
* Build a tree of elements for debugging purposes
* <p>
* Use {@link MineMarkElement#getTree()} to get the full tree
*/
@ApiStatus.Internal
public String buildTree(int depth) {
StringBuilder builder = new StringBuilder();
builder.append(this);
Expand Down

0 comments on commit 7696ca7

Please sign in to comment.