This commit is contained in:
Johannes Schmelz
2024-11-25 06:53:56 +01:00
7 changed files with 141 additions and 68 deletions

View File

@@ -1,5 +1,6 @@
// Styling of Lemur components
// For documentation, see:
// For documentation, see:
// https://github.com/jMonkeyEngine-Contributions/Lemur/wiki/Styling
import com.jme3.math.ColorRGBA
@@ -11,7 +12,6 @@ import com.simsilica.lemur.Command
import com.simsilica.lemur.HAlignment
import com.simsilica.lemur.Insets3f
import com.simsilica.lemur.component.QuadBackgroundComponent
import com.simsilica.lemur.component.TbtQuadBackgroundComponent
def bgColor = color(1, 1, 1, 1)
def buttonEnabledColor = color(0, 0, 0, 1)
@@ -19,7 +19,7 @@ def buttonDisabledColor = color(0.8, 0.9, 1, 0.2)
def buttonBgColor = color(1, 1, 1, 1)
def sliderColor = color(0.6, 0.8, 0.8, 1)
def sliderBgColor = color(0.5, 0.75, 0.75, 1)
def gradientColor = color(0.5, 0.75, 0.85, 0.5)
def gradientColor = color(1, 1, 1, 1)
def tabbuttonEnabledColor = color(0.4, 0.45, 0.5, 1)
def solidWhiteBackground = new QuadBackgroundComponent(new ColorRGBA(1, 1, 1, 1))
def greyBackground = new QuadBackgroundComponent(new ColorRGBA(0.1f, 0.1f, 0.1f, 1.0f));
@@ -30,10 +30,8 @@ def lightGrey = color(0.6, 0.6, 0.6, 1.0)
def gradient = TbtQuadBackgroundComponent.create(
texture(name: "/com/simsilica/lemur/icons/bordered-gradient.png",
generateMips: false),
1, 1, 1, 126, 126,
1f, false)
texture(name: "/com/simsilica/lemur/icons/bordered-gradient.png", generateMips: false),
1, 1, 1, 126, 126, 1f, false)
def doubleGradient = new QuadBackgroundComponent(gradientColor)
doubleGradient.texture = texture(name: "/com/simsilica/lemur/icons/double-gradient-128.png",
@@ -79,6 +77,7 @@ selector("header", "pp") {
textVAlignment = VAlignment.Center
}
// Container Stil
selector("container", "pp") {
background = solidWhiteBackground.clone()
background.setColor(bgColor)
@@ -91,8 +90,8 @@ selector("toolbar") {
}
selector("slider", "pp") {
background = gradient.clone()
background.setColor(bgColor)
insets = new Insets3f(5, 10, 5, 10) // Abstand
background = new QuadBackgroundComponent(sliderBgColor)
}
def pressedCommand = new Command<Button>() {
@@ -113,30 +112,6 @@ def enabledCommand = new Command<Button>() {
}
}
def repeatCommand = new Command<Button>() {
private long startTime
private long lastClick
void execute(Button source) {
// Only do the repeating click while the mouse is
// over the button (and pressed of course)
if (source.isPressed() && source.isHighlightOn()) {
long elapsedTime = System.currentTimeMillis() - startTime
// After half a second pause, click 8 times a second
if (elapsedTime > 500 && elapsedTime > lastClick + 125) {
source.click()
// Try to quantize the last click time to prevent drift
lastClick = ((elapsedTime - 500) / 125) * 125 + 500
}
}
else {
startTime = System.currentTimeMillis()
lastClick = 0
}
}
}
def stdButtonCommands = [
(ButtonAction.Down) : [pressedCommand],
(ButtonAction.Up) : [pressedCommand],