mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 07:19:14 +02:00
some what working d-pad
This commit is contained in:
parent
865a78a8c8
commit
d3fa7651c9
8 changed files with 76 additions and 8 deletions
|
@ -1,15 +1,19 @@
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
|
|
||||||
Item {
|
FocusScope {
|
||||||
id: tablet
|
id: tablet
|
||||||
objectName: "tablet"
|
objectName: "tablet"
|
||||||
|
focus: true
|
||||||
|
enabled: true
|
||||||
property double micLevel: 0.8
|
property double micLevel: 0.8
|
||||||
|
property int index: 0
|
||||||
|
property int count: flowMain.children.length
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
|
||||||
|
//property alias currentItem: flowMain.currentItem
|
||||||
|
|
||||||
// called by C++ code to keep audio bar updated
|
// called by C++ code to keep audio bar updated
|
||||||
function setMicLevel(newMicLevel) {
|
function setMicLevel(newMicLevel) {
|
||||||
tablet.micLevel = newMicLevel;
|
tablet.micLevel = newMicLevel;
|
||||||
|
@ -42,7 +46,6 @@ Item {
|
||||||
|
|
||||||
// pass a reference to the tabletRoot object to the button.
|
// pass a reference to the tabletRoot object to the button.
|
||||||
button.tabletRoot = parent.parent;
|
button.tabletRoot = parent.parent;
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,6 +182,7 @@ Item {
|
||||||
clip: true
|
clip: true
|
||||||
Flow {
|
Flow {
|
||||||
id: flowMain
|
id: flowMain
|
||||||
|
focus: true
|
||||||
spacing: 16
|
spacing: 16
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: 30
|
anchors.rightMargin: 30
|
||||||
|
@ -188,6 +192,50 @@ Item {
|
||||||
anchors.bottomMargin: 30
|
anchors.bottomMargin: 30
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.topMargin: 30
|
anchors.topMargin: 30
|
||||||
|
|
||||||
|
function setCurrentItemState(state) {
|
||||||
|
flowMain.children[index].state = state;
|
||||||
|
}
|
||||||
|
function nextItem() {
|
||||||
|
setCurrentItemState("base state");
|
||||||
|
index = (index + count + 1) % count;
|
||||||
|
setCurrentItemState("hover state");
|
||||||
|
console.log("next item at index: " + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
function previousItem() {
|
||||||
|
setCurrentItemState("base state");
|
||||||
|
index = (index + count - 1 ) % count;
|
||||||
|
setCurrentItemState("hover state");
|
||||||
|
console.log("previous item at index: " + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
function upItem() {
|
||||||
|
setCurrentItemState("base state");
|
||||||
|
index = (index + count - 3) % count;
|
||||||
|
setCurrentItemState("hover state");
|
||||||
|
console.log("up item at index: " + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
function downItem() {
|
||||||
|
setCurrentItemState("base state");
|
||||||
|
index = (index + count + 3) % count;
|
||||||
|
setCurrentItemState("hover state");
|
||||||
|
console.log("down item at index :" + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectItem() {
|
||||||
|
flowMain.children[index].clicked();
|
||||||
|
if(tabletRoot) {
|
||||||
|
tabletRoot.playButtonClickSound();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onRightPressed: nextItem();
|
||||||
|
Keys.onLeftPressed: previousItem();
|
||||||
|
Keys.onDownPressed: downItem();
|
||||||
|
Keys.onUpPressed: upItem();
|
||||||
|
Keys.onReturnPressed: selectItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,7 @@ Item {
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
enabled: true
|
||||||
onClicked: {
|
onClicked: {
|
||||||
console.log("Tablet Button Clicked!");
|
console.log("Tablet Button Clicked!");
|
||||||
if (tabletButton.inDebugMode) {
|
if (tabletButton.inDebugMode) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import QtQml 2.2
|
||||||
import "."
|
import "."
|
||||||
import "../../styles-uit"
|
import "../../styles-uit"
|
||||||
|
|
||||||
Item {
|
FocusScope {
|
||||||
id: tabletMenu
|
id: tabletMenu
|
||||||
objectName: "tabletMenu"
|
objectName: "tabletMenu"
|
||||||
|
|
||||||
|
|
|
@ -111,12 +111,14 @@ FocusScope {
|
||||||
function previousItem() { currentIndex = (currentIndex + count - 1) % count; }
|
function previousItem() { currentIndex = (currentIndex + count - 1) % count; }
|
||||||
function nextItem() { currentIndex = (currentIndex + count + 1) % count; }
|
function nextItem() { currentIndex = (currentIndex + count + 1) % count; }
|
||||||
function selectCurrentItem() { if (currentIndex != -1) root.selected(currentItem.source); }
|
function selectCurrentItem() { if (currentIndex != -1) root.selected(currentItem.source); }
|
||||||
|
function previousPage() {console.log("going to previous page"); }
|
||||||
|
|
||||||
Keys.onUpPressed: previousItem();
|
Keys.onUpPressed: previousItem();
|
||||||
Keys.onDownPressed: nextItem();
|
Keys.onDownPressed: nextItem();
|
||||||
Keys.onSpacePressed: selectCurrentItem();
|
Keys.onSpacePressed: selectCurrentItem();
|
||||||
Keys.onRightPressed: selectCurrentItem();
|
Keys.onRightPressed: selectCurrentItem();
|
||||||
Keys.onReturnPressed: selectCurrentItem();
|
Keys.onReturnPressed: selectCurrentItem();
|
||||||
|
Keys.onLeftPressed: previousPage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ Item {
|
||||||
breadcrumbText.text = "Menu";
|
breadcrumbText.text = "Menu";
|
||||||
topMenu = null;
|
topMenu = null;
|
||||||
offscreenFlags.navigationFocused = false;
|
offscreenFlags.navigationFocused = false;
|
||||||
menuRoot.enabled = false;
|
//menuRoot.enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +100,7 @@ Item {
|
||||||
topMenu = newMenu;
|
topMenu = newMenu;
|
||||||
topMenu.focus = true;
|
topMenu.focus = true;
|
||||||
offscreenFlags.navigationFocused = true;
|
offscreenFlags.navigationFocused = true;
|
||||||
|
console.log(offscreenWindow.activeFocusItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearMenus() {
|
function clearMenus() {
|
||||||
|
@ -159,7 +160,7 @@ Item {
|
||||||
|
|
||||||
function popup(parent, items) {
|
function popup(parent, items) {
|
||||||
d.clearMenus();
|
d.clearMenus();
|
||||||
menuRoot.enabled = true;
|
//menuRoot.enabled = true;
|
||||||
d.buildMenu(items, point);
|
d.buildMenu(items, point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ Item {
|
||||||
id: tabletRoot
|
id: tabletRoot
|
||||||
objectName: "tabletRoot"
|
objectName: "tabletRoot"
|
||||||
property var eventBridge;
|
property var eventBridge;
|
||||||
|
property bool desktopRoot: true
|
||||||
|
|
||||||
function loadSource(url) {
|
function loadSource(url) {
|
||||||
loader.source = url;
|
loader.source = url;
|
||||||
|
@ -24,6 +25,10 @@ Item {
|
||||||
buttonClickSound.play(globalPosition);
|
buttonClickSound.play(globalPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function forceFocus() {
|
||||||
|
loader.item.forceActiveFocus();
|
||||||
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: loader
|
id: loader
|
||||||
objectName: "loader"
|
objectName: "loader"
|
||||||
|
@ -44,8 +49,14 @@ Item {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//loader.item.parent = tablxetRoot;
|
||||||
|
loader.item.forceActiveFocus();
|
||||||
|
offscreenFlags.navigationFocus = true;
|
||||||
|
console.log(loader.item.count);
|
||||||
|
console.log("Current focus item " + offscreenWindow.activeFocusItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Component.onDestruction: { offscreenFlags.navigationFocused = false; }
|
||||||
|
|
||||||
width: 480
|
width: 480
|
||||||
height: 720
|
height: 720
|
||||||
|
|
|
@ -1037,7 +1037,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
sendEvent(window, &event);
|
sendEvent(window, &event);
|
||||||
lastKey = key;
|
lastKey = key;
|
||||||
}
|
}
|
||||||
} else if (key != Qt::Key_unknown) {
|
} else if (key != Qt::Key_unknown && window) {
|
||||||
if (state) {
|
if (state) {
|
||||||
QKeyEvent event(QEvent::KeyPress, key, Qt::NoModifier);
|
QKeyEvent event(QEvent::KeyPress, key, Qt::NoModifier);
|
||||||
sendEvent(window, &event);
|
sendEvent(window, &event);
|
||||||
|
|
|
@ -51,6 +51,10 @@ QQuickWindow* TabletScriptingInterface::getTabletWindow() {
|
||||||
TabletProxy* tablet = qobject_cast<TabletProxy*>(getTablet("com.highfidelity.interface.tablet.system"));
|
TabletProxy* tablet = qobject_cast<TabletProxy*>(getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
QObject* qmlSurface = tablet->getTabletSurface();
|
QObject* qmlSurface = tablet->getTabletSurface();
|
||||||
OffscreenQmlSurface* surface = dynamic_cast<OffscreenQmlSurface*>(qmlSurface);
|
OffscreenQmlSurface* surface = dynamic_cast<OffscreenQmlSurface*>(qmlSurface);
|
||||||
|
|
||||||
|
if (!surface) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
QQuickWindow* window = surface->getWindow();
|
QQuickWindow* window = surface->getWindow();
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
@ -212,6 +216,7 @@ void TabletProxy::addButtonsToHomeScreen() {
|
||||||
}
|
}
|
||||||
auto loader = _qmlTabletRoot->findChild<QQuickItem*>("loader");
|
auto loader = _qmlTabletRoot->findChild<QQuickItem*>("loader");
|
||||||
QObject::disconnect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToHomeScreen()));
|
QObject::disconnect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToHomeScreen()));
|
||||||
|
QMetaObject::invokeMethod(_qmlTabletRoot, "forceFocus");
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject* TabletProxy::getTabletSurface() {
|
QObject* TabletProxy::getTabletSurface() {
|
||||||
|
|
Loading…
Reference in a new issue