1
0
Fork 0

canvas.gui: Remove old demo code.

This commit is contained in:
Thomas Geymayer 2014-06-17 17:11:48 +02:00
parent b5dae5b567
commit c4d9310e33

View file

@ -452,97 +452,3 @@ var Dialog = {
return Window.new(size, type, id);
}
};
# Canvas GUI demo
#
# Shows an icon in the top-right corner which upon click opens a simple window
#
var initDemo = func
{
var dlg = canvas.Window.new([32,32]);
dlg.setInt("tf/t[1]", 4)
.setInt("right", 4);
var my_canvas = dlg.createCanvas()
.setColorBackground(0,0,0,0);
var root = my_canvas.createGroup();
canvas.parsesvg(root, "gui/dialogs/images/icon-aircraft.svg");
my_canvas.addEventListener("mouseover", func(event)
{
debug.dump( props.wrapNode(event.target._node_ghost) );
});
my_canvas.addEventListener("click", func(e)
{
var dlg = canvas.Window.new([400,300], "dialog")
.set("resize", 1);
var my_canvas = dlg.createCanvas()
.set("background", style.getColor("bg_color"));
my_canvas.addEventListener("click", func(e) { printf("click: screen(%.1f|%.1f) client(%.1f|%.1f) click count = %d", e.screenX, e.screenY, e.clientX, e.clientY, e.click_count); });
my_canvas.addEventListener("dblclick", func(e) { printf("dblclick: screen(%.1f|%.1f) client(%.1f|%.1f)", e.screenX, e.screenY, e.clientX, e.clientY); });
my_canvas.addEventListener("drag", func(e) { printf("drag: screen(%.1f|%.1f) client(%.1f|%.1f) local(%.1f|%.1f) delta(%.1f|%.1f)", e.screenX, e.screenY, e.clientX, e.clientY, e.localX, e.localY, e.deltaX, e.deltaY); });
my_canvas.addEventListener("wheel", func(e) { printf("wheel: screen(%.1f|%.1f) client(%.1f|%.1f) %.1f", e.screenX, e.screenY, e.clientX, e.clientY, e.deltaY); });
var root = my_canvas.createGroup();
root.createChild("image")
.set("src", "http://wiki.flightgear.org/skins/common/images/icons-fg-135.png");
var text =
root.createChild("text")
.setText("This could be used for building an 'Aircraft Help' dialog.\nYou can also #use it to play around with the new Canvas system :). β")
.setTranslation(10, 30)
.setAlignment("left-top")
.setFontSize(14)
.setFont("LiberationFonts/LiberationSans-Regular.ttf")
.set("max-width", 380)
.setColor(0,0,0);
var text_move =
root.createChild("text")
.setText("Mouse moved over text...")
.set("character-size", 15)
.set("font", "LiberationFonts/LiberationSans-Bold.ttf")
.set("alignment", "left-center")
.setTranslation(20, 200)
.set("fill", "#ff0000")
.hide();
var visible_count = 0;
text.addEventListener("mouseover", func text_move.show());
text.addEventListener("mouseout", func text_move.hide());
text.addEventListener("mousemove", func(e) { printf("move: screen(%.1f|%.1f) client(%.1f|%.1f) local(%.1f|%.1f) delta(%.1f|%.1f)", e.screenX, e.screenY, e.clientX, e.clientY, e.localX, e.localY, e.deltaX, e.deltaY); });
text.set("fill", style.getColor("text_color"));
gui.widgets.Button.new(root, style, {})
.setText("Ok")
.move(20, 250)
.setSize(64, 26);
gui.widgets.Button.new(root, style, {})
.setText("Apply")
.move(100, 250)
.setSize(64, 26);
gui.widgets.Button.new(root, style, {})
.setText("Cancel")
.move(180, 200)
.setSize(64, 64);
var scroll = gui.widgets.ScrollArea.new(root, style, {})
.move(20, 100)
.setSize(96, 128);
var txt = scroll.getContent().createChild("text")
.set("text", "01hallo\n02asdasd\n03\n04\n05asdasd06\n07ß\n08\n09asdasd\n10\n11");
scroll.update();
txt.addEventListener("mouseover", func txt.set("fill", "red"));
txt.addEventListener("mouseout", func txt.set("fill", "green"));
});
}
(func {
var init_listener = setlistener("/nasal/canvas/loaded", func(p)
{
if( !p.getValue() )
return;
removelistener(init_listener);
if( getprop("/sim/gui/canvas/demo") )
initDemo();
}, 1, 0);
})();