From 72c4bde6e95dd232bf9a9c593b2510d8e8785d4b Mon Sep 17 00:00:00 2001 From: Henning Stahlke Date: Mon, 7 Jan 2019 00:10:07 +0100 Subject: [PATCH] gui.nas use API functions --- Nasal/canvas/gui.nas | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Nasal/canvas/gui.nas b/Nasal/canvas/gui.nas index 0313760fe..93d60d5e8 100644 --- a/Nasal/canvas/gui.nas +++ b/Nasal/canvas/gui.nas @@ -92,6 +92,7 @@ var Window = { # Destructor del: func { + me._title.del(); me.clearFocus(); if( me["_canvas"] != nil ) @@ -288,9 +289,9 @@ var Window = { var suffix = me._focused ? "" : "-unfocused"; me._title_bar_bg.set("fill", style.getColor("title" ~ suffix)); - me._frame.set("stroke", style.getColor("title" ~ suffix)); - me._title.set( "fill", style.getColor("title-text" ~ suffix)); - me._top_line.set( "stroke", style.getColor("title-highlight" ~ suffix)); + me._frame.setStroke(style.getColor("title" ~ suffix)); + me._title.setColor(style.getColor("title-text" ~ suffix)); + me._top_line.setStroke(style.getColor("title-highlight" ~ suffix)); me.getCanvasDecoration() .data("focused", me._focused) @@ -457,17 +458,15 @@ var Window = { button_close.listen("clicked", func me.del()); # title - me._title = title_bar.createChild("text", "title") - .set("alignment", "left-center") - .set("character-size", 14) - .set("font", "LiberationFonts/LiberationSans-Bold.ttf") - .setTranslation( int(x + 1.5 * w + 0.5), - int(y + 0.5 * h + 0.5) ); - var title = me.get("title", "Canvas Dialog"); + me._title = title_bar.createChild("text", "title") + .setText(title) + .setAlignment("left-center") + .set("character-size", 14) + .setFont("LiberationFonts/LiberationSans-Bold.ttf") + .setTranslation(int(x + 1.5 * w + 0.5), int(y + 0.5 * h + 0.5)); + me._node.getNode("title", 1).alias(me._title._node.getPath() ~ "/text"); - me.set("title", title); - title_bar.addEventListener("drag", func(e) me.move(e.deltaX, e.deltaY)); me._resizeDecoration(); @@ -495,7 +494,7 @@ var Window = { .moveTo(border_radius - 2, 2) .lineTo(me.get("size[0]") - border_radius + 2, 2); } -}; +}; #Window # Clear focus on click outside any window getDesktop().addEventListener("mousedown", func {