Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[core] Rationalize style property classes #2705

Merged
merged 1 commit into from
Oct 22, 2015
Merged

[core] Rationalize style property classes #2705

merged 1 commit into from
Oct 22, 2015

Conversation

jfirebaugh
Copy link
Contributor

This is the first in a series of PRs that builds towards a full-fledged programmatic style API. This is a big chunk of work, but I'm trying to break it up step by step and not create a long-lived branch with a lot of changes.

Overall, my first major goal is to eliminate ClassProperties -- this is essentially an untyped map of every possible style property. Instead, we should work with classes like:

class FillPaintProperties {
public:
    bool antialias = true;
    float opacity = 1.0f;
    Color fill_color = {{ 0, 0, 0, 1 }};
    Color stroke_color = {{ 0, 0, 0, -1 }};
    std::array<float, 2> translate = {{ 0, 0 }};
    TranslateAnchorType translateAnchor = TranslateAnchorType::Map;
    Faded<std::string> image;

    inline bool isVisible() const {
        return opacity > 0 && (fill_color[3] > 0 || stroke_color[3] > 0);
    }
};

These classes already exist, they are just inconsistently named. This PR makes the naming both internally consistent, and consistent with terminology from the style specification: for each layer type, there is a ____PaintProperties class and a ____LayoutProperties class. For the time being, all of these classes live in style_properties.hpp.

In code that I touch, I'm also fixing style issues like & placement and variable naming conventions. This will be the case with the whole series of PRs.

👀 @kkaefer @brunoabinader

CirclePaintProperties,
SymbolPaintProperties,
RasterPaintProperties,
BackgroundPaintProperties,
std::false_type
> StyleProperties;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this to StylePaintProperties?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's going away in the next commit, so I held off.

@kkaefer
Copy link
Member

kkaefer commented Oct 22, 2015

Looks good!

@brunoabinader
Copy link
Member

It is great that now layout properties are now exported to the public API. 👍 !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants