diff --git a/build.rs b/build.rs index 664dd6e..72e9b4e 100644 --- a/build.rs +++ b/build.rs @@ -9,6 +9,8 @@ fn main() { "qml/ClideEditor.qml", "qml/ClideMenuBar.qml", "qml/ClideLogger.qml", + "qml/Components/ClideScrollBar.qml", + "qml/Components/ClideHandle.qml", "qml/Logger/Logger.qml", ])) // Link Qt's Network library diff --git a/qml/ClideEditor.qml b/qml/ClideEditor.qml index 204df3f..262642e 100644 --- a/qml/ClideEditor.qml +++ b/qml/ClideEditor.qml @@ -22,18 +22,9 @@ SplitView { orientation: Qt.Vertical // Customized handle to drag between the Editor and the Console. - handle: Rectangle { - 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 - radius: 2.5 - - // Execute these behaviors when the color is changed. - Behavior on color { - ColorAnimation { - duration: 400 - } - } + handle: ClideHandle { + pressed: SplitHandle.pressed + hovered: SplitHandle.hovered } Component.onCompleted: { @@ -119,9 +110,9 @@ SplitView { boundsBehavior: Flickable.StopAtBounds height: 650 - ScrollBar.horizontal: MyScrollBar { + ScrollBar.horizontal: ClideScrollBar { } - ScrollBar.vertical: MyScrollBar { + ScrollBar.vertical: ClideScrollBar { } TextArea.flickable: TextArea { id: textArea @@ -174,50 +165,4 @@ SplitView { id: areaConsole } - - // We use an inline component to customize the horizontal and vertical - // scroll-bars. This is convenient when the component is only used in one file. - component MyScrollBar: ScrollBar { - id: scrollBar - - // Scroll bar gutter - background: Rectangle { - color: RustColors.scrollbar_gutter - implicitHeight: scrollBar.interactive ? 8 : 4 - implicitWidth: scrollBar.interactive ? 8 : 4 - - // Fade the scrollbar gutter when inactive. - opacity: scrollBar.active && scrollBar.size < 1.0 ? 1.0 : 0.0 - - Behavior on opacity { - OpacityAnimator { - duration: 500 - } - } - } - - // Scroll bar - contentItem: Rectangle { - - // 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 - implicitHeight: scrollBar.interactive ? 8 : 4 - implicitWidth: scrollBar.interactive ? 8 : 4 - // Fade the scrollbar when inactive. - opacity: scrollBar.active && scrollBar.size < 1.0 ? 1.0 : 0 - - // Smooth transition between color changes based on the state above. - Behavior on color { - ColorAnimation { - duration: 1000 - } - } - Behavior on opacity { - OpacityAnimator { - duration: 1000 - } - } - } - } } diff --git a/qml/Components/ClideHandle.qml b/qml/Components/ClideHandle.qml new file mode 100644 index 0000000..26e72fc --- /dev/null +++ b/qml/Components/ClideHandle.qml @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2026, Shaun Reed +// +// SPDX-License-Identifier: GNU General Public License v3.0 or later + +import QtQuick +import QtQuick.Controls + +import clide.module 1.0 + +Rectangle { + required property bool hovered + required property bool pressed + + border.color: pressed ? RustColors.pressed : hovered ? RustColors.hovered : RustColors.gutter + color: pressed ? RustColors.pressed : hovered ? RustColors.hovered : RustColors.gutter + implicitHeight: 8 + radius: 2.5 + + // Execute these behaviors when the color is changed. + Behavior on color { + ColorAnimation { + duration: 400 + } + } +} diff --git a/qml/Components/ClideScrollBar.qml b/qml/Components/ClideScrollBar.qml new file mode 100644 index 0000000..4549e8d --- /dev/null +++ b/qml/Components/ClideScrollBar.qml @@ -0,0 +1,52 @@ +// SPDX-FileCopyrightText: 2026, Shaun Reed +// +// SPDX-License-Identifier: GNU General Public License v3.0 or later + +import QtQuick +import QtQuick.Controls + +import clide.module 1.0 + +ScrollBar { + id: scrollBar + + // Scroll bar gutter + background: Rectangle { + color: RustColors.scrollbar_gutter + implicitHeight: scrollBar.interactive ? 8 : 4 + implicitWidth: scrollBar.interactive ? 8 : 4 + + // Fade the scrollbar gutter when inactive. + opacity: scrollBar.active && scrollBar.size < 1.0 ? 1.0 : 0.0 + + Behavior on opacity { + OpacityAnimator { + duration: 500 + } + } + } + + // Scroll bar + contentItem: Rectangle { + + // 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 + implicitHeight: scrollBar.interactive ? 8 : 4 + implicitWidth: scrollBar.interactive ? 8 : 4 + // Fade the scrollbar when inactive. + opacity: scrollBar.active && scrollBar.size < 1.0 ? 1.0 : 0 + + // Smooth transition between color changes based on the state above. + Behavior on color { + ColorAnimation { + duration: 1000 + } + } + Behavior on opacity { + OpacityAnimator { + duration: 1000 + } + } + } +} diff --git a/qml/Components/qmldir b/qml/Components/qmldir new file mode 100644 index 0000000..7ff58ef --- /dev/null +++ b/qml/Components/qmldir @@ -0,0 +1,2 @@ +ClideScrollBar ClideScrollBar.qml +ClideHandle ClideHandle.qml