MCPcopy
hub / github.com/g3n/engine / newWindowTitle

Function newWindowTitle

gui/window.go:319–349  ·  view source on GitHub ↗

newWindowTitle creates and returns a pointer to a window title panel.

(win *Window, text string)

Source from the content-addressed store, hash-verified

317
318// newWindowTitle creates and returns a pointer to a window title panel.
319func 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.
352func (wt *WindowTitle) setCloseButton(state bool) {

Callers 1

SetTitleMethod · 0.85

Calls 15

GetFunction · 0.92
StyleDefaultFunction · 0.85
NewButtonFunction · 0.85
SubscribeMethod · 0.65
SetCursorMethod · 0.65
GetNodeMethod · 0.65
ParentMethod · 0.65
DisposeMethod · 0.65
DispatchMethod · 0.65
InitializeMethod · 0.45
initializeMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected