mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-11 07:18:24 +02:00
Fix multiple dynamic brushes not working in some cases (mixing axis would not work neither for rotation nor for translation); Fix tablet hovering detection only working for right hand;
135 lines
5.6 KiB
HTML
135 lines
5.6 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script type="text/javascript" src="../../html/js/jquery-2.1.4.min.js"></script>
|
|
|
|
<style>
|
|
iframe {
|
|
height:100%;
|
|
width:100%;
|
|
position: absolute;
|
|
}
|
|
.tabButton {
|
|
background-color: #aaaaaa;
|
|
color: white;
|
|
font-size: 100%;
|
|
padding: 12px;
|
|
margin: 0px;
|
|
text-align: center;
|
|
vertical-align: middle;
|
|
display: inline-block;
|
|
user-select: none;
|
|
}
|
|
.tabIcon {
|
|
width: 24px;
|
|
height: 24px;
|
|
padding-right: 12px;
|
|
}
|
|
.selected {
|
|
background-color: #4286f4
|
|
}
|
|
</style>
|
|
</head>
|
|
<body style="margin:0px;padding:0px;overflow:hidden">
|
|
<div id="tabs">
|
|
<span class="tabButton" onclick="selectTab(0)"><img class="tabIcon" src="../content/tabicons/colorpaletteBtn.png"/>Color</span>
|
|
<span class="tabButton" onclick="selectTab(1)"><img class="tabIcon" src="../content/tabicons/brushesBtn.png"/>Brushes</span>
|
|
<span class="tabButton" onclick="selectTab(2)"><img class="tabIcon" src="../content/tabicons/eraser.png"/>Eraser</span>
|
|
<span class="tabButton" onclick="selectTab(3)"><img class="tabIcon" src="../content/tabicons/linewidthBtn.png"/>Line Width</span>
|
|
<span class="tabButton" onclick="selectTab(4)"><img class="tabIcon" src="../content/tabicons/pointingfinger128px.png"/>Hand</span>
|
|
</div>
|
|
<div id="settingsLoading" style="display: none; background-color: #F44336; color: white; padding: 8px">Loading previous settings</div>
|
|
<div id="content">
|
|
<iframe frameborder="0" src="colorsTab.html" onLoad="notifyFrameLoaded(this)" id="colorTab" seamless></iframe>
|
|
<iframe frameborder="0" src="brushesTab.html" onLoad="notifyFrameLoaded(this)" id="brushesTab" seamless style="display: none"></iframe>
|
|
<iframe frameborder="0" src="eraserTab.html" onLoad="notifyFrameLoaded(this)" id="eraserTab" seamless style="display: none"></iframe>
|
|
<iframe frameborder="0" src="lineWidthTab.html" onLoad="notifyFrameLoaded(this)" id="lineWidthTab" seamless style="display: none"></iframe>
|
|
<iframe frameborder="0" src="chooseHandTab.html" onLoad="notifyFrameLoaded(this)" id="chooseHandTab" seamless style="display: none"></iframe>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
|
|
<script type="text/javascript">
|
|
var currentTab = 0;
|
|
var settings;
|
|
var iframesLoaded = 0;
|
|
|
|
function selectTab(tabIndex) {
|
|
var tabs = document.getElementById("tabs").children;
|
|
var contentPanels = document.getElementById("content").children;
|
|
tabs[currentTab].classList.remove("selected");
|
|
contentPanels[currentTab].style.display = "none";
|
|
contentPanels[tabIndex].style.display = "block";
|
|
tabs[tabIndex].classList.add("selected");
|
|
currentTab = tabIndex;
|
|
var changeTabEvent = {
|
|
"type" : "changeTab",
|
|
"currentTab": tabIndex
|
|
};
|
|
EventBridge.emitWebEvent(JSON.stringify(changeTabEvent));
|
|
}
|
|
|
|
//Accept events from iframes
|
|
//https://stackoverflow.com/questions/8822907/html5-cross-browser-iframe-postmessage-child-to-parent
|
|
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
|
|
var eventer = window[eventMethod];
|
|
var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
|
|
|
|
|
|
function receiveDataSetup() {
|
|
readyEvent = {"type": "ready"};
|
|
EventBridge.emitWebEvent(JSON.stringify(readyEvent));
|
|
EventBridge.scriptEventReceived.connect(function (message) {
|
|
//EventBridge.emitWebEvent("HTML side received message: " + message);
|
|
//TODO: read settings and set stuff accordingly
|
|
//Web Entity JS message:
|
|
//debugger;
|
|
settings = JSON.parse(message); //setup the settings so they can be added once the iframes load
|
|
setupSettings();
|
|
|
|
});
|
|
}
|
|
|
|
function notifyFrameLoaded(e) {
|
|
iframesLoaded++;
|
|
setupSettings();
|
|
}
|
|
|
|
function setupSettings() {
|
|
//run only when all the tabs have been loaded and the settings have been received
|
|
//no matter the order at which these occur
|
|
if (!settings || iframesLoaded != 5) {
|
|
return;
|
|
}
|
|
$("#settingsLoading").hide();
|
|
if (settings.currentTab) {
|
|
selectTab(settings.currentTab);
|
|
}
|
|
if (settings.currentColor) {
|
|
document.getElementById("colorTab").contentWindow.postMessage(JSON.stringify({currentColor: settings.currentColor}), "*");
|
|
}
|
|
if (settings.customColors) {
|
|
document.getElementById("colorTab").contentWindow.postMessage(JSON.stringify({customColors: settings.customColors}), "*");
|
|
}
|
|
if (settings.currentTexture) {
|
|
document.getElementById("brushesTab").contentWindow.postMessage(JSON.stringify({currentTexture: settings.currentTexture}), "*");
|
|
}
|
|
if (settings.currentDynamicBrushes) {
|
|
document.getElementById("brushesTab").contentWindow.postMessage(JSON.stringify({currentDynamicBrushes: settings.currentDynamicBrushes}), "*");
|
|
}
|
|
if (settings.currentStrokeWidth) {
|
|
document.getElementById("lineWidthTab").contentWindow.postMessage(JSON.stringify(settings.currentStrokeWidth), "*");
|
|
}
|
|
if (settings.currentDrawingHand) {
|
|
document.getElementById("chooseHandTab").contentWindow.postMessage(JSON.stringify(settings.currentDrawingHand), "*");
|
|
}
|
|
}
|
|
|
|
$(document).ready(receiveDataSetup);
|
|
// Listen to message from child window
|
|
eventer(messageEvent,function(e) {
|
|
EventBridge.emitWebEvent(e.data);
|
|
}, false);
|
|
|
|
</script>
|
|
|