Skip to content

Commit 9eba76a

Browse files
committed
Titlebar changes, shadow under it
1 parent 14caf93 commit 9eba76a

File tree

5 files changed

+33
-9
lines changed

5 files changed

+33
-9
lines changed

common/src/main/kotlin/com/lambda/module/modules/client/NewCGui.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ object NewCGui : Module(
1212
description = "ggs",
1313
defaultTags = setOf(ModuleTag.CLIENT)
1414
) {
15-
val titleBarHeight by setting("Title Bar Height", 4.0, 0.0..10.0, 0.1)
15+
val titleBarHeight by setting("Title Bar Height", 16.0, 0.0..25.0, 0.1)
1616
val padding by setting("Padding", 2.0, 1.0..6.0, 0.1)
1717
val listStep by setting("List Step", 2.0, 0.0..6.0, 0.1)
1818

common/src/main/kotlin/com/lambda/newgui/component/core/TextField.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.lambda.newgui.component.core
22

3+
import com.lambda.newgui.component.HAlign
34
import com.lambda.newgui.component.VAlign
45
import com.lambda.newgui.component.layout.Layout
56
import com.lambda.util.math.Vec2d
@@ -52,6 +53,19 @@ class TextField(
5253
}
5354

5455
companion object {
56+
/**
57+
* Creates a [TextField] component
58+
*
59+
* @param text String to draw
60+
*
61+
* @param color Color of the font
62+
*
63+
* @param scale Scale of the font
64+
*
65+
* @param shadow Whether the font should drop a shadow
66+
*
67+
* @param offset Offset from the corner(specified by [horizontalAlignment]) of the text (ignored for [HAlign.CENTER])
68+
*/
5569
@UIBuilder
5670
fun Layout.textField(
5771
text: String,

common/src/main/kotlin/com/lambda/newgui/component/layout/Layout.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ open class Layout(
5757
/**
5858
* The position of the component
5959
*
60-
* Note: actual position could be overridden using [overridePosition], to get actual position [rect].leftTop instead
60+
* Note: actual position could be overridden using [overridePosition], to get actual position use [rect].leftTop instead
6161
*/
6262
var position: Vec2d
6363
get() = ownerRect.leftTop + relativeToAbs(relativePos).let {
@@ -71,7 +71,7 @@ open class Layout(
7171
/**
7272
* The size of this component
7373
*
74-
* Note: actual size could be overridden using [overridePosition], to get actual size [rect].size instead
74+
* Note: actual size could be overridden using [overrideSize], to get actual size use [rect].size instead
7575
*/
7676
var size = Vec2d.ZERO
7777

common/src/main/kotlin/com/lambda/newgui/component/window/Window.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ open class Window(
7070
with(titleBar) {
7171
onRender {
7272
// Update title bar position
73-
val heightVec = Vec2d(0.0, textField.textHeight * 1.5)
74-
rect = Rect(this@Window.rect.leftTop, this@Window.rect.rightTop + heightVec)
73+
rect = Rect(this@Window.rect.leftTop, this@Window.rect.rightTop + Vec2d.BOTTOM * NewCGui.titleBarHeight)
7574
}
7675

7776
onMouseClick { button, action ->
@@ -89,7 +88,7 @@ open class Window(
8988
onRender {
9089
// Update content position
9190
rect = Rect(
92-
titleBar.rect.leftBottom + NewCGui.padding,
91+
titleBar.rect.leftBottom + Vec2d.RIGHT * NewCGui.padding,
9392
this@Window.rect.rightBottom - NewCGui.padding
9493
)
9594
}

common/src/main/kotlin/com/lambda/newgui/component/window/WindowContent.kt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package com.lambda.newgui.component.window
22

33
import com.lambda.graphics.animation.Animation.Companion.exp
4-
import com.lambda.graphics.animation.AnimationTicker
54
import com.lambda.module.modules.client.NewCGui
65
import com.lambda.newgui.component.VAlign
76
import com.lambda.newgui.component.core.UIBuilder
87
import com.lambda.newgui.component.layout.Layout
8+
import com.lambda.util.math.Rect
99
import com.lambda.util.math.Vec2d
10+
import com.lambda.util.math.setAlpha
11+
import java.awt.Color
1012
import kotlin.math.abs
1113

1214
class WindowContent(
@@ -53,6 +55,15 @@ class WindowContent(
5355
}
5456

5557
onRender {
58+
// Shadow
59+
val topColor = Color.BLACK.setAlpha(0.2)
60+
val bottomColor = Color.BLACK.setAlpha(0.0)
61+
filled.build(
62+
Rect(rect.leftTop, rect.rightTop + Vec2d.BOTTOM * 10.0), 0.0,
63+
topColor, topColor,
64+
bottomColor, bottomColor
65+
)
66+
5667
reorderChildren()
5768
}
5869

@@ -66,7 +77,7 @@ class WindowContent(
6677
// Skip for closed windows
6778
if (size.y < 0.1) return
6879

69-
var offset = renderScrollOffset
80+
var offset = renderScrollOffset + NewCGui.padding
7081

7182
scrollableChildren.forEach { child ->
7283
child.position = Vec2d(child.position.x, position.y + offset)
@@ -78,7 +89,7 @@ class WindowContent(
7889
/**
7990
* Creates an empty [WindowContent] component
8091
*
81-
* @param scrollable Whether to scroll
92+
* @param scrollable Whether to let user scroll this layout
8293
*/
8394
@UIBuilder
8495
fun Window.windowContent(scrollable: Boolean) =

0 commit comments

Comments
 (0)