bool TabBarButton::hitTest (int mx, int my) { int x, y, w, h; getActiveArea (x, y, w, h); if (owner->getOrientation() == TabbedButtonBar::TabsAtLeft || owner->getOrientation() == TabbedButtonBar::TabsAtRight) { if (((unsigned int) mx) < (unsigned int) getWidth() && my >= y + overlapPixels && my < y + h - overlapPixels) return true; } else { if (mx >= x + overlapPixels && mx < x + w - overlapPixels && ((unsigned int) my) < (unsigned int) getHeight()) return true; } Path p; getLookAndFeel() .createTabButtonShape (p, w, h, tabIndex, getButtonText(), *this, owner->getOrientation(), false, false, getToggleState()); return p.contains ((float) (mx - x), (float) (my - y)); }
bool ofxWidget::mouseIn(){ ofRectangle area = getActiveArea(getCurrentStyle()); bool mouseIn= mouse.x >= area.x && mouse.x <= area.x + area.width && mouse.y >= area.y && mouse.y <= area.y + area.height ; //ofLog(OF_LOG_VERBOSE,(title + " mousein: %i").c_str(),mouseIn?1:0); return (mouseIn); }
bool ofxWidget::cursorIn(TUIO::TuioCursor & tuioCursor){ ofRectangle area = getActiveArea(getCurrentStyle()); bool cursorIn= tuioCursor.getX()>= area.x && tuioCursor.getX() <= area.x + area.width && tuioCursor.getY() >= area.y && tuioCursor.getY() <= area.y + area.height ; ofLog(OF_LOG_VERBOSE,"cursorIn: %i",cursorIn?1:0); return (cursorIn); }
void TabBarButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) { int x, y, w, h; getActiveArea (x, y, w, h); g.setOrigin (x, y); getLookAndFeel() .drawTabButton (g, w, h, owner->getTabBackgroundColour (tabIndex), tabIndex, getButtonText(), *this, owner->getOrientation(), isMouseOverButton, isButtonDown, getToggleState()); }
void TabBarButton::calcAreas (Rectangle<int>& extraComp, Rectangle<int>& text) const { LookAndFeel& lf = getLookAndFeel(); text = getActiveArea(); const int depth = owner.isVertical() ? text.getWidth() : text.getHeight(); const int overlap = lf.getTabButtonOverlap (depth); if (overlap > 0) { if (owner.isVertical()) text.reduce (0, overlap); else text.reduce (overlap, 0); } if (extraComponent != nullptr) extraComp = lf.getTabButtonExtraComponentBounds (*this, text, *extraComponent); }
void TabBarButton::calcAreas (Rectangle<int>& extraComp, Rectangle<int>& textArea) const { LookAndFeel& lf = getLookAndFeel(); textArea = getActiveArea(); const int depth = owner.isVertical() ? textArea.getWidth() : textArea.getHeight(); const int overlap = lf.getTabButtonOverlap (depth); if (overlap > 0) { if (owner.isVertical()) textArea.reduce (0, overlap); else textArea.reduce (overlap, 0); } if (extraComponent != nullptr) { extraComp = lf.getTabButtonExtraComponentBounds (*this, textArea, *extraComponent); const TabbedButtonBar::Orientation orientation = owner.getOrientation(); if (orientation == TabbedButtonBar::TabsAtLeft || orientation == TabbedButtonBar::TabsAtRight) { if (extraComp.getCentreY() > textArea.getCentreY()) textArea.setBottom (jmin (textArea.getBottom(), extraComp.getY())); else textArea.setTop (jmax (textArea.getY(), extraComp.getBottom())); } else { if (extraComp.getCentreX() > textArea.getCentreX()) textArea.setRight (jmin (textArea.getRight(), extraComp.getX())); else textArea.setLeft (jmax (textArea.getX(), extraComp.getRight())); } } }
ofPoint ofxWidget::getRelativePosition(float x, float y){ return ofPoint((x-getActiveArea(getCurrentStyle()).x)/getActiveArea(getCurrentStyle()).width ,(y-getActiveArea(getCurrentStyle()).y)/getActiveArea(getCurrentStyle()).height); }
ofPoint ofxWidget::getControlActiveSize(){ ofRectangle area = getActiveArea(styleEnabled); return ofPoint(area.width,area.height); }
ofRectangle ofxWidget::getControlActiveArea(){ return getActiveArea(styleEnabled); }