/*! Init method, for every button created */ void Button2d::init( qreal x, qreal y, const QString &image ) { CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton(); _ceguiButton = (CEGUI::PushButton*)winMgr.createWindow("AquaLook/ImageButton", "bt_" + QString::number(_counter++).toStdString()); // Position _ceguiButton->setPosition(CEGUI::UVector2(cegui_absdim(x), cegui_absdim(y))); // Size CEGUI::Imageset *btImageset = createImageSet(image); if(btImageset == NULL) { qWarning() << "[Button2d::init] Imageset is NULL, reseting size to 64x64"; _ceguiButton->setSize(CEGUI::UVector2(cegui_absdim(64), cegui_absdim(64))); } else { CEGUI::Size s = btImageset->getNativeResolution(); _ceguiButton->setSize(CEGUI::UVector2(cegui_absdim(s.d_width), cegui_absdim(s.d_height))); } // Uses click to make sure that button down occurred. (ex: problem when opening options after clicking a 3D button) _ceguiButton->subscribeEvent(CEGUI::PushButton::EventMouseClick, CEGUI::Event::Subscriber(&Button2d::onMouseClick, this)); _ceguiButton->subscribeEvent(CEGUI::PushButton::EventMouseEnters, CEGUI::Event::Subscriber(&Button2d::onMouseEnters, this)); // _ceguiButton->subscribeEvent(CEGUI::PushButton::EventMouseLeaves, CEGUI::Event::Subscriber(&Button2d::onMouseLeaves, this)); // setCursor(QCursor(Qt::PointingHandCursor)); }
void Button2d::init( CEGUI::UDim x, CEGUI::UDim y, const QString &image ) { CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton(); _ceguiButton = (CEGUI::PushButton*)winMgr.createWindow("AquaLook/ImageButton", "bt_" + QString::number(_counter++).toStdString()); // Position _ceguiButton->setPosition(CEGUI::UVector2(x, y)); // Size CEGUI::Imageset *btImageset = createImageSet(image); CEGUI::Size s = btImageset->getNativeResolution(); _ceguiButton->setSize(CEGUI::UVector2(cegui_absdim(s.d_width), cegui_absdim(s.d_height))); _ceguiButton->subscribeEvent(CEGUI::PushButton::EventMouseButtonUp, CEGUI::Event::Subscriber(&Button2d::onMouseClick, this)); _ceguiButton->subscribeEvent(CEGUI::PushButton::EventMouseEnters, CEGUI::Event::Subscriber(&Button2d::onMouseEnters, this)); // setCursor(QCursor(Qt::PointingHandCursor)); }