Add ship-it skill and menu placement logs
This commit is contained in:
@@ -679,12 +679,14 @@ func (u *ui) handleHeaderActionClicks(gtx layout.Context) {
|
||||
if u.syncMenuOpen {
|
||||
u.mainMenuOpen = false
|
||||
}
|
||||
u.maybeLogHeaderMenuToggle("sync", u.syncMenuOpen)
|
||||
}
|
||||
for u.toggleMainMenu.Clicked(gtx) {
|
||||
u.mainMenuOpen = !u.mainMenuOpen
|
||||
if u.mainMenuOpen {
|
||||
u.syncMenuOpen = false
|
||||
}
|
||||
u.maybeLogHeaderMenuToggle("main", u.mainMenuOpen)
|
||||
}
|
||||
for u.openAdvancedSync.Clicked(gtx) {
|
||||
u.openAdvancedSyncDialog()
|
||||
|
||||
@@ -54,19 +54,29 @@ func (u *ui) headerActions(gtx layout.Context) layout.Dimensions {
|
||||
if u.syncMenuOpen {
|
||||
u.phoneSyncMenuVisible = true
|
||||
u.phoneSyncMenuAnchor = cluster.Metrics.SyncAnchor().Point()
|
||||
u.maybeLogHeaderMenuToggle("sync-visible", true)
|
||||
}
|
||||
if u.mainMenuOpen {
|
||||
u.phoneMainMenuVisible = true
|
||||
u.phoneMainMenuAnchor = cluster.Metrics.MainAnchor().Point()
|
||||
u.maybeLogHeaderMenuToggle("main-visible", true)
|
||||
}
|
||||
return layout.Dimensions{Size: image.Pt(gtx.Constraints.Max.X, rowDims.Size.Y)}
|
||||
}
|
||||
|
||||
if cluster.ShowSyncMenu() {
|
||||
surface.Draw(gtx, cluster.Metrics.SyncAnchor(), cluster.SyncMenu)
|
||||
placement, menuCall := surface.Place(gtx, cluster.Metrics.SyncAnchor(), cluster.SyncMenu)
|
||||
u.maybeLogHeaderMenuPlacement("sync", surface, placement)
|
||||
stack := op.Offset(placement.Origin).Push(gtx.Ops)
|
||||
menuCall.Add(gtx.Ops)
|
||||
stack.Pop()
|
||||
}
|
||||
if cluster.ShowMainMenu() {
|
||||
surface.Draw(gtx, cluster.Metrics.MainAnchor(), cluster.MainMenu)
|
||||
placement, menuCall := surface.Place(gtx, cluster.Metrics.MainAnchor(), cluster.MainMenu)
|
||||
u.maybeLogHeaderMenuPlacement("main", surface, placement)
|
||||
stack := op.Offset(placement.Origin).Push(gtx.Ops)
|
||||
menuCall.Add(gtx.Ops)
|
||||
stack.Pop()
|
||||
}
|
||||
|
||||
return rowDims
|
||||
@@ -171,10 +181,18 @@ func (u *ui) phoneHeaderMenus(gtx layout.Context) layout.Dimensions {
|
||||
}
|
||||
|
||||
if u.syncMenuVisibleOnPhone() {
|
||||
surface.Draw(gtx, headerlayout.DropdownAnchor{TriggerRightX: u.phoneSyncMenuAnchor.X, TriggerBottomY: u.phoneSyncMenuAnchor.Y}, u.syncMenu)
|
||||
placement, menuCall := surface.Place(gtx, headerlayout.DropdownAnchor{TriggerRightX: u.phoneSyncMenuAnchor.X, TriggerBottomY: u.phoneSyncMenuAnchor.Y}, u.syncMenu)
|
||||
u.maybeLogHeaderMenuPlacement("sync-phone", surface, placement)
|
||||
stack := op.Offset(placement.Origin).Push(gtx.Ops)
|
||||
menuCall.Add(gtx.Ops)
|
||||
stack.Pop()
|
||||
}
|
||||
if u.mainMenuVisibleOnPhone() {
|
||||
surface.Draw(gtx, headerlayout.DropdownAnchor{TriggerRightX: u.phoneMainMenuAnchor.X, TriggerBottomY: u.phoneMainMenuAnchor.Y}, u.mainMenu)
|
||||
placement, menuCall := surface.Place(gtx, headerlayout.DropdownAnchor{TriggerRightX: u.phoneMainMenuAnchor.X, TriggerBottomY: u.phoneMainMenuAnchor.Y}, u.mainMenu)
|
||||
u.maybeLogHeaderMenuPlacement("main-phone", surface, placement)
|
||||
stack := op.Offset(placement.Origin).Push(gtx.Ops)
|
||||
menuCall.Add(gtx.Ops)
|
||||
stack.Pop()
|
||||
}
|
||||
return layout.Dimensions{Size: gtx.Constraints.Max}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,12 @@ type DropdownSurface struct {
|
||||
TopInset int
|
||||
}
|
||||
|
||||
type DropdownPlacement struct {
|
||||
Anchor DropdownAnchor
|
||||
Origin image.Point
|
||||
Size image.Point
|
||||
}
|
||||
|
||||
func (s DropdownSurface) MenuConstraints(gtx layout.Context) layout.Context {
|
||||
menuGTX := gtx
|
||||
menuGTX.Constraints.Min = image.Point{}
|
||||
@@ -51,13 +57,22 @@ func (s DropdownSurface) Origin(anchor DropdownAnchor, menuWidth int) image.Poin
|
||||
return image.Pt(x, y)
|
||||
}
|
||||
|
||||
func (s DropdownSurface) Draw(gtx layout.Context, anchor DropdownAnchor, menu layout.Widget) layout.Dimensions {
|
||||
func (s DropdownSurface) Place(gtx layout.Context, anchor DropdownAnchor, menu layout.Widget) (DropdownPlacement, op.CallOp) {
|
||||
menuGTX := s.MenuConstraints(gtx)
|
||||
menuOps := op.Record(gtx.Ops)
|
||||
menuDims := layout.Inset{Top: unit.Dp(6)}.Layout(menuGTX, menu)
|
||||
menuCall := menuOps.Stop()
|
||||
menuOrigin := s.Origin(anchor, menuDims.Size.X)
|
||||
stack := op.Offset(menuOrigin).Push(gtx.Ops)
|
||||
return DropdownPlacement{
|
||||
Anchor: anchor,
|
||||
Origin: menuOrigin,
|
||||
Size: menuDims.Size,
|
||||
}, menuCall
|
||||
}
|
||||
|
||||
func (s DropdownSurface) Draw(gtx layout.Context, anchor DropdownAnchor, menu layout.Widget) layout.Dimensions {
|
||||
placement, menuCall := s.Place(gtx, anchor, menu)
|
||||
stack := op.Offset(placement.Origin).Push(gtx.Ops)
|
||||
menuCall.Add(gtx.Ops)
|
||||
stack.Pop()
|
||||
return layout.Dimensions{Size: gtx.Constraints.Max}
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"gioui.org/widget"
|
||||
"gioui.org/widget/material"
|
||||
editormodel "git.julianfamily.org/keepassgo/internal/appui/editor"
|
||||
headerlayout "git.julianfamily.org/keepassgo/internal/appui/header/layout"
|
||||
"git.julianfamily.org/keepassgo/internal/appui/platform"
|
||||
settingsmodel "git.julianfamily.org/keepassgo/internal/appui/settings"
|
||||
"git.julianfamily.org/keepassgo/internal/vault"
|
||||
@@ -309,6 +310,32 @@ func (u *ui) maybeLogHeaderBounds(bounds headerButtonBounds) {
|
||||
u.lastHeaderBoundsLog = line
|
||||
}
|
||||
|
||||
func (u *ui) maybeLogHeaderMenuToggle(menu string, open bool) {
|
||||
if !u.debugLogHeaderBounds {
|
||||
return
|
||||
}
|
||||
platform.LogInfo("KeePassGO", fmt.Sprintf("keepassgo header-menu-toggle menu=%s open=%t", menu, open))
|
||||
}
|
||||
|
||||
func (u *ui) maybeLogHeaderMenuPlacement(menu string, surface headerlayout.DropdownSurface, placement headerlayout.DropdownPlacement) {
|
||||
if !u.debugLogHeaderBounds {
|
||||
return
|
||||
}
|
||||
platform.LogInfo("KeePassGO", fmt.Sprintf(
|
||||
"keepassgo header-menu-placement menu=%s anchor=%d,%d origin=%d,%d size=%dx%d container=%d inset=%d,%d",
|
||||
menu,
|
||||
placement.Anchor.TriggerRightX,
|
||||
placement.Anchor.TriggerBottomY,
|
||||
placement.Origin.X,
|
||||
placement.Origin.Y,
|
||||
placement.Size.X,
|
||||
placement.Size.Y,
|
||||
surface.ContainerWidth,
|
||||
surface.LeftInset,
|
||||
surface.TopInset,
|
||||
))
|
||||
}
|
||||
|
||||
func (u *ui) showStatusMessage(message string) {
|
||||
u.state.StatusMessage = message
|
||||
if u.accessibilityPrefs.ReducedMotion {
|
||||
|
||||
Reference in New Issue
Block a user