Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Add ZBox, an implementation of stacked / modal Widgets #109

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

cceckman
Copy link
Contributor

This is an alternative to #103: a different way to have Widgets that overlay each other.

It defines a new ZBox, which is analogous to HBox and VBox, except that instead of constraining "same width" or "same height", it constrains "same size", and forces overwriting.

The Append API is slightly different, as well; rather than providing access to indices, it returns a "remover" function that can remove the just-added widget. This feels to me like an intuitive way to handle multi-dialog closure:

ui.Update(func() {
  d := NewCustomDialog()
  d.Remover= root.Append(d)
})

since indices may change if the dialogs aren't removed in stack order.

Some main differences from #103:

  • It allows for multiple popups, on top of each other; see the added example in zbox_test.go.
  • It is itself a Widget, so it can be used for not-the-entire-view dialogs as well- e.g. rendering an underlying view invisible without overwriting the whole screen.
  • It's unbuffered; Draw delegates to all the Draw methods of its contents, serially. I haven't checked to see if this causes flickering / tearing / etc- that's a detail of tcell I haven't dug in to.

It follows #105, since it makes "box with transparent background" an ~easy way to do layout. (Maybe it's worth extracting center publicly- func Center(w Widget) Widget - if this is the approach we want to take?)

@cceckman cceckman changed the title Add ZBox, an implementation of vertical widgets Add ZBox, an implementation of stacked / modal Widgets Jan 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant