mirror of https://github.com/rivo/tview.git
Flex and Grid don't clear their backgrounds anymore. Resolves #104
This commit is contained in:
parent
f855bee020
commit
d7d44cb0d2
|
@ -64,6 +64,8 @@ Add your issue here on GitHub. Feel free to get in touch if you have any questio
|
||||||
|
|
||||||
(There are no corresponding tags in the project. I only keep such a history in this README.)
|
(There are no corresponding tags in the project. I only keep such a history in this README.)
|
||||||
|
|
||||||
|
- v0.15 (2018-05-02)
|
||||||
|
- `Flex` and `Grid` don't clear their background per default, thus allowing for custom modals. See the [Wiki](https://github.com/rivo/tview/wiki/Modal) for an example.
|
||||||
- v0.14 (2018-04-13)
|
- v0.14 (2018-04-13)
|
||||||
- Added an `Escape()` function which keep strings like color or region tags from being recognized as such.
|
- Added an `Escape()` function which keep strings like color or region tags from being recognized as such.
|
||||||
- Added `ANSIIWriter()` and `TranslateANSII()` which convert ANSII escape sequences to `tview` color tags.
|
- Added `ANSIIWriter()` and `TranslateANSII()` which convert ANSII escape sequences to `tview` color tags.
|
||||||
|
|
8
box.go
8
box.go
|
@ -223,9 +223,11 @@ func (b *Box) Draw(screen tcell.Screen) {
|
||||||
|
|
||||||
// Fill background.
|
// Fill background.
|
||||||
background := def.Background(b.backgroundColor)
|
background := def.Background(b.backgroundColor)
|
||||||
for y := b.y; y < b.y+b.height; y++ {
|
if b.backgroundColor != tcell.ColorDefault {
|
||||||
for x := b.x; x < b.x+b.width; x++ {
|
for y := b.y; y < b.y+b.height; y++ {
|
||||||
screen.SetContent(x, y, ' ', nil, background)
|
for x := b.x; x < b.x+b.width; x++ {
|
||||||
|
screen.SetContent(x, y, ' ', nil, background)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 74 KiB |
15
flex.go
15
flex.go
|
@ -33,17 +33,24 @@ type Flex struct {
|
||||||
// FlexRow or FlexColumn.
|
// FlexRow or FlexColumn.
|
||||||
direction int
|
direction int
|
||||||
|
|
||||||
// If set to true, will use the entire screen as its available space instead
|
// If set to true, Flex will use the entire screen as its available space
|
||||||
// its box dimensions.
|
// instead its box dimensions.
|
||||||
fullScreen bool
|
fullScreen bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFlex returns a new flexbox layout container with no primitives and its
|
// NewFlex returns a new flexbox layout container with no primitives and its
|
||||||
// direction set to FlexColumn. To add primitives to this layout, see AddItem().
|
// direction set to FlexColumn. To add primitives to this layout, see AddItem().
|
||||||
// To change the direction, see SetDirection().
|
// 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:
|
||||||
|
//
|
||||||
|
// flex.SetBackgroundColor(tview.Styles.PrimitiveBackgroundColor)
|
||||||
func NewFlex() *Flex {
|
func NewFlex() *Flex {
|
||||||
f := &Flex{
|
f := &Flex{
|
||||||
Box: NewBox(),
|
Box: NewBox().SetBackgroundColor(tcell.ColorDefault),
|
||||||
direction: FlexColumn,
|
direction: FlexColumn,
|
||||||
}
|
}
|
||||||
f.focus = f
|
f.focus = f
|
||||||
|
@ -96,8 +103,6 @@ func (f *Flex) RemoveItem(p Primitive) *Flex {
|
||||||
|
|
||||||
// Draw draws this primitive onto the screen.
|
// Draw draws this primitive onto the screen.
|
||||||
func (f *Flex) Draw(screen tcell.Screen) {
|
func (f *Flex) Draw(screen tcell.Screen) {
|
||||||
f.Box.Draw(screen)
|
|
||||||
|
|
||||||
// Calculate size and position of the items.
|
// Calculate size and position of the items.
|
||||||
|
|
||||||
// Do we use the entire screen?
|
// Do we use the entire screen?
|
||||||
|
|
9
grid.go
9
grid.go
|
@ -59,9 +59,16 @@ type Grid struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewGrid returns a new grid-based layout container with no initial primitives.
|
// 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:
|
||||||
|
//
|
||||||
|
// grid.SetBackgroundColor(tview.Styles.PrimitiveBackgroundColor)
|
||||||
func NewGrid() *Grid {
|
func NewGrid() *Grid {
|
||||||
g := &Grid{
|
g := &Grid{
|
||||||
Box: NewBox(),
|
Box: NewBox().SetBackgroundColor(tcell.ColorDefault),
|
||||||
bordersColor: Styles.GraphicsColor,
|
bordersColor: Styles.GraphicsColor,
|
||||||
}
|
}
|
||||||
g.focus = g
|
g.focus = g
|
||||||
|
|
Loading…
Reference in New Issue