GPSmap196: widget is working as expected and also 3d model
This commit is contained in:
parent
17799e8450
commit
2095d57971
3 changed files with 91 additions and 100 deletions
|
@ -1,7 +1,7 @@
|
|||
|
||||
|
||||
var GPSmap196 = {
|
||||
new: func(canvas_group) {
|
||||
new: func() {
|
||||
print("Load Garmin GPSmap196 canvas");
|
||||
m = { parents : [GPSmap196] };
|
||||
m.node = props.globals.initNode("/instrumentation/gps196");
|
||||
|
@ -18,32 +18,36 @@ var GPSmap196 = {
|
|||
m.buttonPower = m.node.initNode("inputs/button-power", 0, "BOOL");
|
||||
m.rockerRight = m.node.initNode("inputs/rocker-right", 0, "BOOL");
|
||||
m.buttonEnter = m.node.initNode("inputs/button-enter", 0, "BOOL");
|
||||
m.gmt = props.globals.getNode("sim/time/gmt");
|
||||
m.gpsmap196Screen = canvas.new({
|
||||
"name": "GPSmap196-screen",
|
||||
"size": [512, 512],
|
||||
"view": [320, 240],
|
||||
"mipmapping": 1
|
||||
});
|
||||
m.gpsmap196Screen.addPlacement({"node": "gps196.screen"});
|
||||
var g = m.gpsmap196Screen.createGroup();
|
||||
|
||||
m.text = canvas_group.createChild("text", "optional-id-for element")
|
||||
.setFontSize(14)
|
||||
.setColor(1,0,0)
|
||||
.setTranslation(10, 20)
|
||||
.setAlignment("left-center")
|
||||
.setText("This is a text element")
|
||||
.setFont("LiberationFonts/LiberationSans-Regular.ttf");
|
||||
m.text_title =
|
||||
g.createChild("text", "line-title")
|
||||
.setDrawMode(canvas.Text.TEXT + canvas.Text.FILLEDBOUNDINGBOX)
|
||||
.setColor(0,0,0)
|
||||
.setColorFill(0,1,0)
|
||||
.setAlignment("center-top")
|
||||
.setFont("LiberationFonts/LiberationMono-Bold.ttf")
|
||||
.setFontSize(35, 1.5)
|
||||
.setTranslation(150, 50);
|
||||
|
||||
return m;
|
||||
},
|
||||
update: func() {
|
||||
|
||||
me.text_title.setText(me.gmt.getValue());
|
||||
settimer(func me.update(), 0);
|
||||
}
|
||||
};
|
||||
|
||||
setlistener("sim/signals/fdm-initialized", func() {
|
||||
var gpsmap196Screen = canvas.new({
|
||||
"name": "GPSmap196-screen",
|
||||
"size": [512, 512],
|
||||
"view": [320, 240],
|
||||
"mipmapping": 1
|
||||
});
|
||||
gpsmap196Screen.addPlacement({"node": "gps196.screen"});
|
||||
gpsmap196Canvas = GPSmap196.new(gpsmap196Screen.createGroup());
|
||||
gpsmap196Canvas = GPSmap196.new();
|
||||
gpsmap196Canvas.update();
|
||||
});
|
||||
|
||||
|
|
|
@ -292,44 +292,37 @@
|
|||
<command>nasal</command>
|
||||
<script>
|
||||
<![CDATA[
|
||||
var dlg = canvas.Window.new([512, 256], "dialog").set("resize", 1).set("title", "Garmin GPSmap196");
|
||||
var gps196CanvasInstance = canvas.get({name: "GPSmap196-screen"});
|
||||
var dlg = canvas.Window.new([1024, 512], "dialog").set("title", "Garmin GPSmap196");
|
||||
var buttons = [
|
||||
["gps196.widget.button.in", "button-in"], ["gps196.widget.button.out", "button-out"],
|
||||
["gps196.widget.button.dto", "button-dto"], ["gps196.widget.button.page", "button-page"],
|
||||
["gps196.widget.button.quit", "button-quit"], ["gps196.widget.button.nrst", "button-nrst"],
|
||||
["gps196.widget.button.menu", "button-menu"], ["gps196.widget.button.enter", "button-enter"],
|
||||
["gps196.widget.button.power", "button-power"], ["gps196.widget.rocker.up", "rocker-up"],
|
||||
["gps196.widget.rocker.down", "rocker-down"], ["gps196.widget.rocker.left", "rocker-left"],
|
||||
["gps196.widget.rocker.right", "rocker-right"]
|
||||
];
|
||||
|
||||
var gps196Widget = dlg.createCanvas().setColorBackground(1,1,1,1);
|
||||
var root = gps196Widget.createGroup();
|
||||
|
||||
canvas.parsesvg(root, "Aircraft/Instruments-3d/GPSmap196/widget/gpsmap196-widget.svg");
|
||||
|
||||
var display = root.getElementById("gps196.widget.screen");
|
||||
|
||||
var buttons = [
|
||||
["gps196.widget.button.in", "button-in"],
|
||||
["gps196.widget.button.out", "button-out"],
|
||||
["gps196.widget.button.dto", "button-dto"],
|
||||
["gps196.widget.button.page", "button-page"],
|
||||
["gps196.widget.button.quit", "button-quit"],
|
||||
["gps196.widget.button.nrst", "button-nrst"],
|
||||
["gps196.widget.button.enter", "button-enter"],
|
||||
["gps196.widget.button.menu", "button-menu"],
|
||||
["gps196.widget.button.power", "button-power"],
|
||||
["gps196.widget.rocker.up", "rocker-up"],
|
||||
["gps196.widget.rocker.down", "rocker-down"],
|
||||
["gps196.widget.rocker.left", "rocker-left"],
|
||||
["gps196.widget.rocker.right", "rocker-right"]
|
||||
];
|
||||
|
||||
foreach(var button; buttons){
|
||||
print(button[0]~" & "~button[1]);
|
||||
var element = root.getElementById(button[0]);
|
||||
element.addEventListener("mousedown", func(e) { setprop("instrumentation/gps196/inputs/"~button[1], 1); });
|
||||
element.addEventListener("mouseup", func(e) { setprop("instrumentation/gps196/inputs/"~button[1], 0); });
|
||||
element.set("z-index", 11);
|
||||
var setButtonListener = func(btn, prop) {
|
||||
root.getElementById(btn).addEventListener("mousedown", func(e) { setprop("instrumentation/gps196/inputs/"~prop, 1); });
|
||||
root.getElementById(btn).addEventListener("mouseup", func(e) { setprop("instrumentation/gps196/inputs/"~prop, 0); });
|
||||
root.getElementById(btn).set("z-index", 11);
|
||||
}
|
||||
|
||||
var background = root.createChild("image").setFile("Aircraft/Instruments-3d/GPSmap196/widget/gpsmap196-widget.png").setSize(512,256).set("z-index",10);
|
||||
for( var i=0; i<size(buttons); i=i+1){
|
||||
setButtonListener(buttons[i][0], buttons[i][1]);
|
||||
}
|
||||
|
||||
var gps196CanvasInstance = canvas.get({name: "GPSmap196-screen"});
|
||||
#display.createChild("image").setFile(gps196CanvasInstance);
|
||||
var background = root.createChild("image");
|
||||
background.setFile("Aircraft/Instruments-3d/GPSmap196/widget/gpsmap196-widget.png").setSize(1024,512).set("z-index",10);
|
||||
|
||||
#dlg.setCanvas(canvas.get({name: "GPSmap196-screen"}));
|
||||
var canvasScreenWidget = root.createChild("image");
|
||||
canvasScreenWidget.setFile(gps196CanvasInstance.getPath()).setSize(563,359).setTranslation(87,53).set("z-index", 11);
|
||||
]]>
|
||||
</script>
|
||||
</binding>
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
version="1.1"
|
||||
width="512"
|
||||
height="256"
|
||||
width="1024"
|
||||
height="512"
|
||||
id="svg2">
|
||||
<metadata
|
||||
id="metadata8">
|
||||
|
@ -25,76 +25,70 @@
|
|||
</metadata>
|
||||
<defs
|
||||
id="defs6" />
|
||||
<rect
|
||||
width="281.48007"
|
||||
height="179.12369"
|
||||
x="43.213867"
|
||||
y="25.086664"
|
||||
id="gps196.widget.screen"
|
||||
style="fill:#4aff1c;fill-opacity:0.40201015;stroke:none" />
|
||||
<path
|
||||
d="m 937.82332,83.996651 a 26.079056,26.079056 0 1 1 -52.15811,0 26.079056,26.079056 0 1 1 52.15811,0 z"
|
||||
transform="matrix(0.50041838,0,0,0.50041838,-1.8229431,-3.8963709)"
|
||||
d="m 933.51996,81.269959 a 26.100878,26.100878 0 1 1 -52.20174,0 26.100878,26.100878 0 1 1 52.20174,0 z"
|
||||
id="gps196.widget.button.out"
|
||||
style="fill:#4aff1c;fill-opacity:0.40201015;stroke:none" />
|
||||
style="fill:none;fill-opacity:0.40201015;stroke:none" />
|
||||
<path
|
||||
d="m 937.82332,83.996651 a 26.079056,26.079056 0 1 1 -52.15811,0 26.079056,26.079056 0 1 1 52.15811,0 z"
|
||||
transform="matrix(0.50041838,0,0,0.50041838,-1.5670421,29.113569)"
|
||||
d="m 934.03176,147.28984 a 26.100878,26.100878 0 1 1 -52.20174,0 26.100878,26.100878 0 1 1 52.20174,0 z"
|
||||
id="gps196.widget.button.in"
|
||||
style="fill:#4aff1c;fill-opacity:0.40201015;stroke:none" />
|
||||
style="fill:none;fill-opacity:0.40201015;stroke:none" />
|
||||
<path
|
||||
d="m 937.82332,83.996651 a 26.079056,26.079056 0 1 1 -52.15811,0 26.079056,26.079056 0 1 1 52.15811,0 z"
|
||||
transform="matrix(0.50041838,0,0,0.50041838,-30.22683,180.08923)"
|
||||
d="m 876.7122,449.24116 a 26.10088,26.10088 0 0 1 -52.20176,0 26.10088,26.10088 0 1 1 52.20176,0 z"
|
||||
id="gps196.widget.button.dto"
|
||||
style="fill:#4aff1c;fill-opacity:0.40201015;stroke:none" />
|
||||
style="fill:none;fill-opacity:0.40201015;stroke:none" />
|
||||
<path
|
||||
d="m 937.82332,83.996651 a 26.079056,26.079056 0 1 1 -52.15811,0 26.079056,26.079056 0 1 1 52.15811,0 z"
|
||||
transform="matrix(0.56910326,0,0,0.56910326,-137.11902,174.06404)"
|
||||
d="m 791.75638,448.72938 a 29.683352,29.683352 0 1 1 -59.3667,0 29.683352,29.683352 0 1 1 59.3667,0 z"
|
||||
id="gps196.widget.button.power"
|
||||
style="fill:#4aff1c;fill-opacity:0.40201015;stroke:none" />
|
||||
style="fill:none;fill-opacity:0.40201015;stroke:none" />
|
||||
<path
|
||||
d="m 937.82332,83.996651 a 26.079056,26.079056 0 1 1 -52.15811,0 26.079056,26.079056 0 1 1 52.15811,0 z"
|
||||
transform="matrix(0.63778813,0,0,0.63778813,-174.92064,11.945369)"
|
||||
d="m 844.98168,136.03064 a 33.265824,33.265824 0 1 1 -66.53164,0 33.265824,33.265824 0 1 1 66.53164,0 z"
|
||||
id="gps196.widget.button.page"
|
||||
style="fill:#4aff1c;fill-opacity:0.40201015;stroke:none" />
|
||||
style="fill:none;fill-opacity:0.40201015;stroke:none" />
|
||||
<path
|
||||
d="m 937.82332,83.996651 a 26.079056,26.079056 0 1 1 -52.15811,0 26.079056,26.079056 0 1 1 52.15811,0 z"
|
||||
transform="matrix(0.63778813,0,0,0.63778813,-200.50974,50.840799)"
|
||||
d="m 793.80348,213.8215 a 33.265824,33.265824 0 1 1 -66.53164,0 33.265824,33.265824 0 1 1 66.53164,0 z"
|
||||
id="gps196.widget.button.quit"
|
||||
style="fill:#4aff1c;fill-opacity:0.40201015;stroke:none" />
|
||||
style="fill:none;fill-opacity:0.40201015;stroke:none" />
|
||||
<path
|
||||
d="m 937.82332,83.996651 a 26.079056,26.079056 0 1 1 -52.15811,0 26.079056,26.079056 0 1 1 52.15811,0 z"
|
||||
transform="matrix(0.63778813,0,0,0.63778813,-201.02151,94.854049)"
|
||||
d="m 792.77994,301.848 a 33.265824,33.265824 0 1 1 -66.53164,0 33.265824,33.265824 0 1 1 66.53164,0 z"
|
||||
id="gps196.widget.button.enter"
|
||||
style="fill:#4aff1c;fill-opacity:0.40201015;stroke:none" />
|
||||
style="fill:none;fill-opacity:0.40201015;stroke:none" />
|
||||
<path
|
||||
d="m 937.82332,83.996651 a 26.079056,26.079056 0 1 1 -52.15811,0 26.079056,26.079056 0 1 1 52.15811,0 z"
|
||||
transform="matrix(0.63778813,0,0,0.63778813,-174.92063,133.74946)"
|
||||
d="m 844.9817,379.63882 a 33.265824,33.265824 0 1 1 -66.53164,0 33.265824,33.265824 0 1 1 66.53164,0 z"
|
||||
id="gps196.widget.button.menu"
|
||||
style="fill:#4aff1c;fill-opacity:0.40201015;stroke:none" />
|
||||
style="fill:none;fill-opacity:0.40201015;stroke:none" />
|
||||
<path
|
||||
d="m 937.82332,83.996651 a 26.079056,26.079056 0 1 1 -52.15811,0 26.079056,26.079056 0 1 1 52.15811,0 z"
|
||||
transform="matrix(0.63778813,0,0,0.63778813,-122.71887,141.42619)"
|
||||
d="m 949.38522,394.99228 a 33.265824,33.265824 0 1 1 -66.53164,0 33.265824,33.265824 0 1 1 66.53164,0 z"
|
||||
id="gps196.widget.button.nrst"
|
||||
style="fill:#4aff1c;fill-opacity:0.40201015;stroke:none" />
|
||||
<path
|
||||
d="m 853.96124,266.94855 -20.54345,-35.5823 -20.54346,-35.58231 41.08691,0 41.08691,0 -20.54345,35.58231 z"
|
||||
transform="matrix(0.92683535,0,0,0.43241036,-350.81919,11.360869)"
|
||||
id="gps196.widget.rocker.up"
|
||||
style="fill:#4aff1c;fill-opacity:0.40201015;stroke:none" />
|
||||
<path
|
||||
d="m 853.96124,266.94855 -20.54345,-35.5823 -20.54346,-35.58231 41.08691,0 41.08691,0 -20.54345,35.58231 z"
|
||||
transform="matrix(0,-0.74682129,0.53191407,0,298.59919,764.69939)"
|
||||
style="fill:none;fill-opacity:0.40201015;stroke:none" />
|
||||
<rect
|
||||
width="46.64407"
|
||||
height="56.045197"
|
||||
x="804.16229"
|
||||
y="230.62289"
|
||||
id="gps196.widget.rocker.left"
|
||||
style="fill:#4aff1c;fill-opacity:0.40201015;stroke:none" />
|
||||
<path
|
||||
d="m 853.96124,266.94855 -20.54345,-35.5823 -20.54346,-35.58231 41.08691,0 41.08691,0 -20.54345,35.58231 z"
|
||||
transform="matrix(-0.92683535,0,0,-0.43241036,1232.1505,242.43972)"
|
||||
style="fill:none;fill-opacity:0.40201015;stroke:none" />
|
||||
<rect
|
||||
width="41.943504"
|
||||
height="56.045197"
|
||||
x="196.27261"
|
||||
y="-907.39392"
|
||||
transform="matrix(0,1,-1,0,0,0)"
|
||||
id="gps196.widget.rocker.up"
|
||||
style="fill:none;fill-opacity:0.40201015;stroke:none" />
|
||||
<rect
|
||||
width="41.943504"
|
||||
height="56.045197"
|
||||
x="279.07486"
|
||||
y="-907.39398"
|
||||
transform="matrix(0,1,-1,0,0,0)"
|
||||
id="gps196.widget.rocker.down"
|
||||
style="fill:#4aff1c;fill-opacity:0.40201015;stroke:none" />
|
||||
<path
|
||||
d="m 853.96124,266.94855 -20.54345,-35.5823 -20.54346,-35.58231 41.08691,0 41.08691,0 -20.54345,35.58231 z"
|
||||
transform="matrix(0,0.74682129,-0.53191407,0,582.73224,-510.89875)"
|
||||
style="fill:none;fill-opacity:0.40201015;stroke:none" />
|
||||
<rect
|
||||
width="48.81356"
|
||||
height="56.045197"
|
||||
x="907.57477"
|
||||
y="230.80368"
|
||||
id="gps196.widget.rocker.right"
|
||||
style="fill:#4aff1c;fill-opacity:0.40201015;stroke:none" />
|
||||
style="fill:none;fill-opacity:0.40201015;stroke:none" />
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 3.4 KiB |
Loading…
Add table
Reference in a new issue