@@ -27,6 +27,14 @@ typedef WindowOptions = {
27
27
@:optional var focusable : Bool ;
28
28
/** Whether or not the window is collapsible */
29
29
@:optional var collapsible : Bool ;
30
+ /** The x offset of the title bar (draggable label area) */
31
+ @:optional var title_margin_left : Float ;
32
+ /** The y offset of the title bar (draggable label area) */
33
+ @:optional var title_margin_top : Float ;
34
+ /** The offset of the title bar from the right edge (draggable label area) */
35
+ @:optional var title_margin_right : Float ;
36
+ /** The height of the title bar (draggable label area) */
37
+ @:optional var title_height : Float ;
30
38
31
39
} // WindowOptions
32
40
@@ -52,6 +60,11 @@ class Window extends Control {
52
60
var drag_x : Float = 0 ;
53
61
var drag_y : Float = 0 ;
54
62
63
+ var title_margin_top : Float = 2 ;
64
+ var title_margin_left : Float = 2 ;
65
+ var title_margin_right : Float = 4 ;
66
+ var title_height : Float = 22 ;
67
+
55
68
var options : WindowOptions ;
56
69
var ready = false ;
57
70
@@ -72,6 +85,11 @@ class Window extends Control {
72
85
focusable = def (options .focusable , true );
73
86
collapsible = def (options .collapsible , false );
74
87
88
+ title_height = def (options .title_height , 22 );
89
+ title_margin_left = def (options .title_margin_left , 2 );
90
+ title_margin_top = def (options .title_margin_top , 2 );
91
+ title_margin_right = def (options .title_margin_right , 4 );
92
+
75
93
resize_handle = new Control ({
76
94
parent : this ,
77
95
x : w - 24 , y : h - 24 , w : 24 , h : 24 ,
@@ -85,7 +103,10 @@ class Window extends Control {
85
103
86
104
title = new Label ({
87
105
parent : this ,
88
- x : 2 , y : 2 , w : w - 4 , h : 22 ,
106
+ x : title_margin_left ,
107
+ y : title_margin_top ,
108
+ w : w - title_margin_right ,
109
+ h : title_height ,
89
110
text : options .title ,
90
111
align : TextAlign .center ,
91
112
align_vertical : TextAlign .center ,
@@ -97,7 +118,10 @@ class Window extends Control {
97
118
98
119
close_handle = new Control ({
99
120
parent : this ,
100
- x : w - 24 , y : 2 , w : 22 , h : 22 ,
121
+ x : w - title_margin_right - 24 ,
122
+ y : title_margin_top ,
123
+ w : 22 ,
124
+ h : title_height ,
101
125
name : name + ' .close' ,
102
126
options : options .options .close_handle ,
103
127
internal_visible : options .visible
@@ -115,7 +139,10 @@ class Window extends Control {
115
139
116
140
collapse_handle = new Control ({
117
141
parent : this ,
118
- x : closable ? w - 48 : w - 24 , y : 2 , w : 22 , h : 22 ,
142
+ x : closable ? w - title_margin_right - 48 : w - title_margin_right - 24 ,
143
+ y : title_margin_top ,
144
+ w : 22 ,
145
+ h : title_height ,
119
146
name : name + ' .collapse' ,
120
147
options : options .options .collapse_handle ,
121
148
internal_visible : options .visible
@@ -332,10 +359,10 @@ class Window extends Control {
332
359
333
360
super .bounds_changed (_dx , _dy , _dw , _dh );
334
361
335
- if (close_handle != null ) close_handle .x_local = w - 24 ;
336
- if (collapse_handle != null ) collapse_handle .x_local = closable ? w - 48 : w - 24 ;
337
- if (title != null ) title .w = w - 4 ;
338
- if (resize_handle != null ) resize_handle .set_pos (x + w - 24 , y + h - 24 );
362
+ if (close_handle != null ) close_handle .x_local = w - title_margin_right - 24 ;
363
+ if (collapse_handle != null ) collapse_handle .x_local = closable ? w - title_margin_right - 48 : w - title_margin_right - 24 ;
364
+ if (title != null ) title .w = w - title_margin_right ;
365
+ if (resize_handle != null ) resize_handle .set_pos (x + w - 24 , y + h - 24 );
339
366
340
367
} // bounds_changed
341
368
0 commit comments