Add mode selector (my view / radar), not finished

This commit is contained in:
Gabriel Calero 2018-01-24 12:29:58 -03:00 committed by Cristian Luis Duarte
parent 917cbd73b1
commit d5e101c2e8
9 changed files with 431 additions and 1 deletions

View file

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Layer_1"
x="0px"
y="0px"
width="150px"
height="150px"
viewBox="0 0 150 150"
enable-background="new 0 0 150 150"
xml:space="preserve"
inkscape:version="0.91 r13725"
sodipodi:docname="myview-a.svg"><metadata
id="metadata15"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
id="defs13" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="640"
inkscape:window-height="480"
id="namedview11"
showgrid="false"
inkscape:zoom="1.5733333"
inkscape:cx="75"
inkscape:cy="75"
inkscape:window-x="0"
inkscape:window-y="23"
inkscape:window-maximized="0"
inkscape:current-layer="Layer_1" /><title
id="title3">Asset 3</title><g
id="Layer_2"
transform="translate(0,18)"><g
id="Layer_1-2"><path
d="M 135.105,20 12.135,20 C 4.381,20 0,25.958 0,34.238 l 0,80.608 c -0.653,7.229 4.677,13.618 11.906,14.271 0.411,0.037 0.824,0.055 1.236,0.053 l 122.664,0 c 7.709,0 14.105,-8.061 14.105,-16.34 l 0,-80.607 C 150,23.943 142.815,20 135.105,20 Z m 2.322,95.678 c 0.005,2.32 -1.802,4.241 -4.118,4.381 l -118.02,0 c -2.316,-0.14 -4.122,-2.061 -4.118,-4.381 l 0,-82.229 c -0.004,-2.32 1.802,-4.242 4.118,-4.381 l 118.02,0 c 2.316,0.139 4.123,2.061 4.118,4.381 l 0,82.229 z"
id="path7"
inkscape:connector-curvature="0"
style="fill:#ffffff" /><polygon
points="107.462,74.322 129.761,74.322 129.761,67.576 99.795,67.576 99.62,67.444 99.533,67.576 49.854,67.576 49.767,67.444 49.547,67.576 18.137,67.576 18.137,74.322 42.188,74.322 18.137,89.349 18.137,97.584 53.578,74.322 61.595,74.322 44.378,113.838 51.519,113.838 68.691,74.322 80.651,74.322 97.868,113.838 105.009,113.838 87.792,74.322 96.072,74.322 129.761,97.41 129.761,89.174 "
id="polygon9"
style="fill:#ffffff" /></g></g></svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

View file

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Layer_1"
x="0px"
y="0px"
width="150px"
height="150px"
viewBox="0 0 150 150"
enable-background="new 0 0 150 150"
xml:space="preserve"
inkscape:version="0.91 r13725"
sodipodi:docname="myview-hover.svg"><metadata
id="metadata30"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
id="defs28" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="640"
inkscape:window-height="480"
id="namedview26"
showgrid="false"
inkscape:zoom="1.5733333"
inkscape:cx="130.51898"
inkscape:cy="69.038136"
inkscape:window-x="20"
inkscape:window-y="65"
inkscape:window-maximized="0"
inkscape:current-layer="Layer_1" /><title
id="title18">Asset 3</title><g
id="Layer_2"
transform="translate(0,20)"><g
id="Layer_1-2"><path
d="m 135.105,19.5 -122.97,0 C 4.381,19.5 0,25.458 0,33.738 l 0,80.608 c -0.653,7.229 4.677,13.618 11.906,14.271 0.411,0.037 0.824,0.055 1.236,0.053 l 122.664,0 c 7.709,0 14.105,-8.061 14.105,-16.34 l 0,-80.607 C 150,23.443 142.815,19.5 135.105,19.5 Z m 2.322,95.678 c 0.005,2.32 -1.802,4.241 -4.118,4.381 l -118.02,0 c -2.316,-0.14 -4.122,-2.061 -4.118,-4.381 l 0,-82.229 c -0.004,-2.32 1.802,-4.242 4.118,-4.381 l 118.02,0 c 2.316,0.139 4.123,2.061 4.118,4.381 l 0,82.229 z"
id="path22"
inkscape:connector-curvature="0" /><polygon
points="99.533,67.076 49.854,67.076 49.767,66.944 49.547,67.076 18.137,67.076 18.137,73.822 42.188,73.822 18.137,88.849 18.137,97.084 53.578,73.822 61.595,73.822 44.378,113.338 51.519,113.338 68.691,73.822 80.651,73.822 97.868,113.338 105.009,113.338 87.792,73.822 96.072,73.822 129.761,96.91 129.761,88.674 107.462,73.822 129.761,73.822 129.761,67.076 99.795,67.076 99.62,66.944 "
id="polygon24" /></g></g></svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Layer_1"
x="0px"
y="0px"
width="150px"
height="150px"
viewBox="0 0 150 150"
enable-background="new 0 0 150 150"
xml:space="preserve"
inkscape:version="0.91 r13725"
sodipodi:docname="myview-i.svg"><metadata
id="metadata45"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
id="defs43" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="668"
inkscape:window-height="480"
id="namedview41"
showgrid="false"
inkscape:zoom="1.5733333"
inkscape:cx="75"
inkscape:cy="75"
inkscape:window-x="40"
inkscape:window-y="107"
inkscape:window-maximized="0"
inkscape:current-layer="Layer_1" /><title
id="title33">Asset 3</title><g
id="Layer_2"
transform="translate(0,20)"><g
id="Layer_1-2"><path
d="M 135.105,20 12.135,20 C 4.381,20 0,25.958 0,34.238 l 0,80.608 c -0.653,7.229 4.677,13.618 11.906,14.271 0.411,0.037 0.824,0.055 1.236,0.053 l 122.664,0 c 7.709,0 14.105,-8.061 14.105,-16.34 l 0,-80.607 C 150,23.943 142.815,20 135.105,20 Z m 2.322,95.678 c 0.005,2.32 -1.802,4.241 -4.118,4.381 l -118.02,0 c -2.316,-0.14 -4.122,-2.061 -4.118,-4.381 l 0,-82.229 c -0.004,-2.32 1.802,-4.242 4.118,-4.381 l 118.02,0 c 2.316,0.139 4.123,2.061 4.118,4.381 l 0,82.229 z"
id="path37"
inkscape:connector-curvature="0"
style="fill:#afafaf" /><polygon
points="129.761,74.322 129.761,67.576 99.795,67.576 99.62,67.444 99.533,67.576 49.854,67.576 49.767,67.444 49.547,67.576 18.137,67.576 18.137,74.322 42.188,74.322 18.137,89.349 18.137,97.584 53.578,74.322 61.595,74.322 44.378,113.838 51.519,113.838 68.691,74.322 80.651,74.322 97.868,113.838 105.009,113.838 87.792,74.322 96.072,74.322 129.761,97.41 129.761,89.174 107.462,74.322 "
id="polygon39"
style="fill:#afafaf" /></g></g></svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 31.87 31.87"><defs><style type="text/css">.cls-1{fill:#ffffff;}</style></defs><title>Asset 1</title><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path class="cls-1" d="M15.94,19.45a3.51,3.51,0,1,1,3.51-3.51A3.51,3.51,0,0,1,15.94,19.45Zm0-5.36a1.85,1.85,0,1,0,1.85,1.85A1.85,1.85,0,0,0,15.94,14.09Z"/><circle class="cls-1" cx="22.65" cy="20.94" r="1.85"/><path class="cls-1" d="M15.94,0A15.84,15.84,0,0,0,7.16,2.65,3.52,3.52,0,0,1,8.24,3.94,14.34,14.34,0,1,1,3.67,8.68a3.51,3.51,0,0,1-1.31-1A15.92,15.92,0,1,0,15.94,0Z"/><circle class="cls-1" cx="5.1" cy="5.48" r="1.85"/><path class="cls-1" d="M19.73,22.88A7.9,7.9,0,0,1,8.82,19.37a3.48,3.48,0,0,1-1.28.25,3.46,3.46,0,0,1-.46,0A9.55,9.55,0,0,0,21,24,3.52,3.52,0,0,1,19.73,22.88Z"/><path class="cls-1" d="M15.94,6.36a9.59,9.59,0,0,0-9,6.3,3.49,3.49,0,0,1,.59-.06,3.47,3.47,0,0,1,1.13.2,7.91,7.91,0,0,1,15,4.79,3.5,3.5,0,0,1,1.48.89A9.55,9.55,0,0,0,15.94,6.36Z"/><circle class="cls-1" cx="7.54" cy="16.11" r="1.85"/><!--<path class="cls-1" d="M5.2,38.52v2H4.09V35.37H5.71c1.39,0,2.09.5,2.09,1.55a1.42,1.42,0,0,1-1,1.4l1.34,2.23H6.87l-1.11-2Zm.58-.78c.58,0,.89-.24.89-.82s-.31-.77-1-.77H5.2v1.59Z"/><path class="cls-1" d="M9.9,39.39l-.29,1.16H8.46l1.6-5.19H11.4L13,40.55H11.82l-.29-1.16Zm.81-3.21-.6,2.39h1.21Z"/><path class="cls-1" d="M17.87,37.94a2.3,2.3,0,0,1-2.55,2.62H13.84V35.37H15.2C16.57,35.37,17.87,35.79,17.87,37.94Zm-2.93,1.81h.45c.76,0,1.33-.35,1.33-1.81s-.61-1.76-1.36-1.76h-.43Z"/><path class="cls-1" d="M19.69,39.39l-.29,1.16H18.25l1.6-5.19h1.34l1.59,5.19H21.61l-.29-1.16Zm.81-3.21-.6,2.39h1.21Z"/><path class="cls-1" d="M24.74,38.52v2h-1.1V35.37h1.62c1.39,0,2.09.5,2.09,1.55a1.42,1.42,0,0,1-1,1.4l1.34,2.23H26.41l-1.11-2Zm.58-.78c.58,0,.89-.24.89-.82s-.31-.77-1-.77h-.49v1.59Z"/>--></g></g></svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 31.87 31.87"><defs><style type="text/css">.cls-1{fill:#ffffff;}</style></defs><title>Asset 1</title><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path class="cls-1" d="M15.94,19.45a3.51,3.51,0,1,1,3.51-3.51A3.51,3.51,0,0,1,15.94,19.45Zm0-5.36a1.85,1.85,0,1,0,1.85,1.85A1.85,1.85,0,0,0,15.94,14.09Z"/><circle class="cls-1" cx="22.65" cy="20.94" r="1.85"/><path class="cls-1" d="M15.94,0A15.84,15.84,0,0,0,7.16,2.65,3.52,3.52,0,0,1,8.24,3.94,14.34,14.34,0,1,1,3.67,8.68a3.51,3.51,0,0,1-1.31-1A15.92,15.92,0,1,0,15.94,0Z"/><circle class="cls-1" cx="5.1" cy="5.48" r="1.85"/><path class="cls-1" d="M19.73,22.88A7.9,7.9,0,0,1,8.82,19.37a3.48,3.48,0,0,1-1.28.25,3.46,3.46,0,0,1-.46,0A9.55,9.55,0,0,0,21,24,3.52,3.52,0,0,1,19.73,22.88Z"/><path class="cls-1" d="M15.94,6.36a9.59,9.59,0,0,0-9,6.3,3.49,3.49,0,0,1,.59-.06,3.47,3.47,0,0,1,1.13.2,7.91,7.91,0,0,1,15,4.79,3.5,3.5,0,0,1,1.48.89A9.55,9.55,0,0,0,15.94,6.36Z"/><circle class="cls-1" cx="7.54" cy="16.11" r="1.85"/><!--<path class="cls-1" d="M5.2,38.52v2H4.09V35.37H5.71c1.39,0,2.09.5,2.09,1.55a1.42,1.42,0,0,1-1,1.4l1.34,2.23H6.87l-1.11-2Zm.58-.78c.58,0,.89-.24.89-.82s-.31-.77-1-.77H5.2v1.59Z"/><path class="cls-1" d="M9.9,39.39l-.29,1.16H8.46l1.6-5.19H11.4L13,40.55H11.82l-.29-1.16Zm.81-3.21-.6,2.39h1.21Z"/><path class="cls-1" d="M17.87,37.94a2.3,2.3,0,0,1-2.55,2.62H13.84V35.37H15.2C16.57,35.37,17.87,35.79,17.87,37.94Zm-2.93,1.81h.45c.76,0,1.33-.35,1.33-1.81s-.61-1.76-1.36-1.76h-.43Z"/><path class="cls-1" d="M19.69,39.39l-.29,1.16H18.25l1.6-5.19h1.34l1.59,5.19H21.61l-.29-1.16Zm.81-3.21-.6,2.39h1.21Z"/><path class="cls-1" d="M24.74,38.52v2h-1.1V35.37h1.62c1.39,0,2.09.5,2.09,1.55a1.42,1.42,0,0,1-1,1.4l1.34,2.23H26.41l-1.11-2Zm.58-.78c.58,0,.89-.24.89-.82s-.31-.77-1-.77h-.49v1.59Z"/>--></g></g></svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 31.87 31.87"><defs><style type="text/css">.cls-1{fill:#afafaf;}</style></defs><title>Asset 1</title><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path class="cls-1" d="M15.94,19.45a3.51,3.51,0,1,1,3.51-3.51A3.51,3.51,0,0,1,15.94,19.45Zm0-5.36a1.85,1.85,0,1,0,1.85,1.85A1.85,1.85,0,0,0,15.94,14.09Z"/><circle class="cls-1" cx="22.65" cy="20.94" r="1.85"/><path class="cls-1" d="M15.94,0A15.84,15.84,0,0,0,7.16,2.65,3.52,3.52,0,0,1,8.24,3.94,14.34,14.34,0,1,1,3.67,8.68a3.51,3.51,0,0,1-1.31-1A15.92,15.92,0,1,0,15.94,0Z"/><circle class="cls-1" cx="5.1" cy="5.48" r="1.85"/><path class="cls-1" d="M19.73,22.88A7.9,7.9,0,0,1,8.82,19.37a3.48,3.48,0,0,1-1.28.25,3.46,3.46,0,0,1-.46,0A9.55,9.55,0,0,0,21,24,3.52,3.52,0,0,1,19.73,22.88Z"/><path class="cls-1" d="M15.94,6.36a9.59,9.59,0,0,0-9,6.3,3.49,3.49,0,0,1,.59-.06,3.47,3.47,0,0,1,1.13.2,7.91,7.91,0,0,1,15,4.79,3.5,3.5,0,0,1,1.48.89A9.55,9.55,0,0,0,15.94,6.36Z"/><circle class="cls-1" cx="7.54" cy="16.11" r="1.85"/><!--<path class="cls-1" d="M5.2,38.52v2H4.09V35.37H5.71c1.39,0,2.09.5,2.09,1.55a1.42,1.42,0,0,1-1,1.4l1.34,2.23H6.87l-1.11-2Zm.58-.78c.58,0,.89-.24.89-.82s-.31-.77-1-.77H5.2v1.59Z"/><path class="cls-1" d="M9.9,39.39l-.29,1.16H8.46l1.6-5.19H11.4L13,40.55H11.82l-.29-1.16Zm.81-3.21-.6,2.39h1.21Z"/><path class="cls-1" d="M17.87,37.94a2.3,2.3,0,0,1-2.55,2.62H13.84V35.37H15.2C16.57,35.37,17.87,35.79,17.87,37.94Zm-2.93,1.81h.45c.76,0,1.33-.35,1.33-1.81s-.61-1.76-1.36-1.76h-.43Z"/><path class="cls-1" d="M19.69,39.39l-.29,1.16H18.25l1.6-5.19h1.34l1.59,5.19H21.61l-.29-1.16Zm.81-3.21-.6,2.39h1.21Z"/><path class="cls-1" d="M24.74,38.52v2h-1.1V35.37h1.62c1.39,0,2.09.5,2.09,1.55a1.42,1.42,0,0,1-1,1.4l1.34,2.23H26.41l-1.11-2Zm.58-.78c.58,0,.89-.24.89-.82s-.31-.77-1-.77h-.49v1.59Z"/>--></g></g></svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -0,0 +1,73 @@
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.3
import Qt.labs.settings 1.0
import "../../styles-uit"
import "../../controls-uit" as HifiControlsUit
import "../../controls" as HifiControls
import ".."
Item {
id: modesbar
y:60
Rectangle {
anchors.fill : parent
color: "transparent"
Flow {
id: flowMain
spacing: 0
flow: Flow.TopToBottom
layoutDirection: Flow.TopToBottom
anchors.fill: parent
anchors.margins: 4
}
}
Component.onCompleted: {
width = 330;
height = 330;
x=Window.innerWidth - width;
}
function addButton(properties) {
var component = Qt.createComponent("button.qml");
console.log("load button");
if (component.status == Component.Ready) {
console.log("load button 2");
var button = component.createObject(flowMain);
// copy all properites to button
var keys = Object.keys(properties).forEach(function (key) {
button[key] = properties[key];
});
return button;
} else if( component.status == Component.Error) {
console.log("Load button errors " + component.errorString());
}
}
function removeButton(name) {
}
function urlHelper(src) {
if (src.match(/\bhttp/)) {
return src;
} else {
return "../../../" + src;
}
}
function fromScript(message) {
switch (message.type) {
case "allButtonsShown":
modesbar.height = flowMain.children.length * 100 + 10;
break;
case "inactiveButtonsHidden":
modesbar.height = 100 + 10;
break;
default:
break;
}
}
}

View file

@ -15,7 +15,8 @@ var DEFAULT_SCRIPTS_COMBINED = [
"system/progress.js",
"system/+android/touchscreenvirtualpad.js",
"system/+android/bottombar.js",
"system/+android/audio.js" /*,
"system/+android/audio.js" /,
"system/+android/modes.js"*,
"system/away.js",
"system/controllers/controllerDisplayManager.js",
"system/controllers/handControllerGrabAndroid.js",

View file

@ -0,0 +1,187 @@
"use strict";
//
// modes.js
// scripts/system/
//
// Created by Gabriel Calero & Cristian Duarte on Jan 23, 2018
// Copyright 2018 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
//
(function() { // BEGIN LOCAL_SCOPE
var modesbar;
var modesButtons;
var currentSelectedBtn;
var SETTING_CURRENT_MODE_KEY = 'Android/Mode';
var MODE_VR = "VR", MODE_RADAR = "RADAR", MODE_MY_VIEW = "MY VIEW";
var DEFAULT_MODE = MODE_RADAR;
var logEnabled = true;
function printd(str) {
if (logEnabled) {
print("[modes.js] " + str);
}
}
function init() {
setupModesBar();
}
function shutdown() {
}
function setupModesBar() {
var bar = new QmlFragment({
qml: "hifi/modesbar.qml"
});
var buttonRadarMode = bar.addButton({
icon: "icons/radar-i.svg",
activeIcon: "icons/radar-a.svg",
hoverIcon: "icons/radar-a.svg",
activeBgOpacity: 0.0,
hoverBgOpacity: 0.0,
activeHoverBgOpacity: 0.0,
text: "RADAR",
height:240,
bottomMargin: 6,
textSize: 45
});
var buttonMyViewMode = bar.addButton({
icon: "icons/myview-i.svg",
activeIcon: "icons/myview-a.svg",
hoverIcon: "icons/myview-a.svg",
activeBgOpacity: 0.0,
hoverBgOpacity: 0.0,
activeHoverBgOpacity: 0.0,
text: "MY VIEW",
height: 240,
bottomMargin: 6,
textSize: 45
});
modesButtons = [buttonRadarMode, buttonMyViewMode];
var mode = getCurrentModeSetting();
var buttonsRevealed = false;
bar.sendToQml({type: "inactiveButtonsHidden"});
modesbar = {
restoreMyViewButton: function() {
switchModeButtons(buttonMyViewMode);
saveCurrentModeSetting(MODE_MY_VIEW);
},
sendToQml: function(o) { bar.sendToQml(o); },
qmlFragment: bar
};
buttonRadarMode.clicked.connect(function() {
//if (connections.isVisible()) return;
saveCurrentModeSetting(MODE_RADAR);
printd("Radar clicked");
onButtonClicked(buttonRadarMode, function() {
//radar.startRadarMode();
});
});
buttonMyViewMode.clicked.connect(function() {
//if (connections.isVisible()) return;
saveCurrentModeSetting(MODE_MY_VIEW);
printd("My View clicked");
onButtonClicked(buttonMyViewMode, function() {
if (currentSelectedBtn == buttonRadarMode) {
//radar.endRadarMode();
}
});
});
var savedButton;
if (mode == MODE_MY_VIEW) {
savedButton = buttonMyViewMode;
} else {
savedButton = buttonRadarMode;
}
printd("[MODE] previous mode " + mode);
savedButton.clicked();
}
function saveCurrentModeSetting(mode) {
Settings.setValue(SETTING_CURRENT_MODE_KEY, mode);
}
function getCurrentModeSetting(mode) {
return Settings.getValue(SETTING_CURRENT_MODE_KEY, DEFAULT_MODE);
}
function showAllButtons() {
for (var i=0; i<modesButtons.length; i++) {
modesButtons[i].visible = true;
}
buttonsRevealed = true;
print("Modesbar: " + modesbar);
modesbar.sendToQml({type: "allButtonsShown"});
}
function hideAllButtons() {
for (var i=0; i<modesButtons.length; i++) {
modesButtons[i].visible = false;
}
}
function hideOtherButtons(thisButton) {
printd("Hiding all but " + thisButton);
printd("modesButtons: " + modesButtons.length);
for (var i=0; i<modesButtons.length; i++) {
if (modesButtons[i] != thisButton) {
printd("----Hiding " + thisButton);
modesButtons[i].visible = false;
} else {
// be sure to keep it visible
modesButtons[i].visible = true;
}
}
buttonsRevealed = false;
print("Modesbar: " + modesbar);
modesbar.sendToQml({type: "inactiveButtonsHidden"});
}
function switchModeButtons(clickedButton, hideAllAfter) {
if (currentSelectedBtn) {
currentSelectedBtn.isActive = false;
}
currentSelectedBtn = clickedButton;
clickedButton.isActive = true;
if (hideAllAfter) {
hideAllButtons();
} else {
hideOtherButtons(clickedButton);
}
}
function onButtonClicked(clickedButton, whatToDo, hideAllAfter) {
if (currentSelectedBtn == clickedButton) {
if (buttonsRevealed) {
hideOtherButtons(clickedButton);
} else {
showAllButtons();
}
} else {
// mode change
whatToDo();
switchModeButtons(clickedButton, hideAllAfter);
}
}
Script.scriptEnding.connect(function () {
shutdown();
});
init();
}()); // END LOCAL_SCOPE