Skip to content

Commit

Permalink
ADd standard ui sizes. Add inline kd.
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmacdonald committed Mar 7, 2023
1 parent 0c4ce79 commit 4564483
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 65 deletions.
2 changes: 1 addition & 1 deletion internal/translations/active.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ menu_name_history:
one: "View Name History"

label_message_count:
one: "Message Count: "
one: "Messages: "

label_result_count:
one: "Results: "
Expand Down
2 changes: 1 addition & 1 deletion internal/ui/chat_game.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func newGameChatWindow(ctx context.Context, app fyne.App, cb callBacks, attrs bi
nil,
nil,
container.NewVScroll(gcw.list)))
gcw.window.Resize(fyne.NewSize(1000, 500))
gcw.window.Resize(fyne.NewSize(sizeWindowChatWidth, sizeWindowChatHeight))
return &gcw
}

Expand Down
10 changes: 7 additions & 3 deletions internal/ui/chat_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ func newUserChatWindow(ctx context.Context, app fyne.App, queryFunc model.QueryU
nil,
widget.NewRichTextWithText(""))
}, func(i binding.DataItem, o fyne.CanvasObject) {
window.objectMu.Lock()
defer window.objectMu.Unlock()
value := i.(binding.Untyped)
obj, _ := value.Get()
um := obj.(model.UserMessage)
window.objectMu.Lock()
rootContainer := o.(*fyne.Container)
timeStamp := rootContainer.Objects[1].(*widget.Label)
timeStamp.SetText(um.Created.Format(time.RFC822))
Expand All @@ -77,7 +78,6 @@ func newUserChatWindow(ctx context.Context, app fyne.App, queryFunc model.QueryU
Text: um.Message,
}
messageRichText.Refresh()
window.objectMu.Unlock()
})
window.SetContent(container.NewBorder(
container.NewBorder(
Expand Down Expand Up @@ -117,6 +117,10 @@ func newUserChatWindow(ctx context.Context, app fyne.App, queryFunc model.QueryU
if errSet := window.boundList.Set(messages.AsAny()); errSet != nil {
log.Printf("Failed to set messages: %v\n", errSet)
}
window.Resize(fyne.NewSize(600, 600))
_ = window.messageCount.Set(window.boundList.Length())
if ase, errASE := window.autoScrollEnabled.Get(); errASE == nil && ase {
window.list.ScrollToBottom()
}
window.Resize(fyne.NewSize(sizeWindowChatWidth, sizeWindowChatHeight))
return &window
}
37 changes: 0 additions & 37 deletions internal/ui/embed_font.go

This file was deleted.

4 changes: 2 additions & 2 deletions internal/ui/links.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func newLinksDialog(parent fyne.Window, settings *model.Settings) *linksConfigDi

d := dialog.NewCustom("Edit Entry", "Close", container.NewMax(form), parent)
sz := d.MinSize()
sz.Width = defaultDialogueWidth
sz.Width = sizeDialogueWidth
d.Resize(sz)
d.Show()
}
Expand Down Expand Up @@ -145,6 +145,6 @@ func newLinksDialog(parent fyne.Window, settings *model.Settings) *linksConfigDi
lcd.Dialog = dialog.NewCustom("Edit Links", translations.One(translations.LabelClose),
container.NewBorder(container.NewHBox(addButton, delButton), nil, nil, nil, lcd.list), parent)

lcd.Resize(fyne.NewSize(defaultDialogueWidth, 500))
lcd.Resize(fyne.NewSize(sizeDialogueWidth, sizeDialogueHeight))
return &lcd
}
15 changes: 8 additions & 7 deletions internal/ui/lists.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func newRuleListConfigDialog(parent fyne.Window, settings *model.Settings) dialo
container.NewVScroll(container.NewMax(form)),
parent)
sz := d.MinSize()
sz.Width = defaultDialogueWidth
sz.Width = sizeDialogueWidth
sz.Height *= 3
d.Resize(sz)
d.Show()
Expand Down Expand Up @@ -107,16 +107,18 @@ func newRuleListConfigDialog(parent fyne.Window, settings *model.Settings) dialo
nil,
nil, container.NewHBox(
widget.NewButtonWithIcon(translations.One(translations.LabelAdd), theme.ContentAddIcon(), func() {
lc := &model.ListConfig{
newLists := settings.GetLists()
newLists = append(newLists, &model.ListConfig{
ListType: model.ListTypeTF2BDPlayerList,
Name: fmt.Sprintf("New List %d", listCount),
Enabled: false,
URL: "",
}
listCount++
if errAppend := boundList.Append(lc); errAppend != nil {
})
settings.SetLists(newLists)
if errAppend := boundList.Set(settings.GetLists().AsAny()); errAppend != nil {
log.Printf("Failed to update config list: %v", errAppend)
}
list.Refresh()
})), nil,
container.NewHBox())

Expand All @@ -136,7 +138,6 @@ func newRuleListConfigDialog(parent fyne.Window, settings *model.Settings) dialo
settings: settings,
}

configDialog.Resize(fyne.NewSize(defaultDialogueWidth, 500))
//settingsWindow.Resize(fyne.NewSize(5050, 700))
configDialog.Resize(fyne.NewSize(sizeDialogueWidth, sizeDialogueWidth))
return &configDialog
}
2 changes: 1 addition & 1 deletion internal/ui/menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func generateUserMenu(ctx context.Context, app fyne.App, window fyne.Window, ste
player.RUnlock()
item := widget.NewFormItem("", entry)
sz := item.Widget.Size()
sz.Height = 450
sz.Height = sizeDialogueHeight
item.Widget.Resize(sz)
d := dialog.NewForm("Edit Player Notes", "Save", "Cancel", []*widget.FormItem{item}, func(b bool) {
if !b {
Expand Down
2 changes: 1 addition & 1 deletion internal/ui/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func newUserNameWindow(ctx context.Context, app fyne.App, namesFunc model.QueryN
nil,
nil,
container.NewVScroll(unl.list)))
unl.Resize(fyne.NewSize(600, 600))
unl.Resize(fyne.NewSize(sizeDialogueWidth, sizeDialogueHeight))
unl.Show()
return unl
}
31 changes: 26 additions & 5 deletions internal/ui/players.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,27 @@ func newPlayerWindow(app fyne.App, settings *model.Settings, showChatWindowFunc
} else {
nameStyle.ColorName = theme.ColorNamePrimary
}
profileLabel.Segments = []widget.RichTextSegment{&widget.TextSegment{Text: ps.Name, Style: nameStyle}}
stlKD := widget.RichTextStyleInline
if ps.Kills > ps.Deaths {
stlKD.ColorName = theme.ColorNameSuccess
} else if ps.Deaths > ps.Kills {
stlKD.ColorName = theme.ColorNameError
}
stlPing := widget.RichTextStyleInline
if ps.Ping > 150 {
stlPing.ColorName = theme.ColorNameError
} else if ps.Ping > 100 {
stlPing.ColorName = theme.ColorNameWarning
} else {
stlPing.ColorName = theme.ColorNameSuccess
}
profileLabel.Segments = []widget.RichTextSegment{
&widget.TextSegment{Text: ps.Name, Style: nameStyle},
&widget.TextSegment{Text: fmt.Sprintf(" %d", ps.Kills), Style: stlKD},
&widget.TextSegment{Text: ":", Style: widget.RichTextStyleInline},
&widget.TextSegment{Text: fmt.Sprintf("%d", ps.Deaths), Style: stlKD},
&widget.TextSegment{Text: fmt.Sprintf(" %dms", ps.Ping), Style: stlPing},
}
profileLabel.Refresh()
var vacState []string
if ps.NumberOfVACBans > 0 {
Expand Down Expand Up @@ -430,13 +450,14 @@ func newPlayerWindow(app fyne.App, settings *model.Settings, showChatWindowFunc
}
matchLabel.Refresh()
vacLabel := lc.Objects[1].(*widget.RichText)
vacLabel.Segments = []widget.RichTextSegment{
&widget.TextSegment{Text: vacMsgFull, Style: vacStyle},
vacLabel.Segments = []widget.RichTextSegment{}
if vacMsg != "" {
vacLabel.Segments = append(vacLabel.Segments, &widget.TextSegment{Text: vacMsgFull, Style: vacStyle})
}
if ps.Notes != "" {
notesStyle := stlOk
notesStyle.ColorName = theme.ColorNameWarning
vacLabel.Segments = append(vacLabel.Segments, &widget.TextSegment{Text: " [note] ", Style: notesStyle})
vacLabel.Segments = append(vacLabel.Segments, &widget.TextSegment{Text: "[note]", Style: notesStyle})
}
lc.Refresh()
vacLabel.Refresh()
Expand All @@ -456,7 +477,7 @@ func newPlayerWindow(app fyne.App, settings *model.Settings, showChatWindowFunc
screen.labelHostname,
)
screen.createMainMenu()
screen.window.Resize(fyne.NewSize(800, 990))
screen.window.Resize(fyne.NewSize(sizeWindowMainWidth, sizeWindowMainHeight))
screen.window.SetCloseIntercept(func() {
screen.app.Quit()
})
Expand Down
2 changes: 1 addition & 1 deletion internal/ui/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func newSearchWindow(ctx context.Context, app fyne.App, cb callBacks, attrs bind
),
nil, nil, nil,
container.NewMax(sw.list)))
sw.Window.Resize(fyne.NewSize(650, 700))
sw.Window.Resize(fyne.NewSize(sizeDialogueWidth, sizeDialogueHeight))

return &sw
}
2 changes: 1 addition & 1 deletion internal/ui/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,6 @@ func newSettingsDialog(parent fyne.Window, origSettings *model.Settings) dialog.
)

settingsForm.Refresh()
settingsWindow.Resize(fyne.NewSize(800, 800))
settingsWindow.Resize(fyne.NewSize(sizeDialogueWidth, sizeWindowMainHeight))
return settingsWindow
}
6 changes: 3 additions & 3 deletions internal/ui/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ func (bdTheme) Icon(n fyne.ThemeIconName) fyne.Resource {
func (bdTheme) Size(s fyne.ThemeSizeName) float32 {
switch s {
case theme.SizeNameCaptionText:
return 10
return 11
case theme.SizeNameInlineIcon:
return 16
return 20
case theme.SizeNamePadding:
return 0
case theme.SizeNameScrollBar:
Expand All @@ -66,7 +66,7 @@ func (bdTheme) Size(s fyne.ThemeSizeName) float32 {
case theme.SizeNameSeparatorThickness:
return 1
case theme.SizeNameText:
return 10
return 12
case theme.SizeNameInputBorder:
return 2
default:
Expand Down
11 changes: 11 additions & 0 deletions internal/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ const (
urlHelp = "https://github.com/leighmacdonald/bd/wiki"
)

const (
sizeWindowMainWidth = 800
sizeWindowMainHeight = 1000

sizeDialogueWidth = 700
sizeDialogueHeight = 500

sizeWindowChatWidth = 1000
sizeWindowChatHeight = 500
)

func defaultApp() fyne.App {
application := app.NewWithID(AppId)
application.Settings().SetTheme(&bdTheme{})
Expand Down
2 changes: 0 additions & 2 deletions internal/ui/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"fyne.io/fyne/v2/widget"
)

const defaultDialogueWidth = 600

type contextMenuRichText struct {
*widget.Button
menu *fyne.Menu
Expand Down

0 comments on commit 4564483

Please sign in to comment.