Skip to content

Commit

Permalink
focusing between cluster table and cluster details table(s) now inclu…
Browse files Browse the repository at this point in the history
…des a yellow border around the active focus.
  • Loading branch information
swartzja committed Dec 17, 2020
1 parent eb16d5d commit 11454b0
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions cmd/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func showPage(selectedPage *pages.ClusterDetailsPage, key int32) {

// If the page about to be hidden has focus, switch focus to the new page
if frontPageView != nil && frontPageView.HasFocus() {
frontPageView.Blur()
selectedPage.GetTable().Focus(nil)
RemoveFocus(frontPageView)
AddFocus(selectedPage.GetTable())
}
}

Expand All @@ -73,15 +73,30 @@ func renderCurrentClusterDetailsPage() {
// Change focus between the cluster table and the cluster details page
func changeFocus() {
_, pageView := clusterDetailsPages.GetFrontPage()

if pageView == nil {
return
}
if pageView.HasFocus() {
pageView.Blur()
clusterTable.Focus(nil)
if clusterTable.HasFocus() {
RemoveFocus(clusterTable)
AddFocus(pageView)
} else {
clusterTable.Blur()
pageView.Focus(nil)
RemoveFocus(pageView)
AddFocus(clusterTable)
}
}

func AddFocus(p tview.Primitive) {
if table, ok := p.(*tview.Table); ok {
table.Focus(nil)
table.SetBorderColor(tcell.ColorGoldenrod)
}
}

func RemoveFocus(p tview.Primitive) {
if table, ok := p.(*tview.Table); ok {
table.Blur()
table.SetBorderColor(tcell.ColorGray)
}
}

Expand Down Expand Up @@ -176,6 +191,7 @@ func buildUIElements() {

// Show the services page
selectClusterDetailsPageByKey('1')
changeFocus()

if err := tviewApp.SetRoot(flex, true).Run(); err != nil {
panic(err)
Expand All @@ -191,7 +207,6 @@ func buildClusterTable() *tview.Table {
SetSelectable(true, false)
table.
SetBorder(true).
SetBorderColor(tcell.ColorDimGray).
SetTitle(" ✨ ECS Clusters ").
SetBorderPadding(0, 0, 1, 1)

Expand Down

0 comments on commit 11454b0

Please sign in to comment.