mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-10 08:17:51 -06:00
Little refactoring of get_mouse_position_in_control() for const
correctness and readability.
This commit is contained in:
parent
79be13438e
commit
87303951a7
2 changed files with 7 additions and 15 deletions
|
@ -118,7 +118,7 @@ ObjectList::ObjectList(wxWindow* parent) :
|
||||||
// detect the current mouse position here, to pass it to list_manipulation() method
|
// detect the current mouse position here, to pass it to list_manipulation() method
|
||||||
// if we detect it later, the user may have moved the mouse pointer while calculations are performed, and this would mess-up the HitTest() call performed into list_manipulation()
|
// if we detect it later, the user may have moved the mouse pointer while calculations are performed, and this would mess-up the HitTest() call performed into list_manipulation()
|
||||||
// see: https://github.com/prusa3d/PrusaSlicer/issues/3802
|
// see: https://github.com/prusa3d/PrusaSlicer/issues/3802
|
||||||
const wxPoint mouse_pos = get_mouse_position_in_control();
|
const wxPoint mouse_pos = this->get_mouse_position_in_control();
|
||||||
|
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
// On Windows and Linux, forces a kill focus emulation on the object manipulator fields because this event handler is called
|
// On Windows and Linux, forces a kill focus emulation on the object manipulator fields because this event handler is called
|
||||||
|
@ -155,7 +155,7 @@ ObjectList::ObjectList(wxWindow* parent) :
|
||||||
// Workaround for entering the column editing mode on Windows. Simulate keyboard enter when another column of the active line is selected.
|
// Workaround for entering the column editing mode on Windows. Simulate keyboard enter when another column of the active line is selected.
|
||||||
wxDataViewItem item;
|
wxDataViewItem item;
|
||||||
wxDataViewColumn *col;
|
wxDataViewColumn *col;
|
||||||
this->HitTest(get_mouse_position_in_control(), item, col);
|
this->HitTest(this->get_mouse_position_in_control(), item, col);
|
||||||
new_selected_column = (col == nullptr) ? -1 : (int)col->GetModelColumn();
|
new_selected_column = (col == nullptr) ? -1 : (int)col->GetModelColumn();
|
||||||
if (new_selected_item == m_last_selected_item && m_last_selected_column != -1 && m_last_selected_column != new_selected_column) {
|
if (new_selected_item == m_last_selected_item && m_last_selected_column != -1 && m_last_selected_column != new_selected_column) {
|
||||||
// Mouse clicked on another column of the active row. Simulate keyboard enter to enter the editing mode of the current column.
|
// Mouse clicked on another column of the active row. Simulate keyboard enter to enter the editing mode of the current column.
|
||||||
|
@ -171,7 +171,7 @@ ObjectList::ObjectList(wxWindow* parent) :
|
||||||
|
|
||||||
selection_changed();
|
selection_changed();
|
||||||
#ifndef __WXMSW__
|
#ifndef __WXMSW__
|
||||||
set_tooltip_for_item(get_mouse_position_in_control());
|
set_tooltip_for_item(this->get_mouse_position_in_control());
|
||||||
#endif //__WXMSW__
|
#endif //__WXMSW__
|
||||||
|
|
||||||
#ifndef __WXOSX__
|
#ifndef __WXOSX__
|
||||||
|
@ -211,7 +211,7 @@ ObjectList::ObjectList(wxWindow* parent) :
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
GetMainWindow()->Bind(wxEVT_MOTION, [this](wxMouseEvent& event) {
|
GetMainWindow()->Bind(wxEVT_MOTION, [this](wxMouseEvent& event) {
|
||||||
set_tooltip_for_item(get_mouse_position_in_control());
|
set_tooltip_for_item(this->get_mouse_position_in_control());
|
||||||
event.Skip();
|
event.Skip();
|
||||||
});
|
});
|
||||||
#endif //__WXMSW__
|
#endif //__WXMSW__
|
||||||
|
@ -419,14 +419,6 @@ void ObjectList::set_tooltip_for_item(const wxPoint& pt)
|
||||||
GetMainWindow()->SetToolTip(tooltip);
|
GetMainWindow()->SetToolTip(tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPoint ObjectList::get_mouse_position_in_control()
|
|
||||||
{
|
|
||||||
const wxPoint& pt = wxGetMousePosition();
|
|
||||||
// wxWindow* win = GetMainWindow();
|
|
||||||
// wxPoint screen_pos = win->GetScreenPosition();
|
|
||||||
return wxPoint(pt.x - /*win->*/GetScreenPosition().x, pt.y - /*win->*/GetScreenPosition().y);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObjectList::get_selected_obj_idx() const
|
int ObjectList::get_selected_obj_idx() const
|
||||||
{
|
{
|
||||||
if (GetSelectedItemsCount() == 1)
|
if (GetSelectedItemsCount() == 1)
|
||||||
|
@ -792,7 +784,7 @@ void ObjectList::OnChar(wxKeyEvent& event)
|
||||||
void ObjectList::OnContextMenu(wxDataViewEvent& evt)
|
void ObjectList::OnContextMenu(wxDataViewEvent& evt)
|
||||||
{
|
{
|
||||||
// The mouse position returned by get_mouse_position_in_control() here is the one at the time the mouse button is released (mouse up event)
|
// The mouse position returned by get_mouse_position_in_control() here is the one at the time the mouse button is released (mouse up event)
|
||||||
wxPoint mouse_pos = get_mouse_position_in_control();
|
wxPoint mouse_pos = this->get_mouse_position_in_control();
|
||||||
|
|
||||||
// Do not show the context menu if the user pressed the right mouse button on the 3D scene and released it on the objects list
|
// Do not show the context menu if the user pressed the right mouse button on the 3D scene and released it on the objects list
|
||||||
GLCanvas3D* canvas = wxGetApp().plater()->canvas3D();
|
GLCanvas3D* canvas = wxGetApp().plater()->canvas3D();
|
||||||
|
@ -925,7 +917,7 @@ void ObjectList::extruder_editing()
|
||||||
|
|
||||||
const int column_width = GetColumn(colExtruder)->GetWidth() + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X) + 5;
|
const int column_width = GetColumn(colExtruder)->GetWidth() + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X) + 5;
|
||||||
|
|
||||||
wxPoint pos = get_mouse_position_in_control();
|
wxPoint pos = this->get_mouse_position_in_control();
|
||||||
wxSize size = wxSize(column_width, -1);
|
wxSize size = wxSize(column_width, -1);
|
||||||
pos.x = GetColumn(colName)->GetWidth() + GetColumn(colPrint)->GetWidth() + 5;
|
pos.x = GetColumn(colName)->GetWidth() + GetColumn(colPrint)->GetWidth() + 5;
|
||||||
pos.y -= GetTextExtent("m").y;
|
pos.y -= GetTextExtent("m").y;
|
||||||
|
|
|
@ -284,7 +284,7 @@ public:
|
||||||
bool selected_instances_of_same_object();
|
bool selected_instances_of_same_object();
|
||||||
bool can_split_instances();
|
bool can_split_instances();
|
||||||
|
|
||||||
wxPoint get_mouse_position_in_control();
|
wxPoint get_mouse_position_in_control() const { return wxGetMousePosition() - this->GetScreenPosition(); }
|
||||||
wxBoxSizer* get_sizer() {return m_sizer;}
|
wxBoxSizer* get_sizer() {return m_sizer;}
|
||||||
int get_selected_obj_idx() const;
|
int get_selected_obj_idx() const;
|
||||||
DynamicPrintConfig& get_item_config(const wxDataViewItem& item) const;
|
DynamicPrintConfig& get_item_config(const wxDataViewItem& item) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue