bool GUIListGadget::pickColumn(GUIListColumn* &Column, bool &isEdgePick) { if (!mouseOver(dim::rect2di(Rect_.Left, Rect_.Top, Rect_.Right, Rect_.Top + COLUMN_HEIGHT))) return false; s32 ColumnPosHorz = Rect_.Left + ScrollPos_.X; s32 ColumnPosVert = Rect_.Top; if (!(Flags_ & GUIFLAG_NOCOLUMNSCROLL)) ColumnPosVert += ScrollPos_.Y; for (std::list<GUIListColumn*>::iterator it = ColumnList_.begin(); it != ColumnList_.end(); ++it) { FocusedColumnPosHorz_ = ColumnPosHorz; ColumnPosHorz += (*it)->getColumnSize(); if (mouseOver(dim::rect2di(ColumnPosHorz - 5, ColumnPosVert, ColumnPosHorz + 5, ColumnPosVert + COLUMN_HEIGHT))) { Column = *it; isEdgePick = true; return true; } else if (mouseOver(dim::rect2di(ColumnPosHorz - (*it)->getColumnSize(), ColumnPosVert, ColumnPosHorz, ColumnPosVert + COLUMN_HEIGHT))) { Column = *it; isEdgePick = false; return true; } } return false; }
void GuiButton::render(RenderDevice* rd, const shared_ptr<GuiTheme>& skin) const { (void)rd; if (m_visible) { skin->renderButton(m_rect, m_enabled, focused() || mouseOver(), m_down && mouseOver(), m_caption, (GuiTheme::ButtonStyle)m_style); } }
void GuiRadioButton::render(RenderDevice* rd, const shared_ptr<GuiTheme>& skin) const { (void)rd; if (m_visible) { if (m_style == GuiTheme::NORMAL_RADIO_BUTTON_STYLE) { skin->renderRadioButton(m_rect, m_enabled, focused() || mouseOver(), selected(), m_caption); } else { skin->renderButton(m_rect, m_enabled, focused() || mouseOver(), selected(), m_caption, (m_style == GuiTheme::BUTTON_RADIO_BUTTON_STYLE) ? GuiTheme::NORMAL_BUTTON_STYLE : GuiTheme::TOOL_BUTTON_STYLE); } } }
void GuiCheckBox::render(RenderDevice* rd, const GuiThemeRef& skin) const { (void)rd; if (m_visible) { switch (m_style) { case GuiTheme::NORMAL_CHECK_BOX_STYLE: skin->renderCheckBox(m_rect, m_enabled, focused() || mouseOver(), *m_value, m_caption); break; default: skin->renderButton(m_rect, m_enabled, focused() || mouseOver(), *m_value, m_caption, (m_style == GuiTheme::BUTTON_CHECK_BOX_STYLE) ? GuiTheme::NORMAL_BUTTON_STYLE : GuiTheme::TOOL_BUTTON_STYLE); } } }
void GLWidget::mouseMoveEvent(QMouseEvent *event) { if(lastMousePos.isNull()) lastMousePos = event->pos(); // rotate the board if(event->buttons() & Qt::RightButton) { const QPoint _curpos = event->pos(); cameraAngleX += ( lastMousePos.x() - _curpos.x() ) * -CAM_X_ROT_DELTA; cameraAngleY += ( lastMousePos.y() - _curpos.y() ) * CAM_Y_ROT_DELTA; if(cameraAngleY > CAM_MAX_Y_ANGLE) cameraAngleY = CAM_MAX_Y_ANGLE; if(cameraAngleY < CAM_MIN_Y_ANGLE) cameraAngleY = CAM_MIN_Y_ANGLE; if(cameraAngleX > 2*M_PI) cameraAngleX = 0; if(cameraAngleX < 0) cameraAngleX = 2*M_PI; updateGL(); } else { emit mouseOver(event); } lastMousePos = event->pos(); }
/**************************************************************************** ** ** Copyright (C) 2015 ** ** This file is generated by the Magus toolkit ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ****************************************************************************/ // Include #include <QHBoxLayout> #include <QVBoxLayout> #include <QMessageBox> #include <QDir> #include <QImageReader> #include "tool_simple_texturewidget.h" namespace Magus { //****************************************************************************/ QtSimpleTextureWidget::QtSimpleTextureWidget(QWidget* parent) : QWidget(parent) { setWindowTitle(QString("Texture selection")); mNameTexture = QString(""); mBaseNameTexture = QString(""); mTextureSize = QSize(128, 128); mOriginIsFile = true; QHBoxLayout* mainLayout = new QHBoxLayout; QVBoxLayout* textureSelectionLayout = new QVBoxLayout; // Define selection widget (QListView) mSelectionList = new QListView(this); mSelectionList->setViewMode(QListView::IconMode); mSelectionList->setIconSize(mTextureSize); mSelectionList->setSpacing(0); mSelectionList->setMovement(QListView::Snap); mSelectionList->setFlow(QListView::LeftToRight); mSelectionList->setWrapping(true); mSelectionList->setDragEnabled(true); mSelectionList->setAcceptDrops(false); mSelectionList->setDropIndicatorShown(false); mSelectionList->setMouseTracking(true); mSelectionModel = new QtSimpleTextureModel(); mSelectionList->setModel(mSelectionModel); connect(mSelectionList, SIGNAL(clicked(QModelIndex)), this, SLOT(handleSelected(QModelIndex))); connect(mSelectionList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(handleDoubleClicked(QModelIndex))); connect(mSelectionList, SIGNAL(entered(QModelIndex)), this, SLOT(mouseOver(QModelIndex))); // Layout textureSelectionLayout->addWidget(mSelectionList); mainLayout->addLayout(textureSelectionLayout); setLayout(mainLayout); }
void GuiDropDownList::render(RenderDevice* rd, const shared_ptr<GuiTheme>& skin) const { (void)rd; if (m_visible) { skin->renderDropDownList(m_rect, m_enabled, focused() || mouseOver(), m_selecting, selectedValue(), m_caption, m_captionWidth); } }
const bool C_LineEdit::clicked(const float x, const float y) { if(mouseOver(x, y)) { focus(true); return true; } focus(false); return false; }
void GuiDropDownList::render(RenderDevice* rd, const GuiSkinRef& skin) const { if (m_visible) { if (m_useStringList) { // If there are no elements in the list, display the empty string const std::string& str = (m_stringListValue->size() > 0) ? (*m_stringListValue)[iMax(0, iMin(m_stringListValue->size() - 1, *m_indexValue))] : ""; skin->renderDropDownList(m_rect, m_enabled, focused() || mouseOver(), m_selecting, str, m_caption); } else { // If there are no elements in the list, display the empty string const GuiCaption& str = (m_captionListValue->size() > 0) ? (*m_captionListValue)[iMax(0, iMin(m_captionListValue->size() - 1, *m_indexValue))] : ""; skin->renderDropDownList(m_rect, m_enabled, focused() || mouseOver(), m_selecting, str, m_caption); } } }
bool PositionSlider::click(vec2f pos, float* percent_ptr) { if(mouseOver(pos, &percent)) { if(percent_ptr != 0) { *percent_ptr = percent; } return true; } return false; }
//return if clicked or mouse over sf::Event GuiObject::pollEvent(sf::Event event){ if(mouseOver()){ if(event.MouseButtonPressed){ setTexture(mouseDownTexture); }else{ setTexture(mouseOverTexture); } }else{ setTexture(defaultTexture); } return event; }
void GUIGadget::drawBgRect( const dim::rect2di &DrawRect, const dim::rect2di &MouseRect, bool isSwaped, bool isAlwaysUsing, s32 UsageType) { const f32 Factor = ( isEnabled_ && Usable_ && ( mouseOver(MouseRect) || ( isAlwaysUsing && usage() ) ) ? 0.8f : 0.6f ); video::color ColorA(Color_), ColorB(Color_ * Factor); if ( ( UsageType == -1 && usage() ) || usage(UsageType) ) std::swap(ColorA, ColorB); if (isSwaped) std::swap(ColorA, ColorB); GlbRenderSys->draw2DRectangle(DrawRect, ColorA, ColorA, ColorB, ColorB); }
void MouseInteractive::collidedWith( Collidable *arg ) { MousePointer *m_p; if( m_p = dynamic_cast<MousePointer *>( arg ) ) { if( !mouse_over_running ) { mouse_over_running = true; mouseOver(); } if( m_p->isClicked() ) click(); } }
/** * Handles camera mouse shortcuts. * @param action Pointer to an action. * @param state State that the action handlers belong to. */ void Camera::mousePress(Action *action, State *) { if (action->getDetails()->button.button == SDL_BUTTON_WHEELUP) { up(); } else if (action->getDetails()->button.button == SDL_BUTTON_WHEELDOWN) { down(); } else if (action->getDetails()->button.button == SDL_BUTTON_LEFT && Options::getInt("battleScrollType") == SCROLL_TRIGGER) { _scrollTrigger = true; mouseOver(action, 0); } }
bool GUIListGadget::update() { updateScrollBars(&HorzScroll_, &VertScroll_); if (hasFocus() && GlbGUIMngr->MouseWheel_) VertScroll_.scroll(-GlbGUIMngr->MouseWheel_ * 30); if (!checkDefaultUpdate()) return false; if (isEnabled_ && mouseOver(Rect_) && !foreignUsage()) { if (mouseLeft()) { focus(); GUIListColumn* Column; bool isEdgePick; if (pickColumn(Column, isEdgePick)) { FocusedColumn_ = Column; if (isEdgePick) useFocus(USAGE_RESIZE_COLUMN); else ; // !TODO! } } } dim::point2di Pos(getItemsStartPos()); for (std::list<GUIListItem*>::iterator it = ItemList_.begin(); it != ItemList_.end(); ++it) updateItem(*it, Pos); if (usage(USAGE_RESIZE_COLUMN) && FocusedColumn_) FocusedColumn_->setColumnSize(GlbGUIMngr->CursorPos_.X - FocusedColumnPosHorz_); updateChildren(); return true; }
/** * Handles camera mouse shortcuts. * @param action Pointer to an action. * @param state State that the action handlers belong to. */ void Camera::mousePress(Action *action, State *) { if (action->getDetails()->button.button == SDL_BUTTON_LEFT && Options::battleEdgeScroll == SCROLL_TRIGGER) { _scrollTrigger = true; mouseOver(action, 0); } else if (Options::battleDragScrollButton != SDL_BUTTON_MIDDLE || (SDL_GetMouseState(0,0)&SDL_BUTTON(Options::battleDragScrollButton)) == 0) { if (action->getDetails()->button.button == SDL_BUTTON_WHEELUP) { up(); } else if (action->getDetails()->button.button == SDL_BUTTON_WHEELDOWN) { down(); } } }
void GUIListGadget::updateItem(GUIListItem* Item, dim::point2di &Pos) { if (!Item || !Item->getVisible()) return; dim::rect2di Rect( Rect_.Left, Pos.Y, Rect_.Right, Pos.Y + Item->getItemSize() ); if (VertScroll_.getVisible()) Rect.Right -= SCROLLBAR_SIZE; if (HorzScroll_.getVisible() && Rect.Bottom > Rect_.Bottom - SCROLLBAR_SIZE) Rect.Bottom = Rect_.Bottom - SCROLLBAR_SIZE; Pos.Y += Item->getItemSize(); /* Update current item */ if (mouseOver(Rect)) { Item->isPicked_ = true; if (mouseLeft()) { SelectedItem_ = Item; SGUIEvent Event; { Event.Object = EVENT_GADGET; Event.Type = EVENT_ACTIVATE; Event.Gadget = this; Event.SubData = Item; } sendEvent(Event); } } }
void board::placePeg(RenderWindow& Window, int pegSelect) { int pegPosition = mouseOver(Window); if(pegPosition >= 0 && pegSelect) { pegDrop = 1; } if(!Mouse::isButtonPressed(Mouse::Left) && pegDrop && pegPosition >= 0) { switch(pegSelect) { case 1: circleArr[pegPosition][rowSelect].setFillColor(Color::Red); break; case 2: circleArr[pegPosition][rowSelect].setFillColor(Color::Green); break; case 3: circleArr[pegPosition][rowSelect].setFillColor(Color::Blue); break; case 4: circleArr[pegPosition][rowSelect].setFillColor(Color::Yellow); break; case 5: circleArr[pegPosition][rowSelect].setFillColor(Color::White); break; case 6: circleArr[pegPosition][rowSelect].setFillColor(Color(50, 0, 100)); break; } if(!pegPresent[pegPosition]) pegCount++; pegPresent[pegPosition] = 1; pegDrop = 0; } }
void MenuState::mouseDown(int x, int y) { if(mouseOver(x,y) == 1) { //play printf("1 : Play"); m_engine->m_SoundMgr->PlayPause(); } if(mouseOver(x,y) == 2) { //next m_engine->m_SoundMgr->PlayNext(); } if(mouseOver(x,y) == 3) { //prev m_engine->m_SoundMgr->PlayPrev(); } if(mouseOver(x,y) == 4) { //stop printf("4 : Stop"); m_engine->m_SoundMgr->Stop(); } if(mouseOver(x,y) == 5) { m_engine->m_state_manager.SetState("GameState"); } if(mouseOver(x,y) == 6) { m_engine->m_state_manager.SetState("StartState"); } }
bool GUIScrollbarGadget::update() { if (hasFocus() && GlbGUIMngr->MouseWheel_) scroll(-GlbGUIMngr->MouseWheel_ * 30); if (!checkDefaultUpdate()) return false; if (isEnabled_ && mouseOver(Rect_) && !foreignUsage()) { if (mouseLeft()) { focus(); CursorPosBias_ = GlbGUIMngr->CursorPos_ - dim::point2di(Rect_.Left, Rect_.Top + 1) - dim::point2di(BarPos_); dim::rect2di BarRect, ButtonARect, ButtonBRect, PageARect, PageBRect; getButtonRects(BarRect, ButtonARect, ButtonBRect, PageARect, PageBRect); if (mouseOver(BarRect)) useFocus(USAGE_DRAG); else if (mouseOver(ButtonARect)) useFocus(USAGE_FORWARDS); else if (mouseOver(ButtonBRect)) useFocus(USAGE_BACKWARDS); else if (mouseOver(PageARect)) scroll(-PageSize_); else if (mouseOver(PageBRect)) scroll(PageSize_); } } if (usage(USAGE_DRAG)) updateDrag(); else if (usage(USAGE_FORWARDS)) scroll(-3); else if (usage(USAGE_BACKWARDS)) scroll(3); return true; }
bool Quad::leftPressed() const { return MouseL.pressed() && mouseOver(); }
void _GuiSliderBase::render(RenderDevice* rd, const GuiThemeRef& skin) const { (void)rd; if (m_visible) { if (m_horizontal) { skin->renderHorizontalSlider(m_rect, floatValue(), m_enabled, focused() || mouseOver(), m_caption, m_captionSize); } } }
bool Quad::rightClicked() const { return MouseR.down() && mouseOver(); }
bool Quad::rightReleased() const { return MouseR.up() && mouseOver(); }
bool Quad::rightPressed() const { return MouseR.pressed() && mouseOver(); }
bool Ellipse::rightClicked() const { return MouseR.down() && mouseOver(); }
bool Quad::leftClicked() const { return MouseL.down() && mouseOver(); }
bool Ellipse::rightPressed() const { return MouseR.pressed() && mouseOver(); }
bool Quad::leftReleased() const { return MouseL.up() && mouseOver(); }
bool Ellipse::rightReleased() const { return MouseR.up() && mouseOver(); }