set the window width to half the display size
This commit is contained in:
+5
-6
@@ -15,7 +15,6 @@ import (
|
|||||||
"github.com/ktr0731/go-fuzzyfinder/matching"
|
"github.com/ktr0731/go-fuzzyfinder/matching"
|
||||||
)
|
)
|
||||||
|
|
||||||
const windowWidth = 800
|
|
||||||
const fontSize = 20
|
const fontSize = 20
|
||||||
const textBoxHeight = fontSize + 6
|
const textBoxHeight = fontSize + 6
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@ func isPressedRepeat(key int32) bool {
|
|||||||
|
|
||||||
|
|
||||||
func raymenu(options []string) (choice string, result RayMenuResult) {
|
func raymenu(options []string) (choice string, result RayMenuResult) {
|
||||||
state := initialize()
|
state := initialize(len(options))
|
||||||
rg.SetFont(state.Font)
|
rg.SetFont(state.Font)
|
||||||
rg.SetStyle(rg.DEFAULT, rg.TEXT_SIZE, fontSize)
|
rg.SetStyle(rg.DEFAULT, rg.TEXT_SIZE, fontSize)
|
||||||
// TODO kinda dumb with additional initialization here
|
// TODO kinda dumb with additional initialization here
|
||||||
@@ -169,9 +168,9 @@ func nextBounds() (bounds rl.Rectangle) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func initialize() State {
|
func initialize(nOptions int) State {
|
||||||
rl.SetTraceLogLevel(rl.LogError)
|
rl.SetTraceLogLevel(rl.LogError)
|
||||||
rl.InitWindow(windowWidth, 0, "raymenu")
|
rl.InitWindow(0, 0, "raymenu")
|
||||||
rl.SetWindowState(rl.FlagWindowUndecorated)
|
rl.SetWindowState(rl.FlagWindowUndecorated)
|
||||||
rl.SetTargetFPS(
|
rl.SetTargetFPS(
|
||||||
int32(
|
int32(
|
||||||
@@ -184,8 +183,8 @@ func initialize() State {
|
|||||||
monitorWidth := rl.GetMonitorWidth(monitor)
|
monitorWidth := rl.GetMonitorWidth(monitor)
|
||||||
monitorHeight := rl.GetMonitorHeight(monitor)
|
monitorHeight := rl.GetMonitorHeight(monitor)
|
||||||
rl.SetWindowSize(
|
rl.SetWindowSize(
|
||||||
windowWidth,
|
monitorWidth/2,
|
||||||
monitorHeight/2/textBoxHeight*textBoxHeight,
|
min(monitorHeight/2/textBoxHeight, nOptions+1)*textBoxHeight,
|
||||||
)
|
)
|
||||||
rl.SetWindowPosition(
|
rl.SetWindowPosition(
|
||||||
monitorWidth/2-rl.GetScreenWidth()/2,
|
monitorWidth/2-rl.GetScreenWidth()/2,
|
||||||
|
|||||||
Reference in New Issue
Block a user