Skip to content

Commit 99f623d

Browse files
committed
update hitboxes of some buttons
1 parent 6b39ae3 commit 99f623d

File tree

3 files changed

+61
-19
lines changed

3 files changed

+61
-19
lines changed

src/main/kotlin/dev/dediamondpro/resourcify/elements/Paginator.kt

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,62 @@ import dev.dediamondpro.resourcify.gui.data.Colors
2222
import dev.dediamondpro.resourcify.gui.data.Icons
2323
import dev.dediamondpro.resourcify.util.localize
2424
import gg.essential.elementa.components.UIBlock
25+
import gg.essential.elementa.components.UIContainer
2526
import gg.essential.elementa.components.UIText
2627
import gg.essential.elementa.constraints.CenterConstraint
2728
import gg.essential.elementa.dsl.*
2829
import gg.essential.universal.UScreen
2930

3031
class Paginator(screen: PaginatedScreen) : UIBlock(Colors.BACKGROUND) {
3132
init {
33+
constrain {
34+
width = 160.pixels()
35+
height = 29.pixels()
36+
}
37+
38+
val backHitBox = UIContainer().constrain {
39+
x = 3.pixels()
40+
y = CenterConstraint()
41+
width = 19.pixels()
42+
height = 19.pixels()
43+
}.onMouseClick { screen.goBack() } childOf this
3244
Icon(Icons.BACK, true, basicColorConstraint {
3345
if (PaginatedScreen.backScreens.isEmpty()) Colors.TEXT_SECONDARY else Colors.TEXT_PRIMARY
3446
}).constrain {
35-
x = 8.pixels()
47+
x = 5.pixels()
3648
y = CenterConstraint()
3749
width = 9.pixels()
3850
height = 9.pixels()
39-
}.onMouseClick { screen.goBack() } childOf this
40-
UIText("resourcify.screens.close".localize()).constrain {
51+
} childOf backHitBox
52+
53+
val closeHitBox = UIContainer().constrain {
4154
x = CenterConstraint()
4255
y = CenterConstraint()
43-
color = Colors.TEXT_PRIMARY.toConstraint()
56+
width = 50.pixels()
57+
height = 19.pixels()
4458
}.onMouseClick {
4559
UScreen.displayScreen(PaginatedScreen.backScreens.findLast { it !is PaginatedScreen })
4660
PaginatedScreen.cleanUp()
4761
} childOf this
62+
UIText("resourcify.screens.close".localize()).constrain {
63+
x = CenterConstraint()
64+
y = CenterConstraint()
65+
color = Colors.TEXT_PRIMARY.toConstraint()
66+
} childOf closeHitBox
67+
68+
val forwardHitBox = UIContainer().constrain {
69+
x = 3.pixels(true)
70+
y = CenterConstraint()
71+
width = 19.pixels()
72+
height = 19.pixels()
73+
}.onMouseClick { screen.goForward() } childOf this
4874
Icon(Icons.FORWARD, true, basicColorConstraint {
4975
if (PaginatedScreen.forwardScreens.isEmpty()) Colors.TEXT_SECONDARY else Colors.TEXT_PRIMARY
5076
}).constrain {
51-
x = 8.pixels(true)
77+
x = 5.pixels(true)
5278
y = CenterConstraint()
5379
width = 9.pixels()
5480
height = 9.pixels()
55-
}.onMouseClick { screen.goForward() } childOf this
81+
} childOf forwardHitBox
5682
}
5783
}

src/main/kotlin/dev/dediamondpro/resourcify/gui/browsepage/BrowseScreen.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,20 +314,25 @@ class BrowseScreen(
314314
}
315315
}
316316

317+
val searchBoxHitBox = UIContainer().constrain {
318+
x = 6.pixels()
319+
y = CenterConstraint()
320+
height = 19.pixels()
321+
width = 100.percent() - 111.pixels()
322+
}.onMouseClick {
323+
if (it.mouseButton != 0) return@onMouseClick
324+
searchBox.grabWindowFocus()
325+
} childOf headerBox
317326
searchBox = (UITextInput(
318327
"resourcify.browse.search".localize(type.displayName.localize()),
319328
cursorColor = Colors.TEXT_PRIMARY
320329
).constrain {
321-
x = 6.pixels()
322330
y = CenterConstraint()
323-
width = 100.percent() - 89.pixels()
331+
width = 100.percent()
324332
color = Colors.TEXT_PRIMARY.toConstraint()
325333
}.onUpdate {
326334
loadPacks()
327-
}.onMouseClick {
328-
if (it.mouseButton != 0) return@onMouseClick
329-
grabWindowFocus()
330-
} childOf headerBox) as UITextInput
335+
} childOf searchBoxHitBox) as UITextInput
331336

332337
// Settings button
333338
Icon(Icons.SETTINGS, true, Colors.TEXT_SECONDARY).constrain {

src/main/kotlin/dev/dediamondpro/resourcify/gui/projectpage/ProjectScreen.kt

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,12 @@ class ProjectScreen(
173173
if (project.hasGallery()) pages["resourcify.project.gallery".localize()] = ::GalleryPage
174174
pages["resourcify.project.versions".localize()] = ::VersionsPage
175175
pages.forEach { (text, page) ->
176-
UIText("${ChatColor.BOLD}$text").constrain {
176+
val hitBox = UIContainer().constrain {
177177
x = if (text == "resourcify.project.description".localize()) 6.pixels()
178178
else SiblingConstraint(padding = 8f)
179179
y = CenterConstraint()
180-
color = Colors.TEXT_PRIMARY.toConstraint()
180+
width = ChildBasedSizeConstraint()
181+
height = 19.pixels()
181182
}.onMouseClick {
182183
if (page == currentPage || it.mouseButton != 0) return@onMouseClick
183184
currentPage = page
@@ -186,20 +187,30 @@ class ProjectScreen(
186187
page(this@ProjectScreen) childOf mainBox
187188
}.unhide()
188189
} childOf navigationBox
190+
191+
UIText("${ChatColor.BOLD}$text").constrain {
192+
y = CenterConstraint()
193+
color = Colors.TEXT_PRIMARY.toConstraint()
194+
} childOf hitBox
189195
}
196+
val sourceHitbox = UIContainer().constrain {
197+
x = SiblingConstraint(padding = 8f)
198+
y = CenterConstraint()
199+
width = ChildBasedSizeConstraint()
200+
height = 19.pixels()
201+
}.onMouseClick {
202+
if (it.mouseButton != 0) return@onMouseClick
203+
UDesktop.browse(URI(project.getBrowserUrl()))
204+
} childOf navigationBox
190205
TextIcon(
191206
"${ChatColor.BOLD}${service.getName().localize()}",
192207
Icons.EXTERNAL_LINK,
193208
color = Colors.TEXT_PRIMARY.toConstraint()
194209
).constrain {
195-
x = SiblingConstraint(padding = 8f)
196210
y = CenterConstraint()
197211
width = ChildLocationSizeConstraint()
198212
height = ChildBasedMaxSizeConstraint()
199-
}.onMouseClick {
200-
if (it.mouseButton != 0) return@onMouseClick
201-
UDesktop.browse(URI(project.getBrowserUrl()))
202-
} childOf navigationBox
213+
} childOf sourceHitbox
203214
}
204215

205216
private fun sideBar() {

0 commit comments

Comments
 (0)