glfw: add Window.setTitle
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
1f193ff018
commit
2b75b13123
1 changed files with 31 additions and 0 deletions
|
|
@ -267,6 +267,21 @@ pub inline fn setShouldClose(self: Window, value: bool) Error!void {
|
|||
try getError();
|
||||
}
|
||||
|
||||
/// Sets the UTF-8 encoded title of the specified window.
|
||||
///
|
||||
/// This function sets the window title, encoded as UTF-8, of the specified window.
|
||||
///
|
||||
/// Possible errors include glfw.Error.NotInitialized and glfw.Error.PlatformError.
|
||||
///
|
||||
/// macos: The window title will not be updated until the next time you process events.
|
||||
///
|
||||
/// @thread_safety This function must only be called from the main thread.
|
||||
///
|
||||
/// see also: window_title
|
||||
pub inline fn setTitle(self: Window, title: [*c]const u8) Error!void {
|
||||
c.glfwSetWindowTitle(self.handle, title);
|
||||
}
|
||||
|
||||
test "defaultHints" {
|
||||
const glfw = @import("main.zig");
|
||||
try glfw.init();
|
||||
|
|
@ -320,3 +335,19 @@ test "setShouldClose" {
|
|||
try window.setShouldClose(true);
|
||||
defer window.destroy();
|
||||
}
|
||||
|
||||
test "setTitle" {
|
||||
const glfw = @import("main.zig");
|
||||
try glfw.init();
|
||||
defer glfw.terminate();
|
||||
|
||||
const window = glfw.Window.create(640, 480, "Hello, Zig!", null, null) catch |err| {
|
||||
// return without fail, because most of our CI environments are headless / we cannot open
|
||||
// windows on them.
|
||||
std.debug.print("note: failed to create window: {}\n", .{err});
|
||||
return;
|
||||
};
|
||||
defer window.destroy();
|
||||
|
||||
try window.setTitle("Updated title!");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue