Transparency appears broken compared to tview #15

Closed
opened 2020-05-24 02:29:06 +00:00 by nlowe · 6 comments
nlowe commented 2020-05-24 02:29:06 +00:00 (Migrated from gitlab.com)

I'm attempting to make a modal with background transparency as shown in https://github.com/rivo/tview/wiki/Modal. The code snippet appears to work with tview Master:

tview

However, running the same snippet with cview does not render the background page:

cview

I've uploaded the example to GitHub: https://github.com/nlowe/cview-transparency-bug/blob/master/main.go. It's the same snippet that is in tview's wiki. Looking at the go.sum I only see a single copy of tcell being pulled in so I think this is related something to the fork.

I'm attempting to make a modal with background transparency as shown in https://github.com/rivo/tview/wiki/Modal. The code snippet appears to work with `tview` `Master`: ![tview](/uploads/c24dc5d1345a3fbb88974d49b66ac973/image.png) However, running the same snippet with `cview` does not render the background page: ![cview](/uploads/a692f905580b738884970e3ba5df7c8d/image.png) I've uploaded the example to GitHub: https://github.com/nlowe/cview-transparency-bug/blob/master/main.go. It's the same snippet that is in `tview`'s wiki. Looking at the `go.sum` I only see a single copy of `tcell` being pulled in so I think this is related something to the fork.
tslocum commented 2020-05-24 16:00:14 +00:00 (Migrated from gitlab.com)

closed via commit 7a4f8737ad3b54f61d9f5289cfb362ac40c74fd1

closed via commit 7a4f8737ad3b54f61d9f5289cfb362ac40c74fd1
tslocum commented 2020-05-24 16:07:48 +00:00 (Migrated from gitlab.com)

reopened

reopened
tslocum commented 2020-05-24 16:36:20 +00:00 (Migrated from gitlab.com)

closed via commit eafc5b33a2

closed via commit eafc5b33a249a5d23abcc93a9b3fe61ea1db1853
tslocum commented 2020-05-24 16:36:29 +00:00 (Migrated from gitlab.com)

Thanks @nlowe. This seems to be caused by this change. I've added Box.SetBackgroundTransparent to resolve this.

modal := func(p cview.Primitive, width, height int) cview.Primitive {
	verticalFlex := cview.NewFlex().SetDirection(cview.FlexRow).
		AddItem(nil, 0, 1, false).
		AddItem(p, height, 1, false).
		AddItem(nil, 0, 1, false)

	horizontalFlex := cview.NewFlex().
		AddItem(nil, 0, 1, false).
		AddItem(verticalFlex, width, 1, false).
		AddItem(nil, 0, 1, false)

	verticalFlex.SetBackgroundTransparent(true)
	horizontalFlex.SetBackgroundTransparent(true)

	return horizontalFlex
}
Thanks @nlowe. This seems to be caused by [this change](https://github.com/rivo/tview/pull/395). I've added Box.SetBackgroundTransparent to resolve this. ```go modal := func(p cview.Primitive, width, height int) cview.Primitive { verticalFlex := cview.NewFlex().SetDirection(cview.FlexRow). AddItem(nil, 0, 1, false). AddItem(p, height, 1, false). AddItem(nil, 0, 1, false) horizontalFlex := cview.NewFlex(). AddItem(nil, 0, 1, false). AddItem(verticalFlex, width, 1, false). AddItem(nil, 0, 1, false) verticalFlex.SetBackgroundTransparent(true) horizontalFlex.SetBackgroundTransparent(true) return horizontalFlex } ```
nlowe commented 2020-05-24 16:49:04 +00:00 (Migrated from gitlab.com)

Yup, seems to work, thanks! Note that the docs for NewFlex() and NewGrid() still imply they have a transparent background by default.

Yup, seems to work, thanks! Note that the docs for `NewFlex()` and `NewGrid()` still imply they have a transparent background by default.
tslocum commented 2020-05-25 04:41:29 +00:00 (Migrated from gitlab.com)

Thanks, I've restored this default behavior.

Thanks, I've restored this default behavior.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: tslocum/cview#15
No description provided.