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

Improve engine extensions #475

Merged
merged 76 commits into from
Jan 25, 2025
Merged
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
61b379c
Introduce relative size axes
Reco1I Dec 18, 2024
e001f6e
Fix ExtendedEntity collision checks
Reco1I Dec 18, 2024
f9579f4
Invalidate transformations properly
Reco1I Dec 18, 2024
33ab259
Introduce relativePositionAxes feature and add helper functions to ge…
Reco1I Dec 19, 2024
6e366e6
Use drawWidth and drawHeight dimensions to compute container measurem…
Reco1I Dec 19, 2024
90234ce
Improve ScrollableContainer
Reco1I Dec 19, 2024
30ff3e8
Improve documentation
Reco1I Dec 19, 2024
811e2f2
Add whitespace
Reco1I Dec 19, 2024
381d4a5
Fix critical bug
Reco1I Dec 19, 2024
8541066
Set opposite when changing relativeSizeAxes and autoSizeAxes
Reco1I Dec 19, 2024
0d61dcd
Introduce `clipChildren`
Reco1I Dec 19, 2024
3db7465
Fix ConstraintContainer misplacement of constraints
Reco1I Dec 19, 2024
61c7a42
Add setRelativePosition() function
Reco1I Dec 19, 2024
0f28e16
Replace exceptions by automatic handling behavior
Reco1I Dec 20, 2024
93e15e8
Introduce GradientCircle
Reco1I Dec 20, 2024
7a1d953
Make Circle open
Reco1I Dec 20, 2024
a58863d
Don't auto assign the texture region at constructor
Reco1I Dec 21, 2024
f7f0d8e
Implement long constructor
Reco1I Dec 21, 2024
2d09d50
Introduce Triangle shape
Reco1I Dec 21, 2024
59846bf
Introduce TextSprite and TextTexture
Reco1I Dec 21, 2024
4aefc41
Introduce DepthInfo specification
Reco1I Dec 21, 2024
f78f5db
Make GradientCircle compatible with inherited alpha
Reco1I Dec 21, 2024
3e4d3aa
Implement relativeSize to TextSprite
Reco1I Dec 21, 2024
783b97a
Merge branch 'osudroid:master' into new-ui
Reco1I Dec 23, 2024
0f9f29e
Move texture classes to the same file
Reco1I Dec 23, 2024
529bd38
Rename function
Reco1I Dec 23, 2024
4ae7953
Remove test code
Reco1I Dec 23, 2024
db3c9d3
Update vertex buffer in draw thread
Reco1I Dec 23, 2024
6ddb7a6
Introduce ExtendedText
Reco1I Dec 23, 2024
3e52bfb
Pass HorizontalAlign through update method in TextVertexBuffer
Reco1I Dec 23, 2024
271e0f5
Fix constructor's textureRegion not being used
Reco1I Dec 24, 2024
102dbcf
Document DepthInfo
Reco1I Dec 25, 2024
98d4df3
Remove RoundedBox vertex buffer pre-initialization
Reco1I Dec 25, 2024
7d8a720
Register touch area to all `Scene` types
Reco1I Dec 25, 2024
f37d0e3
Inherit colors only if parents are of type `ExtendedEntity`
Reco1I Dec 25, 2024
11db319
Propagate input events along children in ExtendedEntity
Reco1I Dec 25, 2024
5693ba3
Use `Vector2` to represent entities anchor and origin properties
Reco1I Dec 25, 2024
88dc64e
Fix compilation errors
Reco1I Dec 25, 2024
964949e
Always inherit colors
Reco1I Dec 26, 2024
12b2d4a
Introduce BlendInfo
Reco1I Dec 26, 2024
4f3f39f
Allow to use custom rotation and scale center / Reverting back old be…
Reco1I Dec 26, 2024
6821b77
Revert "Register touch area to all `Scene` types"
Reco1I Dec 26, 2024
e28c630
Fix scale center not being applied properly in CirclePiece
Reco1I Dec 26, 2024
9f18d7f
Merge branch 'upstream-master' into new-ui
Rian8337 Dec 26, 2024
f5301c5
Update some confusing and outdated comments
Rian8337 Dec 26, 2024
a8af4b7
Make relativeSizeAxes compatible with autoSizeAxes
Reco1I Dec 26, 2024
c4fd6bf
Call value instead
Reco1I Dec 26, 2024
3a9b59d
Introduce Padding for ExtendedEntity
Reco1I Dec 27, 2024
df8316d
Make `Vec2` and `Vec4` immutable
Reco1I Dec 27, 2024
92c006f
Fix getPaddedWidth() and getPaddedHeight() missing cases
Reco1I Dec 27, 2024
14260c1
Override autoSizeAxes when changing manually the dimensions
Reco1I Dec 27, 2024
933cb9d
Support padding in Container sub-classes
Reco1I Dec 27, 2024
9ecb8c7
Fix padding not being applied properly in LinearContainer
Reco1I Dec 27, 2024
85561f5
Don't pre-multiply fonts
Reco1I Dec 27, 2024
f991d58
Optimize RoundedBox
Reco1I Dec 28, 2024
6c1a2af
Introduce size property
Reco1I Dec 28, 2024
ee7b195
Improve Vec2 and Vec4 constructors
Reco1I Dec 28, 2024
3e6ea8f
Fix padding in ConstraintContainer
Reco1I Dec 28, 2024
443e0a8
Use Vec2 for ExtendedEntity.size property
Reco1I Dec 28, 2024
5279392
Fix potential crash due to corner radius being 0
Reco1I Dec 28, 2024
3e87067
Introduce foreground and background
Reco1I Dec 28, 2024
32305dc
Improve Padding compatibility
Reco1I Dec 28, 2024
a6f7722
Introduce touch area binding
Reco1I Dec 28, 2024
f2cb224
Make ConstraintContainer open
Reco1I Dec 28, 2024
35a631f
Change transform order
Reco1I Dec 29, 2024
06ac2c8
Use drawWidth and drawHeight to check whether a point it's on a Entity
Reco1I Dec 29, 2024
17e1741
Prevent event propagation if ScrollableContainer is scrolling
Reco1I Dec 29, 2024
88fbc3b
Update background and foreground
Reco1I Dec 29, 2024
c0ccd9a
Set traversal front to back by default for ExtendedScene
Reco1I Dec 29, 2024
3fdc324
Difference whether to apply transformation from scene or from parent …
Reco1I Dec 29, 2024
f4f7659
Draw indicators on top
Reco1I Dec 29, 2024
ebb81d5
Merge branch 'upstream-master' into new-ui
Rian8337 Jan 25, 2025
b5bc690
Resolve... weird "syntax" error?
Rian8337 Jan 25, 2025
e2e3605
Reformat line to fix weird indentation issue
Rian8337 Jan 25, 2025
3ce2c13
Make `invalidateTransformations` `protected`
Rian8337 Jan 25, 2025
7c1e3cf
Update `GradientCircle` KDoc
Rian8337 Jan 25, 2025
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
Prev Previous commit
Next Next commit
Improve Padding compatibility
Reco1I committed Dec 28, 2024
commit 32305dcfbaf2152ab8fabbc3d3cc974d4007f5cd
54 changes: 36 additions & 18 deletions src/com/reco1l/andengine/ExtendedEntity.kt
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@ import org.anddev.andengine.opengl.util.*
import org.anddev.andengine.opengl.vertex.*
import org.anddev.andengine.util.Transformation
import javax.microedition.khronos.opengles.*
import kotlin.math.max


/**
@@ -284,7 +283,7 @@ abstract class ExtendedEntity(
x *= parent.getPaddedWidth()
}

return max(parent.getPadding().left, x) + totalOffsetX
return x + totalOffsetX
}


@@ -304,7 +303,7 @@ abstract class ExtendedEntity(
y *= parent.getPaddedHeight()
}

return max(parent.getPadding().top, y) + totalOffsetY
return y + totalOffsetY
}


@@ -476,26 +475,20 @@ abstract class ExtendedEntity(
}

override fun onDrawChildren(gl: GL10, camera: Camera) {
super.onDrawChildren(gl, camera)

foreground?.setSize(drawWidth, drawHeight)
foreground?.onDraw(gl, camera)
}

override fun onManagedDraw(gl: GL10, camera: Camera) {
val hasPaddingApplicable = padding.left > 0f || padding.top > 0f

if (isVertexBufferDirty) {
isVertexBufferDirty = false
onUpdateVertexBuffer()
if (hasPaddingApplicable) {
gl.glTranslatef(padding.left, padding.top, 0f)
}

if (clipChildren) {
GLHelper.enableScissorTest(gl)

var (bottomLeftX, bottomLeftY) = camera.getScreenSpaceCoordinates(convertLocalToSceneCoordinates(0f, 0f))
var (topLeftX, topLeftY) = camera.getScreenSpaceCoordinates(convertLocalToSceneCoordinates(0f, drawHeight))
var (topRightX, topRightY) = camera.getScreenSpaceCoordinates(convertLocalToSceneCoordinates(drawWidth, drawHeight))
var (bottomRightX, bottomRightY) = camera.getScreenSpaceCoordinates(convertLocalToSceneCoordinates(drawWidth, 0f))
var (topLeftX, topLeftY) = camera.getScreenSpaceCoordinates(convertLocalToSceneCoordinates(0f, getPaddedHeight()))
var (topRightX, topRightY) = camera.getScreenSpaceCoordinates(convertLocalToSceneCoordinates(getPaddedWidth(), getPaddedHeight()))
var (bottomRightX, bottomRightY) = camera.getScreenSpaceCoordinates(convertLocalToSceneCoordinates(getPaddedWidth(), 0f))

// Flip the Y axis to match the OpenGL coordinate system.
bottomLeftY = camera.surfaceHeight - bottomLeftY
@@ -517,11 +510,28 @@ abstract class ExtendedEntity(
)
}

super.onManagedDraw(gl, camera)
super.onDrawChildren(gl, camera)

if (clipChildren) {
GLHelper.disableScissorTest(gl)
}

if (hasPaddingApplicable) {
gl.glTranslatef(-padding.right, -padding.top, 0f)
}

foreground?.setSize(drawWidth, drawHeight)
foreground?.onDraw(gl, camera)
}

override fun onManagedDraw(gl: GL10, camera: Camera) {

if (isVertexBufferDirty) {
isVertexBufferDirty = false
onUpdateVertexBuffer()
}

super.onManagedDraw(gl, camera)
}

override fun onInitDraw(pGL: GL10) {
@@ -584,11 +594,19 @@ abstract class ExtendedEntity(
if (contentWidth != width || contentHeight != height) {

if (autoSizeAxes.isHorizontal) {
width = if (relativeSizeAxes.isHorizontal) contentWidth / parent.getPaddedWidth() else contentWidth
width = contentWidth + padding.horizontal

if (relativeSizeAxes.isHorizontal) {
width /= parent.getPaddedWidth()
}
}

if (autoSizeAxes.isVertical) {
height = if (relativeSizeAxes.isVertical) contentHeight / parent.getPaddedHeight() else contentHeight
height = contentHeight + padding.vertical

if (relativeSizeAxes.isVertical) {
height /= parent.getPaddedHeight()
}
}

updateVertexBuffer()
40 changes: 24 additions & 16 deletions src/com/reco1l/andengine/container/ConstraintContainer.kt
Original file line number Diff line number Diff line change
@@ -20,18 +20,22 @@ class ConstraintContainer : Container() {

val target = constraints[child] ?: this

val targetX = if (target == this) 0f else target.getDrawX()
val targetWidth = if (target == this) getPaddedWidth() else target.getDrawWidth()
var targetX = target.getDrawX()
var targetWidth = target.getDrawWidth()

val paddingLeft = if (target == this) getPadding().left else 0f
val anchorOffsetX = targetWidth * child.anchor.x
if (target == this) {
targetX = 0f
targetWidth = getPaddedWidth()
}

var childX = max(paddingLeft, child.x)
val anchorOffsetX = targetWidth * child.anchor.x

// Relative positions will be multiplied by the remaining space from the
// target's position to the edge of the container.
var childX = child.x
if (child.relativePositionAxes.isHorizontal) {
childX *= drawWidth - targetX

// Relative positions will be multiplied by the remaining space from the
// target's position to the edge of the container.
childX *= getPaddedWidth() - targetX
}

return targetX + childX + child.originOffsetX + anchorOffsetX + child.translationX
@@ -41,18 +45,22 @@ class ConstraintContainer : Container() {

val target = constraints[child] ?: this

val targetY = if (target == this) 0f else target.getDrawY()
val targetHeight = if (target == this) getPaddedHeight() else target.getDrawHeight()
var targetY = target.getDrawY()
var targetHeight = target.getDrawHeight()

val paddingTop = if (target == this) getPadding().top else 0f
val anchorOffsetY = targetHeight * child.anchor.y
if (target == this) {
targetY = 0f
targetHeight = getPaddedHeight()
}

var childY = max(paddingTop, child.y)
val anchorOffsetY = targetHeight * child.anchor.y

// Relative positions will be multiplied by the remaining space from the
// target's position to the edge of the container.
var childY = child.y
if (child.relativePositionAxes.isVertical) {
childY *= drawHeight - targetY

// Relative positions will be multiplied by the remaining space from the
// target's position to the edge of the container.
childY *= getPaddedHeight() - targetY
}

return targetY + childY + child.originOffsetY + anchorOffsetY + child.translationY
4 changes: 2 additions & 2 deletions src/com/reco1l/andengine/container/Container.kt
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ open class Container : ExtendedEntity() {
x *= getPaddedWidth()
}

return max(getPadding().left, x) + child.totalOffsetX
return x + child.totalOffsetX
}

open fun getChildDrawY(child: ExtendedEntity): Float {
@@ -74,7 +74,7 @@ open class Container : ExtendedEntity() {
y *= getPaddedHeight()
}

return max(getPadding().top, y) + child.totalOffsetY
return y + child.totalOffsetY
}


8 changes: 0 additions & 8 deletions src/com/reco1l/andengine/container/LinearContainer.kt
Original file line number Diff line number Diff line change
@@ -51,10 +51,6 @@ open class LinearContainer : Container() {
contentWidth += child.getDrawWidth()
contentHeight = max(contentHeight, child.getDrawHeight())

if (i == 0) {
contentWidth += getPadding().left
}

if (i < childCount - 1) {
contentWidth += spacing
}
@@ -66,10 +62,6 @@ open class LinearContainer : Container() {
contentWidth = max(contentWidth, child.getDrawWidth())
contentHeight += child.getDrawHeight()

if (i == 0) {
contentHeight += getPadding().top
}

if (i < childCount - 1) {
contentHeight += spacing
}
4 changes: 2 additions & 2 deletions src/com/reco1l/andengine/container/ScrollableContainer.kt
Original file line number Diff line number Diff line change
@@ -342,7 +342,7 @@ open class ScrollableContainer : Container() {
return super.getChildDrawX(child)
}

return -scrollX + max(getPadding().left, child.x) - child.originOffsetX + child.translationX
return -scrollX + child.x - child.originOffsetX + child.translationX
}

override fun getChildDrawY(child: ExtendedEntity): Float {
@@ -351,7 +351,7 @@ open class ScrollableContainer : Container() {
return super.getChildDrawY(child)
}

return -scrollY + max(getPadding().top, child.y) - child.originOffsetY + child.translationY
return -scrollY + child.y - child.originOffsetY + child.translationY
}