mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-05-23 06:34:15 -04:00
UI: Avoid overlapping ImGui menu bar
This commit is contained in:
@@ -23,7 +23,6 @@ popup {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
width: 100%;
|
||||
height: 64dp;
|
||||
background-color: rgba(21, 22, 16, 80%);
|
||||
border-bottom: 2dp #92875B;
|
||||
|
||||
+13
-4
@@ -3,15 +3,14 @@
|
||||
#include <RmlUi/Core.h>
|
||||
|
||||
#include "aurora/rmlui.hpp"
|
||||
#include "dusk/main.h"
|
||||
#include "editor.hpp"
|
||||
#include "imgui.h"
|
||||
#include "settings.hpp"
|
||||
#include "ui.hpp"
|
||||
#include "window.hpp"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "dusk/main.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace dusk::ui {
|
||||
@@ -47,7 +46,9 @@ Popup::Popup() : Document(kDocumentSource), mRoot(mDocument->GetElementById("pop
|
||||
|
||||
// Hide document after transition completion
|
||||
listen(mRoot, Rml::EventId::Transitionend, [this](Rml::Event& event) {
|
||||
if (event.GetTargetElement() == mRoot && !mRoot->HasAttribute("open") && Document::visible()) {
|
||||
if (event.GetTargetElement() == mRoot && !mRoot->HasAttribute("open") &&
|
||||
Document::visible())
|
||||
{
|
||||
Document::hide(mPendingClose);
|
||||
}
|
||||
});
|
||||
@@ -79,6 +80,14 @@ void Popup::update_safe_area() noexcept {
|
||||
return;
|
||||
}
|
||||
|
||||
// Avoid ImGui menu bar if shown
|
||||
if (const auto* viewport = ImGui::GetMainViewport();
|
||||
viewport != nullptr && mTopMargin != viewport->WorkPos.y)
|
||||
{
|
||||
mTopMargin = viewport->WorkPos.y;
|
||||
mRoot->SetProperty(Rml::PropertyId::MarginTop, Rml::Property(mTopMargin, Rml::Unit::DP));
|
||||
}
|
||||
|
||||
Rml::Context* context = mDocument->GetContext();
|
||||
Insets safeInsets = safe_area_insets(context);
|
||||
safeInsets = {
|
||||
|
||||
@@ -31,6 +31,7 @@ private:
|
||||
std::unique_ptr<TabBar> mTabBar;
|
||||
std::unique_ptr<Button> mCloseButton;
|
||||
Insets mTabBarPadding;
|
||||
float mTopMargin = 0.f;
|
||||
};
|
||||
|
||||
} // namespace dusk::ui
|
||||
|
||||
@@ -96,7 +96,7 @@ bool is_selected_path_valid() noexcept {
|
||||
void open_iso_picker() noexcept {
|
||||
ensure_initialized();
|
||||
ShowFileSelect(&file_dialog_callback, nullptr, aurora::window::get_sdl_window(),
|
||||
kDiscFileFilters.data(), static_cast<int>(kDiscFileFilters.size()), nullptr, false);
|
||||
kDiscFileFilters.data(), kDiscFileFilters.size(), nullptr, false);
|
||||
}
|
||||
|
||||
void apply_intro_animation(Rml::Element* element, const char* delay_class) {
|
||||
@@ -200,7 +200,7 @@ void Prelaunch::update() {
|
||||
if (mDiscDetail != nullptr) {
|
||||
if (hasValidPath) {
|
||||
mDiscDetail->SetProperty(Rml::PropertyId::Display, Rml::Style::Display::Block);
|
||||
mDiscDetail->SetInnerRML(prelaunch_state().isPal ? "GameCube • PAL" : "GameCube • USA");
|
||||
mDiscDetail->SetInnerRML(state.isPal ? "GameCube • PAL" : "GameCube • USA");
|
||||
} else {
|
||||
mDiscDetail->SetProperty(Rml::PropertyId::Display, Rml::Style::Display::None);
|
||||
}
|
||||
@@ -234,13 +234,13 @@ bool Prelaunch::handle_nav_command(Rml::Event& event, NavCommand cmd) {
|
||||
}
|
||||
auto* target = event.GetTargetElement();
|
||||
int focusedButton = -1;
|
||||
for (size_t i = 0; i < mMenuButtons.size(); ++i) {
|
||||
for (int i = 0; i < mMenuButtons.size(); ++i) {
|
||||
if (mMenuButtons[i]->contains(target)) {
|
||||
focusedButton = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int i = (focusedButton + direction) % mMenuButtons.size();
|
||||
int i = (focusedButton + direction) % static_cast<int>(mMenuButtons.size());
|
||||
while (i >= 0 && i < mMenuButtons.size()) {
|
||||
if (mMenuButtons[i]->focus()) {
|
||||
event.StopPropagation();
|
||||
|
||||
Reference in New Issue
Block a user