void MenuItem::initialiseOverride() { Base::initialiseOverride(); // FIXME проверить смену скина ибо должно один раз вызываться Widget* parent = getParent(); MYGUI_ASSERT(parent, "MenuItem must have parent MenuControl"); if (!parent->isType<MenuControl>()) { Widget* client = parent; parent = client->getParent(); MYGUI_ASSERT(parent, "MenuItem must have parent MenuControl"); MYGUI_ASSERT(parent->getClientWidget() == client, "MenuItem must have parent MenuControl"); MYGUI_ASSERT(parent->isType<MenuControl>(), "MenuItem must have parent MenuControl"); } mOwner = parent->castType<MenuControl>(); assignWidget(mCheck, "Check"); //if (isUserString("MinSize")) //mMinSize = IntSize::parse(getUserString("MinSize")); //FIXME нам нуженфокус клавы setNeedKeyFocus(true); updateCheck(); }
const Ogre::UTFString & MultiList::getSubItem(size_t _column, size_t _index) { MYGUI_ASSERT(false == mVectorColumnInfo.empty(), "multilist has no columns"); MYGUI_ASSERT(_column < mVectorColumnInfo.size(), "column " << _column <<" out of range"); MYGUI_ASSERT(_index < mVectorColumnInfo.begin()->list->getItemCount(), "index " << _index <<" out of range"); return mVectorColumnInfo[_column].list->getItem(convertToSort(_index)); }
void step_create_widget() { MyGUI::Widget* widget = get_random(all_widgets); if (widget) { int select = random(3); if (select == 0) { MyGUI::Widget* child = widget->createWidget<MyGUI::Widget>(MyGUI::WidgetStyle::Child, get_skin(), get_coord(), MyGUI::Align::Default); MYGUI_ASSERT(child, "child nullptr"); all_widgets.push_back(child); } else if (select == 1) { MyGUI::Widget* child = widget->createWidget<MyGUI::Widget>(MyGUI::WidgetStyle::Popup, get_skin(), get_coord(), MyGUI::Align::Default, get_layer()); MYGUI_ASSERT(child, "child nullptr"); all_widgets.push_back(child); } else if (select == 2) { MyGUI::Widget* child = widget->createWidget<MyGUI::Widget>(MyGUI::WidgetStyle::Overlapped, get_skin(), get_coord(), MyGUI::Align::Default); MYGUI_ASSERT(child, "child nullptr"); all_widgets.push_back(child); } } else { MyGUI::Widget* child = MyGUI::Gui::getInstance().createWidget<MyGUI::Widget>(get_skin(), get_coord(), MyGUI::Align::Default, get_layer()); MYGUI_ASSERT(child, "child nullptr"); all_widgets.push_back(child); } test_widgets(); }
void Canvas::setPixel( int _x, int _y, const Ogre::ColourValue & value ) { MYGUI_ASSERT( _x >= 0 && _x < getTextureRealWidth() && _y >= 0 && _y < getTextureRealHeight(), "Access to non-exists pixel! Check real dimensions of texture!" ); MYGUI_ASSERT( isLocked(), "Must lock MyGUI::Canvas before set pixel!" ); Ogre::PixelUtil::packColour( value, getTextureFormat(), pointPixel( _x, _y ) ); }
void MultiList::setItemSelect(size_t _index) { MYGUI_ASSERT(false == mVectorColumnInfo.empty(), "multilist has no columns"); MYGUI_ASSERT(_index < mVectorColumnInfo.begin()->list->getItemCount(), "index " << _index <<" out of range"); size_t index = convertToSort(_index); for (VectorColumnInfo::iterator iter=mVectorColumnInfo.begin(); iter!=mVectorColumnInfo.end(); ++iter) { (*iter).list->setItemSelect(index); } }
void Gui::setActiveViewport(Ogre::ushort _num) { if (_num == mActiveViewport) return; MYGUI_ASSERT(mWindow, "Gui is not initialised."); MYGUI_ASSERT(mWindow->getNumViewports() >= _num, "index out of range"); mActiveViewport = _num; // рассылка обновлений windowResized(mWindow); }
//----------------------------------------------------------------------------------// // методы для работы с саб строками void MultiList::setSubItem(size_t _column, size_t _index, const Ogre::UTFString & _item) { MYGUI_ASSERT(false == mVectorColumnInfo.empty(), "multilist has no columns"); MYGUI_ASSERT(_column < mVectorColumnInfo.size(), "column " << _column <<" out of range"); MYGUI_ASSERT(_index < mVectorColumnInfo.begin()->list->getItemCount(), "index " << _index <<" out of range"); mVectorColumnInfo[_column].list->setItem(convertToSort(_index), _item); // если мы попортили список с активным сортом, надо пересчитывать if (_column == mSortColumnIndex) setDirtySort(); }
size_t ItemBox::getIndexByWidget(Widget* _widget) { MYGUI_ASSERT(_widget, "ItemBox::getIndexByWidget : Widget == nullptr"); if (_widget == _getClientWidget()) return ITEM_NONE; MYGUI_ASSERT(_widget->getParent() == _getClientWidget(), "ItemBox::getIndexByWidget : Widget is not child"); size_t index = calcIndexByWidget(_widget); MYGUI_ASSERT_RANGE(index, mItemsInfo.size(), "ItemBox::getIndexByWidget"); return index; }
ItemBox::ItemBox(const IntCoord& _coord, char _align, const WidgetSkinInfoPtr _info, CroppedRectanglePtr _parent, const Ogre::String & _name) : Widget(_coord, _align, _info, _parent, _name), mWidgetScroll(null), mWidgetClient(null), mTopIndex(0), mOffsetTop(0), mRangeIndex(-1), //mLastRedrawLine(0), //mIndexSelect(ITEM_NONE), mIsFocus(false), mCountItems(0) { // нам нужен фокус клавы mNeedKeyFocus = true; for (VectorWidgetPtr::iterator iter=mWidgetChild.begin(); iter!=mWidgetChild.end(); ++iter) { if ((*iter)->_getInternalString() == "VScroll") { mWidgetScroll = castWidget<VScroll>(*iter); mWidgetScroll->eventScrollChangePosition = newDelegate(this, &ItemBox::notifyScrollChangePosition); //mWidgetScroll->eventMouseButtonPressed = newDelegate(this, &ItemBox::notifyMousePressed); } else if ((*iter)->_getInternalString() == "Client") { mWidgetClient = (*iter); //mWidgetClient->eventMouseButtonPressed = newDelegate(this, &ItemBox::notifyMousePressed); mWidgetClient->eventMouseWheel = newDelegate(this, &ItemBox::notifyMouseWheel); } } MYGUI_ASSERT(null != mWidgetScroll, "Child VScroll not found in skin (ItemBox must have VScroll)"); MYGUI_ASSERT(null != mWidgetClient, "Child Widget Client not found in skin (ItemBox must have Client)"); // парсим свойства /*const MapString & param = _info->getParams(); MapString::const_iterator iter = param.find("SkinLine"); if (iter != param.end()) mSkinLine = iter->second; MYGUI_ASSERT(false == mSkinLine.empty(), "SkinLine property or skin not found (ItemBox must have SkinLine property)"); iter = param.find("HeightLine"); if (iter != param.end()) mHeightLine = utility::parseInt(iter->second); if (mHeightLine < 1) mHeightLine = 1; */ mWidgetScroll->setScrollPage((size_t)mSizeItem.height); mSizeItem.set(50, 50); mCountItems = 200; updateMetrics(); updateScroll(); _redrawAllVisible(); //updateLine(); }
void SeparatorV::notifyMouseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id) { MYGUI_ASSERT(mLeftPanel, "SeparatorV left panel must not be null."); MYGUI_ASSERT(mRightPanel, "SeparatorV left panel must not be null."); if (_id == MyGUI::MouseButton::Left) { mStartLeftPanel = mLeftPanel->getCoord(); mStartRightPanel = mRightPanel->getCoord(); mStartSeparatorV = getCoord(); mStartMousePosition = MyGUI::InputManager::getInstance().getMousePosition(); } }
void* Canvas::pointPixel( int _x, int _y ) { MYGUI_ASSERT( _x >= 0 && _x < getTextureRealWidth() && _y >= 0 && _y < getTextureRealHeight(), "Access to non-exists pixel! Check real dimensions of texture!" ); MYGUI_ASSERT( isLocked(), "Must lock MyGUI::Canvas before point pixel!" ); size_t _pixelDataSize = Ogre::PixelUtil::getNumElemBytes( mTexPtr->getFormat() ); MYGUI_ASSERT( _pixelDataSize, "Unknown texture format!" ); return mTexData + ( _y * getTextureRealWidth() + _x ) * _pixelDataSize; }
Ogre::ColourValue Canvas::getPixel( int _x, int _y ) { MYGUI_ASSERT( _x >= 0 && _x < getTextureRealWidth() && _y >= 0 && _y < getTextureRealHeight(), "Access to non-exists pixel! Check real dimensions of texture!" ); MYGUI_ASSERT( isLocked(), "Must lock MyGUI::Canvas before set pixel!" ); Ogre::ColourValue result; Ogre::PixelUtil::unpackColour( & result, getTextureFormat(), pointPixel( _x, _y ) ); return result; }
void StateManager::pushState(StateController* _state) { MYGUI_ASSERT(_state != nullptr, "State is nullptr"); MYGUI_ASSERT(std::find(mStates.begin(), mStates.end(), _state) == mStates.end(), "State already added"); StateController* pauseState = getCurentState(); mStates.push_back(_state); if (pauseState != nullptr) pauseState->pauseState(); _state->initState(); }
void InputManager::initialise() { MYGUI_ASSERT(!mIsInitialise, getClassTypeName() << " initialised twice"); MYGUI_LOG(Info, "* Initialise: " << getClassTypeName()); mWidgetMouseFocus = nullptr; mWidgetKeyFocus = nullptr; mLayerMouseFocus = nullptr; for (int i = MouseButton::Button0; i < MouseButton::MAX; ++i) { mMouseCapture[i] = false; } mIsShiftPressed = false; mIsControlPressed = false; mHoldKey = KeyCode::None; mHoldChar = 0; mFirstPressKey = true; mTimerKey = 0.0f; mOldAbsZ = 0; WidgetManager::getInstance().registerUnlinker(this); Gui::getInstance().eventFrameStart += newDelegate(this, &InputManager::frameEntered); MYGUI_LOG(Info, getClassTypeName() << " successfully initialized"); mIsInitialise = true; }
void MainSkin::_setUVSet(const FloatRect& _rect) { MYGUI_ASSERT(null != mOverlayContainer, "overlay is not create"); mRectTexture = _rect; // если обрезаны, то просчитываем с учето обрезки if (mIsMargin) { float UV_lft = mParent->getMarginLeft() / (float)mParent->getWidth(); float UV_top = mParent->getMarginTop() / (float)mParent->getHeight(); float UV_rgt = (mParent->getWidth() - mParent->getMarginRight()) / (float)mParent->getWidth(); float UV_btm = (mParent->getHeight() - mParent->getMarginBottom()) / (float)mParent->getHeight(); float UV_sizeX = mRectTexture.right - mRectTexture.left; float UV_sizeY = mRectTexture.bottom - mRectTexture.top; float UV_lft_total = mRectTexture.left + UV_lft * UV_sizeX; float UV_top_total = mRectTexture.top + UV_top * UV_sizeY; float UV_rgt_total = mRectTexture.right - (1-UV_rgt) * UV_sizeX; float UV_btm_total = mRectTexture.bottom - (1-UV_btm) * UV_sizeY; mOverlayContainer->setUVInfo(UV_lft_total, UV_top_total, UV_rgt_total, UV_btm_total, 0); } else { // мы не обрезаны, базовые координаты mOverlayContainer->setUVInfo(mRectTexture.left, mRectTexture.top, mRectTexture.right, mRectTexture.bottom, 0); } }
// удяляет неудачника void Gui::_destroyChildWidget(Widget* _widget) { MYGUI_ASSERT(nullptr != _widget, "invalid widget pointer"); VectorWidgetPtr::iterator iter = std::find(mWidgetChild.begin(), mWidgetChild.end(), _widget); if (iter != mWidgetChild.end()) { // сохраняем указатель MyGUI::Widget* widget = *iter; // удаляем из списка *iter = mWidgetChild.back(); mWidgetChild.pop_back(); // отписываем от всех mWidgetManager->unlinkFromUnlinkers(_widget); // непосредственное удаление WidgetManager::getInstance()._deleteWidget(widget); } else { MYGUI_EXCEPT("Widget '" << _widget->getName() << "' not found"); } }
void SizeDescription::setSizeBehaviour( uint8 _beh ) { MYGUI_ASSERT( checkBehaviour( _beh ), "Invalid size benaviour!" ); mSizeBehaviour = _beh; //mIsInitialized = true; }
void LayerManager::initialise() { MYGUI_ASSERT(false == mIsInitialise, INSTANCE_TYPE_NAME << " initialised twice"); MYGUI_LOG(Info, "* Initialise: " << INSTANCE_TYPE_NAME); WidgetManager::getInstance().registerUnlinker(this); Gui::getInstance().registerLoadXmlDelegate(XML_TYPE) = newDelegate(this, &LayerManager::_load); Ogre::SceneManagerEnumerator::SceneManagerIterator iter = Ogre::Root::getSingleton().getSceneManagerIterator(); if (iter.hasMoreElements()) { mSceneManager = iter.getNext(); mSceneManager->addRenderQueueListener(this); } else { mSceneManager = null; } // инициализация mPixScaleX = mPixScaleY = 1; mHOffset = mVOffset = 0; mAspectCoef = 1; mUpdate = false; MYGUI_LOG(Info, INSTANCE_TYPE_NAME << " successfully initialized"); mIsInitialise = true; // не забывай, о великий построитель гуёв // Кто здесь? mMaximumDepth = Ogre::Root::getSingleton().getRenderSystem()->getMaximumDepthInputValue(); }
// поправить на виджет и проверять на рутовость void LayerManager::attachToLayerKeeper(const std::string& _name, WidgetPtr _item) { MYGUI_ASSERT(_item->isRootWidget(), "attached widget must be root"); // сначала отсоединяем detachFromLayerKeeper(_item); // а теперь аттачим for (VectorLayerKeeper::iterator iter=mLayerKeepers.begin(); iter!=mLayerKeepers.end(); ++iter) { if (_name == (*iter)->getName()) { // запоминаем в рутовом виджете хранитель лееров _item->mLayerKeeper = (*iter); // достаем из хранителя леер для себя _item->mLayerItemKeeper = (*iter)->getItem(); // подписываемся на пиккинг _item->mLayerItemKeeper->_addPeekItem(_item); // физически подсоединяем иерархию _item->_attachToLayerItemKeeper(_item->mLayerItemKeeper); return; } } MYGUI_EXCEPT("Layer '" << _name << "' is not found"); }
void DemoKeeper::createDemo(size_t _index) { destroyDemo(); if (_index == 0) { MyGUI::LanguageManager::getInstance().loadUserTags("core_theme_tag.xml"); getGUI()->load("core_skin.xml"); } else if (_index == 1) { MyGUI::LanguageManager::getInstance().loadUserTags("core_theme_black_blue_tag.xml"); getGUI()->load("core_skin.xml"); } else if (_index == 2) { MyGUI::LanguageManager::getInstance().loadUserTags("core_theme_black_orange_tag.xml"); getGUI()->load("core_skin.xml"); } MyGUI::VectorWidgetPtr windows = MyGUI::LayoutManager::getInstance().load("Themes.layout"); MYGUI_ASSERT(windows.size() == 1, "Error load layout"); mDemoView = windows[0]; mComboSkins = getGUI()->findWidget<MyGUI::ComboBox>("Combo"); mComboSkins->setComboModeDrop(true); mComboSkins->addItem("core"); mComboSkins->addItem("black & blue"); mComboSkins->addItem("black & orange"); mComboSkins->setIndexSelected(_index); mComboSkins->eventComboAccept = MyGUI::newDelegate(this, &DemoKeeper::notifyComboAccept); }
PropertyPtr Data::getProperty(const std::string& _name) const { MapProperty::const_iterator property = mProperties.find(_name); MYGUI_ASSERT(property != mProperties.end(), "Property " << _name << " not found"); return (*property).second; }
void Data::insertChild(size_t _index, DataPtr _child) { MYGUI_ASSERT(_child != nullptr, "Child is nullptr"); MYGUI_ASSERT(_child->getParent() == nullptr, "Child already attached"); MYGUI_ASSERT(_child->getType() != nullptr, "Type not found"); MYGUI_ASSERT(getType() != nullptr, "Type not found"); MYGUI_ASSERT(getType()->isChild(_child->getType()->getName()), "Type is not child"); MYGUI_ASSERT_RANGE_INSERT(_index, mChilds.size(), "Data::insertChild"); if (_index == MyGUI::ITEM_NONE) _index = mChilds.size(); mChilds.insert(mChilds.begin() + _index, _child); _child->mParent = mWeakThis.lock(); }
void InputManager::initialise() { MYGUI_ASSERT(false == mIsInitialise, INSTANCE_TYPE_NAME << " initialised twice"); MYGUI_LOG(Info, "* Initialise: " << INSTANCE_TYPE_NAME); mWidgetMouseFocus = 0; mWidgetKeyFocus = 0; mWidgetRootMouseFocus = 0; mWidgetRootKeyFocus = 0; mIsWidgetMouseCapture = false; mIsShiftPressed = false; mIsControlPressed = false; mHoldKey = KC_UNASSIGNED; //mUseOISKeyLayout = false; mFirstPressKey = true; mTimerKey = 0.0f; mOldAbsZ = 0; createDefaultCharSet(); WidgetManager::getInstance().registerUnlinker(this); Gui::getInstance().addFrameListener(this); Gui::getInstance().registerLoadXmlDelegate(XML_TYPE) = newDelegate(this, &InputManager::_load); MYGUI_LOG(Info, INSTANCE_TYPE_NAME << " successfully initialized"); mIsInitialise = true; }
void MenuBar::setItem(size_t _index, const Ogre::UTFString & _item) { MYGUI_ASSERT(_index < mVectorMenuItemInfo.size(), "index '" << _index << "' out of range"); mVectorMenuItemInfo[_index].button->setCaption(_item); update(); }
void* BaseManager::loadImage(int& _width, int& _height, MyGUI::PixelFormat& _format, const std::string& _filename) { std::string fullname = MyGUI::OpenGLESDataManager::getInstance().getDataPath(_filename); void* result = nullptr; SDL_Surface *image = nullptr; SDL_Surface *cvtImage = nullptr; // converted surface with RGBA/RGB pixel format image = IMG_Load(fullname.c_str()); MYGUI_ASSERT(image != nullptr, "Failed to load image: " + fullname); _width = image->w; _height = image->h; int bpp = image->format->BytesPerPixel; if (bpp < 3) { result = convertPixelData(image, _format); } else { Uint32 pixelFmt = bpp == 3 ? SDL_PIXELFORMAT_BGR24 : SDL_PIXELFORMAT_ARGB8888; cvtImage = SDL_ConvertSurfaceFormat(image, pixelFmt, 0); result = convertPixelData(cvtImage, _format); SDL_FreeSurface(cvtImage); } SDL_FreeSurface(image); return result; }
bool PluginManager::loadPlugin(const std::string& _file) { #ifdef EMSCRIPTEN return false; #endif MYGUI_ASSERT(mIsInitialise, getClassTypeName() << " used but not initialised"); // Load plugin library DynLib* lib = DynLibManager::getInstance().load(_file); if (!lib) { MYGUI_LOG(Error, "Plugin '" << _file << "' not found"); return false; } // Call startup function DLL_START_PLUGIN pFunc = reinterpret_cast<DLL_START_PLUGIN>(lib->getSymbol("dllStartPlugin")); if (!pFunc) { MYGUI_LOG(Error, "Cannot find symbol 'dllStartPlugin' in library " << _file); return false; } // Store for later unload mLibs[_file] = lib; // This must call installPlugin pFunc(); return true; }
void MultiListBox::removeItemAt(size_t _index) { MYGUI_ASSERT(!mVectorColumnInfo.empty(), "MultiListBox::removeItemAt"); MYGUI_ASSERT_RANGE(_index, mVectorColumnInfo.begin()->list->getItemCount(), "MultiListBox::removeItemAt"); size_t index = BiIndexBase::removeItemAt(_index); for (VectorColumnInfo::iterator iter = mVectorColumnInfo.begin(); iter != mVectorColumnInfo.end(); ++iter) { (*iter).list->removeItemAt(index); } // если надо, то меняем выделенный элемент size_t count = mVectorColumnInfo.begin()->list->getItemCount(); if (count == 0) mItemSelected = ITEM_NONE; else if (mItemSelected != ITEM_NONE) { if (_index < mItemSelected) mItemSelected --; else if ((_index == mItemSelected) && (mItemSelected == count)) mItemSelected --; } updateBackSelected(BiIndexBase::convertToBack(mItemSelected)); }
void OgreFont::changeImage(int _Width, int _Height) { // 纹理大小不够了,没办法只能重画了 GlyphMap::iterator it = mGlyphInfo.begin(); while (it != mGlyphInfo.end()) { delete it->second; it++; } mGlyphInfo.clear(); if (!mTexture) { mTexture = (OgreTexture*)RenderManager::getInstance().createTexture(MyGUI::utility::toString((size_t)this, "OgreFont")); MYGUI_ASSERT(mTexture != nullptr, "can't alloc texture for font"); } mTexture->destroy(); mTexture->createManual(_Width, _Height, TextureUsage::Static | TextureUsage::Write, PixelFormat::R8G8B8A8); uint8* texBuffer = static_cast<uint8*>(mTexture->lock(TextureUsage::Write)); if (texBuffer != nullptr) { // Make the texture background transparent white. for (unsigned i = 0; i < _Width * _Height * 4; ++i) { texBuffer[i] = 0; } mTexture->unlock(); } Gui::getInstance().correctTextView(); MYGUI_LOG(Info, "Alloc Font Texture Buffer"); }
void WidgetManager::initialise() { MYGUI_ASSERT(false == mIsInitialise, INSTANCE_TYPE_NAME << " initialised twice"); MYGUI_LOG(Info, "* Initialise: " << INSTANCE_TYPE_NAME); registerUnlinker(this); // создаем фабрики виджетов mIntegratedFactoryList.insert(new factory::WidgetFactory()); mIntegratedFactoryList.insert(new factory::ButtonFactory()); mIntegratedFactoryList.insert(new factory::EditFactory()); mIntegratedFactoryList.insert(new factory::ListFactory()); mIntegratedFactoryList.insert(new factory::StaticTextFactory()); mIntegratedFactoryList.insert(new factory::StaticImageFactory()); mIntegratedFactoryList.insert(new factory::VScrollFactory()); mIntegratedFactoryList.insert(new factory::HScrollFactory()); mIntegratedFactoryList.insert(new factory::WindowFactory()); mIntegratedFactoryList.insert(new factory::ComboBoxFactory()); mIntegratedFactoryList.insert(new factory::TabFactory()); mIntegratedFactoryList.insert(new factory::SheetFactory()); mIntegratedFactoryList.insert(new factory::MessageFactory()); mIntegratedFactoryList.insert(new factory::ProgressFactory()); mIntegratedFactoryList.insert(new factory::RenderBoxFactory()); mIntegratedFactoryList.insert(new factory::ItemBoxFactory()); mIntegratedFactoryList.insert(new factory::MultiListFactory()); mIntegratedFactoryList.insert(new factory::PopupMenuFactory()); mIntegratedFactoryList.insert(new factory::FooBarFactory()); MYGUI_LOG(Info, INSTANCE_TYPE_NAME << " successfully initialized"); mIsInitialise = true; }
void FactoryManager::shutdown() { MYGUI_ASSERT(mIsInitialise, getClassTypeName() << " is not initialised"); MYGUI_LOG(Info, "* Shutdown: " << getClassTypeName()); MYGUI_LOG(Info, getClassTypeName() << " successfully shutdown"); mIsInitialise = false; }