Add the ability to specify properties and requiring confirmation (#3006)

This commit is contained in:
Alexander Bock
2024-02-15 15:56:19 +09:00
parent f9a01d507e
commit 815dfe11f1
5 changed files with 34 additions and 2 deletions

View File

@@ -381,6 +381,17 @@ public:
*/
void setReadOnly(bool state);
/**
* This method determines if this Property requires confirmation upon every change of
* the value. This setting is only a hint and does not need to be followed by GUI
* applications and does not have any effect on the Property::set or
* Property::setLuaValue methods. The value is stored in the metaData Dictionary with
* the key: `needsConfirmation`. The default value is `false`.
*
* \param state `true` if the Property needs confirmation, `false` otherwise
*/
void setNeedsConfirmation(bool state);
/**
* Default view options that can be used in the Property::setViewOption method. The
* values are:

View File

@@ -316,6 +316,8 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& data, const Deferred
ghoul::opengl::ProgramObject& prg)
{
ZoneScoped;
TracyGpuZone("Atmosphere preRaycast");
// Atmosphere Frustum Culling
glm::dvec3 tPlanetPos = glm::dvec3(_modelTransform * glm::dvec4(0.0, 0.0, 0.0, 1.0));
@@ -521,6 +523,8 @@ void AtmosphereDeferredcaster::postRaycast(const RenderData&, const Deferredcast
{
ZoneScoped;
TracyGpuZone("Atmosphere postRaycast");
// Deactivate the texture units
_transmittanceTableTextureUnit.deactivate();
_irradianceTableTextureUnit.deactivate();

View File

@@ -118,6 +118,8 @@ void BrowserInstance::reshape(const glm::ivec2& windowSize) {
void BrowserInstance::draw() {
ZoneScoped;
TracyGpuZone("CEF Draw");
if (_zoomLevel != _browser->GetHost()->GetZoomLevel()) {
_browser->GetHost()->SetZoomLevel(_zoomLevel);

View File

@@ -34,6 +34,7 @@
namespace {
constexpr std::string_view MetaDataKeyGroup = "Group";
constexpr std::string_view MetaDataKeyReadOnly = "isReadOnly";
constexpr std::string_view MetaDataKeyNeedsConfirmation = "needsConfirmation";
constexpr std::string_view MetaDataKeyViewOptions = "ViewOptions";
constexpr std::string_view MetaDataKeyVisibility = "Visibility";
@@ -150,6 +151,10 @@ void Property::setReadOnly(bool state) {
_metaData.setValue(std::string(MetaDataKeyReadOnly), state);
}
void Property::setNeedsConfirmation(bool state) {
_metaData.setValue(std::string(MetaDataKeyNeedsConfirmation), state);
}
void Property::setViewOption(std::string option, bool value) {
ghoul::Dictionary d;
d.setValue(option, value);
@@ -295,6 +300,12 @@ std::string Property::generateMetaDataJsonDescription() const {
}
std::string isReadOnlyString = (isReadOnly ? "true" : "false");
bool needsConfirmation = false;
if (_metaData.hasValue<bool>(MetaDataKeyNeedsConfirmation)) {
needsConfirmation = _metaData.value<bool>(MetaDataKeyNeedsConfirmation);
}
std::string needsConfirmationString = (needsConfirmation ? "true" : "false");
std::string groupId = groupIdentifier();
std::string sanitizedGroupId = escapedJson(groupId);
@@ -306,10 +317,11 @@ std::string Property::generateMetaDataJsonDescription() const {
}
std::string result = fmt::format(
R"({{"{}":"{}","{}":"{}","{}":{},"{}":{}}})",
R"({{"{}":"{}","{}":"{}","{}":{},"{}":{},"{}":{}}})",
MetaDataKeyGroup, sanitizedGroupId,
MetaDataKeyVisibility, vis,
MetaDataKeyReadOnly, isReadOnlyString,
MetaDataKeyNeedsConfirmation, needsConfirmationString,
MetaDataKeyViewOptions, viewOptions
);
return result;

View File

@@ -914,7 +914,10 @@ Asset* AssetManager::retrieveAsset(const std::filesystem::path& path,
}
if (!std::filesystem::is_regular_file(path)) {
throw ghoul::RuntimeError(fmt::format("Could not find asset file {}", path));
throw ghoul::RuntimeError(fmt::format(
"Could not find asset file {} requested by {}",
path, retriever
));
}
auto asset = std::make_unique<Asset>(*this, path, explicitEnable);
Asset* res = asset.get();