Bladeren bron

Rename logical pixel (lp) to density-independent pixel (dp)

Michael 8 jaren geleden
bovenliggende
commit
ed39b743ff

+ 7 - 7
Include/Rocket/Core/Context.h

@@ -80,12 +80,12 @@ public:
 	/// @return The current dimensions of the context.
 	const Vector2i& GetDimensions() const;
 
-	/// Changes the size ratio of 'lp' unit to 'px' unit
-	/// @param[in] dimensions The new logical pixel ratio of the context.
-	void SetLogicalPixelRatio(float logical_pixel_ratio);
-	/// Returns the size ratio of 'lp' unit to 'px' unit
-	/// @return The current logical pixel ratio of the context.
-	float GetLogicalPixelRatio() const;
+	/// Changes the size ratio of 'dp' unit to 'px' unit
+	/// @param[in] dimensions The new density-independent pixel ratio of the context.
+	void SetDensityIndependentPixelRatio(float density_independent_pixel_ratio);
+	/// Returns the size ratio of 'dp' unit to 'px' unit
+	/// @return The current density-independent pixel ratio of the context.
+	float GetDensityIndependentPixelRatio() const;
 
 	/// Updates all elements in the context's documents.
 	bool Update();
@@ -238,7 +238,7 @@ protected:
 private:
 	String name;
 	Vector2i dimensions;
-	float logical_pixel_ratio;
+	float density_independent_pixel_ratio;
 
 	ContextInstancer* instancer;
 

+ 1 - 1
Include/Rocket/Core/ElementDocument.h

@@ -148,7 +148,7 @@ protected:
 	virtual bool IsLayoutDirty();
 
 	/// Updates all sizes defined by the 'lp' unit.
-	virtual void DirtyLpProperties();
+	virtual void DirtyDpProperties();
 
 	/// Processes the 'onpropertychange' event, checking for a change in position or size.
 	virtual void ProcessEvent(Event& event);

+ 4 - 4
Include/Rocket/Core/ElementUtilities.h

@@ -81,10 +81,10 @@ public:
 	/// @param[in] element The element to determine the font face for.
 	/// @return The element's font face. This will be NULL if no valid RCSS font styles have been set up for this element.
 	static FontFaceHandle* GetFontFaceHandle(Element* element);
-	/// Returns an element's logical pixel ratio, defined by it's context
-	/// @param[in] element The element to determine the logical pixel ratio for.
-	/// @return The logical pixel ratio of the context, or 1.0 if no context assigned.
-	static float GetLogicalPixelRatio(Element* element);
+	/// Returns an element's density-independent pixel ratio, defined by it's context
+	/// @param[in] element The element to determine the density-independent pixel ratio for.
+	/// @return The density-independent pixel ratio of the context, or 1.0 if no context assigned.
+	static float GetDensityIndependentPixelRatio(Element* element);
 	/// Returns an element's font size, if it has a font defined.
 	/// @param[in] element The element to determine the font size for.
 	/// @return The font size as determined by the element's font, or 0 if it has no font specified.

+ 2 - 2
Include/Rocket/Core/Property.h

@@ -70,8 +70,8 @@ public:
 		PPI_UNIT = INCH | CM | MM | PT | PC,
 
 		REM = 1 << 13,				// number suffixed by 'rem'; fetch as < float >
-		LP = 1 << 14,				// logical pixel; number suffixed by 'lp'; fetch as < float >
-		RELATIVE_UNIT = EM | REM | PERCENT | LP
+		DP = 1 << 14,				// density-independent pixel; number suffixed by 'dp'; fetch as < float >
+		RELATIVE_UNIT = EM | REM | PERCENT | DP
 	};
 
 	Property();

+ 7 - 7
Source/Core/Context.cpp

@@ -40,7 +40,7 @@ namespace Core {
 
 const float DOUBLE_CLICK_TIME = 0.5f;
 
-Context::Context(const String& name) : name(name), dimensions(0, 0), logical_pixel_ratio(1.0f), mouse_position(0, 0), clip_origin(-1, -1), clip_dimensions(-1, -1)
+Context::Context(const String& name) : name(name), dimensions(0, 0), density_independent_pixel_ratio(1.0f), mouse_position(0, 0), clip_origin(-1, -1), clip_dimensions(-1, -1)
 {
 	instancer = NULL;
 
@@ -132,26 +132,26 @@ const Vector2i& Context::GetDimensions() const
 	return dimensions;
 }
 
-void Context::SetLogicalPixelRatio(float _logical_pixel_ratio)
+void Context::SetDensityIndependentPixelRatio(float _density_independent_pixel_ratio)
 {
-	if (logical_pixel_ratio != _logical_pixel_ratio)
+	if (density_independent_pixel_ratio != _density_independent_pixel_ratio)
 	{
-		logical_pixel_ratio = _logical_pixel_ratio;
+		density_independent_pixel_ratio = _density_independent_pixel_ratio;
 
 		for (int i = 0; i < root->GetNumChildren(); ++i)
 		{
 			ElementDocument* document = root->GetChild(i)->GetOwnerDocument();
 			if (document != NULL)
 			{
-				document->DirtyLpProperties();
+				document->DirtyDpProperties();
 			}
 		}
 	}
 }
 
-float Context::GetLogicalPixelRatio() const
+float Context::GetDensityIndependentPixelRatio() const
 {
-	return logical_pixel_ratio;
+	return density_independent_pixel_ratio;
 }
 
 // Updates all elements in the element tree.

+ 2 - 2
Source/Core/ElementDocument.cpp

@@ -361,9 +361,9 @@ bool ElementDocument::IsLayoutDirty()
 	return layout_dirty;
 }
 
-void ElementDocument::DirtyLpProperties()
+void ElementDocument::DirtyDpProperties()
 {
-	GetStyle()->DirtyLpProperties();
+	GetStyle()->DirtyDpProperties();
 }
 
 // Refreshes the document layout if required.

+ 13 - 13
Source/Core/ElementStyle.cpp

@@ -358,8 +358,8 @@ float ElementStyle::ResolveProperty(const Property* property, float base_value)
 			return property->value.Get< float >() * ElementUtilities::GetFontSize(element);
 		else if (property->unit & Property::REM)
 			return property->value.Get< float >() * ElementUtilities::GetFontSize(element->GetOwnerDocument());
-		else if (property->unit & Property::LP)
-			return property->value.Get< float >() * ElementUtilities::GetLogicalPixelRatio(element);
+		else if (property->unit & Property::DP)
+			return property->value.Get< float >() * ElementUtilities::GetDensityIndependentPixelRatio(element);
 	}
 
 	if (property->unit & Property::NUMBER || property->unit & Property::PX)
@@ -398,9 +398,9 @@ float ElementStyle::ResolveProperty(const String& name, float base_value)
 		return 0.0f;
 	}
 
-	if (property->unit & Property::LP)
+	if (property->unit & Property::DP)
 	{
-		return property->value.Get< float >() * ElementUtilities::GetLogicalPixelRatio(element);
+		return property->value.Get< float >() * ElementUtilities::GetDensityIndependentPixelRatio(element);
 	}
 
 	if (property->unit & Property::RELATIVE_UNIT)
@@ -635,25 +635,25 @@ void ElementStyle::DirtyRemProperties()
 		element->GetChild(i)->GetStyle()->DirtyRemProperties();
 }
 
-void ElementStyle::DirtyLpProperties()
+void ElementStyle::DirtyDpProperties()
 {
 	const PropertyNameList &properties = StyleSheetSpecification::GetRegisteredProperties();
-	PropertyNameList lp_properties;
+	PropertyNameList dp_properties;
 
-	// Dirty all the properties of this element that use the lp unit.
+	// Dirty all the properties of this element that use the dp unit.
 	for (PropertyNameList::const_iterator list_iterator = properties.begin(); list_iterator != properties.end(); ++list_iterator)
 	{
-		if (element->GetProperty(*list_iterator)->unit == Property::LP)
-			lp_properties.insert(*list_iterator);
+		if (element->GetProperty(*list_iterator)->unit == Property::DP)
+			dp_properties.insert(*list_iterator);
 	}
 
-	if (!lp_properties.empty())
-		DirtyProperties(lp_properties, false);
+	if (!dp_properties.empty())
+		DirtyProperties(dp_properties, false);
 
-	// Now dirty all of our descendant's properties that use the lp unit.
+	// Now dirty all of our descendant's properties that use the dp unit.
 	int num_children = element->GetNumChildren(true);
 	for (int i = 0; i < num_children; ++i)
-		element->GetChild(i)->GetStyle()->DirtyLpProperties();
+		element->GetChild(i)->GetStyle()->DirtyDpProperties();
 }
 
 // Sets a single property as dirty.

+ 2 - 2
Source/Core/ElementStyle.h

@@ -142,8 +142,8 @@ public:
 	void DirtyInheritedEmProperties();
 	// Dirties rem properties.
 	void DirtyRemProperties();
-	// Dirties lp properties.
-	void DirtyLpProperties();
+	// Dirties dp properties.
+	void DirtyDpProperties();
 
 	/// Returns 'top', 'bottom', 'left' and 'right' properties from element's style or local cache.
 	void GetOffsetProperties(const Property **top, const Property **bottom, const Property **left, const Property **right );	

+ 5 - 5
Source/Core/ElementUtilities.cpp

@@ -123,13 +123,13 @@ FontFaceHandle* ElementUtilities::GetFontFaceHandle(Element* element)
 	return font;
 }
 
-float ElementUtilities::GetLogicalPixelRatio(Element * element)
+float ElementUtilities::GetDensityIndependentPixelRatio(Element * element)
 {
 	Context* context = element->GetContext();
 	if (context == NULL)
 		return 1.0f;
 
-	return context->GetLogicalPixelRatio();
+	return context->GetDensityIndependentPixelRatio();
 }
 
 // Returns an element's font size, if it has a font defined.
@@ -178,9 +178,9 @@ int ElementUtilities::GetLineHeight(Element* element)
 	case Property::PX:
 		// A px measurement.
 		return Math::Round(line_height_property->value.Get< float >());
-	case Property::LP:
-		// A logical pixel measurement.
-		return Math::Round(line_height_property->value.Get< float >() * ElementUtilities::GetLogicalPixelRatio(element));
+	case Property::DP:
+		// A density-independent pixel measurement.
+		return Math::Round(line_height_property->value.Get< float >() * ElementUtilities::GetDensityIndependentPixelRatio(element));
 	case Property::INCH:
 		// Values based on pixels-per-inch.
 		return Math::Round(line_height_property->value.Get< float >() * inch);

+ 1 - 1
Source/Core/PropertyDefinition.cpp

@@ -132,7 +132,7 @@ bool PropertyDefinition::GetValue(String& value, const Property& property) const
 		break;
 
 		case Property::PX:		value.Append("px"); break;
-		case Property::LP:		value.Append("lp"); break;
+		case Property::DP:		value.Append("dp"); break;
 		case Property::EM:		value.Append("em"); break;
 		case Property::REM:		value.Append("rem"); break;
 		case Property::PERCENT:	value.Append("%"); break;

+ 1 - 1
Source/Core/PropertyParserNumber.cpp

@@ -34,7 +34,7 @@ namespace Core {
 PropertyParserNumber::PropertyParserNumber()
 {
 	unit_suffixes.push_back(UnitSuffix(Property::PX, "px"));
-	unit_suffixes.push_back(UnitSuffix(Property::LP, "lp"));
+	unit_suffixes.push_back(UnitSuffix(Property::DP, "dp"));
 	unit_suffixes.push_back(UnitSuffix(Property::REM, "rem"));
 	unit_suffixes.push_back(UnitSuffix(Property::EM, "em"));
 	unit_suffixes.push_back(UnitSuffix(Property::INCH, "in"));