//-------------------------------------------------------------- void ofxMuiKnob::doContentBoxLayout() { // TODO: handle the case where the label is EMPTY // vertical ofxMuiLabelCaps if(label->getHeight() > getHitBoxHeight()) { setContentBoxHeight(label->getHeight()); setHitBoxY((label->getHeight() - getHitBoxHeight())/2.0); label->setY(0); } else { setContentBoxHeight(getHitBoxHeight()); label->setY((getHitBoxHeight() - label->getHeight())/2.0); setHitBoxY(0); } // label to the right label->setX(getHitBoxWidth()); // label to the right setHitBoxX(0); // value label placement valueLabel->setX(getHitBoxX()); valueLabel->setY(getHitBoxY() + (getHitBoxHeight() - valueLabel->getHeight())/2.0); // TODO: this doesn't account for auto widths ... setContentBoxWidth(getHitBoxWidth() + label->getWidth()); }
//-------------------------------------------------------------- void ofxMuiButton::doContentBoxLayout() { //cout << "0: ofxMuiButton::doContentBoxLayout=>" << endl << boxToString() << endl; /* // TODO: handle the case where the label is EMPTY // vertical ofxMuiLabelCaps if(label->getHeight() > getHitBoxHeight()) { setContentBoxHeight(label->getHeight()); setHitBoxY((label->getHeight() - getHitBoxHeight()) / 2.0f); label->setY(0); } else { setContentBoxHeight(getHitBoxHeight()); label->setY((getHitBoxHeight() - label->getHeight()) / 2.0f); setHitBoxY(0); } // label to the right label->setX(getHitBoxWidth()); // label to the right */ // setHitBoxX(0); // TODO: this doesn't account for auto widths ... setContentBoxHeight(getHitBoxHeight()); setContentBoxWidth(getHitBoxWidth());// + label->getWidth()); //cout << "1: ofxMuiButton::doContentBoxLayout=>" << endl << boxToString() << endl; }
//-------------------------------------------------------------- void ofxMuiWindow::doContentBoxLayout() { cout << "doing content box layout " << endl; int currentX = 0; int currentY = 0; int maxX = 0; int maxY = 0; // position the minmax/enable/disable buttons enableDisableButton->setPosition(0,0); currentX+=enableDisableButton->getWidth(); minMaxButton->setPosition(currentX,0); currentX+=minMaxButton->getWidth(); // position the label // TODO: center this // int labelY = (minMaxButton->getY() + minMaxButton->getHeight()) / 2.0 -label->getHeight() / 2.0 ; // label->setPosition(currentX, labelY); // // // maxX = MAX(maxX, label->getPosition().x + label->getWidth()); // // currentY+=MAX(MAX(enableDisableButton->getHeight(), // minMaxButton->getHeight()), // label->getHeight()); // // // currentX = 0; minimizedRect.x = 0; minimizedRect.y = 0; minimizedRect.width = maxX; minimizedRect.height = currentY; if(isMinimized) { } else { for(int i = 0; i < childObjects.size(); i++) { if(childObjects[i] != enableDisableButton && childObjects[i] != minMaxButton/*&& childObjects[i] != label && childObjects[i] != valueLabel*/) { currentX = 0; childObjects[i]->setPosition(currentX,currentY); currentY += childObjects[i]->getHeight(); maxX = MAX(maxX,childObjects[i]->getWidth()); } } } setHitBox(0,0,maxX,currentY); setContentBoxWidth(getHitBoxWidth()); setContentBoxHeight(getHitBoxHeight()); }
//-------------------------------------------------------------- bool ofxMuiKnob::localHitTest(float localX, float localY) { // Normalize the coordinates compared to the ellipse // having a center at 0,0 and a radius of 0.5. // via Java Ellipse2D float ellw = getHitBoxWidth(); if (ellw <= 0.0) return false; float normx = (localX - getHitBoxX()) / ellw - 0.5f; float ellh = getHitBoxHeight(); if (ellh <= 0.0) return false; float normy = (localY - getHitBoxY()) / ellh - 0.5f; return (normx * normx + normy * normy) < 0.25f; }
//-------------------------------------------------------------- void ofxMuiWindow::draw() { ofPushStyle(); ofPushMatrix(); // initial push ofTranslate(getHitBoxPosition()); ofSetColor(255,0,255); if(isMinimized) { //ofxRect(0.0f, 0.0f, width, windowButtonHeight + 1); ofxRect(0.0f, 0.0f, minimizedRect.width,minimizedRect.height); } else { ofxRect(0.0f, 0.0f, getHitBoxWidth(), getHitBoxHeight()); } ofNoFill(); /* if(name != "") { if(isMinimized) { ofPushMatrix(); ofTranslate(mGlobals->mPadLeft,mGlobals->mPadTop); drawParamString(windowButtonWidth*2, 0, name, false); ofPopMatrix(); } else { drawHeadString(mBorder, mBorder + windowButtonHeight, name, false); } } if(mBorder > 0) { // border //glColor4f(mGlobals->mBorderColor.r, mGlobals->mBorderColor.g, mGlobals->mBorderColor.b, mGlobals->mBorderColor.a); ofSetColor(mGlobals->mBorderColor); if(isMinimized) { ofxRect(0.0f, 0.0f, minimizedRect.width,minimizedRect.height); //ofxRect(0.0f, 0.0f, width, windowButtonHeight ); } else { ofxRect(0.0f, 0.0f, width, height); } } if(isEnabled && !isMinimized) { ofxMuiObject* tmpObj; for(int i = 0; i < childObjects.size(); i++) { tmpObj = (ofxMuiObject*)childObjects.at(i); tmpObj->draw(); } } else { // minMaxButton->draw(); // enableDisableButton->draw(); } */ ofPopMatrix(); ofPopStyle(); }
//-------------------------------------------------------------- void ofxMuiButton::draw() { ofPushStyle(); ofPushMatrix(); // initial push ofTranslate(getHitBoxPosition()); //--------- DRAW THE BUTTON BACKGROUND // default ofFill(); ofSetColor(cActiveAreaBackground.get(isTouchOver(),isTouchDown(),isEnabled(),alphaScale)); if(roundFrame) { // assuming that the icon is square ... ofCircle(getHitBoxWidth()/2, getHitBoxHeight()/2, getHitBoxWidth()/2); } else { ofxRect(0, 0, getHitBoxWidth(), getHitBoxHeight()); } ofNoFill(); ofSetColor(cActiveAreaForeground.get(isTouchOver(),isTouchDown(),isEnabled(),alphaScale)); if(useIcon) { int iconWidth = icon->getIcon(getValue())->getWidth(); int iconHeight = icon->getIcon(getValue())->getHeight();; int hitWidth = getHitBoxWidth(); int hitHeight = getHitBoxHeight(); int xlateX = 0; int xlateY = 0; // center the icon ofPushMatrix(); if(iconWidth < hitWidth) { int diffX = hitWidth - iconWidth; xlateX = diffX/2; } else { int diffX = iconWidth - hitWidth; xlateX = -diffX/2; } if(iconHeight < hitHeight) { int diffY = hitHeight - iconHeight; xlateY = diffY/2; } else { int diffY = iconHeight - hitHeight; xlateY = -diffY/2; } ofTranslate(xlateX, xlateY); icon->getIcon(getValue())->draw(0,0); ofPopMatrix(); } else { ofFill(); ofxRect(0, 0, getHitBoxWidth(), getHitBoxHeight()); } ofNoFill(); ofSetColor(cActiveAreaFrame.get(isTouchOver(),isTouchDown(),isEnabled(),alphaScale)); if(roundFrame) { // assuming that the icon is square ... ofCircle(getHitBoxWidth()/2, getHitBoxHeight()/2, getHitBoxWidth()/2); } else { ofxRect(0, 0, getHitBoxWidth(), getHitBoxHeight()); } ofPopMatrix(); // HIT RECT PUSH ofPopStyle(); }
//-------------------------------------------------------------- int ofxMuiButton::getButtonHeight() { return getHitBoxHeight(); }
//-------------------------------------------------------------- float ofxMuiBox::getHitBoxHalfHeight() const { return getHitBoxHeight() * 0.5f; }