Skip to content

Commit

Permalink
zoom callsign when close to frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
ftl committed Nov 26, 2023
1 parent a5efd30 commit 21dea80
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions ui/spotsTableView.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"
"time"

"github.com/ftl/hamradio/callsign"
"github.com/ftl/hellocontest/core"
"github.com/ftl/hellocontest/ui/style"
"github.com/gotk3/gotk3/gdk"
Expand Down Expand Up @@ -36,7 +37,7 @@ func setupSpotsTableView(v *spotsView, builder *gtk.Builder, controller SpotsCon
v.table.Connect("button-press-event", v.activateTableSelection)

v.table.AppendColumn(createSpotMarkupColumn("Frequency", spotColumnFrequency))
v.table.AppendColumn(createSpotTextColumn("Callsign", spotColumnCallsign))
v.table.AppendColumn(createSpotMarkupColumn("Callsign", spotColumnCallsign))
v.table.AppendColumn(createSpotTextColumn("Exchange", spotColumnPredictedExchange))
v.table.AppendColumn(createSpotMarkupColumn("Pts", spotColumnPoints))
v.table.AppendColumn(createSpotMarkupColumn("Mult", spotColumnMultis))
Expand Down Expand Up @@ -146,7 +147,7 @@ func (v *spotsView) fillEntryToTableRow(row *gtk.TreeIter, entry core.BandmapEnt
},
[]any{
formatSpotFrequency(entry.Frequency, entry.ProximityFactor(v.currentFrame.Frequency), entry.OnFrequency(v.currentFrame.Frequency)),
entry.Call.String(),
formatSpotCall(entry.Call, entry.ProximityFactor(v.currentFrame.Frequency), entry.OnFrequency(v.currentFrame.Frequency)),
entry.Info.ExchangeText,
formatPoints(entry.Info.Points, entry.Info.Duplicate, 1),
formatPoints(entry.Info.Multis, entry.Info.Duplicate, 0),
Expand All @@ -170,6 +171,16 @@ func formatSpotFrequency(frequency core.Frequency, proximity float64, onFrequenc
return result
}

func formatSpotCall(call callsign.Callsign, proximity float64, onFrequency bool) string {
size := 100 + math.Abs(proximity)*30
result := fmt.Sprintf("<span size=\"%.0f%%\">%s</span>", size, call)
if onFrequency {
return fmt.Sprintf("<b>%s</b>", result)
}

return result
}

func formatPoints(value int, duplicate bool, threshold int) string {
result := pointsToString(value, duplicate)
if value > threshold && !duplicate {
Expand Down

0 comments on commit 21dea80

Please sign in to comment.