Commit Graph

14 Commits

Author SHA1 Message Date
Jonathan Daugherty
d442145c78 Merge branch 'master' into refactor/vty-crossplatform 2023-10-22 19:55:22 -07:00
Jonathan Daugherty
6b7195cf6e Split up ScrollbarRenderer type into vertical and horizontal versions
This change helps users avoid undesirable behavior by accidentally
using the wrong type of renderer to draw a scroll bar. This change:

* Splits up the ScrollbarRenderer type into two new types,
  VScrollbarRenderer and HScrollbarRenderer, with nearly identical
  fields except that each field now has some 'V' or 'H' in it.

* Renames 'scrollbarAllocation' to 'scrollbar(Height|Width)Allocation'
  depending on the renderer type.

* Updates the Core API to take values of the new renderer types as
  appropriate.

* Updates the types of the default renderers.

* Updates the demo program that uses the custom renderers.
2023-09-01 10:19:48 -07:00
Jonathan Daugherty
c1aa33098b ViewportScrollbarsDemo.hs: nit 2023-09-01 10:02:56 -07:00
Jonathan Daugherty
324b5adfbd Add scrollbar space allocation control
This change is motivated by a desire to be able to control how scroll
bars are rendered adjacent to viewport contents. It isn't always
desirable to render them right up against the contents; sometimes,
spacing would be nice between the bar and contents, for example. In
general, we want users to be able to control more aspects of how scroll
bars are drawn. This change is a step in that direction. This change
won't affect any users who are using the default scroll bar renderers.

This change:

* Adds a new field to ScrollbarRenderer, scrollbarAllocation :: Int,
  which specifies the height (for horizontal scroll bars) or width (for
  vertical ones) of the region in which the bar is rendered. This allows
  scroll bar element widgets to take up more than one row in height (for
  horizontal scroll bars) or more than one column in width (for vertical
  ones).

* Updates the scroll bar rendering logic to clamp scroll bar handles to
  one row in height (for vertical scroll bars) or one column in width
  (for horizontal ones) since we need to be able to assume the size
  of the handles when computing the size of the scroll bar and trough
  regions.

* Updates programs/ViewportScrollbarsDemo.hs to demonstrate the use of
  the new allocation feature to draw a vertical scroll bar that takes up
  more than one column in various ways.
2023-09-01 09:36:12 -07:00
Jonathan Daugherty
dc046ca8ef Update core library and demo programs to use vty-crossplatform to initialize the terminal 2023-08-20 08:37:40 -07:00
Jan Hrček
3bd2235c0c Fix some hlint warnings 2022-09-24 12:56:11 +02:00
Jonathan Daugherty
bf2f6be870 Move Padding type from Brick.Types to Brick.Widgets.Core 2022-07-22 16:07:00 -07:00
Jonathan Daugherty
a5b3240758 Hide state type variable in ViewportScroll to avoid unnecessary API change 2022-07-16 23:13:37 -07:00
Jonathan Daugherty
4ea1f65d86 Update demo programs for changes to EventM 2022-07-16 23:10:03 -07:00
Jonathan Daugherty
539823ee78 Add mouse click reporting of scroll bar elements 2021-11-19 20:32:47 -08:00
Jonathan Daugherty
663b014110 Add withH/VScrollBarHandles, scrollbarHandleAttr, and renderer fields 2021-11-19 20:00:04 -08:00
Jonathan Daugherty
8966495d47 ViewportScrollbarsDemo: fix keybindings 2021-11-12 19:19:33 -08:00
Jonathan Daugherty
b915768b55 Scroll bar demo program cleanup 2021-11-12 16:51:43 -08:00
Jonathan Daugherty
9ca9a39b89 Add support for vertical and horizontal scroll bars on viewports 2021-11-12 16:31:48 -08:00