Merge branch 'wxRibbon-coord-functions'

Fix wxRibbonToolBar coordinate functions for non-first group: they only
worked correctly for the first group before.

See https://github.com/wxWidgets/wxWidgets/pull/2152

Closes https://github.com/wxWidgets/wxWidgets/pull/2163
This commit is contained in:
Vadim Zeitlin
2021-01-10 19:28:18 +01:00
2 changed files with 6 additions and 6 deletions

View File

@@ -308,7 +308,8 @@ public:
wxRibbonToolBarToolBase* GetToolByPos(size_t pos)const; wxRibbonToolBarToolBase* GetToolByPos(size_t pos)const;
/** /**
Return the opaque pointer for the tool at the given coordinates. Returns the opaque pointer for the tool at the given coordinates,
which are relative to the toolbar's parent.
@return an opaque pointer, NULL if is not found. @return an opaque pointer, NULL if is not found.
@@ -391,8 +392,8 @@ public:
virtual int GetToolPos(int tool_id)const; virtual int GetToolPos(int tool_id)const;
/** /**
Returns the rect in the toolbar, or a default-constructed rect if the tool Returns the tool's rect with coordinates relative to the toolbar's parent,
is not found. or a default-constructed rect if the tool is not found.
@param tool_id @param tool_id
ID of the tool in question, as passed to AddTool(). ID of the tool in question, as passed to AddTool().

View File

@@ -439,7 +439,7 @@ wxRibbonToolBarToolBase* wxRibbonToolBar::GetToolByPos(wxCoord x, wxCoord y)cons
for ( size_t t = 0; t < tool_count; ++t ) for ( size_t t = 0; t < tool_count; ++t )
{ {
wxRibbonToolBarToolBase* tool = group->tools.Item(t); wxRibbonToolBarToolBase* tool = group->tools.Item(t);
wxRect rect(tool->position, tool->size); wxRect rect(group->position + tool->position, tool->size);
if(rect.Contains(x, y)) if(rect.Contains(x, y))
{ {
return tool; return tool;
@@ -535,8 +535,7 @@ wxRect wxRibbonToolBar::GetToolRect(int tool_id)const
wxRibbonToolBarToolBase* tool = group->tools.Item(t); wxRibbonToolBarToolBase* tool = group->tools.Item(t);
if (tool->id == tool_id) if (tool->id == tool_id)
{ {
wxRect rect(tool->position.x, tool->position.y, tool->size.GetWidth(), tool->size.GetHeight()); return wxRect(group->position + tool->position, tool->size);
return rect;
} }
++pos; ++pos;
} }