Skip to content

Commit 698ff88

Browse files
committed
Initial icon integration. Should work on X11 and Windows (but doesn't integrate as an ICO resource), although only tested on X11 so far. Still needs work to display properly on Wayland and MacOS. Fixes #204.
1 parent 3f2bf30 commit 698ff88

File tree

7 files changed

+14
-2
lines changed

7 files changed

+14
-2
lines changed

src/ngscopeclient/AboutDialog.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ bool AboutDialog::DoRender()
9494
nullptr //userData
9595
};
9696

97+
float iconsize = 5 * ImGui::GetFontSize();
98+
float width = ImGui::GetContentRegionAvail().x;
99+
float off = (width - iconsize) * 0.5;
100+
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + off);
101+
ImGui::Image(m_parent->GetTexture("app-icon"), ImVec2(iconsize, iconsize));
102+
97103
ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_None;
98104
if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
99105
{

src/ngscopeclient/MainWindow_Icons.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,14 @@ void MainWindow::LoadAppIcon()
229229
//Wayland gets icons from the .desktop file unless you have xdg-toplevel-icon which glfw doesn't support
230230

231231
//Load the images
232-
const int nimages = 1;
232+
const int nimages = 5;
233233
GLFWimage images[nimages] =
234234
{
235-
m_texmgr.LoadPNGToGLFWImage(FindDataFile("icons/32x32/app-icon.png"))
235+
m_texmgr.LoadPNGToGLFWImage(FindDataFile("icons/16x16/app-icon.png")),
236+
m_texmgr.LoadPNGToGLFWImage(FindDataFile("icons/32x32/app-icon.png")),
237+
m_texmgr.LoadPNGToGLFWImage(FindDataFile("icons/48x48/app-icon.png")),
238+
m_texmgr.LoadPNGToGLFWImage(FindDataFile("icons/128x128/app-icon.png")),
239+
m_texmgr.LoadPNGToGLFWImage(FindDataFile("icons/256x256/app-icon.png"))
236240
};
237241

238242
//Set it as the window icon
@@ -242,6 +246,8 @@ void MainWindow::LoadAppIcon()
242246
for(auto img : images)
243247
delete[] img.pixels;
244248
#endif
249+
250+
m_texmgr.LoadTexture("app-icon", FindDataFile("icons/256x256/app-icon.png"));
245251
}
246252

247253
/**
22.7 KB
Loading
3.44 KB
Loading
79.7 KB
Loading
-1.72 KB
Loading
6.92 KB
Loading

0 commit comments

Comments
 (0)