mirror of
https://github.com/overte-org/overte.git
synced 2025-06-22 18:01:06 +02:00
Scroll and snap to attachment with focus
This commit is contained in:
parent
c7d1aa8ff4
commit
b539c55c02
5 changed files with 79 additions and 20 deletions
|
@ -25,6 +25,8 @@ Original.CheckBox {
|
||||||
readonly property int checkSize: Math.max(boxSize - 8, 10)
|
readonly property int checkSize: Math.max(boxSize - 8, 10)
|
||||||
readonly property int checkRadius: 2
|
readonly property int checkRadius: 2
|
||||||
|
|
||||||
|
activeFocusOnPress: true
|
||||||
|
|
||||||
style: CheckBoxStyle {
|
style: CheckBoxStyle {
|
||||||
indicator: Rectangle {
|
indicator: Rectangle {
|
||||||
id: box
|
id: box
|
||||||
|
|
|
@ -17,10 +17,24 @@ Item {
|
||||||
|
|
||||||
HifiConstants { id: hifi }
|
HifiConstants { id: hifi }
|
||||||
|
|
||||||
|
signal selectAttachment();
|
||||||
signal deleteAttachment(var attachment);
|
signal deleteAttachment(var attachment);
|
||||||
signal updateAttachment();
|
signal updateAttachment();
|
||||||
property bool completed: false;
|
property bool completed: false;
|
||||||
|
|
||||||
|
function doSelectAttachment(control, focus) {
|
||||||
|
if (focus) {
|
||||||
|
selectAttachment();
|
||||||
|
|
||||||
|
// Refocus control after possibly changing focus to attachment.
|
||||||
|
if (control.setControlFocus !== undefined) {
|
||||||
|
control.setControlFocus();
|
||||||
|
} else {
|
||||||
|
control.focus = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle { color: hifi.colors.baseGray; anchors.fill: parent; radius: 4 }
|
Rectangle { color: hifi.colors.baseGray; anchors.fill: parent; radius: 4 }
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
@ -50,6 +64,7 @@ Item {
|
||||||
updateAttachment();
|
updateAttachment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onFocusChanged: doSelectAttachment(this, focus);
|
||||||
}
|
}
|
||||||
HifiControls.Button {
|
HifiControls.Button {
|
||||||
id: modelChooserButton;
|
id: modelChooserButton;
|
||||||
|
@ -91,6 +106,7 @@ Item {
|
||||||
updateAttachment();
|
updateAttachment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onFocusChanged: doSelectAttachment(this, focus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,6 +124,7 @@ Item {
|
||||||
updateAttachment();
|
updateAttachment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onControlFocusChanged: doSelectAttachment(this, controlFocus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,6 +142,7 @@ Item {
|
||||||
updateAttachment();
|
updateAttachment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onControlFocusChanged: doSelectAttachment(this, controlFocus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,6 +171,7 @@ Item {
|
||||||
updateAttachment();
|
updateAttachment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onFocusChanged: doSelectAttachment(this, focus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +197,7 @@ Item {
|
||||||
updateAttachment();
|
updateAttachment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onFocusChanged: doSelectAttachment(this, focus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,37 @@ Item {
|
||||||
property real stepSize: 1
|
property real stepSize: 1
|
||||||
property real maximumValue: 99
|
property real maximumValue: 99
|
||||||
property real minimumValue: 0
|
property real minimumValue: 0
|
||||||
|
property bool controlFocus: false; // True if one of the ordinate controls has focus.
|
||||||
|
property var controlFocusControl: undefined
|
||||||
|
|
||||||
signal valueChanged();
|
signal valueChanged();
|
||||||
|
|
||||||
|
function setControlFocus() {
|
||||||
|
if (controlFocusControl) {
|
||||||
|
controlFocusControl.focus = true;
|
||||||
|
// The controlFocus value is updated via onFocusChanged.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setFocus(control, focus) {
|
||||||
|
if (focus) {
|
||||||
|
controlFocusControl = control;
|
||||||
|
setControlFocusTrue.start(); // After any subsequent false from previous control.
|
||||||
|
} else {
|
||||||
|
controlFocus = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: setControlFocusTrue
|
||||||
|
interval: 50
|
||||||
|
repeat: false
|
||||||
|
running: false
|
||||||
|
onTriggered: {
|
||||||
|
controlFocus = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HifiConstants { id: hifi }
|
HifiConstants { id: hifi }
|
||||||
|
|
||||||
HifiControls.SpinBox {
|
HifiControls.SpinBox {
|
||||||
|
@ -38,6 +66,7 @@ Item {
|
||||||
root.valueChanged();
|
root.valueChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onFocusChanged: setFocus(this, focus);
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControls.SpinBox {
|
HifiControls.SpinBox {
|
||||||
|
@ -58,6 +87,7 @@ Item {
|
||||||
root.valueChanged();
|
root.valueChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onFocusChanged: setFocus(this, focus);
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControls.SpinBox {
|
HifiControls.SpinBox {
|
||||||
|
@ -78,6 +108,6 @@ Item {
|
||||||
root.valueChanged();
|
root.valueChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onFocusChanged: setFocus(this, focus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,17 +45,32 @@ Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: 4
|
anchors.margins: 4
|
||||||
clip: true
|
clip: true
|
||||||
focus: true
|
snapMode: ListView.SnapToItem
|
||||||
|
|
||||||
model: ListModel {}
|
model: ListModel {}
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
id: attachmentDelegate
|
id: attachmentDelegate
|
||||||
implicitHeight: attachmentView.height + 8;
|
implicitHeight: attachmentView.height + 8;
|
||||||
implicitWidth: attachmentView.width
|
implicitWidth: attachmentView.width
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
// User can click on whitespace to select item.
|
||||||
|
anchors.fill: parent
|
||||||
|
propagateComposedEvents: true
|
||||||
|
onClicked: {
|
||||||
|
listView.currentIndex = index;
|
||||||
|
attachmentsBackground.forceActiveFocus(); // Unfocus from any control.
|
||||||
|
mouse.accepted = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Attachment {
|
Attachment {
|
||||||
id: attachmentView
|
id: attachmentView
|
||||||
width: listView.width
|
width: listView.width
|
||||||
attachment: content.attachments[index]
|
attachment: content.attachments[index]
|
||||||
|
onSelectAttachment: {
|
||||||
|
listView.currentIndex = index;
|
||||||
|
}
|
||||||
onDeleteAttachment: {
|
onDeleteAttachment: {
|
||||||
attachments.splice(index, 1);
|
attachments.splice(index, 1);
|
||||||
listView.model.remove(index, 1);
|
listView.model.remove(index, 1);
|
||||||
|
@ -63,11 +78,18 @@ Item {
|
||||||
onUpdateAttachment: MyAvatar.setAttachmentsVariant(attachments);
|
onUpdateAttachment: MyAvatar.setAttachmentsVariant(attachments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onCountChanged: MyAvatar.setAttachmentsVariant(attachments);
|
onCountChanged: MyAvatar.setAttachmentsVariant(attachments);
|
||||||
|
|
||||||
function scrollBy(delta) {
|
/* */
|
||||||
// @@@@@@@
|
// DEBUG
|
||||||
//flickableItem.contentY += delta;
|
highlight: Rectangle { color: "#40ffff00" }
|
||||||
|
highlightFollowsCurrentItem: true
|
||||||
|
/* */
|
||||||
|
|
||||||
|
onHeightChanged: {
|
||||||
|
// Keyboard has been raised / lowered.
|
||||||
|
positionViewAtIndex(currentIndex, ListView.SnapPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,9 +167,4 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollBy(delta) {
|
|
||||||
listView.scrollBy(delta);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,16 +107,6 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onKeyboardRaisedChanged: {
|
|
||||||
if (keyboardEnabled && keyboardRaised) {
|
|
||||||
var buttonsHeight = 120; // Allow for New Attachment plus Cancel & OK buttons.
|
|
||||||
var delta = activator.mouseY - (root.height - keyboard.raisedHeight - buttonsHeight);
|
|
||||||
if (delta > 0) {
|
|
||||||
attachments.scrollBy(delta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: activator
|
id: activator
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
Loading…
Reference in a new issue