Skip to content

Commit 941c880

Browse files
Merge pull request #395 from FlyAndNotDown/master
Feat: Widget Samples Update
2 parents d9255c3 + 3ab8d40 commit 941c880

File tree

2,122 files changed

+225
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,122 files changed

+225
-6
lines changed

CMake/Common.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
option(BUILD_EDITOR "Build Explosion editor" ON)
22
option(CI "Build in CI" OFF)
3-
option(USE_UNITY_BUILD "Use unity build" OFF)
3+
option(USE_UNITY_BUILD "Use unity build" ON)
44

55
set(CMAKE_CXX_STANDARD 20)
66
set(CMAKE_UNITY_BUILD ${USE_UNITY_BUILD})

Editor/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ AddResourcesCopyCommand(
5050

5151
# ---- begin qml -------------------------------------------------------------------------------------
5252
set(EDITOR_QML_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/Qml)
53-
set(EDITOR_RESOURCE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/Qml/Resource)
53+
set(EDITOR_RESOURCE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/Resource)
5454
get_filename_component(EDITOR_RESOURCE_ROOT_ABSOLUTE ${EDITOR_RESOURCE_ROOT} ABSOLUTE)
5555

5656
file(GLOB QML_SOURCES ${EDITOR_QML_ROOT}/*.qml)

Editor/Qml/EFloatSliderInput.qml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import QtQuick
2+
import QtQuick.Controls
3+
import QtQuick.Controls.Basic
4+
5+
EFloatInput {
6+
property double step: 0.1
7+
property int decimals: 2
8+
property bool sliding: false
9+
property double slideStartValue: root.value
10+
property int slideStartX: 0
11+
12+
id: root
13+
14+
Rectangle {
15+
implicitWidth: (root.implicitWidth - 4) * (root.value - root.from) / (root.to - root.from)
16+
implicitHeight: 3
17+
radius: 5
18+
anchors.bottom: root.bottom
19+
anchors.left: root.left
20+
anchors.leftMargin: 2
21+
color: ETheme.primaryColor
22+
}
23+
24+
MouseArea {
25+
implicitWidth: root.implicitWidth
26+
implicitHeight: root.implicitHeight / 2
27+
anchors.bottom: root.bottom
28+
hoverEnabled: true
29+
preventStealing: true
30+
31+
onPressed: (mouse) => {
32+
root.sliding = true;
33+
root.slideStartX = mouse.x;
34+
root.slideStartValue = root.value;
35+
}
36+
37+
onReleased: {
38+
root.sliding = false;
39+
}
40+
41+
onPositionChanged: (mouse) => {
42+
if (root.sliding) {
43+
const distance = mouse.x - root.slideStartX;
44+
const valueDistance = (distance / 10.0) * root.step;
45+
root.value = Math.min(Math.max(root.slideStartValue + valueDistance, root.from), root.to).toFixed(root.decimals);
46+
}
47+
}
48+
}
49+
}

Editor/Qml/EIntInput.qml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import QtQuick
2+
import QtQuick.Controls
3+
import QtQuick.Controls.Basic
4+
5+
Item {
6+
property int value: Number(textField.text)
7+
property int from: 0
8+
property int to: 10
9+
10+
id: root
11+
implicitWidth: textField.implicitWidth
12+
implicitHeight: textField.implicitHeight
13+
14+
ETextField {
15+
id: textField
16+
implicitWidth: 100
17+
text: value
18+
19+
onAccepted: {
20+
root.value = Number(displayText)
21+
}
22+
23+
validator: IntValidator {
24+
bottom: root.from
25+
top: root.to
26+
}
27+
}
28+
}

Editor/Qml/EIntSliderInput.qml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import QtQuick
2+
import QtQuick.Controls
3+
import QtQuick.Controls.Basic
4+
5+
EIntInput {
6+
property int step: 1
7+
property bool sliding: false
8+
property int slideStartValue: root.value
9+
property int slideStartX: 0
10+
11+
id: root
12+
13+
Rectangle {
14+
implicitWidth: (root.implicitWidth - 4) * (root.value - root.from) / (root.to - root.from)
15+
implicitHeight: 3
16+
radius: 5
17+
anchors.bottom: root.bottom
18+
anchors.left: root.left
19+
anchors.leftMargin: 2
20+
color: ETheme.primaryColor
21+
}
22+
23+
MouseArea {
24+
implicitWidth: root.implicitWidth
25+
implicitHeight: root.implicitHeight / 2
26+
anchors.bottom: root.bottom
27+
hoverEnabled: true
28+
preventStealing: true
29+
30+
onPressed: (mouse) => {
31+
root.sliding = true;
32+
root.slideStartX = mouse.x;
33+
root.slideStartValue = root.value;
34+
}
35+
36+
onReleased: {
37+
root.sliding = false;
38+
}
39+
40+
onPositionChanged: (mouse) => {
41+
if (root.sliding) {
42+
const distance = mouse.x - root.slideStartX;
43+
const valueDistance = Math.floor((distance / 10.0) * root.step);
44+
root.value = Math.min(Math.max(root.slideStartValue + valueDistance, root.from), root.to);
45+
}
46+
}
47+
}
48+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Item {
66
property int value: spinBox.value
77
property int from: spinBox.from
88
property int to: spinBox.to
9+
property int stepSize: spinBox.stepSize
910
property bool editable: spinBox.editable
1011

1112
id: root
@@ -19,6 +20,7 @@ Item {
1920
editable: root.editable
2021
from: root.from
2122
to: root.to
23+
stepSize: root.stepSize
2224

2325
contentItem: ETextField {
2426
id: textField

Editor/Qml/EWidgetSamples.qml

Lines changed: 96 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ Rectangle {
395395
Layout.leftMargin: 5
396396
Layout.topMargin: 15
397397
EText {
398-
text: 'IntegerInput'
398+
text: 'IntSpinInput'
399399
style: EText.Style.Title1
400400
}
401401
}
@@ -404,7 +404,7 @@ Rectangle {
404404
Layout.margins: 5
405405

406406
RowLayout {
407-
EIntegerInput {}
407+
EIntSpinInput {}
408408

409409
EText {
410410
Layout.leftMargin: 5
@@ -413,7 +413,7 @@ Rectangle {
413413
}
414414

415415
RowLayout {
416-
EIntegerInput {
416+
EIntSpinInput {
417417
from: 0
418418
to: 10
419419
}
@@ -425,7 +425,7 @@ Rectangle {
425425
}
426426

427427
RowLayout {
428-
EIntegerInput {
428+
EIntSpinInput {
429429
editable: true
430430
}
431431

@@ -436,6 +436,39 @@ Rectangle {
436436
}
437437
}
438438

439+
RowLayout {
440+
Layout.leftMargin: 5
441+
Layout.topMargin: 15
442+
EText {
443+
text: 'IntInput'
444+
style: EText.Style.Title1
445+
}
446+
}
447+
448+
ColumnLayout {
449+
Layout.margins: 5
450+
451+
RowLayout {
452+
EIntInput {}
453+
454+
EText {
455+
Layout.leftMargin: 5
456+
text: 'Default'
457+
}
458+
}
459+
460+
RowLayout {
461+
EIntInput {
462+
value: 5
463+
}
464+
465+
EText {
466+
Layout.leftMargin: 5
467+
text: 'With Property Value'
468+
}
469+
}
470+
}
471+
439472
RowLayout {
440473
Layout.leftMargin: 5
441474
Layout.topMargin: 15
@@ -456,6 +489,65 @@ Rectangle {
456489
text: 'Default'
457490
}
458491
}
492+
493+
RowLayout {
494+
EFloatInput {
495+
value: 5
496+
}
497+
498+
EText {
499+
Layout.leftMargin: 5
500+
text: 'With Property Value'
501+
}
502+
}
503+
}
504+
505+
RowLayout {
506+
Layout.leftMargin: 5
507+
Layout.topMargin: 15
508+
EText {
509+
text: 'IntSliderInput'
510+
style: EText.Style.Title1
511+
}
512+
}
513+
514+
ColumnLayout {
515+
Layout.margins: 5
516+
517+
RowLayout {
518+
EIntSliderInput {
519+
value: 3
520+
}
521+
522+
EText {
523+
Layout.leftMargin: 5
524+
text: 'Default'
525+
}
526+
}
527+
}
528+
529+
RowLayout {
530+
Layout.leftMargin: 5
531+
Layout.topMargin: 15
532+
EText {
533+
text: 'FloatSliderInput'
534+
style: EText.Style.Title1
535+
}
536+
}
537+
538+
ColumnLayout {
539+
Layout.margins: 5
540+
541+
RowLayout {
542+
EFloatSliderInput {
543+
value: 0.3
544+
}
545+
546+
EText {
547+
Layout.leftMargin: 5
548+
text: 'Default'
549+
}
550+
}
459551
}
460552
}
461553
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)