Add right-pane for item descriptions

This commit is contained in:
Irastris
2026-04-27 22:00:18 -04:00
parent e39079c0f8
commit b3333241c5
3 changed files with 45 additions and 2 deletions
+24 -1
View File
@@ -67,6 +67,21 @@ constexpr int kShadowResolutionMax = 8;
constexpr std::array<float, 5> kBloomMultiplierStops{0.0f, 0.25f, 0.50f, 0.75f, 1.00f};
constexpr std::array<const char*, 3> kBloomModeNames{"Off", "Classic", "Dusk"};
// TODO: Needs more spacing for newlines
static const char* get_description_for_item(std::string_view id) {
if (id == "internal-resolution") {
return "Auto renders at the native window resolution.\nHigher values scale the internal framebuffer.";
}
if (id == "shadow-resolution") {
return "Improves the shadow resolution, making them higher quality.";
}
if (id == "frame-interp") {
return "Uses inter-frame interpolation to enable higher frame rates.\nVisual artifacts, animation glitches, or instability may occur.";
}
return "No description found.";
}
struct Row {
std::string id;
std::function<void()> activate;
@@ -170,6 +185,7 @@ public:
}
ui::update();
sync_description_pane();
}
void ProcessEvent(Rml::Event& event) override {
@@ -199,6 +215,8 @@ private:
bool m_requestClose = false;
bool m_needsRebuild = false;
std::string m_pendingTabId;
Rml::Element* m_descriptionElement = nullptr;
Rml::Element* m_lastDescriptionSyncFocus = nullptr;
Row* find_row(std::string_view id) {
for (auto& row : m_rows) {
@@ -229,6 +247,8 @@ private:
m_options.clear();
m_rows.clear();
m_focusIds.clear();
m_descriptionElement = nullptr;
m_lastDescriptionSyncFocus = nullptr;
m_window.reset();
m_document->Close();
m_document = nullptr;
@@ -466,7 +486,7 @@ private:
add_section_header(scroll, "Display");
// RMLUI TODO: Replace this with a Display Mode toggle.
// TODO: Replace this with a Display Mode toggle.
add_toggle(scroll, "fullscreen", "Toggle Fullscreen",
getSettings().video.enableFullscreen,
[](bool enabled) { VISetWindowFullscreen(enabled); });
@@ -553,10 +573,12 @@ private:
}
void build_body() {
m_window->set_right_pane_visible(m_tab == Tab::Graphics);
Rml::Element* body = m_window->body();
switch (m_tab) {
case Tab::Graphics:
build_graphics_tab(body);
build_description_pane();
break;
default:
build_placeholder_tab(body, kTabs[static_cast<size_t>(m_tab)].label);
@@ -602,6 +624,7 @@ private:
m_document->Show();
focus_id(preferredFocus.empty() ? first_focus_id() : preferredFocus);
sync_description_pane();
}
void request_close() { m_requestClose = true; }
+16
View File
@@ -266,6 +266,22 @@ Window::Window(Rml::Element* parent, std::string_view id, std::function<void()>
{"overflow-y", "auto"},
});
m_rightPane = append(m_contentRow, "div");
set_props(m_rightPane, {
{"display", "none"},
{"flex-direction", "column"},
{"box-sizing", "border-box"},
{"min-width", "0"},
{"min-height", "0"},
{"padding-top", "24dp"},
{"padding-bottom", "24dp"},
{"padding-right", "24dp"},
{"padding-left", "8dp"},
{"align-items", "flex-start"},
{"overflow-y", "auto"},
});
apply_pane_layout();
apply_close_style();
}
+5 -1
View File
@@ -67,12 +67,16 @@ private:
Rml::Element* m_tabBar = nullptr;
Rml::Element* m_tabStrip = nullptr;
Rml::Element* m_closeButton = nullptr;
Rml::Element* m_body = nullptr;
Rml::Element* m_contentRow = nullptr;
Rml::Element* m_leftPane = nullptr;
Rml::Element* m_rightPane = nullptr;
bool m_rightPaneVisible = false;
std::function<void()> m_closeCallback;
std::vector<std::unique_ptr<WindowTab> > m_tabs;
bool m_closeHovered = false;
bool m_closeFocused = false;
void apply_close_style();
void apply_pane_layout();
};
} // namespace dusk::ui