feat: wip recolor titlebar

This commit is contained in:
Liz3 (Yann HN) 2024-01-11 03:22:23 +01:00
parent 0dc3a76438
commit 5591b9043c
17 changed files with 47 additions and 2 deletions

View File

@ -3312,6 +3312,8 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
*/
GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images);
GLFWAPI void glfwSetWindowTitlebarColor(GLFWwindow* window, int r, int g, int b, int a);
/*! @brief Retrieves the position of the content area of the specified window.
*
* This function retrieves the position, in screen coordinates, of the

View File

@ -527,6 +527,7 @@ GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform)
_glfwCreateWindowCocoa,
_glfwDestroyWindowCocoa,
_glfwSetWindowTitleCocoa,
_glfwSetWindowTitlebarColorCocoa,
_glfwSetWindowIconCocoa,
_glfwGetWindowPosCocoa,
_glfwSetWindowPosCocoa,

View File

@ -217,6 +217,7 @@ void _glfwTerminateCocoa(void);
GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
void _glfwDestroyWindowCocoa(_GLFWwindow* window);
void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title);
void _glfwSetWindowTitlebarColorCocoa(_GLFWwindow* window, int r, int g, int b, int a);
void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos);
void _glfwSetWindowPosCocoa(_GLFWwindow* window, int xpos, int ypos);

View File

@ -1027,6 +1027,20 @@ void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title)
[window->ns.object setMiniwindowTitle:string];
} // autoreleasepool
}
void _glfwSetWindowTitlebarColorCocoa(_GLFWwindow* window, int r, int g, int b, int a)
{
@autoreleasepool {
CGFloat red = r/ 255;
CGFloat green =g / 255;
CGFloat blue = b / 255;
CGFloat alpha = a / 255;
NSColor *color = [NSColor colorWithCalibratedRed:red green:green blue:blue alpha:alpha];
[window->ns.object setTitlebarAppearsTransparent:YES]; // gives it "flat" look
[window->ns.object setBackgroundColor:color];
} // autoreleasepool
}
void _glfwSetWindowIconCocoa(_GLFWwindow* window,
int count, const GLFWimage* images)

View File

@ -708,6 +708,7 @@ struct _GLFWplatform
GLFWbool (*createWindow)(_GLFWwindow*,const _GLFWwndconfig*,const _GLFWctxconfig*,const _GLFWfbconfig*);
void (*destroyWindow)(_GLFWwindow*);
void (*setWindowTitle)(_GLFWwindow*,const char*);
void (*setWindowTitlebarColor)(_GLFWwindow*,int, int, int, int);
void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*);
void (*getWindowPos)(_GLFWwindow*,int*,int*);
void (*setWindowPos)(_GLFWwindow*,int,int);

View File

@ -212,6 +212,7 @@ void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
GLFWbool _glfwCreateWindowNull(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
void _glfwDestroyWindowNull(_GLFWwindow* window);
void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title);
void _glfwSetWindowTitlebarColorNull(_GLFWwindow* window, int r, int g, int b, int a);
void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwSetWindowMonitorNull(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos);

View File

@ -181,6 +181,9 @@ void _glfwDestroyWindowNull(_GLFWwindow* window)
void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title)
{
}
void _glfwSetWindowTitlebarColorNull(_GLFWwindow* window, int r, int g, int b, int a) {
}
void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images)

View File

@ -637,6 +637,7 @@ GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform)
_glfwCreateWindowWin32,
_glfwDestroyWindowWin32,
_glfwSetWindowTitleWin32,
_glfwSetWindowTitlebarColorWin32,
_glfwSetWindowIconWin32,
_glfwGetWindowPosWin32,
_glfwSetWindowPosWin32,

View File

@ -542,6 +542,7 @@ void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* ys
GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
void _glfwDestroyWindowWin32(_GLFWwindow* window);
void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title);
void _glfwSetWindowTitlebarColorWin32(_GLFWwindow* window, int r, int g, int b, int a);
void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos);
void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos);

View File

@ -1538,7 +1538,9 @@ void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title)
SetWindowTextW(window->win32.handle, wideTitle);
_glfw_free(wideTitle);
}
void _glfwSetWindowTitlebarColorWin32(GLFWwindow* window, int r, int g, int b, int a) {
}
void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images)
{
HICON bigIcon = NULL, smallIcon = NULL;

View File

@ -524,7 +524,13 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
_GLFW_REQUIRE_INIT();
_glfw.platform.setWindowTitle(window, title);
}
GLFWAPI void glfwSetWindowTitlebarColor(GLFWwindow* handle, int r, int g, int b, int a) {
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
assert(window != NULL);
_GLFW_REQUIRE_INIT();
_glfw.platform.setWindowTitlebarColor(handle, r,g,b,a);
}
GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle,
int count, const GLFWimage* images)
{

View File

@ -447,6 +447,7 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform)
_glfwCreateWindowWayland,
_glfwDestroyWindowWayland,
_glfwSetWindowTitleWayland,
_glfwSetWindowTitlebarColorWayland,
_glfwSetWindowIconWayland,
_glfwGetWindowPosWayland,
_glfwSetWindowPosWayland,

View File

@ -24,6 +24,7 @@
//
//========================================================================
#include "internal.h"
#include <wayland-client-core.h>
#include <xkbcommon/xkbcommon.h>
#include <xkbcommon/xkbcommon-compose.h>
@ -612,6 +613,7 @@ void _glfwTerminateWayland(void);
GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
void _glfwDestroyWindowWayland(_GLFWwindow* window);
void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title);
void _glfwSetWindowTitlebarColorWayland(_GLFWwindow* window, int r, int g, int b, int a);
void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos);
void _glfwSetWindowPosWayland(_GLFWwindow* window, int xpos, int ypos);

View File

@ -2111,6 +2111,9 @@ void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title)
else if (window->wl.xdg.toplevel)
xdg_toplevel_set_title(window->wl.xdg.toplevel, title);
}
void _glfwSetWindowTitlebarColorWayland(_GLFWwindow* window, int r, int g, int b, int a) {
}
void _glfwSetWindowIconWayland(_GLFWwindow* window,
int count, const GLFWimage* images)

View File

@ -1208,6 +1208,7 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform)
_glfwCreateWindowX11,
_glfwDestroyWindowX11,
_glfwSetWindowTitleX11,
_glfwSetWindowTitlebarColorX11,
_glfwSetWindowIconX11,
_glfwGetWindowPosX11,
_glfwSetWindowPosX11,

View File

@ -25,6 +25,7 @@
//
//========================================================================
#include "internal.h"
#include <unistd.h>
#include <signal.h>
#include <stdint.h>
@ -904,6 +905,7 @@ void _glfwTerminateX11(void);
GLFWbool _glfwCreateWindowX11(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
void _glfwDestroyWindowX11(_GLFWwindow* window);
void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title);
void _glfwSetWindowTitlebarColorX11(_GLFWwindow* window, int r, int g, int b, int a);
void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos);
void _glfwSetWindowPosX11(_GLFWwindow* window, int xpos, int ypos);

View File

@ -2101,6 +2101,9 @@ void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title)
XFlush(_glfw.x11.display);
}
void _glfwSetWindowTitlebarColorX11(_GLFWwindow* window, int r, int g, int b, int a) {
}
void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images)
{