CurveEditor::CurveEditor(MyGUI::Widget* _parent) { initialiseByAttributes(this, _parent); mEditTimeEditBox->setEditReadOnly(true); mEditValueEditBox->setEditReadOnly(true); mRangeMinEditBox->eventKeyLostFocus += MyGUI::newDelegate(this, &CurveEditor::NotifyRangeLostFocus); mRangeMinEditBox->eventEditSelectAccept += MyGUI::newDelegate(this, &CurveEditor::NotifyRangeEditAccept); mRangeMaxEditBox->eventKeyLostFocus += MyGUI::newDelegate(this, &CurveEditor::NotifyRangeLostFocus); mRangeMaxEditBox->eventEditSelectAccept += MyGUI::newDelegate(this, &CurveEditor::NotifyRangeEditAccept); MyGUI::PolygonalSkin::CreateLineSets = false; MyGUI::Widget* widget = mCurveCanvasWidget->createWidget<MyGUI::Widget>("PolygonalSkin", MyGUI::IntCoord(MyGUI::IntPoint(), mCurveCanvasWidget->getSize()), MyGUI::Align::Stretch); widget->setColour(MyGUI::Colour::Red); MyGUI::ISubWidget* main = widget->getSubWidgetMain(); mCurveLines = main->castType<MyGUI::PolygonalSkin>(); MyGUI::PolygonalSkin::CreateLineSets = true; widget = mCurveCanvasWidget->createWidget<MyGUI::Widget>("PolygonalSkin", MyGUI::IntCoord(MyGUI::IntPoint(), mCurveCanvasWidget->getSize()), MyGUI::Align::Stretch); widget->setColour(MyGUI::Colour::Red); main = widget->getSubWidgetMain(); mCurveCanvas = main->castType<MyGUI::PolygonalSkin>(); widget->eventMouseButtonPressed += MyGUI::newDelegate(this, &CurveEditor::NotifyMousePressed); MyGUI::PolygonalSkin::CreateLineSets = false; mCanvasWidget = widget; mCurveCanvas->setWidth(5.0f); std::vector<MyGUI::FloatPoint> mLinePoints; mLinePoints.push_back(MyGUI::FloatPoint(0, 0)); mLinePoints.push_back(MyGUI::FloatPoint(0, 1)); mCurveCanvas->setPoints(mLinePoints); mLinePoints.clear(); mCurveCanvas->setPoints(mLinePoints); // todo fix it mCurveLines->_setColour(MyGUI::Colour(0.2f, 0.2f, 0.2f)); // default range mValueRange.x = 0; mValueRange.y = 10; mRangeMinEditBox->setCaption("0"); mRangeMaxEditBox->setCaption("10"); InitGrid(); RefreshNumbers(); MyGUI::Window* window = mMainWidget->castType<MyGUI::Window>(false); if (window != nullptr) window->eventWindowButtonPressed += newDelegate(this, &CurveEditor::NotifyWindowButtonPressed); mSplineButton = mMainWidget->createWidget<MyGUI::Button>("CheckBox", MyGUI::IntCoord(15, 10, 95, 25), MyGUI::Align::Left | MyGUI::Align::Top); mSplineButton->setCaption("Use Spline"); mSplineButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CurveEditor::NotifySplineChecked); }
void DemoKeeper::createScene() { base::BaseDemoManager::createScene(); MyGUI::ResourceManager::getInstance().load("SplineSkin.xml"); const MyGUI::VectorWidgetPtr& root = MyGUI::LayoutManager::getInstance().loadLayout("HelpPanel.layout"); root.at(0)->findWidget("Text")->castType<MyGUI::TextBox>()->setCaption("PolygonalSkin usage. Drag white rectangles to move points for bezier curve."); MyGUI::VectorWidgetPtr widgets = MyGUI::LayoutManager::getInstance().loadLayout("SplineWindow.layout"); mQualityText = widgets.at(0)->findWidget("SplineText")->castType<MyGUI::TextBox>(); MyGUI::ScrollBar* qualityScroll = widgets.at(0)->findWidget("SplineQuality")->castType<MyGUI::ScrollBar>(); qualityScroll->eventScrollChangePosition += MyGUI::newDelegate(this, &DemoKeeper::notifyChangeQuality); mClient = widgets.at(0)->findWidget("SplineClient"); // create widget with skin that contain specific sub skin - PolygonalSkin MyGUI::Widget* widget = mClient->createWidget<MyGUI::Widget>("PolygonalSkin", MyGUI::IntCoord(MyGUI::IntPoint(), mClient->getSize()), MyGUI::Align::Stretch); widget->setColour(MyGUI::Colour::Red); // get main subskin MyGUI::ISubWidget* main = widget->getSubWidgetMain(); mPolygonalSkin = main->castType<MyGUI::PolygonalSkin>(); // set PolygonalSkin properties and points mPolygonalSkin->setWidth(8.0f); for (int i = 0; i < PointsCount; ++i) { point[i] = mClient->createWidget<MyGUI::Button>("Button", MyGUI::IntCoord(10 + (i + i % 2 * 3) * 40, 10 + (i + i / 2 * 3) * 40, 16, 16), MyGUI::Align::Default); point[i]->eventMouseDrag += newDelegate(this, &DemoKeeper::notifyPointMove); point[i]->eventMouseButtonPressed += newDelegate(this, &DemoKeeper::notifyPointPressed); } notifyChangeQuality(qualityScroll, 12); updateSpline(); }