A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/AlmasB/FXGL/commit/68241ee20 below:

javafx sliders are now replaced with FXGLSlider type · AlmasB/FXGL@68241ee · GitHub

File tree Expand file treeCollapse file tree 5 files changed

+90

-3

lines changed

Filter options

Expand file treeCollapse file tree 5 files changed

+90

-3

lines changed Original file line number Diff line number Diff line change

@@ -56,6 +56,8 @@ public abstract class UIFactoryService extends EngineService {

56 56 57 57

public abstract CheckBox newCheckBox();

58 58 59 +

public abstract Slider newSlider();

60 + 59 61

public abstract <T> Spinner<T> newSpinner(ObservableList<T> items);

60 62 61 63

public abstract <T> ListView<T> newListView(ObservableList<T> items);

Original file line number Diff line number Diff line change

@@ -0,0 +1,44 @@

1 +

/*

2 +

* FXGL - JavaFX Game Library. The MIT License (MIT).

3 +

* Copyright (c) AlmasB (almaslvl@gmail.com).

4 +

* See LICENSE for details.

5 +

*/

6 + 7 +

package com.almasb.fxgl.ui

8 + 9 +

import javafx.scene.control.Slider

10 +

import javafx.scene.effect.BoxBlur

11 + 12 +

/**

13 +

*

14 +

* @author Almas Baimagambetov (almaslvl@gmail.com)

15 +

*/

16 +

class FXGLSlider : Slider() {

17 + 18 +

init {

19 +

styleClass.add("fxgl-slider")

20 + 21 +

effect = BoxBlur(1.2, 1.2, 2)

22 + 23 +

valueProperty().addListener { _, _, newValue ->

24 +

val percentage: Double = 100.0 * newValue.toDouble() / max

25 + 26 +

// solution from https://stackoverflow.com/questions/51343759/how-to-change-fill-color-of-slider-in-javafx

27 +

// in the String format,

28 +

// %1$.1f%% gives the first format argument ("1$"),

29 +

// i.e. percentage, formatted to 1 decimal place (".1f").

30 +

// Note literal % signs must be escaped ("%%")

31 + 32 +

val style = String.format(

33 +

"-track-color: linear-gradient(to right, " +

34 +

"-active-color 0.5%%, " +

35 +

"-active-color %1$.1f%%, " +

36 +

"-inactive-color %1$.1f%%, " +

37 +

"-inactive-color 100%%);",

38 +

percentage

39 +

)

40 + 41 +

setStyle(style)

42 +

}

43 +

}

44 +

}

Original file line number Diff line number Diff line change

@@ -117,6 +117,10 @@ class FXGLUIFactoryServiceProvider : UIFactoryService() {

117 117

return FXGLCheckBox()

118 118

}

119 119 120 +

override fun newSlider(): Slider {

121 +

return FXGLSlider()

122 +

}

123 + 120 124

override fun <T> newSpinner(items: ObservableList<T>): Spinner<T> {

121 125

return FXGLSpinner(items).also {

122 126

it.editor.fontProperty().bind(fontProperty(UI, 18.0))

Original file line number Diff line number Diff line change

@@ -696,14 +696,18 @@ open class FXGLDefaultMenu(type: MenuType) : FXGLMenu(type) {

696 696

protected fun createContentAudio(): MenuContent {

697 697

log.debug("createContentAudio()")

698 698 699 -

val sliderMusic = Slider(0.0, 1.0, 1.0)

699 +

val sliderMusic = getUIFactoryService().newSlider()

700 +

sliderMusic.min = 0.0

701 +

sliderMusic.max = 1.0

700 702

sliderMusic.valueProperty().bindBidirectional(getSettings().globalMusicVolumeProperty)

701 703 702 704

val textMusic = getUIFactoryService().newText(localizedStringProperty("menu.music.volume").concat(": "))

703 705

val percentMusic = getUIFactoryService().newText("")

704 706

percentMusic.textProperty().bind(sliderMusic.valueProperty().multiply(100).asString("%.0f"))

705 707 706 -

val sliderSound = Slider(0.0, 1.0, 1.0)

708 +

val sliderSound = getUIFactoryService().newSlider()

709 +

sliderSound.min = 0.0

710 +

sliderSound.max = 1.0

707 711

sliderSound.valueProperty().bindBidirectional(getSettings().globalSoundVolumeProperty)

708 712 709 713

val textSound = getUIFactoryService().newText(localizedStringProperty("menu.sound.volume").concat(": "))

@@ -714,7 +718,7 @@ open class FXGLDefaultMenu(type: MenuType) : FXGLMenu(type) {

714 718

gridPane.hgap = 15.0

715 719

gridPane.addRow(0, textMusic, sliderMusic, percentMusic)

716 720

gridPane.addRow(1, textSound, sliderSound, percentSound)

717 - 721 + 718 722

return MenuContent(gridPane)

719 723

}

720 724 Original file line number Diff line number Diff line change

@@ -278,6 +278,39 @@

278 278 279 279 280 280 281 + 282 +

/**

283 +

* FXGL slider

284 +

*/

285 + 286 +

.fxgl-slider {

287 +

-active-color: gold;

288 +

-inactive-color: darkgray;

289 +

-track-color: -active-color;

290 +

}

291 + 292 +

.fxgl-slider .track,

293 +

.fxgl-slider:vertical .track {

294 +

-fx-background-color: -track-color;

295 +

-fx-background-radius: 1;

296 +

-fx-background-insets: 0;

297 +

-fx-pref-width: 2px;

298 +

-fx-pref-height: 12px;

299 +

}

300 + 301 +

.fxgl-slider .thumb,

302 +

.fxgl-slider:focused .thumb {

303 +

-fx-background-color: white;

304 +

-fx-background-radius: 20;

305 +

-fx-background-insets: 0;

306 +

-fx-border-radius: 7px;

307 +

-fx-border-width: 2px;

308 +

-fx-border-color: black;

309 +

}

310 + 311 + 312 + 313 + 281 314

/*

282 315

From

283 316

https://github.com/jfoenixadmin/JFoenix/blob/master/jfoenix/src/main/resources/css/controls/jfx-check-box.css

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4