mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 05:37:26 +02:00
Style drop-down combo box for Developer > Graphics...
This commit is contained in:
parent
a309a2e08f
commit
5a3f74d51b
3 changed files with 128 additions and 19 deletions
98
interface/resources/qml/controls-uit/ComboBox.qml
Normal file
98
interface/resources/qml/controls-uit/ComboBox.qml
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
//
|
||||||
|
// ComboBox.qml
|
||||||
|
//
|
||||||
|
// Created by David Rowe on 27 Feb 2016
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
import QtQuick 2.5
|
||||||
|
import QtQuick.Controls 1.4
|
||||||
|
import QtQuick.Controls.Styles 1.4
|
||||||
|
|
||||||
|
import "../styles-uit"
|
||||||
|
import "../controls-uit" as HifiControls
|
||||||
|
|
||||||
|
// FIXME: Currently supports only the "Drop Down Box" case in the UI Toolkit doc;
|
||||||
|
// Should either be made to also support the "Combo Box" case or drop-down and combo box should be separate controls.
|
||||||
|
|
||||||
|
// FIXME: Style dropped-down items per UI Toolkit Drop Down Box.
|
||||||
|
// http://stackoverflow.com/questions/27089779/qml-combobox-item-dropdownmenu-style/27217209#27217209
|
||||||
|
|
||||||
|
ComboBox {
|
||||||
|
id: comboBox
|
||||||
|
|
||||||
|
property int colorScheme: hifi.colorSchemes.light
|
||||||
|
readonly property bool isLightColorScheme: colorScheme == hifi.colorSchemes.light
|
||||||
|
property string label: ""
|
||||||
|
property real controlHeight: height + (comboBoxLabel.visible ? comboBoxLabel.height : 0)
|
||||||
|
|
||||||
|
height: hifi.fontSizes.textFieldInput + 14 // Match height of TextField control.
|
||||||
|
|
||||||
|
y: comboBoxLabel.visible ? comboBoxLabel.height : 0
|
||||||
|
|
||||||
|
style: ComboBoxStyle {
|
||||||
|
FontLoader { id: firaSansSemiBold; source: "../../fonts/FiraSans-SemiBold.ttf"; }
|
||||||
|
font {
|
||||||
|
family: firaSansSemiBold.name
|
||||||
|
pixelSize: hifi.fontSizes.textFieldInput
|
||||||
|
}
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
gradient: Gradient {
|
||||||
|
GradientStop {
|
||||||
|
position: 0.2
|
||||||
|
color: pressed
|
||||||
|
? (isLightColorScheme ? hifi.colors.dropDownPressedLight : hifi.colors.dropDownPressedDark)
|
||||||
|
: (isLightColorScheme ? hifi.colors.dropDownLightStart : hifi.colors.dropDownDarkStart)
|
||||||
|
}
|
||||||
|
GradientStop {
|
||||||
|
position: 1.0
|
||||||
|
color: pressed
|
||||||
|
? (isLightColorScheme ? hifi.colors.dropDownPressedLight : hifi.colors.dropDownPressedDark)
|
||||||
|
: (isLightColorScheme ? hifi.colors.dropDownLightFinish : hifi.colors.dropDownDarkFinish)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HiFiGlyphs {
|
||||||
|
text: hifi.glyphs.backward // Adapt backward triangle to be downward triangle
|
||||||
|
rotation: -90
|
||||||
|
y: -2
|
||||||
|
size: hifi.dimensions.spinnerSize
|
||||||
|
color: pressed ? (isLightColorScheme ? hifi.colors.black : hifi.colors.white) : hifi.colors.baseGray
|
||||||
|
anchors {
|
||||||
|
right: parent.right
|
||||||
|
rightMargin: 3
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: 1
|
||||||
|
height: parent.height
|
||||||
|
color: isLightColorScheme ? hifi.colors.faintGray : hifi.colors.baseGray
|
||||||
|
anchors {
|
||||||
|
top: parent.top
|
||||||
|
right: parent.right
|
||||||
|
rightMargin: parent.height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
textColor: pressed ? hifi.colors.baseGray : (isLightColorScheme ? hifi.colors.lightGray : hifi.colors.lightGrayText )
|
||||||
|
selectedTextColor: hifi.colors.baseGray
|
||||||
|
selectionColor: hifi.colors.primaryHighlight
|
||||||
|
}
|
||||||
|
|
||||||
|
HifiControls.Label {
|
||||||
|
id: comboBoxLabel
|
||||||
|
text: comboBox.label
|
||||||
|
colorScheme: comboBox.colorScheme
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.bottom: parent.top
|
||||||
|
anchors.bottomMargin: 4
|
||||||
|
visible: label != ""
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,37 +1,42 @@
|
||||||
|
//
|
||||||
|
// ComboBoxPreference.qml
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 18 Jan 2016
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
import QtQuick 2.5
|
import QtQuick 2.5
|
||||||
import QtQuick.Controls 1.4
|
|
||||||
import QtQuick.Controls.Styles 1.4
|
import "../../controls-uit"
|
||||||
|
|
||||||
Preference {
|
Preference {
|
||||||
id: root
|
id: root
|
||||||
property real spacing: 8
|
property alias comboBox: comboBox
|
||||||
height: labelText.height + dataComboBox.height + spacing
|
height: comboBox.controlHeight
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
dataComboBox.currentIndex = dataComboBox.find(preference.value);
|
comboBox.currentIndex = comboBox.find(preference.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
preference.value = dataComboBox.currentText;
|
preference.value = comboBox.currentText;
|
||||||
preference.save();
|
preference.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Label {
|
||||||
id: labelText
|
text: root.label + ":"
|
||||||
color: enabled ? "black" : "gray"
|
colorScheme: hifi.colorSchemes.dark
|
||||||
text: root.label
|
anchors.verticalCenter: comboBox.verticalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
ComboBox {
|
ComboBox {
|
||||||
id: dataComboBox
|
id: comboBox
|
||||||
model: preference.items
|
model: preference.items
|
||||||
style: ComboBoxStyle { renderType: Text.QtRendering }
|
width: 150
|
||||||
anchors {
|
anchors { right: parent.right }
|
||||||
top: labelText.bottom
|
colorScheme: hifi.colorSchemes.dark
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
topMargin: root.spacing
|
|
||||||
rightMargin: root.spacing
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,12 @@ Item {
|
||||||
readonly property color sliderLightFinish: "#afafaf"
|
readonly property color sliderLightFinish: "#afafaf"
|
||||||
readonly property color sliderDarkStart: "#7d7d7d"
|
readonly property color sliderDarkStart: "#7d7d7d"
|
||||||
readonly property color sliderDarkFinish: "#6b6a6b"
|
readonly property color sliderDarkFinish: "#6b6a6b"
|
||||||
|
readonly property color dropDownPressedLight: "#d4d4d4"
|
||||||
|
readonly property color dropDownPressedDark: "#afafaf"
|
||||||
|
readonly property color dropDownLightStart: "#ffffff"
|
||||||
|
readonly property color dropDownLightFinish: "#afafaf"
|
||||||
|
readonly property color dropDownDarkStart: "#7d7d7d"
|
||||||
|
readonly property color dropDownDarkFinish: "#6b6a6b"
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
Loading…
Reference in a new issue