Use menu items for titlebar buttons, so the titlebar looks better.
Some checks failed
Build / build-deb (push) Blocked by required conditions
Build / build-appimage (push) Blocked by required conditions
Build / build-android (push) Blocked by required conditions
Build / build-windows (push) Blocked by required conditions
Build / build-gentoo (push) Successful in 2m8s
Build / download-system-deps (push) Successful in 5m20s
Build / get-source-code (push) Has been cancelled
Some checks failed
Build / build-deb (push) Blocked by required conditions
Build / build-appimage (push) Blocked by required conditions
Build / build-android (push) Blocked by required conditions
Build / build-windows (push) Blocked by required conditions
Build / build-gentoo (push) Successful in 2m8s
Build / download-system-deps (push) Successful in 5m20s
Build / get-source-code (push) Has been cancelled
This commit is contained in:
parent
0bcb5d42d2
commit
553e8b58a5
1 changed files with 23 additions and 10 deletions
|
@ -498,21 +498,34 @@ void RendererBackend::EndMainMenuBar() {
|
|||
int btn_count = 3;
|
||||
ImVec2 btn_size(btnw, btnw);
|
||||
ImGui::SetCursorPosY(0);
|
||||
ImGui::SetCursorPosX(size.x - (btnw * 3));
|
||||
if (ImGui::Button(ICON_FK_WINDOW_MINIMIZE, btn_size)) {
|
||||
static const size_t titlebar_btn_count = 3;
|
||||
const char *titlebar_icons[titlebar_btn_count] = {
|
||||
ICON_FK_WINDOW_MINIMIZE,
|
||||
is_maximized() ? ICON_FK_WINDOW_RESTORE : ICON_FK_WINDOW_MAXIMIZE,
|
||||
ICON_FK_WINDOW_CLOSE
|
||||
};
|
||||
float tmp = size.x;
|
||||
float padding = ImGui::GetStyle().FramePadding.x;
|
||||
float spacing = ImGui::GetStyle().ItemSpacing.x;
|
||||
for (size_t i = 0; i < titlebar_btn_count; i++) {
|
||||
tmp += padding;
|
||||
// No need to use the correct index, as long as this is hit only once.
|
||||
if (i == 0) tmp += spacing / 2;
|
||||
else tmp += spacing;
|
||||
tmp += ImGui::CalcTextSize(titlebar_icons[i]).x;
|
||||
}
|
||||
title_btn_start = std::ceil(tmp);
|
||||
ImGui::SetCursorPosX(title_btn_start);
|
||||
if (ImGui::MenuItem(titlebar_icons[0])) {
|
||||
SDL_MinimizeWindow(window);
|
||||
}
|
||||
ImGui::SetCursorPosX(size.x - (btnw * 2));
|
||||
if (is_maximized()) {
|
||||
if (ImGui::Button(ICON_FK_WINDOW_RESTORE, btn_size)) SDL_RestoreWindow(window);
|
||||
} else {
|
||||
if (ImGui::Button(ICON_FK_WINDOW_MAXIMIZE, btn_size)) SDL_MaximizeWindow(window);
|
||||
if (ImGui::MenuItem(titlebar_icons[1])) {
|
||||
if (is_maximized()) SDL_RestoreWindow(window);
|
||||
else SDL_MaximizeWindow(window);
|
||||
}
|
||||
ImGui::SetCursorPosX(size.x - btnw);
|
||||
if (ImGui::Button(ICON_FK_WINDOW_CLOSE, btn_size)) {
|
||||
if (ImGui::MenuItem(titlebar_icons[2])) {
|
||||
done = true;
|
||||
}
|
||||
title_btn_start = size.x - (btnw * 3);
|
||||
#endif
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue