void RenderItem::setTexture(ITexture* _value) { MYGUI_DEBUG_ASSERT(mVertexBuffer->getVertextCount() == 0, "change texture only empty buffer"); MYGUI_DEBUG_ASSERT(mNeedVertexCount == 0, "change texture only empty buffer"); mTexture = _value; #if MYGUI_DEBUG_MODE == 1 mTextureName = mTexture == nullptr ? "" : mTexture->getName(); #endif }
void Widget::_updateAlpha() { MYGUI_DEBUG_ASSERT(null != mParent, "Widget must have parent"); mRealAlpha = mAlpha * (mInheritsAlpha ? static_cast<Widget*>(mParent)->_getRealAlpha() : ALPHA_MAX); for (VectorWidgetPtr::iterator widget = mWidgetChild.begin(); widget != mWidgetChild.end(); ++widget) (*widget)->_updateAlpha(); for (VectorCroppedRectanglePtr::iterator skin = mSubSkinChild.begin(); skin != mSubSkinChild.end(); ++skin) (*skin)->setAlpha(mRealAlpha); }
void LayerItem::attachToLayerItemNode(ILayerNode* _item, bool _deep) { MYGUI_DEBUG_ASSERT(nullptr != _item, "attached item must be valid"); // сохраняем, чтобы последующие дети могли приаттачиться mLayerNode = _item; for (VectorSubWidget::iterator skin = mDrawItems.begin(); skin != mDrawItems.end(); ++skin) { (*skin)->createDrawItem(mTexture, _item); } for (VectorLayerItem::iterator item = mLayerItems.begin(); item != mLayerItems.end(); ++item) { (*item)->attachToLayerItemNode(_item, _deep); } for (VectorLayerItem::iterator item = mLayerNodes.begin(); item != mLayerNodes.end(); ++item) { // создаем оверлаппеду новый айтем if (_deep) { ILayerNode* child_node = _item->createChildItemNode(); (*item)->attachToLayerItemNode(child_node, _deep); } } }
void Widget::_updateAlpha() { MYGUI_DEBUG_ASSERT(null != mParent, "parent must be"); mRealAlpha = mAlpha * static_cast<Widget*>(mParent)->_getRealAlpha(); for (VectorWidgetPtr::iterator widget = mWidgetChild.begin(); widget != mWidgetChild.end(); widget++) (*widget)->_updateAlpha(); for (VectorCroppedRectanglePtr::iterator skin = mSubSkinChild.begin(); skin != mSubSkinChild.end(); skin++) (*skin)->setAlpha(mRealAlpha); }
void ItemBox::findCurrentActiveItem() { MYGUI_DEBUG_ASSERT(mIndexActive == ITEM_NONE, "use : resetCurrentActiveItem() before findCurrentActiveItem()"); const IntPoint& point = InputManager::getInstance().getMousePositionByLayer(); // сначала проверяем клиентскую зону const IntRect& rect = _getClientAbsoluteRect(); if ((point.left < rect.left) || (point.left > rect.right) || (point.top < rect.top) || (point.top > rect.bottom)) { return; } for (size_t pos = 0; pos < mVectorItems.size(); ++pos) { Widget* item = mVectorItems[pos]; const IntRect& abs_rect = item->getAbsoluteRect(); if ((point.left >= abs_rect.left) && (point.left <= abs_rect.right) && (point.top >= abs_rect.top) && (point.top <= abs_rect.bottom)) { size_t index = calcIndexByWidget(item); // при переборе индекс может быть больше, так как может создасться сколько угодно if (index < mItemsInfo.size()) { mIndexActive = index; IBDrawItemInfo data(index, mIndexSelect, mIndexActive, mIndexAccept, mIndexRefuse, false, false); requestDrawItem(this, item, data); } break; } } }
void RenderItem::renderToTarget(IRenderTarget* _target, bool _update) { if (mTexture == nullptr) return; mRenderTarget = _target; mCurrentUpdate = _update; if (mOutOfDate || _update) { mCountVertex = 0; Vertex* buffer = mVertexBuffer->lock(); mOutOfDate = false; if (buffer != nullptr) { for (VectorDrawItem::iterator iter = mDrawItems.begin(); iter != mDrawItems.end(); ++iter) { // перед вызовом запоминаем позицию в буфере mCurrentVertex = buffer; mLastVertexCount = 0; (*iter).first->doRender(); // колличество отрисованных вершин MYGUI_DEBUG_ASSERT(mLastVertexCount <= (*iter).second, "It is too much vertexes"); buffer += mLastVertexCount; mCountVertex += mLastVertexCount; } mVertexBuffer->unlock(); } } // хоть с 0 не выводиться батч, но все равно не будем дергать стейт и операцию if (0 != mCountVertex) { #if MYGUI_DEBUG_MODE == 1 if (!RenderManager::getInstance().checkTexture(mTexture)) { mTexture = nullptr; MYGUI_EXCEPT("texture pointer is not valid, texture name '" << mTextureName << "'"); return; } #endif // непосредственный рендринг if (mManualRender) { for (VectorDrawItem::iterator iter = mDrawItems.begin(); iter != mDrawItems.end(); ++iter) (*iter).first->doManualRender(mVertexBuffer, mTexture, mCountVertex); } else { _target->doRender(mVertexBuffer, mTexture, mCountVertex); } } }
void Message::initialiseWidgetSkin(ResourceSkin* _info) { // парсим виджет для текста for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter) { if (*(*iter)->_getInternalData<std::string>() == "Text") { MYGUI_DEBUG_ASSERT( ! mWidgetText, "widget already assigned"); mWidgetText = (*iter); mOffsetText.set(mCoord.width - mWidgetText->getWidth(), mCoord.height - mWidgetText->getHeight()); mLeftOffset2 = mLeftOffset1 = mWidgetText->getLeft(); } else if (*(*iter)->_getInternalData<std::string>() == "Icon") { MYGUI_DEBUG_ASSERT( ! mIcon, "widget already assigned"); mIcon = (*iter)->castType<StaticImage>(); } } //MYGUI_ASSERT(nullptr != mWidgetText, "Child Text not found in skin (MessageBox must have widget for text)"); if (mIcon != nullptr) { mLeftOffset2 = mIcon->getRight() + 3; } // парсим свойства const MapString& properties = _info->getProperties(); if (!properties.empty()) { MapString::const_iterator iter = properties.find("ButtonSkin"); if (iter != properties.end()) mButtonSkin = iter->second; iter = properties.find("ButtonType"); if (iter != properties.end()) mButtonType = iter->second; iter = properties.find("ButtonSize"); if (iter != properties.end()) mButtonSize = IntSize::parse(iter->second); iter = properties.find("ButtonOffset"); if (iter != properties.end()) mButtonOffset = IntSize::parse(iter->second); iter = properties.find("DefaultLayer"); if (iter != properties.end()) mDefaultLayer = iter->second; iter = properties.find("FadeSkin"); if (iter != properties.end()) mFadeSkin = iter->second; iter = properties.find("FadeLayer"); if (iter != properties.end()) mFadeLayer = iter->second; } }
void ControllerPosition::prepareItem(Widget* _widget) { MYGUI_DEBUG_ASSERT(mTime > 0, "Time must be > 0"); mStartCoord = _widget->getCoord(); // вызываем пользовательский делегат для подготовки eventPreAction(_widget, this); }
void ScrollView::initialiseWidgetSkin(ResourceSkin* _info) { // нам нужен фокус клавы mNeedKeyFocus = true; for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter) { if (*(*iter)->_getInternalData<std::string>() == "Client") { MYGUI_DEBUG_ASSERT( ! mScrollClient, "widget already assigned"); mScrollClient = (*iter); mScrollClient->eventMouseSetFocus = newDelegate(this, &ScrollView::notifyMouseSetFocus); mScrollClient->eventMouseLostFocus = newDelegate(this, &ScrollView::notifyMouseLostFocus); mScrollClient->eventMouseWheel = newDelegate(this, &ScrollView::notifyMouseWheel); mClient = mScrollClient; // создаем холcт, реальный владелец детей mWidgetClient = mScrollClient->createWidget<Widget>("Default", IntCoord(), Align::Default); mWidgetClient->eventMouseWheel = newDelegate(this, &ScrollView::notifyMouseWheel); mWidgetClient->eventMouseSetFocus = newDelegate(this, &ScrollView::notifyMouseSetFocus); mWidgetClient->eventMouseLostFocus = newDelegate(this, &ScrollView::notifyMouseLostFocus); } else if (*(*iter)->_getInternalData<std::string>() == "VScroll") { MYGUI_DEBUG_ASSERT( ! mVScroll, "widget already assigned"); mVScroll = (*iter)->castType<VScroll>(); mVScroll->eventScrollChangePosition = newDelegate(this, &ScrollView::notifyScrollChangePosition); } else if (*(*iter)->_getInternalData<std::string>() == "HScroll") { MYGUI_DEBUG_ASSERT( ! mHScroll, "widget already assigned"); mHScroll = (*iter)->castType<HScroll>(); mHScroll->eventScrollChangePosition = newDelegate(this, &ScrollView::notifyScrollChangePosition); } } //MYGUI_ASSERT(nullptr != mScrollClient, "Child Widget Client not found in skin (ScrollView must have Client)"); updateView(); }
void Button::initialiseWidgetSkin(WidgetSkinInfoPtr _info) { // парсим свойства const MapString & properties = _info->getProperties(); if (!properties.empty()) { MapString::const_iterator iter = properties.find("ButtonPressed"); if (iter != properties.end()) setButtonPressed(utility::parseBool(iter->second)); iter = properties.find("StateCheck"); if (iter != properties.end()) setStateCheck(utility::parseBool(iter->second)); } for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter) { if (*(*iter)->_getInternalData<std::string>() == "Image") { MYGUI_DEBUG_ASSERT( ! mImage, "widget already assigned"); mImage = (*iter)->castType<StaticImage>(); } } }
void Widget::_attachToLayerItemKeeper(LayerItemKeeper * _item) { MYGUI_DEBUG_ASSERT(null != _item, "attached item must be valid"); // сохраняем, чтобы последующие дети могли приаттачиться setLayerItemKeeper(_item); RenderItem * renderItem = null; for (VectorCroppedRectanglePtr::iterator skin = mSubSkinChild.begin(); skin != mSubSkinChild.end(); ++skin) { // создаем только если есть хоть один не текстовой сабскин if ((null == renderItem) && (false == (*skin)->_isText())) { renderItem = _item->addToRenderItem(mTexture, true, false); } (*skin)->_createDrawItem(_item, renderItem); } for (VectorWidgetPtr::iterator widget = mWidgetChild.begin(); widget != mWidgetChild.end(); ++widget) { (*widget)->_attachToLayerItemKeeper(_item); } }
size_t MultiList::convertToSort(size_t _index) { if (_index == ITEM_NONE) return ITEM_NONE; MYGUI_DEBUG_ASSERT(_index < mToSortIndex.size(), "index out of range"); return mToSortIndex[_index]; }
UString::const_iterator getTextIter() const { MYGUI_DEBUG_ASSERT(rollback, "rollback point not valid"); return space_point; }
size_t getPosition() const { MYGUI_DEBUG_ASSERT(rollback, "rollback point not valid"); return position; }
size_t getCount() const { MYGUI_DEBUG_ASSERT(rollback, "rollback point not valid"); return count; }
int getLenght() const { MYGUI_DEBUG_ASSERT(rollback, "rollback point not valid"); return lenght; }
ControllerFadeAlpha::ControllerFadeAlpha(float _alpha, float _coef, bool _enabled) : mAlpha(_alpha), mCoef(_coef), mEnabled(_enabled) { MYGUI_DEBUG_ASSERT(mCoef > 0, "coef must be > 0"); }
void VScroll::initialiseWidgetSkin(ResourceSkin* _info) { // при нуле, будет игнорировать кнопки mScrollPage = 1; mScrollViewPage = 1; for (VectorWidgetPtr::iterator iter = mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter) { if (*(*iter)->_getInternalData<std::string>() == "Start") { MYGUI_DEBUG_ASSERT( ! mWidgetStart, "widget already assigned"); mWidgetStart = (*iter)->castType<Button>(); mWidgetStart->eventMouseButtonPressed = newDelegate(this, &VScroll::notifyMousePressed); mWidgetStart->eventMouseWheel = newDelegate(this, &VScroll::notifyMouseWheel); } else if (*(*iter)->_getInternalData<std::string>() == "End") { MYGUI_DEBUG_ASSERT( ! mWidgetEnd, "widget already assigned"); mWidgetEnd = (*iter)->castType<Button>(); mWidgetEnd->eventMouseButtonPressed = newDelegate(this, &VScroll::notifyMousePressed); mWidgetEnd->eventMouseWheel = newDelegate(this, &VScroll::notifyMouseWheel); } else if (*(*iter)->_getInternalData<std::string>() == "Track") { MYGUI_DEBUG_ASSERT( ! mWidgetTrack, "widget already assigned"); mWidgetTrack = (*iter)->castType<Button>(); mWidgetTrack->eventMouseDrag = newDelegate(this, &VScroll::notifyMouseDrag); mWidgetTrack->eventMouseButtonPressed = newDelegate(this, &VScroll::notifyMousePressed); mWidgetTrack->eventMouseButtonReleased = newDelegate(this, &VScroll::notifyMouseReleased); mWidgetTrack->eventMouseWheel = newDelegate(this, &VScroll::notifyMouseWheel); mWidgetTrack->setVisible(false); } else if (*(*iter)->_getInternalData<std::string>() == "FirstPart") { MYGUI_DEBUG_ASSERT( ! mWidgetFirstPart, "widget already assigned"); mWidgetFirstPart = (*iter)->castType<Button>(); mWidgetFirstPart->eventMouseButtonPressed = newDelegate(this, &VScroll::notifyMousePressed); mWidgetFirstPart->eventMouseWheel = newDelegate(this, &VScroll::notifyMouseWheel); } else if (*(*iter)->_getInternalData<std::string>() == "SecondPart") { MYGUI_DEBUG_ASSERT( ! mWidgetSecondPart, "widget already assigned"); mWidgetSecondPart = (*iter)->castType<Button>(); mWidgetSecondPart->eventMouseButtonPressed = newDelegate(this, &VScroll::notifyMousePressed); mWidgetSecondPart->eventMouseWheel = newDelegate(this, &VScroll::notifyMouseWheel); } } // slider don't have buttons //MYGUI_ASSERT(nullptr != mWidgetTrack, "Child Button Track not found in skin (Scroll must have Track)"); // парсим свойства const MapString& properties = _info->getProperties(); MapString::const_iterator iter = properties.find("TrackRangeMargins"); if (iter != properties.end()) { IntSize range = IntSize::parse(iter->second); mSkinRangeStart = range.width; mSkinRangeEnd = range.height; } else { mSkinRangeStart = 0; mSkinRangeEnd = 0; } iter = properties.find("MinTrackSize"); if (iter != properties.end()) mMinTrackSize = utility::parseInt(iter->second); else mMinTrackSize = 0; iter = properties.find("MoveToClick"); if (iter != properties.end()) mMoveToClick = utility::parseBool(iter->second); }
float getWidth() const { MYGUI_DEBUG_ASSERT(rollback, "rollback point not valid"); return width; }
void ComboBox::initialiseWidgetSkin(WidgetSkinInfoPtr _info) { // парсим свойства const MapString & properties = _info->getProperties(); MapString::const_iterator iter = properties.find("HeightList"); if (iter != properties.end()) mMaxHeight = utility::parseSizeT(iter->second); iter = properties.find("ListSmoothShow"); if (iter != properties.end()) setSmoothShow(utility::parseBool(iter->second)); // парсим кнопку for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter) { if (*(*iter)->_getInternalData<std::string>() == "Button") { MYGUI_DEBUG_ASSERT( ! mButton, "widget already assigned"); mButton = (*iter)->castType<Button>(); mButton->eventMouseButtonPressed = newDelegate(this, &ComboBox::notifyButtonPressed); } else if (*(*iter)->_getInternalData<std::string>() == "List") { MYGUI_DEBUG_ASSERT( ! mList, "widget already assigned"); mList = (*iter)->castType<List>(); mList->setVisible(false); mList->eventKeyLostFocus = newDelegate(this, &ComboBox::notifyListLostFocus); mList->eventListSelectAccept = newDelegate(this, &ComboBox::notifyListSelectAccept); mList->eventListMouseItemActivate = newDelegate(this, &ComboBox::notifyListMouseItemActivate); mList->eventListChangePosition = newDelegate(this, &ComboBox::notifyListChangePosition); } } //OBSOLETE MYGUI_ASSERT(nullptr != mButton, "Child Button not found in skin (combobox must have Button)"); //MYGUI_ASSERT(nullptr != mList, "Child List not found in skin (combobox must have List)"); mManualList = mList == nullptr; if (mList == nullptr) { std::string list_skin; iter = properties.find("ListSkin"); if (iter != properties.end()) list_skin = iter->second; std::string list_layer; iter = properties.find("ListLayer"); if (iter != properties.end()) list_layer = iter->second; mList = createWidget<MyGUI::List>(WidgetStyle::Popup, list_skin, IntCoord(), Align::Default, list_layer); mWidgetChild.pop_back(); mList->setVisible(false); mList->eventKeyLostFocus = newDelegate(this, &ComboBox::notifyListLostFocus); mList->eventListSelectAccept = newDelegate(this, &ComboBox::notifyListSelectAccept); mList->eventListMouseItemActivate = newDelegate(this, &ComboBox::notifyListMouseItemActivate); mList->eventListChangePosition = newDelegate(this, &ComboBox::notifyListChangePosition); } // корректируем высоту списка //if (mMaxHeight < mList->getFontHeight()) mMaxHeight = mList->getFontHeight(); // подписываем дочерние классы на скролл mWidgetClient->eventMouseWheel = newDelegate(this, &ComboBox::notifyMouseWheel); mWidgetClient->eventMouseButtonPressed = newDelegate(this, &ComboBox::notifyMousePressed); // подписываемся на изменения текста eventEditTextChange = newDelegate(this, &ComboBox::notifyEditTextChange); }