21#include <initializer_list>
23#include <unordered_map>
71float dp(
float length);
84 StyleValues(std::initializer_list<std::pair<std::string, float>> list);
92 void addLength(
const std::string& name,
float value);
104 void setOverlay(
const std::unordered_map<std::string, float>& overlay);
107 std::unordered_map<std::string, float> base;
108 std::unordered_map<std::string, float> overlay;
109 std::unordered_map<std::string, float> values;
110 std::unordered_map<std::string, MetricKind> kinds;
bool hasMetric(const std::string &name) const
Whether the metric exists.
void addMetric(const std::string &, float value)
void setOverlay(const std::unordered_map< std::string, float > &overlay)
The theme file's metrics, over the base (empty: the base alone).
float getMetric(const std::string &name)
StyleValues(std::initializer_list< std::pair< std::string, float > > list)
The base metrics, of kind OTHER.
float getRawMetric(const std::string &name)
The metric as written, before the density.
void addLength(const std::string &name, float value)
A length of the base (kind LENGTH): it follows the density.
StyleValues(std::initializer_list< StyleMetric > list)
The base metrics, each with its kind.
MetricKind getKind(const std::string &name) const
The kind of a metric (OTHER when unknown).
Simple wrapper around StyleValues for the array operator.
Definition style.hpp:115
void addLength(const std::string &name, float value)
Adds or changes a length of the base (StyleValues::addLength).
float operator[](const std::string &name)
The metric name (getMetric()).
void addMetric(const std::string &name, float value)
Adds or changes a metric of the base (StyleValues::addMetric).
Style(StyleValues *values)
A handle on values (not owned).
bool hasMetric(const std::string &name)
Whether the metric exists.
StyleValues * getValues()
The metrics behind the handle.
Definition style.hpp:131
float getMetric(const std::string &name)
A metric; an unknown name is logged as an error and gives 0.
Definition actions.hpp:25
constexpr float DENSITY_MIN
Definition style.hpp:57
constexpr float DENSITY_DENSE
small screens
Definition style.hpp:56
MetricKind
Definition style.hpp:33
void setDensity(float density)
bool parseDensity(const std::string &text, float *density)
constexpr float DENSITY_COMFORTABLE
The density: lengths drawn that many times their size (aurore::dp()).
Definition style.hpp:54
float dp(float length)
length at the density in use: what 16dp is in XML.
constexpr float DENSITY_MAX
Definition style.hpp:58
Style getStyle()
The app's metrics: what XML reads with @style/….
float getDensity()
The density in use (DENSITY_COMFORTABLE by default).
constexpr float DENSITY_COMPACT
Definition style.hpp:55
A metric of the base, with its kind.
Definition style.hpp:40
StyleMetric(std::string name, float value, MetricKind kind)
Definition style.hpp:41
std::string name
Definition style.hpp:48
MetricKind kind
Definition style.hpp:50
float value
Definition style.hpp:49