From 961c23145cae238ca051946d8397ffdd1b64a23f Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Sun, 24 May 2020 21:40:34 -0700 Subject: [PATCH] Fix default background transparency of Flex and Grid --- FORK.md | 6 ++---- doc.go | 6 +++--- flex.go | 11 +++++------ go.mod | 2 +- go.sum | 4 ++-- grid.go | 11 +++++------ 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/FORK.md b/FORK.md index ccb8233..50072f5 100644 --- a/FORK.md +++ b/FORK.md @@ -38,11 +38,9 @@ tview [blocks until the queued function returns](https://github.com/rivo/tview/b All clicks are handled as single clicks until an interval is set with [Application.SetDoubleClickInterval](https://docs.rocketnine.space/gitlab.com/tslocum/cview/#Application.SetDoubleClickInterval). -## All primitives have non-transparent backgrounds by default +## Setting a primitive's background color to `tcell.ColorDefault` does not result in transparency -Setting background colors to `tcell.ColorDefault` is insufficient. Call -`SetBackgroundTransparent(true)` to enable background transparency. See -[#15](https://gitlab.com/tslocum/cview/-/issues/15) for more info. +Call `SetBackgroundTransparent(true)` to enable background transparency. ## Lists and Forms do not wrap around by default diff --git a/doc.go b/doc.go index 5390389..ca2094f 100644 --- a/doc.go +++ b/doc.go @@ -137,9 +137,9 @@ character that may be used in color or region tags will be recognized. Examples: You can use the Escape() function to insert brackets automatically where needed. -Note that setting the background color of a primitive to tcell.ColorDefault is -insufficient to achieve transparency (having one or more widgets behind another -widget). Call SetBackgroundTransparent to enable transparency. +Setting the background color of a primitive to tcell.ColorDefault will use the +default terminal background color. To enable transparency (allowing one or more +primitives to display behind a primitive) call SetBackgroundTransparent. Styles diff --git a/flex.go b/flex.go index 7dd65c6..046de9b 100644 --- a/flex.go +++ b/flex.go @@ -44,15 +44,14 @@ type Flex struct { // direction set to FlexColumn. To add primitives to this layout, see AddItem(). // To change the direction, see SetDirection(). // -// Note that Box, the superclass of Flex, will have its background color set to -// transparent so that any nil flex items will leave their background unchanged. -// To clear a Flex's background before any items are drawn, set it to the -// desired color: +// Note that Flex will have a transparent background by default so that any nil +// flex items will show primitives behind the Flex. +// To disable this transparency: // -// flex.SetBackgroundColor(cview.Styles.PrimitiveBackgroundColor) +// flex.SetBackgroundTransparent(false) func NewFlex() *Flex { f := &Flex{ - Box: NewBox().SetBackgroundColor(tcell.ColorDefault), + Box: NewBox().SetBackgroundTransparent(true), direction: FlexColumn, } f.focus = f diff --git a/go.mod b/go.mod index 41655cd..60978f7 100644 --- a/go.mod +++ b/go.mod @@ -8,5 +8,5 @@ require ( github.com/mattn/go-runewidth v0.0.9 github.com/rivo/uniseg v0.1.0 gitlab.com/tslocum/cbind v0.1.1 - golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 // indirect + golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect ) diff --git a/go.sum b/go.sum index 54722a8..4b8f5e9 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,8 @@ gitlab.com/tslocum/cbind v0.1.1/go.mod h1:rX7vkl0pUSg/yy427MmD1FZAf99S7WwpUlxF/q golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756 h1:9nuHUbU8dRnRRfj9KjWUVrJeoexdbeMjttk6Oh1rD10= golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 h1:YTzHMGlqJu67/uEo1lBv0n3wBXhXNeUbB1XfN2vmTm0= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121 h1:rITEj+UZHYC927n8GT97eC3zrpzXdb/voyeOuVKS46o= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= diff --git a/grid.go b/grid.go index f866353..0a3cb5b 100644 --- a/grid.go +++ b/grid.go @@ -61,15 +61,14 @@ type Grid struct { // NewGrid returns a new grid-based layout container with no initial primitives. // -// Note that Box, the superclass of Grid, will have its background color set to -// transparent so that any grid areas not covered by any primitives will leave -// their background unchanged. To clear a Grid's background before any items are -// drawn, set it to the desired color: +// Note that Grid will have a transparent background by default so that any +// areas not covered by any primitives will show primitives behind the Grid. +// To disable this transparency: // -// grid.SetBackgroundColor(cview.Styles.PrimitiveBackgroundColor) +// grid.SetBackgroundTransparent(false) func NewGrid() *Grid { g := &Grid{ - Box: NewBox().SetBackgroundColor(tcell.ColorDefault), + Box: NewBox().SetBackgroundTransparent(true), bordersColor: Styles.GraphicsColor, } g.focus = g