Add Windows app icon resource & load it
Add Windows resource files and load the app icon in the window class. Introduce resources/nebula.rc and resources/resource.h (defines IDI_APPICON referencing assets/images/branding/Nebula-Favicon.ico). Include resource.h in nebula_window_win.cpp and set window_class.hIcon/hIconSm via LoadImageW. Update CMakeLists.txt to compile the .rc and add the resources include directory for Windows.
This commit is contained in:
@@ -60,6 +60,7 @@ if(OS_WINDOWS)
|
|||||||
src/platform/win/startup_win.cpp
|
src/platform/win/startup_win.cpp
|
||||||
src/platform/win/browser_host_win.cpp
|
src/platform/win/browser_host_win.cpp
|
||||||
src/platform/win/nebula_window_win.cpp
|
src/platform/win/nebula_window_win.cpp
|
||||||
|
resources/nebula.rc
|
||||||
)
|
)
|
||||||
elseif(OS_MACOSX)
|
elseif(OS_MACOSX)
|
||||||
set(NEBULA_PLATFORM_SOURCES
|
set(NEBULA_PLATFORM_SOURCES
|
||||||
@@ -156,6 +157,9 @@ function(add_nebula_app_target nebula_target entry_source)
|
|||||||
|
|
||||||
if(OS_WINDOWS)
|
if(OS_WINDOWS)
|
||||||
target_link_libraries(${nebula_target} PRIVATE dwmapi)
|
target_link_libraries(${nebula_target} PRIVATE dwmapi)
|
||||||
|
target_include_directories(${nebula_target} PRIVATE
|
||||||
|
"${CMAKE_SOURCE_DIR}/resources"
|
||||||
|
)
|
||||||
target_compile_definitions(${nebula_target} PRIVATE
|
target_compile_definitions(${nebula_target} PRIVATE
|
||||||
NOMINMAX
|
NOMINMAX
|
||||||
WIN32_LEAN_AND_MEAN
|
WIN32_LEAN_AND_MEAN
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
IDI_APPICON ICON "..\\assets\\images\\branding\\Nebula-Favicon.ico"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define IDI_APPICON 1
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
|
#include "resource.h"
|
||||||
#include "ui/paths.h"
|
#include "ui/paths.h"
|
||||||
|
|
||||||
namespace nebula::window {
|
namespace nebula::window {
|
||||||
@@ -426,6 +427,20 @@ void nebula::window::NebulaWindowImpl::RegisterClass(HINSTANCE instance_handle)
|
|||||||
window_class.lpfnWndProc = StaticWndProc;
|
window_class.lpfnWndProc = StaticWndProc;
|
||||||
window_class.hInstance = instance_handle;
|
window_class.hInstance = instance_handle;
|
||||||
window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||||
|
window_class.hIcon = static_cast<HICON>(LoadImageW(
|
||||||
|
instance_handle,
|
||||||
|
MAKEINTRESOURCEW(IDI_APPICON),
|
||||||
|
IMAGE_ICON,
|
||||||
|
GetSystemMetrics(SM_CXICON),
|
||||||
|
GetSystemMetrics(SM_CYICON),
|
||||||
|
LR_DEFAULTCOLOR));
|
||||||
|
window_class.hIconSm = static_cast<HICON>(LoadImageW(
|
||||||
|
instance_handle,
|
||||||
|
MAKEINTRESOURCEW(IDI_APPICON),
|
||||||
|
IMAGE_ICON,
|
||||||
|
GetSystemMetrics(SM_CXSMICON),
|
||||||
|
GetSystemMetrics(SM_CYSMICON),
|
||||||
|
LR_DEFAULTCOLOR));
|
||||||
window_class.lpszClassName = WindowClassName();
|
window_class.lpszClassName = WindowClassName();
|
||||||
|
|
||||||
RegisterClassExW(&window_class);
|
RegisterClassExW(&window_class);
|
||||||
|
|||||||
Reference in New Issue
Block a user