Can now add scoped rcss files
This commit is contained in:
14
src/app.cpp
14
src/app.cpp
@@ -2,6 +2,7 @@
|
||||
#include <RmlUi/Core/Core.h>
|
||||
#include <RmlUi/Core/Factory.h>
|
||||
#include <RmlUi/Lua/Interpreter.h>
|
||||
#include <RmlUi/Core/StyleSheetContainer.h>
|
||||
#include <RmlUi/Lua.h>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
@@ -98,6 +99,17 @@ bool App::NavigateTo(const std::string &pageName) {
|
||||
} else {
|
||||
std::cout << "[WARN] failed to create data model for page '" << pageName << "'\n";
|
||||
}
|
||||
|
||||
std::string rcssPath = GetAssetsPath() + "/pages/" + pageName + ".rcss";
|
||||
if (std::filesystem::exists(rcssPath)) {
|
||||
auto pageStyleSheet = Rml::Factory::InstanceStyleSheetFile(rcssPath);
|
||||
if (pageStyleSheet && baseStyleSheet) {
|
||||
auto combined = baseStyleSheet->CombineStyleSheetContainer(*pageStyleSheet);
|
||||
doc->SetStyleSheetContainer(combined);
|
||||
}
|
||||
} else if (doc && baseStyleSheet) {
|
||||
doc->SetStyleSheetContainer(baseStyleSheet);
|
||||
}
|
||||
|
||||
pageOutlet->SetInnerRML(content);
|
||||
|
||||
@@ -125,6 +137,8 @@ bool App::LoadUi() {
|
||||
std::cout << "[WARN] main.rml has no element with id=\"page-content\"\n";
|
||||
}
|
||||
|
||||
baseStyleSheet = Rml::Factory::InstanceStyleSheetFile(GetAssetsPath() + "/styles/main.rcss");
|
||||
|
||||
listeners.clear();
|
||||
if (onBindListeners) {
|
||||
onBindListeners(doc);
|
||||
|
||||
Reference in New Issue
Block a user