Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc changes and additions #1

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading