-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More changes to ModernSkin, OptionalGroups changes, some refactors an…
…d interface folder.
- Loading branch information
1 parent
3f93c11
commit 09cdc78
Showing
24 changed files
with
1,095 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/layout/LayoutContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.tanishisherewith.dynamichud.utils.contextmenu.layout; | ||
|
||
import com.tanishisherewith.dynamichud.utils.contextmenu.options.Option; | ||
|
||
public class LayoutContext { | ||
private final Offset indent; | ||
private final Option<?> parentOption; | ||
|
||
public LayoutContext() { | ||
this(Offset.zero(), null); | ||
} | ||
|
||
public LayoutContext(Offset margin, Option<?> parentOption) { | ||
this.indent = margin; | ||
this.parentOption = parentOption; | ||
} | ||
|
||
public Offset getIndent() { | ||
return indent; | ||
} | ||
|
||
public Option<?> getParentOption() { | ||
return parentOption; | ||
} | ||
|
||
// Builder-style methods for creating new contexts | ||
public LayoutContext withIndent(Offset indent) { | ||
return new LayoutContext(indent, this.parentOption); | ||
} | ||
|
||
public LayoutContext withParent(Option<?> parent) { | ||
return new LayoutContext(this.indent, parent); | ||
} | ||
|
||
public LayoutContext addIndent(Offset additionalIndent) { | ||
return new LayoutContext( | ||
this.indent.add(additionalIndent), | ||
this.parentOption | ||
); | ||
} | ||
|
||
// Utility methods for calculating positions | ||
public int getEffectiveX(int baseX) { | ||
return baseX + indent.left; | ||
} | ||
|
||
public int getEffectiveY(int baseY) { | ||
return baseY + indent.top; | ||
} | ||
|
||
public int getEffectiveWidth(int baseWidth) { | ||
return baseWidth + indent.left; | ||
} | ||
|
||
public int getEffectiveHeight(int baseHeight) { | ||
return baseHeight + indent.top; | ||
} | ||
|
||
public static class Offset { | ||
public final int left; | ||
public final int top; | ||
|
||
public Offset(int all) { | ||
this(all, all); | ||
} | ||
|
||
public Offset(int horizontal, int vertical) { | ||
this.left = horizontal; | ||
this.top = vertical; | ||
} | ||
|
||
public static Offset zero() { | ||
return new Offset(0); | ||
} | ||
|
||
public Offset add(Offset other) { | ||
return new Offset( | ||
this.left + other.left, | ||
this.top + other.top | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.