UI_Point is 4 items in a single sizer.

Implemented the draw code for the sizer as well.
This commit is contained in:
Joseph Lenox 2018-07-04 13:14:48 -05:00 committed by Joseph Lenox
parent c2c80ecd92
commit 8077100658
3 changed files with 20 additions and 13 deletions

View File

@ -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};

View File

@ -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

View File

@ -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);