mirror of
https://github.com/koho/frpmgr.git
synced 2025-10-20 16:03:47 +08:00
Resize the startup window
This commit is contained in:
2
go.mod
2
go.mod
@ -66,4 +66,4 @@ require (
|
||||
sigs.k8s.io/yaml v1.3.0 // indirect
|
||||
)
|
||||
|
||||
replace github.com/lxn/walk => github.com/koho/frpmgr v0.0.0-20250417143351-c1c196166836
|
||||
replace github.com/lxn/walk => github.com/koho/frpmgr v0.0.0-20250614023804-912b463eb7d6
|
||||
|
4
go.sum
4
go.sum
@ -63,8 +63,8 @@ github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/4
|
||||
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/klauspost/reedsolomon v1.12.0 h1:I5FEp3xSwVCcEh3F5A7dofEfhXdF/bWhQWPH+XwBFno=
|
||||
github.com/klauspost/reedsolomon v1.12.0/go.mod h1:EPLZJeh4l27pUGC3aXOjheaoh1I9yut7xTURiW3LQ9Y=
|
||||
github.com/koho/frpmgr v0.0.0-20250417143351-c1c196166836 h1:bwPsMPZ/qhLlaEISH98f8g4iiPfZqdvEozsZnfIEZT0=
|
||||
github.com/koho/frpmgr v0.0.0-20250417143351-c1c196166836/go.mod h1:BEvTAgZsEET00wLNsOhKg8fX//k6l4b5INTzX2APBb8=
|
||||
github.com/koho/frpmgr v0.0.0-20250614023804-912b463eb7d6 h1:vFU+4JwxgVA1S8200tuSXNRWUzxOMVYppCOfYW3mGE4=
|
||||
github.com/koho/frpmgr v0.0.0-20250614023804-912b463eb7d6/go.mod h1:BEvTAgZsEET00wLNsOhKg8fX//k6l4b5INTzX2APBb8=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
|
@ -1,6 +1,8 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"math"
|
||||
|
||||
"github.com/lxn/walk"
|
||||
. "github.com/lxn/walk/declarative"
|
||||
)
|
||||
@ -40,6 +42,15 @@ func (dv *DetailView) OnCreate() {
|
||||
confDB.ResetFinished().Attach(dv.Invalidate)
|
||||
}
|
||||
|
||||
// sizeBias is the pixel offset used to resize the window to match the size of the proxy table.
|
||||
func (dv *DetailView) sizeBias() walk.Size {
|
||||
tableHeight := math.Phi * float64(dv.panelView.SizeHint().Height)
|
||||
return walk.Size{
|
||||
Width: dv.proxyView.minWidthBias(),
|
||||
Height: int(tableHeight) - dv.proxyView.table.MinSizeHint().Height,
|
||||
}
|
||||
}
|
||||
|
||||
func (dv *DetailView) Invalidate() {
|
||||
dv.panelView.Invalidate(true)
|
||||
dv.proxyView.Invalidate()
|
||||
|
@ -79,6 +79,8 @@ func (pv *ProxyView) OnCreate() {
|
||||
}
|
||||
})
|
||||
pv.table.SelectedIndexesChanged().Attach(pv.switchToggleAction)
|
||||
pv.table.FitColumnHeader(3, 0)
|
||||
pv.table.FitColumnHeader(4, 68)
|
||||
}
|
||||
|
||||
func (pv *ProxyView) Invalidate() {
|
||||
@ -278,10 +280,10 @@ func (pv *ProxyView) createProxyTable() TableView {
|
||||
AssignTo: &pv.table,
|
||||
Columns: []TableViewColumn{
|
||||
{Title: i18n.Sprintf("Name"), DataMember: "Name", Width: 100},
|
||||
{Title: i18n.Sprintf("Type"), DataMember: "Type", Width: 55},
|
||||
{Title: i18n.Sprintf("Type"), DataMember: "Type", Width: 56},
|
||||
{Title: i18n.Sprintf("Local Address"), DataMember: "DisplayLocalIP", Width: 110},
|
||||
{Title: i18n.Sprintf("Local Port"), DataMember: "DisplayLocalPort", Width: 90},
|
||||
{Title: i18n.Sprintf("Remote Port"), DataMember: "DisplayRemotePort", Width: 90},
|
||||
{Title: i18n.Sprintf("Local Port"), DataMember: "DisplayLocalPort"},
|
||||
{Title: i18n.Sprintf("Remote Port"), DataMember: "DisplayRemotePort"},
|
||||
{Title: i18n.Sprintf("Domains"), DataMember: "Domains", Width: 80},
|
||||
{Title: i18n.Sprintf("Plugin"), DataMember: "Plugin", Width: 80},
|
||||
{Title: i18n.Sprintf("Remote Address"), DataMember: "RemoteAddr", Width: 110, Name: "remoteAddr", Hidden: true},
|
||||
|
19
ui/ui.go
19
ui/ui.go
@ -91,14 +91,21 @@ func RunUI() error {
|
||||
fm.logPage.OnCreate()
|
||||
fm.prefPage.OnCreate()
|
||||
fm.aboutPage.OnCreate()
|
||||
// Minimum window height.
|
||||
confPageHeight := fm.confPage.SizeHint().Height
|
||||
maxPageHeight := max(
|
||||
confPageHeight,
|
||||
fm.logPage.SizeHint().Height,
|
||||
fm.prefPage.SizeHint().Height,
|
||||
fm.aboutPage.SizeHint().Height,
|
||||
)
|
||||
// Resize window
|
||||
margins := fm.Layout().Margins()
|
||||
fm.SetClientSizePixels(walk.Size{
|
||||
Width: fm.tabs.SizeHint().Width +
|
||||
walk.IntFrom96DPI(margins.HNear+margins.HFar, fm.DPI()) +
|
||||
fm.confPage.detailView.proxyView.minWidthBias(),
|
||||
Height: fm.IntFrom96DPI(490),
|
||||
})
|
||||
size := fm.tabs.SizeHint()
|
||||
bias := fm.confPage.detailView.sizeBias()
|
||||
size.Width += bias.Width + walk.IntFrom96DPI(margins.HNear+margins.HFar, fm.DPI())
|
||||
size.Height += bias.Height + walk.IntFrom96DPI(margins.VNear+margins.VFar, fm.DPI()) - maxPageHeight + confPageHeight
|
||||
fm.SetClientSizePixels(size)
|
||||
fm.Closing().Attach(func(canceled *bool, reason walk.CloseReason) {
|
||||
// Save window state.
|
||||
var wp win.WINDOWPLACEMENT
|
||||
|
Reference in New Issue
Block a user