mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 01:49:44 +00:00
The refresh callback is triggered by WM_PAINT, but windows does not send it while a border is dragged: the window class has neither CS_HREDRAW nor CS_VREDRAW and nothing invalidates the client area. Only WM_SIZE arrives, so nothing was drawn during such a resize. The frame is drawn from WM_SIZE now, after forwarding the message to GLFW so that the new size is already in. WM_NCHITTEST re-applies the style bits the engine frame needs and which GLFW drops on every window mode change, taking the drag area with them. Every frame setup logs whether the subclass had to be installed again, so a lost window procedure is visible in the log. The live resize switch is honoured by the GLFW backend as well: with it off the frame from the message loop is skipped and the window keeps showing what the system stretches.
88 lines
2.9 KiB
Lua
88 lines
2.9 KiB
Lua
local tostring_overrides = {}
|
|
tostring_overrides["display.framerate"] = function(x)
|
|
if x == -1 then
|
|
return gui.str("V-Sync")
|
|
elseif x == 0 then
|
|
return gui.str("Unlimited")
|
|
else
|
|
return tostring(x)
|
|
end
|
|
end
|
|
|
|
function create_trackbar_setting(id, name, step, postfix, tooltip, changeonrelease)
|
|
local info = app.get_setting_info(id)
|
|
postfix = postfix or ""
|
|
tooltip = tooltip or ""
|
|
changeonrelease = changeonrelease or ""
|
|
document.root:add(gui.template("track_setting", {
|
|
id=id,
|
|
name=gui.str(name, "settings"),
|
|
value=app.get_setting(id),
|
|
min=info.min,
|
|
max=info.max,
|
|
step=step,
|
|
postfix=postfix,
|
|
tooltip=tooltip,
|
|
changeonrelease=changeonrelease
|
|
}))
|
|
update_trackbar_label(app.get_setting(id), id, name, postfix)
|
|
end
|
|
|
|
function update_trackbar_label(x, id, name, postfix)
|
|
local str
|
|
local func = tostring_overrides[id]
|
|
if func then
|
|
str = func(x)
|
|
else
|
|
str = app.str_setting(id)
|
|
end
|
|
-- updating label
|
|
document[id..".L"].text = string.format(
|
|
"%s: %s%s",
|
|
gui.str(name, "settings"),
|
|
str,
|
|
postfix
|
|
)
|
|
end
|
|
|
|
function create_checkbox(id, name, tooltip)
|
|
tooltip = tooltip or ''
|
|
document.root:add(string.format(
|
|
"<checkbox consumer='function(x) app.set_setting(\"%s\", x) end' checked='%s' tooltip='%s'>%s</checkbox>",
|
|
id, app.str_setting(id), gui.str(tooltip, "settings"), gui.str(name, "settings")
|
|
))
|
|
end
|
|
|
|
|
|
function on_open()
|
|
create_trackbar_setting("camera.fov", "FOV", 1, "°")
|
|
create_trackbar_setting("display.framerate", "Framerate", 1, "", "", true)
|
|
|
|
document.root:add(string.format(
|
|
"<select context='settings' onselect='function(opt) app.set_setting(\"display.window-mode\", tonumber(opt)) end' selected='%s'>"..
|
|
"<option value='0'>@Windowed</option>"..
|
|
"<option value='1'>@Fullscreen</option>"..
|
|
"<option value='2'>@Borderless</option>"..
|
|
"</select>", app.get_setting("display.window-mode"))
|
|
)
|
|
|
|
-- the bar height matters wherever the engine draws the window frame
|
|
if app.has_engine_window_frame() then
|
|
create_checkbox(
|
|
"display.compact-window-bar", "Narrow Window Bar",
|
|
"display.compact-window-bar.tooltip"
|
|
)
|
|
end
|
|
-- every backend has an alternative to redrawing during a resize: the
|
|
-- cached frame on wayland, the frame the system stretches elsewhere
|
|
create_checkbox(
|
|
"display.live-resize", "Live Window Resize",
|
|
"display.live-resize.tooltip"
|
|
)
|
|
|
|
create_checkbox("camera.shaking", "Camera Shaking")
|
|
create_checkbox("camera.inertia", "Camera Inertia")
|
|
create_checkbox("camera.fov-effects", "Camera FOV Effects")
|
|
create_checkbox("display.limit-fps-iconified", "Limit Background FPS")
|
|
create_trackbar_setting("graphics.gamma", "Gamma", 0.05, "", "graphics.gamma.tooltip")
|
|
end
|