Add RustColors singleton helper.

This commit is contained in:
2025-03-30 11:20:21 -04:00
parent be9981291c
commit d2f5823594
11 changed files with 145 additions and 197 deletions

View File

@@ -11,14 +11,15 @@ SplitView {
// Customized handle to drag between the Editor and the Console.
handle: Rectangle {
border.color: SplitHandle.hovered ? "#2b2b2b" : "#3c3f41"
color: SplitHandle.pressed ? "#4b4f51" : "#3c3f41"
border.color: SplitHandle.pressed ? RustColors.pressed : SplitHandle.hovered ? RustColors.hovered : RustColors.gutter
color: SplitHandle.pressed ? RustColors.pressed : SplitHandle.hovered ? RustColors.hovered : RustColors.gutter
implicitHeight: 8
opacity: SplitHandle.hovered || areaConsole.height < 15 ? 1.0 : 0.0
radius: 2.5
Behavior on opacity {
OpacityAnimator {
duration: 700
// Execute these behaviors when the color is changed.
Behavior on color {
ColorAnimation {
duration: 400
}
}
}
@@ -33,7 +34,7 @@ SplitView {
Layout.fillWidth: false
// Calculate the width based on the logarithmic scale.
Layout.preferredWidth: fontMetrics.averageCharacterWidth * (Math.floor(Math.log10(areaText.lineCount)) + 1) + 10
Layout.preferredWidth: fontMetrics.averageCharacterWidth * (Math.floor(Math.log10(textArea.lineCount)) + 1) + 10
contentY: editorFlickable.contentY
interactive: false
visible: true
@@ -49,14 +50,15 @@ SplitView {
delegate: Item {
required property int index
height: 17
// Calculate the height of each line in the text area.
height: textArea.contentHeight / textArea.lineCount
width: parent.width
Label {
id: numbers
color: "white"
font: areaText.font
font: textArea.font
height: parent.height
horizontalAlignment: Text.AlignLeft
text: parent.index + 1
@@ -67,20 +69,19 @@ SplitView {
id: indicator
anchors.left: numbers.right
color: Qt.darker("#FFF", 3)
color: RustColors.linenumber
height: parent.height
width: 1
}
}
model: areaText.lineCount
// TODO: Bug where text wrapping shows as new line number.
model: textArea.lineCount
}
}
}
Flickable {
id: editorFlickable
property alias areaText: areaText
Layout.fillHeight: true
Layout.fillWidth: true
boundsBehavior: Flickable.StopAtBounds
@@ -91,20 +92,19 @@ SplitView {
ScrollBar.vertical: MyScrollBar {
}
TextArea.flickable: TextArea {
id: areaText
id: textArea
color: "#ccced3"
color: RustColors.editor_text
focus: true
persistentSelection: true
selectByMouse: true
// selectedTextColor: control.palette.highlightedText
// selectionColor: control.palette.highlight
// selectedTextColor: RustColors.editor_highlighted_text
// selectionColor: RustColors.editor_highlight
textFormat: Qt.AutoText
wrapMode: TextArea.Wrap
background: Rectangle {
color: "#2b2b2b"
color: RustColors.editor_background
}
onLinkActivated: function (link) {
@@ -137,7 +137,7 @@ SplitView {
FontMetrics {
id: fontMetrics
font: areaText.font
font: textArea.font
}
}
}
@@ -150,9 +150,9 @@ SplitView {
readOnly: true
wrapMode: TextArea.Wrap
background: Rectangle {
color: "#2b2b2b"
color: RustColors.editor_background
implicitHeight: 100
// border.color: control.enabled ? "#21be2b" : "transparent"
// border.color: control.enabled ? RustColors.active : RustColors.inactive
}
}
@@ -163,11 +163,12 @@ SplitView {
// Scroll bar gutter
background: Rectangle {
color: "#3b3b3b"
implicitHeight: scrollBar.interactive ? 8 : 4
implicitWidth: scrollBar.interactive ? 8 : 4
opacity: scrollBar.active && scrollBar.size < 1.0 ? 1.0 : 0.0
color: RustColors.scrollbar_gutter
// Fade the scrollbar gutter when inactive.
opacity: scrollBar.active && scrollBar.size < 1.0 ? 1.0 : 0.2
Behavior on opacity {
OpacityAnimator {
duration: 500
@@ -177,14 +178,23 @@ SplitView {
// Scroll bar
contentItem: Rectangle {
color: "#4b4f51"
implicitHeight: scrollBar.interactive ? 8 : 4
implicitWidth: scrollBar.interactive ? 8 : 4
opacity: scrollBar.active && scrollBar.size < 1.0 ? 1.0 : 0.2
// If we don't need a scrollbar, fallback to the gutter color.
// If the scrollbar is required change it's color based on activity.
color: scrollBar.size < 1.0 ? scrollBar.active ? RustColors.scrollbar_active : RustColors.scrollbar : RustColors.scrollbar_gutter
// Smooth transition between color changes based on the state above.
Behavior on color {
ColorAnimation {
duration: 1000
}
}
// Fade the scrollbar when inactive.
opacity: scrollBar.active && scrollBar.size < 1.0 ? 1.0 : 0.35
Behavior on opacity {
OpacityAnimator {
duration: 1000
duration: 500
}
}
}