Merge branch 'master' of https://github.com/prusa3d/Slic3r into scene_manipulators
This commit is contained in:
commit
15f35a9e9e
@ -644,12 +644,9 @@ public:
|
||||
bool deserialize(const std::string &str, bool append = false) override
|
||||
{
|
||||
UNUSED(append);
|
||||
std::istringstream iss(str);
|
||||
iss >> this->value.x;
|
||||
iss.ignore(std::numeric_limits<std::streamsize>::max(), ',');
|
||||
iss.ignore(std::numeric_limits<std::streamsize>::max(), 'x');
|
||||
iss >> this->value.y;
|
||||
return true;
|
||||
char dummy;
|
||||
return sscanf(str.data(), " %lf , %lf %c", &this->value.x, &this->value.y, &dummy) == 2 ||
|
||||
sscanf(str.data(), " %lf x %lf %c", &this->value.x, &this->value.y, &dummy) == 2;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -82,15 +82,27 @@ void wxCheckListBoxComboPopup::OnCheckListBox(wxCommandEvent& evt)
|
||||
{
|
||||
// forwards the checklistbox event to the owner wxComboCtrl
|
||||
|
||||
wxComboCtrl* cmb = GetComboCtrl();
|
||||
if (cmb != nullptr)
|
||||
if (m_check_box_events_status == OnCheckListBoxFunction::FreeToProceed )
|
||||
{
|
||||
wxCommandEvent event(wxEVT_CHECKLISTBOX, cmb->GetId());
|
||||
event.SetEventObject(cmb);
|
||||
cmb->ProcessWindowEvent(event);
|
||||
wxComboCtrl* cmb = GetComboCtrl();
|
||||
if (cmb != nullptr) {
|
||||
wxCommandEvent event(wxEVT_CHECKLISTBOX, cmb->GetId());
|
||||
event.SetEventObject(cmb);
|
||||
cmb->ProcessWindowEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
evt.Skip();
|
||||
|
||||
#ifndef _WIN32 // events are sent differently on OSX+Linux vs Win (more description in header file)
|
||||
if ( m_check_box_events_status == OnCheckListBoxFunction::RefuseToProceed )
|
||||
// this happens if the event was resent by OnListBoxSelection - next call to OnListBoxSelection is due to user clicking the text, so the function should
|
||||
// explicitly change the state on the checkbox
|
||||
m_check_box_events_status = OnCheckListBoxFunction::WasRefusedLastTime;
|
||||
else
|
||||
// if the user clicked the checkbox square, this event was sent before OnListBoxSelection was called, so we don't want it to resend it
|
||||
m_check_box_events_status = OnCheckListBoxFunction::RefuseToProceed;
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxCheckListBoxComboPopup::OnListBoxSelection(wxCommandEvent& evt)
|
||||
@ -100,9 +112,14 @@ void wxCheckListBoxComboPopup::OnListBoxSelection(wxCommandEvent& evt)
|
||||
int selId = GetSelection();
|
||||
if (selId != wxNOT_FOUND)
|
||||
{
|
||||
Check((unsigned int)selId, !IsChecked((unsigned int)selId));
|
||||
SetSelection(wxNOT_FOUND);
|
||||
#ifndef _WIN32
|
||||
if (m_check_box_events_status == OnCheckListBoxFunction::RefuseToProceed)
|
||||
#endif
|
||||
Check((unsigned int)selId, !IsChecked((unsigned int)selId));
|
||||
|
||||
m_check_box_events_status = OnCheckListBoxFunction::FreeToProceed; // so the checkbox reacts to square-click the next time
|
||||
|
||||
SetSelection(wxNOT_FOUND);
|
||||
wxCommandEvent event(wxEVT_CHECKLISTBOX, GetId());
|
||||
event.SetInt(selId);
|
||||
event.SetEventObject(this);
|
||||
|
@ -13,6 +13,21 @@ class wxCheckListBoxComboPopup : public wxCheckListBox, public wxComboPopup
|
||||
|
||||
wxString m_text;
|
||||
|
||||
// Events sent on mouseclick are quite complex. Function OnListBoxSelection is supposed to pass the event to the checkbox, which works fine on
|
||||
// Win. On OSX and Linux the events are generated differently - clicking on the checkbox square generates the event twice (and the square
|
||||
// therefore seems not to respond).
|
||||
// This enum is meant to save current state of affairs, i.e., if the event forwarding is ok to do or not. It is only used on Linux
|
||||
// and OSX by some #ifdefs. It also stores information whether OnListBoxSelection is supposed to change the checkbox status,
|
||||
// or if it changed status on its own already (which happens when the square is clicked). More comments in OnCheckListBox(...)
|
||||
// There indeed is a better solution, maybe making a custom event used for the event passing to distinguish the original and passed message
|
||||
// and blocking one of them on OSX and Linux. Feel free to refactor, but carefully test on all platforms.
|
||||
enum class OnCheckListBoxFunction{
|
||||
FreeToProceed,
|
||||
RefuseToProceed,
|
||||
WasRefusedLastTime
|
||||
} m_check_box_events_status = OnCheckListBoxFunction::FreeToProceed;
|
||||
|
||||
|
||||
public:
|
||||
virtual bool Create(wxWindow* parent);
|
||||
virtual wxWindow* GetControl();
|
||||
|
Loading…
Reference in New Issue
Block a user