textselector/spinner/quickslot(!) selection change using scroll wheel

This commit is contained in:
minjaesong
2021-10-23 22:57:17 +09:00
parent 3be5ac96f2
commit a1bad044fd
4 changed files with 68 additions and 20 deletions

View File

@@ -54,6 +54,8 @@ class UIItemTextSelector(
1
else if (relativeMouseX in width - buttonW..width && relativeMouseY in 0..height)
2
else if (relativeMouseX in buttonW + 3..width - buttonW - 3 && relativeMouseY in 0..height)
3
else
0
@@ -94,8 +96,10 @@ class UIItemTextSelector(
Toolkit.fillArea(batch, posX + width - buttonW, posY, buttonW, height)
// text area border
batch.color = Toolkit.Theme.COL_INACTIVE
Toolkit.drawBoxBorder(batch, posX - 1, posY - 1, width + 2, height + 2)
if (mouseOnButton != 3) {
batch.color = Toolkit.Theme.COL_INACTIVE
Toolkit.drawBoxBorder(batch, posX - 1, posY - 1, width + 2, height + 2)
}
// left button border
batch.color = if (mouseOnButton == 1 && mousePushed) Toolkit.Theme.COL_HIGHLIGHT
@@ -106,6 +110,12 @@ class UIItemTextSelector(
batch.color = if (mouseOnButton == 2 && mousePushed) Toolkit.Theme.COL_HIGHLIGHT
else if (mouseOnButton == 2) Toolkit.Theme.COL_ACTIVE else Toolkit.Theme.COL_INACTIVE
Toolkit.drawBoxBorder(batch, posX + width - buttonW - 1, posY - 1, buttonW + 2, height + 2)
// text area border (again)
if (mouseOnButton == 3) {
batch.color = Toolkit.Theme.COL_ACTIVE
Toolkit.drawBoxBorder(batch, posX + buttonW + 2, posY - 1, width - 2*buttonW - 4, height + 2)
}
}
// left button icon
@@ -126,6 +136,22 @@ class UIItemTextSelector(
super.render(batch, camera)
}
override fun scrolled(amountX: Float, amountY: Float): Boolean {
if (mouseUp) {
if (amountX <= -1 || amountY <= -1)
selection = (selection - 1) fmod labelfuns.size
else if (amountX >= 1 || amountY >= 1)
selection = (selection + 1) fmod labelfuns.size
selectionChangeListener(selection)
fboUpdateLatch = true
return true
}
else {
return false
}
}
override fun dispose() {
fbo.dispose()
}