@@ -16,6 +16,8 @@ import javafx.scene.Node
1616import javafx.scene.layout.*
1717import javafx.scene.paint.Color
1818import javafx.scene.shape.Line
19+ import javafx.scene.shape.Rectangle
20+ import javafx.scene.text.Font
1921import javafx.scene.text.Text
2022import javafx.scene.text.TextFlow
2123import javafx.util.Duration
@@ -69,28 +71,19 @@ open class MDIWindow
6971 val pane = Pane ()
7072 pane.translateY = 1.0
7173
72- val size = 20.0
73- val offset = 3.0
74+ val box = makeButtonBox()
7475
75- val line1 = Line (offset, size / 2 + 1 , size, size / 2 + 1 )
76- val line2 = Line (size, offset, offset, size)
76+ val offset = 6.0
7777
78+ val line1 = Line (offset, 14.0 / 2 + 1 , box.width - offset, 14.0 / 2 + 1 )
7879 line1.strokeWidth = 2.0
79- line2.strokeWidth = 2.0
80-
81- val stroke = Bindings .`when `(pane.hoverProperty()).then(Color .BLUE ).otherwise(Color .WHITE )
82-
83- line1.strokeProperty().bind(
84- stroke
85- )
80+ line1.stroke = Color .WHITE
8681
87- line2.strokeProperty ().bind(
88- stroke
82+ box.opacityProperty ().bind(
83+ Bindings .` when `(pane.hoverProperty()).then( 0.95 ).otherwise( 0.0 )
8984 )
9085
91- line2.isVisible = false
92-
93- pane.children.addAll(line1, line2)
86+ pane.children.addAll(box, line1)
9487
9588 return pane
9689 }
@@ -99,30 +92,32 @@ open class MDIWindow
9992 val pane = Pane ()
10093 pane.translateY = 1.0
10194
102- val size = 22.0
95+ val box = makeButtonBox()
96+
97+ val size = 14.0
10398 val offset = 3.0
10499
105- val line1 = Line (offset, offset, size, size)
106- val line2 = Line (size, offset, offset, size)
100+ val line1 = Line (3.0 + offset, offset - 1 , 3.0 + size, size - 1 )
101+ val line2 = Line (3.0 + size, offset - 1 , 3.0 + offset, size - 1 )
107102
108103 line1.strokeWidth = 2.0
109104 line2.strokeWidth = 2.0
105+ line1.stroke = Color .WHITE
106+ line2.stroke = Color .WHITE
110107
111- val stroke = Bindings .`when `(pane.hoverProperty()).then(Color .RED ).otherwise(Color .WHITE )
112-
113- line1.strokeProperty().bind(
114- stroke
108+ box.opacityProperty().bind(
109+ Bindings .`when `(pane.hoverProperty()).then(0.95 ).otherwise(0.0 )
115110 )
116111
117- line2.strokeProperty().bind(
118- stroke
119- )
120-
121- pane.children.addAll(line1, line2)
112+ pane.children.addAll(box, line1, line2)
122113
123114 return pane
124115 }
125116
117+ private fun makeButtonBox (): Rectangle {
118+ return Rectangle (24.0 , 15.0 , Color .GRAY )
119+ }
120+
126121 private val root = Pane ()
127122 var contentPane: Pane = StackPane ()
128123 set(value) {
@@ -159,8 +154,13 @@ open class MDIWindow
159154 }
160155
161156 private fun updateTitle () {
157+ val titleText = Text (title).also {
158+ it.font = Font .font(14.0 )
159+ it.fill = Color .WHITE
160+ }
161+
162162 header.children.clear()
163- header.children.add(Text (title). also { it.fill = Color . WHITE } )
163+ header.children.add(titleText )
164164 }
165165
166166 init {
@@ -187,10 +187,11 @@ open class MDIWindow
187187 }
188188
189189 private fun initMinimizeButton (box : HBox ) {
190+ minWidth = 160.0
190191 minHeight = 28.0
191192
192- minimizeButton.translateXProperty().bind(box.prefWidthProperty().subtract(54 .0 ))
193- minimizeButton.translateY = - 20 .0
193+ minimizeButton.translateXProperty().bind(box.prefWidthProperty().subtract(56 .0 ))
194+ minimizeButton.translateY = - 22 .0
194195
195196 minimizeButton.setOnMouseClicked {
196197 if (! isAnimationFinished)
@@ -224,14 +225,14 @@ open class MDIWindow
224225 }
225226
226227 private fun initCloseButton (box : HBox ) {
227- closeButton.translateXProperty().bind(box.prefWidthProperty().subtract(27 .0 ))
228+ closeButton.translateXProperty().bind(box.prefWidthProperty().subtract(30 .0 ))
228229 closeButton.translateY = - 22.0
229230
230231 closeButton.setOnMouseClicked {
231232 if (parent is Group ) {
232233 (parent as Group ).children - = this
233- } else {
234- // TODO:
234+ } else if (parent is Pane ) {
235+ (parent as Pane ).children - = this
235236 }
236237 }
237238 }
0 commit comments