newWindowTitle creates and returns a pointer to a window title panel.
(win *Window, text string)
| 317 | |
| 318 | // newWindowTitle creates and returns a pointer to a window title panel. |
| 319 | func newWindowTitle(win *Window, text string) *WindowTitle { |
| 320 | |
| 321 | wt := new(WindowTitle) |
| 322 | wt.win = win |
| 323 | |
| 324 | wt.Panel.Initialize(wt, 0, 0) |
| 325 | wt.label.initialize(text, StyleDefault().Font) |
| 326 | wt.Panel.Add(&wt.label) |
| 327 | |
| 328 | wt.closeButton = NewButton("") |
| 329 | wt.closeButton.SetIcon(icon.Close) |
| 330 | wt.closeButton.Subscribe(OnCursorEnter, func(s string, i interface{}) { |
| 331 | window.Get().SetCursor(window.ArrowCursor) |
| 332 | }) |
| 333 | wt.closeButton.Subscribe(OnClick, func(s string, i interface{}) { |
| 334 | wt.win.Parent().GetNode().Remove(wt.win) |
| 335 | wt.win.Dispose() |
| 336 | wt.win.Dispatch("gui.OnWindowClose", nil) |
| 337 | }) |
| 338 | wt.Panel.Add(wt.closeButton) |
| 339 | wt.closeButtonVisible = true |
| 340 | |
| 341 | wt.Subscribe(OnMouseDown, wt.onMouse) |
| 342 | wt.Subscribe(OnMouseUp, wt.onMouse) |
| 343 | wt.Subscribe(OnCursor, wt.onCursor) |
| 344 | wt.Subscribe(OnCursorEnter, wt.onCursor) |
| 345 | wt.Subscribe(OnCursorLeave, wt.onCursor) |
| 346 | |
| 347 | wt.recalc() |
| 348 | return wt |
| 349 | } |
| 350 | |
| 351 | // setCloseButton sets whether the close button is present on the top right corner. |
| 352 | func (wt *WindowTitle) setCloseButton(state bool) { |
no test coverage detected