From 8077100658965fd82c365b192595991be371a6c5 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Wed, 4 Jul 2018 13:14:48 -0500 Subject: [PATCH] UI_Point is 4 items in a single sizer. Implemented the draw code for the sizer as well. --- src/GUI/OptionsGroup/Field.hpp | 1 + src/GUI/OptionsGroup/UI_Point.cpp | 16 ++++++++++++++++ src/test/GUI/test_field_point.cpp | 16 +++------------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/GUI/OptionsGroup/Field.hpp b/src/GUI/OptionsGroup/Field.hpp index c7b32873f..c4ac6d9d2 100644 --- a/src/GUI/OptionsGroup/Field.hpp +++ b/src/GUI/OptionsGroup/Field.hpp @@ -298,6 +298,7 @@ public: protected: virtual std::string LogChannel() { return "UI_Point"s; } + const Slic3r::ConfigOptionDef opt; //< Reference to the UI-specific bits of this option private: wxSize field_size {40, 1}; diff --git a/src/GUI/OptionsGroup/UI_Point.cpp b/src/GUI/OptionsGroup/UI_Point.cpp index 31caa679a..f18f1bab5 100644 --- a/src/GUI/OptionsGroup/UI_Point.cpp +++ b/src/GUI/OptionsGroup/UI_Point.cpp @@ -67,10 +67,26 @@ UI_Point::UI_Point(wxWindow* parent, Slic3r::ConfigOptionDef _opt, wxWindowID id this->_lbl_x = new wxStaticText(parent, wxID_ANY, wxString("x:")); this->_lbl_y = new wxStaticText(parent, wxID_ANY, wxString("y:")); + this->_sizer = new wxBoxSizer(wxHORIZONTAL); + + this->_sizer->Add(_lbl_x, 0, wxALIGN_CENTER_VERTICAL, 0); + this->_sizer->Add(_ctrl_x, 0, wxALIGN_CENTER_VERTICAL, 0); + this->_sizer->Add(_lbl_y, 0, wxALIGN_CENTER_VERTICAL, 0); + this->_sizer->Add(_ctrl_y, 0, wxALIGN_CENTER_VERTICAL, 0); + + if (this->opt.tooltip != ""s) { + this->_ctrl_x->SetToolTip(this->opt.tooltip); + this->_ctrl_y->SetToolTip(this->opt.tooltip); + } + + // events _ctrl_x->Bind(wxEVT_TEXT_ENTER, [this](wxCommandEvent& e) { this->_on_change(""); e.Skip(); }); _ctrl_y->Bind(wxEVT_TEXT_ENTER, [this](wxCommandEvent& e) { this->_on_change(""); e.Skip(); }); _ctrl_x->Bind(wxEVT_KILL_FOCUS, [this](wxFocusEvent& e) { if (this->on_kill_focus != nullptr) {this->on_kill_focus(""); this->_on_change("");} e.Skip(); }); _ctrl_y->Bind(wxEVT_KILL_FOCUS, [this](wxFocusEvent& e) { if (this->on_kill_focus != nullptr) {this->on_kill_focus(""); this->_on_change("");} e.Skip(); }); + + + } } } // Namespace Slic3r::GUI diff --git a/src/test/GUI/test_field_point.cpp b/src/test/GUI/test_field_point.cpp index fad258371..bee75120c 100644 --- a/src/test/GUI/test_field_point.cpp +++ b/src/test/GUI/test_field_point.cpp @@ -265,23 +265,13 @@ SCENARIO( "UI_Point: get_sizer()") { auto simple_option {ConfigOptionDef()}; auto test_field {Slic3r::GUI::UI_Point(wxTheApp->GetTopWindow(), simple_option)}; WHEN( "get_sizer() is called") { - THEN( "get_sizer() returns a wxSizer that has 2 direct children in it that are sizers.") { - REQUIRE(test_field.get_sizer()->GetItemCount() == 2); + THEN( "get_sizer() returns a wxSizer that has 4 direct children in it that are Windows.") { + REQUIRE(test_field.get_sizer()->GetItemCount() == 4); auto tmp {test_field.get_sizer()->GetChildren().begin()}; - REQUIRE((*tmp)->IsSizer() == true); - tmp++; - REQUIRE((*tmp)->IsSizer() == true); - } - THEN( "The two children have two wxWindows as their children") { - auto tmp_sizer {test_field.get_sizer()->GetChildren().begin()}; - auto tmp {(*tmp_sizer)->GetSizer()->GetChildren().begin()}; REQUIRE((*tmp)->IsWindow() == true); tmp++; REQUIRE((*tmp)->IsWindow() == true); - - // now for the other one - tmp_sizer++; - tmp = (*tmp_sizer)->GetSizer()->GetChildren().begin(); + tmp++; REQUIRE((*tmp)->IsWindow() == true); tmp++; REQUIRE((*tmp)->IsWindow() == true);