1 module w95.titlebar; 2 3 import fluid; 4 import std.path; 5 6 import w95.util; 7 import w95.theme; 8 import w95.image_button; 9 10 @safe: 11 12 alias titlebar = simpleConstructor!Titlebar; 13 14 class Titlebar : Frame { 15 16 public { 17 18 void delegate() @safe onClose; 19 Label titlebarLabel; 20 21 } 22 23 this(Rope text, void delegate() @safe onClose = null) { 24 25 super( 26 titlebarLabel = label( 27 .ignoreMouse, 28 .layout!(1, "start", "end"), 29 text 30 ), 31 imageButton( 32 .layout!("center"), 33 exeDir.buildPath("resources/x.png"), 34 delegate { 35 if (this.onClose) this.onClose(); 36 } 37 ), 38 ); 39 super.theme = w95TitlebarTheme; 40 super.layout = .layout!"fill"; 41 super.isHorizontal = true; 42 this.onClose = onClose; 43 44 } 45 46 this(string text, void delegate() @safe onClose = null) { 47 48 this(Rope(text), onClose); 49 50 } 51 52 Rope text() const { 53 54 return titlebarLabel.text; 55 56 } 57 58 override bool hoveredImpl(Rectangle, Vector2) { 59 60 return false; 61 62 } 63 64 }