mirror of
https://github.com/mum4k/termdash.git
synced 2025-04-25 13:48:50 +08:00
Code refactor and self-review.
This commit is contained in:
parent
79f696a100
commit
ee90ac89dc
@ -43,18 +43,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- the `button` widget allows users to specify multiple trigger keys.
|
- the `button` widget allows users to specify multiple trigger keys.
|
||||||
- the `button` widget now supports different keys for the global and focused
|
- the `button` widget now supports different keys for the global and focused
|
||||||
scope.
|
scope.
|
||||||
- the `button` widget can now be drawn without the shadow and the press
|
- the `button` widget can now be drawn without the shadow or the press
|
||||||
animation.
|
animation.
|
||||||
- the `button` widget can now be drawn without horizontal padding around its
|
- the `button` widget can now be drawn without horizontal padding around its
|
||||||
text.
|
text.
|
||||||
- the `button`widget now allows specifying cell options for each cell of the
|
- the `button` widget now allows specifying cell options for each cell of the
|
||||||
displayed text. Separate cell options can be specified for each of button's
|
displayed text. Separate cell options can be specified for each of button's
|
||||||
main states (up, focused and up, down).
|
main states (up, focused and up, down).
|
||||||
- the `button` widget allows specifying separate fill color values for each of
|
- the `button` widget allows specifying separate fill color values for each of
|
||||||
its main states (up, focused and up, down).
|
its main states (up, focused and up, down).
|
||||||
- added a new demo called `formdemo` under the `button` widget that
|
|
||||||
demonstrates the ability of `termdash` to display forms with editable content
|
|
||||||
and keyboard navigation.
|
|
||||||
|
|
||||||
## [0.13.0] - 17-Nov-2020
|
## [0.13.0] - 17-Nov-2020
|
||||||
|
|
||||||
|
@ -209,7 +209,10 @@ func (b *Button) Draw(cvs *canvas.Canvas, meta *widgetapi.Meta) error {
|
|||||||
if err := cvs.SetAreaCells(buttonAr, buttonRune, cell.BgColor(fillColor)); err != nil {
|
if err := cvs.SetAreaCells(buttonAr, buttonRune, cell.BgColor(fillColor)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
return b.drawText(cvs, meta, buttonAr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Button) drawText(cvs *canvas.Canvas, meta *widgetapi.Meta, buttonAr image.Rectangle) error {
|
||||||
pad := b.opts.textHorizontalPadding
|
pad := b.opts.textHorizontalPadding
|
||||||
textAr := image.Rect(buttonAr.Min.X+pad, buttonAr.Min.Y, buttonAr.Dx()-pad, buttonAr.Max.Y)
|
textAr := image.Rect(buttonAr.Min.X+pad, buttonAr.Min.Y, buttonAr.Dx()-pad, buttonAr.Max.Y)
|
||||||
start, err := alignfor.Text(textAr, b.text.String(), align.HorizontalCenter, align.VerticalMiddle)
|
start, err := alignfor.Text(textAr, b.text.String(), align.HorizontalCenter, align.VerticalMiddle)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user