+
Skip to content

Feature Request: add containers for widgets #320

@gospacedev

Description

@gospacedev

The way to set the positions of widgets is through the x1 y1 coordinates in func (*Block) SetRect:

p := widgets.NewParagraph()
	p.Title = "Lunar"
	p.Text = selectedAudio
	p.SetRect(0, 0, 40, 3)
	p.TitleStyle.Fg = ui.ColorYellow
	p.BorderStyle.Fg = ui.ColorCyan

	c := widgets.NewParagraph()
	c.Title = "Audio Controls"
	c.Text = `Pause and play music: [ENTER]
Volume: [↓ ↑]
Speed:  [← →]
Normal Speed: [Ctrl + N]
Back to menu: [BACKSPACE]
Quit Lunar: [ESC]
	`
	c.SetRect(0, 4, 40, 12)
	c.TitleStyle.Fg = ui.ColorYellow
	c.BorderStyle.Fg = ui.ColorCyan

	ui.Render(p, c)

But this can create overlap over widgets:

+-Lunar--------------------------------+
|Playing Charlie Puth                  |
+--------------------------------------+
|Normal Speed: [Ctrl + N]              |
|Back to menu: [BACKSPACE]             |
|Quit Lunar: [ESC]                     |
+--------------------------------------+

Preferred output:

+-Lunar--------------------------------+
|Playing Charlie Puth                  |
+--------------------------------------+

+-Audio Controls-----------------------+
|Pause and play music: [ENTER]         |
|Volume: [↓ ↑]                         |
|Speed:  [← →]                         |
|Normal Speed: [Ctrl + N]              |
|Back to menu: [BACKSPACE]             |
|Quit Lunar: [ESC]                     |
+--------------------------------------+

My idea is to create a container for the widgets like in the Fyne GUI to position
the widgets and avoid widget overlap:

SetContent(NewVericalBox(c, p))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载