positioning adjustments

This commit is contained in:
sqshq 2019-02-24 19:37:57 -05:00
parent 68acb63715
commit a40cc50f3f
3 changed files with 30 additions and 30 deletions

View File

@ -29,15 +29,16 @@ const (
) )
const ( const (
columnsCount = 50 columnsCount = 60
rowsCount = 30 rowsCount = 40
statusbarHeight = 1
) )
func NewLayout(width, height int, statusline *StatusBar, menu *Menu) *Layout { func NewLayout(width, height int, statusline *StatusBar, menu *Menu) *Layout {
block := *ui.NewBlock() block := *ui.NewBlock()
block.SetRect(0, 0, width, height) block.SetRect(0, 0, width, height)
statusline.SetRect(0, height-1, width, height) statusline.SetRect(0, height-statusbarHeight, width, height)
return &Layout{ return &Layout{
Block: block, Block: block,
@ -119,7 +120,6 @@ func (l *Layout) HandleConsoleEvent(e string) {
switch l.mode { switch l.mode {
case ModeDefault: case ModeDefault:
l.changeMode(ModeComponentSelect) l.changeMode(ModeComponentSelect)
l.selection = 0
l.menu.highlight(l.getComponent(l.selection)) l.menu.highlight(l.getComponent(l.selection))
case ModeChartPinpoint: case ModeChartPinpoint:
chart := l.getSelectedComponent().Drawable.(*runchart.RunChart) chart := l.getSelectedComponent().Drawable.(*runchart.RunChart)
@ -138,7 +138,6 @@ func (l *Layout) HandleConsoleEvent(e string) {
switch l.mode { switch l.mode {
case ModeDefault: case ModeDefault:
l.changeMode(ModeComponentSelect) l.changeMode(ModeComponentSelect)
l.selection = 0
l.menu.highlight(l.getComponent(l.selection)) l.menu.highlight(l.getComponent(l.selection))
case ModeChartPinpoint: case ModeChartPinpoint:
chart := l.getSelectedComponent().Drawable.(*runchart.RunChart) chart := l.getSelectedComponent().Drawable.(*runchart.RunChart)
@ -157,7 +156,6 @@ func (l *Layout) HandleConsoleEvent(e string) {
switch l.mode { switch l.mode {
case ModeDefault: case ModeDefault:
l.changeMode(ModeComponentSelect) l.changeMode(ModeComponentSelect)
l.selection = 0
l.menu.highlight(l.getComponent(l.selection)) l.menu.highlight(l.getComponent(l.selection))
case ModeComponentSelect: case ModeComponentSelect:
if l.selection > 0 { if l.selection > 0 {
@ -175,7 +173,6 @@ func (l *Layout) HandleConsoleEvent(e string) {
switch l.mode { switch l.mode {
case ModeDefault: case ModeDefault:
l.changeMode(ModeComponentSelect) l.changeMode(ModeComponentSelect)
l.selection = 0
l.menu.highlight(l.getComponent(l.selection)) l.menu.highlight(l.getComponent(l.selection))
case ModeComponentSelect: case ModeComponentSelect:
if l.selection < len(l.Components)-1 { if l.selection < len(l.Components)-1 {
@ -194,7 +191,6 @@ func (l *Layout) HandleConsoleEvent(e string) {
func (l *Layout) ChangeDimensions(width, height int) { func (l *Layout) ChangeDimensions(width, height int) {
l.SetRect(0, 0, width, height) l.SetRect(0, 0, width, height)
l.statusbar.SetRect(0, height-1, width, height)
} }
// TODO func to get prev/next component navigating left/right/top/bottom // TODO func to get prev/next component navigating left/right/top/bottom
@ -209,7 +205,7 @@ func (l *Layout) getSelectedComponent() *Component {
func (l *Layout) Draw(buffer *ui.Buffer) { func (l *Layout) Draw(buffer *ui.Buffer) {
columnWidth := float64(l.GetRect().Dx()) / columnsCount columnWidth := float64(l.GetRect().Dx()) / columnsCount
rowHeight := float64(l.GetRect().Dy()) / rowsCount rowHeight := float64(l.GetRect().Dy()-statusbarHeight) / rowsCount
for _, component := range l.Components { for _, component := range l.Components {
@ -222,6 +218,10 @@ func (l *Layout) Draw(buffer *ui.Buffer) {
component.Drawable.Draw(buffer) component.Drawable.Draw(buffer)
} }
l.statusbar.SetRect(
0, l.GetRect().Dy()-statusbarHeight,
l.GetRect().Dx(), l.GetRect().Dy())
l.menu.Draw(buffer) l.menu.Draw(buffer)
l.statusbar.Draw(buffer) l.statusbar.Draw(buffer)
} }

View File

@ -4,8 +4,8 @@ runcharts:
w: 0 w: 0
h: 0 h: 0
size: size:
w: 34 w: 40
h: 14 h: 18
scale: 3 scale: 3
items: items:
- label: GOOGLE - label: GOOGLE
@ -17,11 +17,11 @@ runcharts:
- title: SEARCH ENGINE RESPONSE TIME 2 (sec) - title: SEARCH ENGINE RESPONSE TIME 2 (sec)
refresh-rate-ms: 5000 refresh-rate-ms: 5000
position: position:
w: 34 w: 40
h: 0 h: 0
size: size:
w: 16 w: 20
h: 14 h: 18
legend: legend:
enabled: true enabled: true
details: false details: false
@ -34,11 +34,11 @@ runcharts:
script: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com script: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com
- title: MONGO COLLECTIONS COUNT - title: MONGO COLLECTIONS COUNT
position: position:
w: 17 w: 21
h: 14 h: 18
size: size:
w: 17 w: 19
h: 10 h: 13
scale: 0 scale: 0
items: items:
- label: ACTIVE - label: ACTIVE
@ -50,10 +50,10 @@ barcharts:
refresh-rate-ms: 1000 refresh-rate-ms: 1000
position: position:
w: 0 w: 0
h: 14 h: 18
size: size:
w: 17 w: 21
h: 10 h: 13
scale: 0 scale: 0
items: items:
- label: NEW - label: NEW
@ -69,18 +69,18 @@ barcharts:
asciiboxes: asciiboxes:
- title: LOCAL TIME - title: LOCAL TIME
position: position:
w: 34 w: 40
h: 14 h: 18
size: size:
w: 16 w: 20
h: 4 h: 6
script: date +%r script: date +%r
- title: UTC TIME - title: UTC TIME
position: position:
w: 34 w: 40
h: 18 h: 24
size: size:
w: 16 w: 20
h: 6 h: 7
script: env TZ=UTC date +%r script: env TZ=UTC date +%r
font: 3d font: 3d

View File

@ -156,7 +156,7 @@ func saveFile(config *Config) {
log.Fatalf("Can't marshal config file: %v", err) log.Fatalf("Can't marshal config file: %v", err)
} }
err = ioutil.WriteFile("config.yml", file, 0644) err = ioutil.WriteFile(os.Args[1], file, 0644)
if err != nil { if err != nil {
log.Fatalf("Can't save config file: %v", err) log.Fatalf("Can't save config file: %v", err)
} }