瀏覽代碼

Scrollbar corner: Add the element's border size to the scrollbarcorner position.

Michael Ragazzon 5 年之前
父節點
當前提交
68044da8db
共有 3 個文件被更改,包括 6 次插入5 次删除
  1. 1 1
      Include/RmlUi/Core/Element.h
  2. 1 1
      Source/Core/Element.cpp
  3. 4 3
      Source/Core/ElementScroll.cpp

+ 1 - 1
Include/RmlUi/Core/Element.h

@@ -118,7 +118,7 @@ public:
 	/// @param[in] offset The offset (in pixels) of our primary box's top-left border corner from our offset parent's top-left border corner.
 	/// @param[in] offset The offset (in pixels) of our primary box's top-left border corner from our offset parent's top-left border corner.
 	/// @param[in] offset_parent The element this element is being positioned relative to.
 	/// @param[in] offset_parent The element this element is being positioned relative to.
 	/// @param[in] offset_fixed True if the element is fixed in place (and will not scroll), false if not.
 	/// @param[in] offset_fixed True if the element is fixed in place (and will not scroll), false if not.
-	void SetOffset(const Vector2f& offset, Element* offset_parent, bool offset_fixed = false);
+	void SetOffset(Vector2f offset, Element* offset_parent, bool offset_fixed = false);
 	/// Returns the position of the top-left corner of one of the areas of this element's primary box, relative to its
 	/// Returns the position of the top-left corner of one of the areas of this element's primary box, relative to its
 	/// offset parent's top-left border corner.
 	/// offset parent's top-left border corner.
 	/// @param[in] area The desired area position.
 	/// @param[in] area The desired area position.

+ 1 - 1
Source/Core/Element.cpp

@@ -388,7 +388,7 @@ String Element::GetAddress(bool include_pseudo_classes, bool include_parents) co
 }
 }
 
 
 // Sets the position of this element, as a two-dimensional offset from another element.
 // Sets the position of this element, as a two-dimensional offset from another element.
-void Element::SetOffset(const Vector2f& offset, Element* _offset_parent, bool _offset_fixed)
+void Element::SetOffset(Vector2f offset, Element* _offset_parent, bool _offset_fixed)
 {
 {
 	_offset_fixed |= GetPosition() == Style::Position::Fixed;
 	_offset_fixed |= GetPosition() == Style::Position::Fixed;
 
 

+ 4 - 3
Source/Core/ElementScroll.cpp

@@ -140,7 +140,8 @@ float ElementScroll::GetScrollbarSize(Orientation orientation)
 // Formats the enabled scrollbars based on the current size of the host element.
 // Formats the enabled scrollbars based on the current size of the host element.
 void ElementScroll::FormatScrollbars()
 void ElementScroll::FormatScrollbars()
 {
 {
-	Vector2f containing_block = element->GetBox().GetSize(Box::PADDING);
+	const Box& element_box = element->GetBox();
+	const Vector2f containing_block = element_box.GetSize(Box::PADDING);
 
 
 	for (int i = 0; i < 2; i++)
 	for (int i = 0; i < 2; i++)
 	{
 	{
@@ -179,7 +180,7 @@ void ElementScroll::FormatScrollbars()
 		scrollbars[i].widget->SetLineHeight(element->GetLineHeight());
 		scrollbars[i].widget->SetLineHeight(element->GetLineHeight());
 
 
 		int variable_axis = i == VERTICAL ? 0 : 1;
 		int variable_axis = i == VERTICAL ? 0 : 1;
-		Vector2f offset = element->GetBox().GetPosition(Box::PADDING);
+		Vector2f offset = element_box.GetPosition(Box::PADDING);
 		offset[variable_axis] += containing_block[variable_axis] - (scrollbars[i].element->GetBox().GetSize(Box::BORDER)[variable_axis] + scrollbars[i].element->GetBox().GetEdge(Box::MARGIN, i == VERTICAL ? Box::RIGHT : Box::BOTTOM));
 		offset[variable_axis] += containing_block[variable_axis] - (scrollbars[i].element->GetBox().GetSize(Box::BORDER)[variable_axis] + scrollbars[i].element->GetBox().GetEdge(Box::MARGIN, i == VERTICAL ? Box::RIGHT : Box::BOTTOM));
 		// Add the top or left margin (as appropriate) onto the scrollbar's position.
 		// Add the top or left margin (as appropriate) onto the scrollbar's position.
 		offset[1 - variable_axis] += scrollbars[i].element->GetBox().GetEdge(Box::MARGIN, i == VERTICAL ? Box::TOP : Box::LEFT);
 		offset[1 - variable_axis] += scrollbars[i].element->GetBox().GetEdge(Box::MARGIN, i == VERTICAL ? Box::TOP : Box::LEFT);
@@ -195,7 +196,7 @@ void ElementScroll::FormatScrollbars()
 		Box corner_box;
 		Box corner_box;
 		corner_box.SetContent(Vector2f(scrollbars[VERTICAL].size, scrollbars[HORIZONTAL].size));
 		corner_box.SetContent(Vector2f(scrollbars[VERTICAL].size, scrollbars[HORIZONTAL].size));
 		corner->SetBox(corner_box);
 		corner->SetBox(corner_box);
-		corner->SetOffset(containing_block - Vector2f(scrollbars[VERTICAL].size, scrollbars[HORIZONTAL].size), element, true);
+		corner->SetOffset(containing_block + element_box.GetPosition(Box::PADDING) - Vector2f(scrollbars[VERTICAL].size, scrollbars[HORIZONTAL].size), element, true);
 		corner->SetProperty(PropertyId::Clip, Property(1, Property::NUMBER));
 		corner->SetProperty(PropertyId::Clip, Property(1, Property::NUMBER));
 
 
 		corner->SetProperty(PropertyId::Visibility, Property(Style::Visibility::Visible));
 		corner->SetProperty(PropertyId::Visibility, Property(Style::Visibility::Visible));