diff --git a/CMake/FileList.cmake b/CMake/FileList.cmake index cfb5c5c1a..96253b93e 100644 --- a/CMake/FileList.cmake +++ b/CMake/FileList.cmake @@ -21,8 +21,8 @@ set(Core_HDR_FILES ${PROJECT_SOURCE_DIR}/Source/Core/DocumentHeader.h ${PROJECT_SOURCE_DIR}/Source/Core/ElementAnimation.h ${PROJECT_SOURCE_DIR}/Source/Core/ElementBackgroundBorder.h - ${PROJECT_SOURCE_DIR}/Source/Core/ElementDecoration.h ${PROJECT_SOURCE_DIR}/Source/Core/ElementDefinition.h + ${PROJECT_SOURCE_DIR}/Source/Core/ElementEffects.h ${PROJECT_SOURCE_DIR}/Source/Core/ElementHandle.h ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementImage.h ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementLabel.h @@ -277,9 +277,9 @@ set(Core_SRC_FILES ${PROJECT_SOURCE_DIR}/Source/Core/Element.cpp ${PROJECT_SOURCE_DIR}/Source/Core/ElementAnimation.cpp ${PROJECT_SOURCE_DIR}/Source/Core/ElementBackgroundBorder.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/ElementDecoration.cpp ${PROJECT_SOURCE_DIR}/Source/Core/ElementDefinition.cpp ${PROJECT_SOURCE_DIR}/Source/Core/ElementDocument.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/ElementEffects.cpp ${PROJECT_SOURCE_DIR}/Source/Core/ElementHandle.cpp ${PROJECT_SOURCE_DIR}/Source/Core/ElementInstancer.cpp ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementForm.cpp diff --git a/Include/RmlUi/Core/EffectSpecification.h b/Include/RmlUi/Core/EffectSpecification.h index fde117e66..84b8340f0 100644 --- a/Include/RmlUi/Core/EffectSpecification.h +++ b/Include/RmlUi/Core/EffectSpecification.h @@ -47,18 +47,19 @@ class RMLUICORE_API EffectSpecification { protected: ~EffectSpecification(); - /// Registers a property for the decorator. + /// Registers a property for the effect. /// @param[in] property_name The name of the new property (how it is specified through RCSS). /// @param[in] default_value The default value to be used. /// @return The new property definition, ready to have parsers attached. PropertyDefinition& RegisterProperty(const String& property_name, const String& default_value); - /// Registers a shorthand property definition. Specify a shorthand name of 'decorator' to parse anonymous decorators. + /// Registers a shorthand property definition. Specify a shorthand name of 'decorator' or 'filter' to parse + /// anonymous decorators or filters, respectively. /// @param[in] shorthand_name The name to register the new shorthand property under. - /// @param[in] properties A comma-separated list of the properties this definition is shorthand for. The order in which they are specified here is - /// the order in which the values will be processed. + /// @param[in] properties A comma-separated list of the properties this definition is shorthand for. The order in + /// which they are specified here is the order in which the values will be processed. /// @param[in] type The type of shorthand to declare. - /// @param True if all the property names exist, false otherwise. + /// @return An ID for the new shorthand, or 'Invalid' if the shorthand declaration is invalid. ShorthandId RegisterShorthand(const String& shorthand_name, const String& property_names, ShorthandType type); private: diff --git a/Include/RmlUi/Core/Element.h b/Include/RmlUi/Core/Element.h index 42830a03b..0f60fed35 100644 --- a/Include/RmlUi/Core/Element.h +++ b/Include/RmlUi/Core/Element.h @@ -51,7 +51,6 @@ class ElementInstancer; class EventDispatcher; class EventListener; class ElementBackgroundBorder; -class ElementDecoration; class ElementDefinition; class ElementDocument; class ElementScroll; @@ -578,8 +577,6 @@ class RMLUICORE_API Element : public ScriptInterface, public EnableObserverPtr attribute_event_listeners; EventDispatcher event_dispatcher; ElementStyle style; ElementBackgroundBorder background_border; - ElementDecoration decoration; + ElementEffects effects; ElementScroll scroll; Style::ComputedValues computed_values; }; @@ -177,7 +177,7 @@ void Element::Update(float dp_ratio, Vector2f vp_dimensions) UpdateProperties(dp_ratio, vp_dimensions); } - meta->decoration.InstanceDecorators(); + meta->effects.InstanceEffects(); for (size_t i = 0; i < children.size(); i++) children[i]->Update(dp_ratio, vp_dimensions); @@ -233,13 +233,13 @@ void Element::Render() // Apply our transform ElementUtilities::ApplyTransform(*this); - meta->decoration.RenderDecorators(RenderStage::Enter); + meta->effects.RenderEffects(RenderStage::Enter); // Set up the clipping region for this element. if (ElementUtilities::SetClippingRegion(this)) { meta->background_border.Render(this); - meta->decoration.RenderDecorators(RenderStage::Decoration); + meta->effects.RenderEffects(RenderStage::Decoration); { RMLUI_ZoneScopedNC("OnRender", 0x228B22); @@ -252,7 +252,7 @@ void Element::Render() for (Element* element : stacking_context) element->Render(); - meta->decoration.RenderDecorators(RenderStage::Exit); + meta->effects.RenderEffects(RenderStage::Exit); } ElementPtr Element::Clone() const @@ -452,7 +452,7 @@ void Element::SetBox(const Box& box) meta->background_border.DirtyBackground(); meta->background_border.DirtyBorder(); - meta->decoration.DirtyDecoratorsData(); + meta->effects.DirtyEffectsData(); } } @@ -464,7 +464,7 @@ void Element::AddBox(const Box& box, Vector2f offset) meta->background_border.DirtyBackground(); meta->background_border.DirtyBorder(); - meta->decoration.DirtyDecoratorsData(); + meta->effects.DirtyEffectsData(); } const Box& Element::GetBox() @@ -1553,11 +1553,6 @@ ElementBackgroundBorder* Element::GetElementBackgroundBorder() const return &meta->background_border; } -ElementDecoration* Element::GetElementDecoration() const -{ - return &meta->decoration; -} - ElementScroll* Element::GetElementScroll() const { return &meta->scroll; @@ -1795,18 +1790,18 @@ void Element::OnPropertyChange(const PropertyIdSet& changed_properties) meta->background_border.DirtyBorder(); } - // Dirty the decoration if it's changed. + // Dirty the effects if they've changed. if (border_radius_changed || filter_or_mask_changed || changed_properties.Contains(PropertyId::Decorator)) { - meta->decoration.DirtyDecorators(); + meta->effects.DirtyEffects(); } - // Dirty the decoration data when its visual looks may have changed. + // Dirty the effects data when their visual looks may have changed. if (border_radius_changed || // changed_properties.Contains(PropertyId::Opacity) || // changed_properties.Contains(PropertyId::ImageColor)) { - meta->decoration.DirtyDecoratorsData(); + meta->effects.DirtyEffectsData(); } // Check for `perspective' and `perspective-origin' changes @@ -2813,7 +2808,7 @@ void Element::UpdateTransformState() void Element::OnStyleSheetChangeRecursive() { - GetElementDecoration()->DirtyDecorators(); + meta->effects.DirtyEffects(); OnStyleSheetChange(); @@ -2825,7 +2820,7 @@ void Element::OnStyleSheetChangeRecursive() void Element::OnDpRatioChangeRecursive() { - GetElementDecoration()->DirtyDecorators(); + meta->effects.DirtyEffects(); GetStyle()->DirtyPropertiesWithUnits(Unit::DP_SCALABLE_LENGTH); OnDpRatioChange(); diff --git a/Source/Core/ElementDecoration.cpp b/Source/Core/ElementEffects.cpp similarity index 93% rename from Source/Core/ElementDecoration.cpp rename to Source/Core/ElementEffects.cpp index fd62e88fe..3c47d86ce 100644 --- a/Source/Core/ElementDecoration.cpp +++ b/Source/Core/ElementEffects.cpp @@ -26,7 +26,7 @@ * */ -#include "ElementDecoration.h" +#include "ElementEffects.h" #include "../../Include/RmlUi/Core/ComputedValues.h" #include "../../Include/RmlUi/Core/Decorator.h" #include "../../Include/RmlUi/Core/Element.h" @@ -38,23 +38,23 @@ namespace Rml { -ElementDecoration::ElementDecoration(Element* _element) : element(_element) {} +ElementEffects::ElementEffects(Element* _element) : element(_element) {} -ElementDecoration::~ElementDecoration() +ElementEffects::~ElementEffects() { - ReleaseDecorators(); + ReleaseEffects(); } -void ElementDecoration::InstanceDecorators() +void ElementEffects::InstanceEffects() { - if (!decorators_dirty) + if (!effects_dirty) return; - decorators_dirty = false; - decorators_data_dirty = true; + effects_dirty = false; + effects_data_dirty = true; RMLUI_ZoneScopedC(0xB22222); - ReleaseDecorators(); + ReleaseEffects(); RenderManager* render_manager = element->GetRenderManager(); if (!render_manager) @@ -151,11 +151,11 @@ void ElementDecoration::InstanceDecorators() } } -void ElementDecoration::ReloadDecoratorsData() +void ElementEffects::ReloadEffectsData() { - if (decorators_data_dirty) + if (effects_data_dirty) { - decorators_data_dirty = false; + effects_data_dirty = false; bool decorator_data_failed = false; for (DecoratorEntryList* list : {&decorators, &mask_images}) @@ -190,7 +190,7 @@ void ElementDecoration::ReloadDecoratorsData() } } -void ElementDecoration::ReleaseDecorators() +void ElementEffects::ReleaseEffects() { for (DecoratorEntryList* list : {&decorators, &mask_images}) { @@ -206,10 +206,10 @@ void ElementDecoration::ReleaseDecorators() backdrop_filters.clear(); } -void ElementDecoration::RenderDecorators(RenderStage render_stage) +void ElementEffects::RenderEffects(RenderStage render_stage) { - InstanceDecorators(); - ReloadDecoratorsData(); + InstanceEffects(); + ReloadEffectsData(); if (!decorators.empty()) { @@ -286,7 +286,7 @@ void ElementDecoration::RenderDecorators(RenderStage render_stage) // boundaries, which currently only applies to blur and drop-shadow. Alternatively, we could avoid this // completely if we introduced a render interface API concept of different input and output clipping. That // is, we set a large input scissor to cover all input data, which can be used e.g. during blurring, and use - // our small border-area-only clipping region for the layers composite output. + // our small border-area-only clipping region for the composite layers output. ApplyScissorRegionForBackdrop(); render_manager->PushLayer(); const LayerHandle backdrop_temp_layer = render_manager->GetTopLayer(); @@ -340,14 +340,14 @@ void ElementDecoration::RenderDecorators(RenderStage render_stage) } } -void ElementDecoration::DirtyDecorators() +void ElementEffects::DirtyEffects() { - decorators_dirty = true; + effects_dirty = true; } -void ElementDecoration::DirtyDecoratorsData() +void ElementEffects::DirtyEffectsData() { - decorators_data_dirty = true; + effects_data_dirty = true; } } // namespace Rml diff --git a/Source/Core/ElementDecoration.h b/Source/Core/ElementEffects.h similarity index 69% rename from Source/Core/ElementDecoration.h rename to Source/Core/ElementEffects.h index 636a23144..5420cdb06 100644 --- a/Source/Core/ElementDecoration.h +++ b/Source/Core/ElementEffects.h @@ -26,11 +26,10 @@ * */ -#ifndef RMLUI_CORE_ELEMENTDECORATION_H -#define RMLUI_CORE_ELEMENTDECORATION_H +#ifndef RMLUI_CORE_ELEMENTEFFECTS_H +#define RMLUI_CORE_ELEMENTEFFECTS_H #include "../../Include/RmlUi/Core/CompiledFilterShader.h" -#include "../../Include/RmlUi/Core/Filter.h" #include "../../Include/RmlUi/Core/Types.h" namespace Rml { @@ -38,37 +37,32 @@ namespace Rml { class Decorator; class Element; class Filter; -class CompiledFilter; enum class RenderStage { Enter, Decoration, Exit }; /** - Manages an elements decorator state - - @author Lloyd Weehuizen + Manages and renders an element's effects: decorators, filters, backdrop filters, and mask images. */ -class ElementDecoration { +class ElementEffects { public: - ElementDecoration(Element* element); - ~ElementDecoration(); + ElementEffects(Element* element); + ~ElementEffects(); - /// Instances decorators if necessary. - void InstanceDecorators(); + void InstanceEffects(); - /// Renders all appropriate decorators. - void RenderDecorators(RenderStage render_stage); + void RenderEffects(RenderStage render_stage); - /// Mark decorators as dirty and force them to reset themselves. - void DirtyDecorators(); - /// Mark the element data of decorators as dirty. - void DirtyDecoratorsData(); + // Mark effects as dirty and force them to reset themselves. + void DirtyEffects(); + // Mark the element data of effects as dirty. + void DirtyEffectsData(); private: - // Releases existing element data of decorators, and regenerates it. - void ReloadDecoratorsData(); - // Releases all existing decorators and frees their data. - void ReleaseDecorators(); + // Releases existing element data of effects, and regenerates it. + void ReloadEffectsData(); + // Releases all existing effects and their element data. + void ReleaseEffects(); struct DecoratorEntry { SharedPtr decorator; @@ -85,16 +79,16 @@ class ElementDecoration { Element* element; - // The list of decorators and filters used by this element from all style rules. + // The list of decorators and filters used by this element. DecoratorEntryList decorators; DecoratorEntryList mask_images; FilterEntryList filters; FilterEntryList backdrop_filters; // If set, a full reload is necessary. - bool decorators_dirty = false; + bool effects_dirty = false; // If set, element data of all decorators need to be regenerated. - bool decorators_data_dirty = false; + bool effects_data_dirty = false; }; } // namespace Rml diff --git a/Source/Core/ElementStyle.cpp b/Source/Core/ElementStyle.cpp index e24197296..492c3202d 100644 --- a/Source/Core/ElementStyle.cpp +++ b/Source/Core/ElementStyle.cpp @@ -44,7 +44,6 @@ #include "../../Include/RmlUi/Core/StyleSheetSpecification.h" #include "../../Include/RmlUi/Core/TransformPrimitive.h" #include "ComputeProperty.h" -#include "ElementDecoration.h" #include "ElementDefinition.h" #include "PropertiesIterator.h" #include diff --git a/Source/Core/ElementUtilities.cpp b/Source/Core/ElementUtilities.cpp index f38f605ba..3126fa210 100644 --- a/Source/Core/ElementUtilities.cpp +++ b/Source/Core/ElementUtilities.cpp @@ -290,7 +290,7 @@ bool ElementUtilities::GetBoundingBox(Rectanglef& out_rectangle, Element* elemen if (box_area == BoxArea::Auto) { // 'Auto' acts like border box extended to encompass any ink overflow, including the element's box-shadow. - // Note: Does not currently include ink overflow due to filters, as that is handled manually in ElementDecoration. + // Note: Does not currently include ink overflow due to filters, as that is handled manually in ElementEffects. box_area = BoxArea::Border; if (const Property* p_box_shadow = element->GetLocalProperty(PropertyId::BoxShadow))