From 0ee16339aec3a956ad2c17a92c7b2a79670d890b Mon Sep 17 00:00:00 2001 From: Gary Allen Date: Sun, 10 Jan 2021 18:34:58 +0200 Subject: [PATCH 1/4] Fix wxRibbonToolbar Coord Functions --- src/ribbon/toolbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ribbon/toolbar.cpp b/src/ribbon/toolbar.cpp index b434a39a11..3ce8b33b77 100644 --- a/src/ribbon/toolbar.cpp +++ b/src/ribbon/toolbar.cpp @@ -439,7 +439,7 @@ wxRibbonToolBarToolBase* wxRibbonToolBar::GetToolByPos(wxCoord x, wxCoord y)cons for ( size_t t = 0; t < tool_count; ++t ) { wxRibbonToolBarToolBase* tool = group->tools.Item(t); - wxRect rect(tool->position, tool->size); + wxRect rect(tool->position + group->position, tool->size); if(rect.Contains(x, y)) { return tool; @@ -535,7 +535,7 @@ wxRect wxRibbonToolBar::GetToolRect(int tool_id)const wxRibbonToolBarToolBase* tool = group->tools.Item(t); if (tool->id == tool_id) { - wxRect rect(tool->position.x, tool->position.y, tool->size.GetWidth(), tool->size.GetHeight()); + wxRect rect(tool->position + group->position, tool->size); return rect; } ++pos; From 027c1b8304d98592fdd11136b729eea9ec4762ac Mon Sep 17 00:00:00 2001 From: Gary Allen Date: Sun, 10 Jan 2021 20:18:42 +0200 Subject: [PATCH 2/4] Update wxRibbonToolBar docs --- interface/wx/ribbon/toolbar.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/interface/wx/ribbon/toolbar.h b/interface/wx/ribbon/toolbar.h index 743521ad43..39dccc7f41 100644 --- a/interface/wx/ribbon/toolbar.h +++ b/interface/wx/ribbon/toolbar.h @@ -308,7 +308,8 @@ public: 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. @@ -391,8 +392,8 @@ public: virtual int GetToolPos(int tool_id)const; /** - Returns the rect in the toolbar, or a default-constructed rect if the tool - is not found. + Returns the tool's rect with coordinates relative to the toolbar's parent, + or a default-constructed rect if the tool is not found. @param tool_id ID of the tool in question, as passed to AddTool(). From aed13bb9a91cfc8e67556643d4091131c52ea3e5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 10 Jan 2021 19:25:53 +0100 Subject: [PATCH 3/4] Remove unnecessary temporary variable in wxRibbonToolBar Just return the wxRect directly. No real changes. --- src/ribbon/toolbar.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ribbon/toolbar.cpp b/src/ribbon/toolbar.cpp index 3ce8b33b77..2002fe1bc5 100644 --- a/src/ribbon/toolbar.cpp +++ b/src/ribbon/toolbar.cpp @@ -535,8 +535,7 @@ wxRect wxRibbonToolBar::GetToolRect(int tool_id)const wxRibbonToolBarToolBase* tool = group->tools.Item(t); if (tool->id == tool_id) { - wxRect rect(tool->position + group->position, tool->size); - return rect; + return wxRect(tool->position + group->position, tool->size); } ++pos; } From 5c1a27488f30af06b24215a5f698f85dc9d5584f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 10 Jan 2021 19:26:33 +0100 Subject: [PATCH 4/4] Express tool position rectangle position consistently Use tool position as offset from group position and not vice versa, both because this was already done like this in the other places and because this makes more sense: the tool is inside the group, so its position is relative to it. No real changes. --- src/ribbon/toolbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ribbon/toolbar.cpp b/src/ribbon/toolbar.cpp index 2002fe1bc5..2e49fd7ce0 100644 --- a/src/ribbon/toolbar.cpp +++ b/src/ribbon/toolbar.cpp @@ -439,7 +439,7 @@ wxRibbonToolBarToolBase* wxRibbonToolBar::GetToolByPos(wxCoord x, wxCoord y)cons for ( size_t t = 0; t < tool_count; ++t ) { wxRibbonToolBarToolBase* tool = group->tools.Item(t); - wxRect rect(tool->position + group->position, tool->size); + wxRect rect(group->position + tool->position, tool->size); if(rect.Contains(x, y)) { return tool; @@ -535,7 +535,7 @@ wxRect wxRibbonToolBar::GetToolRect(int tool_id)const wxRibbonToolBarToolBase* tool = group->tools.Item(t); if (tool->id == tool_id) { - return wxRect(tool->position + group->position, tool->size); + return wxRect(group->position + tool->position, tool->size); } ++pos; }