forked from CleanroomMC/ModularUI
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rich text & a bunch of tweaks * find hovering element in rich text * rich tooltip * split GuiContext * fix overlay context * fix & break mouse pos, i havent decided yet * rich text widget with hoverable & interactable * minor changes & fixes, i dont event know anymore * fix space at start of line * improvements, fixes, comments, javadoc
- Loading branch information
Showing
89 changed files
with
2,863 additions
and
808 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
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
25 changes: 25 additions & 0 deletions
25
src/main/java/com/cleanroommc/modularui/api/drawable/IHoverable.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,25 @@ | ||
package com.cleanroommc.modularui.api.drawable; | ||
|
||
import com.cleanroommc.modularui.screen.RichTooltip; | ||
|
||
import com.cleanroommc.modularui.widget.sizer.Area; | ||
|
||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public interface IHoverable extends IIcon { | ||
|
||
/** | ||
* Called every frame this hoverable is hovered inside a {@link com.cleanroommc.modularui.drawable.text.RichText}. | ||
*/ | ||
default void onHover() {} | ||
|
||
@Nullable | ||
default RichTooltip getTooltip() { | ||
return null; | ||
} | ||
|
||
void setRenderedAt(int x, int y); | ||
|
||
Area getRenderedArea(); | ||
} |
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
89 changes: 89 additions & 0 deletions
89
src/main/java/com/cleanroommc/modularui/api/drawable/IRichTextBuilder.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,89 @@ | ||
package com.cleanroommc.modularui.api.drawable; | ||
|
||
import com.cleanroommc.modularui.drawable.text.Spacer; | ||
import com.cleanroommc.modularui.utils.Alignment; | ||
|
||
public interface IRichTextBuilder<T extends IRichTextBuilder<T>> { | ||
|
||
T getThis(); | ||
|
||
IRichTextBuilder<?> getRichText(); | ||
|
||
default T add(String s) { | ||
getRichText().add(s); | ||
return getThis(); | ||
} | ||
|
||
default T add(IDrawable drawable) { | ||
getRichText().add(drawable); | ||
return getThis(); | ||
} | ||
|
||
default T addLine(ITextLine line) { | ||
getRichText().addLine(line); | ||
return getThis(); | ||
} | ||
|
||
default T addLine(IDrawable line) { | ||
getRichText().add(line).newLine(); | ||
return getThis(); | ||
} | ||
|
||
default T newLine() { | ||
return add(IKey.LINE_FEED); | ||
} | ||
|
||
default T space() { | ||
return add(IKey.SPACE); | ||
} | ||
|
||
default T spaceLine(int pixelSpace) { | ||
return addLine(Spacer.of(pixelSpace)); | ||
} | ||
|
||
default T addElements(Iterable<IDrawable> drawables) { | ||
for (IDrawable drawable : drawables) { | ||
getRichText().add(drawable); | ||
} | ||
return getThis(); | ||
} | ||
|
||
default T addDrawableLines(Iterable<IDrawable> drawables) { | ||
for (IDrawable drawable : drawables) { | ||
getRichText().add(drawable).newLine(); | ||
} | ||
return getThis(); | ||
} | ||
|
||
default T addStringLines(Iterable<String> drawables) { | ||
for (String drawable : drawables) { | ||
getRichText().add(drawable).newLine(); | ||
} | ||
return getThis(); | ||
} | ||
|
||
default T clearText() { | ||
getRichText().clearText(); | ||
return getThis(); | ||
} | ||
|
||
default T alignment(Alignment alignment) { | ||
getRichText().alignment(alignment); | ||
return getThis(); | ||
} | ||
|
||
default T textColor(int color) { | ||
getRichText().textColor(color); | ||
return getThis(); | ||
} | ||
|
||
default T scale(float scale) { | ||
getRichText().scale(scale); | ||
return getThis(); | ||
} | ||
|
||
default T textShadow(boolean shadow) { | ||
getRichText().textShadow(shadow); | ||
return getThis(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/cleanroommc/modularui/api/drawable/ITextLine.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,17 @@ | ||
package com.cleanroommc.modularui.api.drawable; | ||
|
||
import com.cleanroommc.modularui.screen.viewport.GuiContext; | ||
|
||
import net.minecraft.client.gui.FontRenderer; | ||
|
||
public interface ITextLine { | ||
|
||
int getWidth(); | ||
|
||
int getHeight(FontRenderer fr); | ||
|
||
void draw(GuiContext context, FontRenderer fr, float x, float y, int color, boolean shadow); | ||
|
||
Object getHoveringElement(FontRenderer fr, int x, int y); | ||
|
||
} |
Oops, something went wrong.