-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f2d3fa
commit 6f409c4
Showing
20 changed files
with
192 additions
and
76 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
51 changes: 51 additions & 0 deletions
51
...c/main/kotlin/dev/dediamondpro/minemark/elementa/elements/MarkdownListElementComponent.kt
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,51 @@ | ||
package dev.dediamondpro.minemark.elementa.elements | ||
|
||
import dev.dediamondpro.minemark.LayoutData | ||
import dev.dediamondpro.minemark.elementa.LayoutConfigImpl | ||
import dev.dediamondpro.minemark.elementa.RenderData | ||
import dev.dediamondpro.minemark.elements.BasicElement | ||
import dev.dediamondpro.minemark.elements.Element | ||
import dev.dediamondpro.minemark.elements.impl.list.ListElement | ||
import dev.dediamondpro.minemark.elements.impl.list.ListHolderElement | ||
import gg.essential.elementa.components.UIBlock | ||
import org.xml.sax.Attributes | ||
import java.awt.Color | ||
|
||
class MarkdownListElementComponent( | ||
layoutConfig: LayoutConfigImpl, | ||
parent: Element<LayoutConfigImpl, RenderData>?, | ||
qName: String, attributes: Attributes? | ||
) : ListElement<LayoutConfigImpl, RenderData>(layoutConfig, parent, qName, attributes) { | ||
private val fontProvider = layoutConfig.fontProvider | ||
private var marker: String = when (listType) { | ||
ListHolderElement.ListType.ORDERED -> "${elementIndex + 1}. " | ||
ListHolderElement.ListType.UNORDERED -> "● " | ||
else -> "● " | ||
} | ||
|
||
override fun drawMarker(x: Float, y: Float, renderData: RenderData) { | ||
val scale = layoutConfig.fontSize | ||
renderData.matrixStack.push() | ||
renderData.matrixStack.scale(scale, scale, 1f) | ||
fontProvider.drawString( | ||
renderData.matrixStack, | ||
marker, | ||
layoutConfig.textColor, | ||
x / scale, y / scale, | ||
1f, 1f | ||
) | ||
renderData.matrixStack.pop() | ||
} | ||
|
||
override fun getMarkerWidth(): Float { | ||
return fontProvider.getStringWidth(marker, 1f) * layoutConfig.fontSize | ||
} | ||
|
||
override fun getMarkerHeight(): Float { | ||
return fontProvider.getStringHeight(marker, 1f) * layoutConfig.fontSize | ||
} | ||
|
||
override fun generateLayout(layoutData: LayoutData?) { | ||
super.generateLayout(layoutData) | ||
} | ||
} |
12 changes: 11 additions & 1 deletion
12
...enta/src/main/kotlin/dev/dediamondpro/minemark/elementa/elements/MarkdownTextComponent.kt
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
9 changes: 9 additions & 0 deletions
9
src/main/java/dev/dediamondpro/minemark/elements/NoPadding.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,9 @@ | ||
package dev.dediamondpro.minemark.elements; | ||
|
||
|
||
/** | ||
* Interface to tell elements like {@link dev.dediamondpro.minemark.elements.impl.ParagraphElement} to not add any padding. | ||
* Useful for elements like {@link dev.dediamondpro.minemark.elements.impl.list.ListElement} | ||
*/ | ||
public interface NoPadding { | ||
} |
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.