int main(void) { // seed pseudorandom number generator srand48(time(NULL)); // instantiate window GWindow window = newGWindow(WIDTH, HEIGHT); // instantiate bricks initBricks(window); // instantiate ball, centered in middle of window GOval ball = initBall(window); // instantiate paddle, centered at bottom of window GRect paddle = initPaddle(window); // instantiate scoreboard, centered in middle of window, just above ball GLabel label = initScoreboard(window); // number of bricks initially int bricks = COLS * ROWS; // number of lives initially int lives = LIVES; // number of points initially int points = 0; double velocity = drand48()*5; double velocityX = drand48()*5; // keep playing until game over while (lives > 0 && bricks > 0) { move(ball, velocityX, velocity); pause(10); // check for mouse event GEvent event = getNextEvent(MOUSE_EVENT); // if we heard one if (event != NULL) { // if the event was movement if (getEventType(event) == MOUSE_MOVED) { // ensure follows cursor double x = getX(event); if(x <= 350&&velocityX!=0) setLocation(paddle, x, 550); } } GObject object = detectCollision(window, ball); if(object != NULL) { if (object == paddle) { velocity = -velocity; updateScoreboard(window,label, points); } else if (strcmp(getType(object), "GRect") == 0) { velocity = -velocity; points++; updateScoreboard(window,label, points); bricks--; removeGWindow(window, object); } } // bounce off bottom edge of window if (getY(ball) + getHeight(ball) >= getHeight(window)) { velocity = 0; velocityX = 0; lives--; } // bounce off up edge of window else if (getY(ball) <= 0) { velocity = -velocity; } if (getX(ball) + getWidth(ball) >= getWidth(window)) { velocityX = -velocityX; } // bounce off bottom edge of window else if (getX(ball) <= 0) { velocityX = -velocityX; } // linger before moving again pause(10); } if(points==50) { GLabel label = newGLabel("You bricked out the breakout!"); setFont(label, "SansSerif-36"); add(window, label); setLocation(label, 100, 200); pause(10); } else if(points<50) { GLabel label = newGLabel("Try again!"); setFont(label, "SansSerif-36"); add(window, label); setLocation(label, 100, 200); pause(10); } // wait for click before exiting if(bricks==0) { waitForClick(); // game over closeGWindow(window); } if(lives==0) { waitForClick(); // game over closeGWindow(window); } waitForClick(); // game over closeGWindow(window); return 0; }
Rectangle BasicContainer::getChildrenArea() { return Rectangle(0, 0, getWidth(), getHeight()); }
void PlayHeadComponent::resized() { positionLabel->setBounds (10, 10, getWidth() - 20, getHeight() - 20); }
void UtilityButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDown) { g.setColour(Colours::grey); g.fillPath(outlinePath); if (getToggleState()) { if (isMouseOver) g.setGradientFill(selectedOverGrad); else g.setGradientFill(selectedGrad); } else { if (isMouseOver) g.setGradientFill(neutralOverGrad); else g.setGradientFill(neutralGrad); } AffineTransform a = AffineTransform::scale(0.98f, 0.94f, float(getWidth())/2.0f, float(getHeight())/2.0f); g.fillPath(outlinePath, a); //int stringWidth = font.getStringWidth(getName()); g.setFont(font); g.setColour(fontColor); g.drawText(getName(),0,0,getWidth(),getHeight(),Justification::centred,true); //g.drawSingleLineText(getName(), getWidth()/2 - stringWidth/2, 12); // if (getToggleState() == true) // g.setColour(Colours::orange); // else // g.setColour(Colours::darkgrey); // if (isMouseOver) // g.setColour(Colours::white); // g.fillRect(0,0,getWidth(),getHeight()); // font.setHeight(10); // g.setFont(font); // g.setColour(Colours::black); // g.drawRect(0,0,getWidth(),getHeight(),1.0); //g.drawText(getName(),0,0,getWidth(),getHeight(),Justification::centred,true); // if (isButtonDown) // { // g.setColour(Colours::white); // } // int thickness = 1; // int offset = 3; // g.fillRect(getWidth()/2-thickness, // offset, // thickness*2, // getHeight()-offset*2); // g.fillRect(offset, // getHeight()/2-thickness, // getWidth()-offset*2, // thickness*2); }
unsigned int getHeightPix() const { return getHeight(); }
float getAspectYOverX() const { return float(getHeight()) / float(getWidth()); }
void putPixel(unsigned int x, unsigned int y, const PIX &color) { if ( x >= getWidth() || y >= getHeight()) return; *(mem + (y * getPitch()) + x) = color; }
void ComboBox::resized() { if (getHeight() > 0 && getWidth() > 0) getLookAndFeel().positionComboBoxText (*this, *label); }
// Get water state on map GridMapLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, GridMapLiquidData *data) { // Check water type (if no water return) if (!m_liquid_type && !m_liquidType) return LIQUID_MAP_NO_WATER; // Get cell float cx = MAP_RESOLUTION * (32 - x/SIZE_OF_GRIDS); float cy = MAP_RESOLUTION * (32 - y/SIZE_OF_GRIDS); int x_int = (int)cx & (MAP_RESOLUTION-1); int y_int = (int)cy & (MAP_RESOLUTION-1); // Check water type in cell uint8 type = m_liquid_type ? m_liquid_type[(x_int>>3)*16 + (y_int>>3)] : m_liquidType; if (type == 0) return LIQUID_MAP_NO_WATER; // Check req liquid type mask if (ReqLiquidType && !(ReqLiquidType&type)) return LIQUID_MAP_NO_WATER; // Check water level: // Check water height map int lx_int = x_int - m_liquid_offY; if (lx_int < 0 || lx_int >=m_liquid_height) return LIQUID_MAP_NO_WATER; int ly_int = y_int - m_liquid_offX; if (ly_int < 0 || ly_int >=m_liquid_width ) return LIQUID_MAP_NO_WATER; // Get water level float liquid_level = m_liquid_map ? m_liquid_map[lx_int*m_liquid_width + ly_int] : m_liquidLevel; // Get ground level (sub 0.2 for fix some errors) float ground_level = getHeight(x, y); // Check water level and ground level if (liquid_level < ground_level || z < ground_level - 2) return LIQUID_MAP_NO_WATER; // All ok in water -> store data if (data) { data->type = type; data->level = liquid_level; data->depth_level = ground_level; } // For speed check as int values int delta = int((liquid_level - z) * 10); // Get position delta if (delta > 20) // Under water return LIQUID_MAP_UNDER_WATER; if (delta > 0 ) // In water return LIQUID_MAP_IN_WATER; if (delta > -1) // Walk on water return LIQUID_MAP_WATER_WALK; // Above water return LIQUID_MAP_ABOVE_WATER; }
void Player::setCurrentTile(Tile* tile) { //Set the current tile pointer m_CurrentTile = tile; //Center the player's position on the tile setPosition(tile->getX() + ((tile->getWidth() - getWidth()) / 2), tile->getY() + ((tile->getHeight() - getHeight()) / 2)); }
Vector3 MeshObject::getCenter() { return Vector3(0, 0, getHeight() / 2.0); }
gcn::Rectangle Inventory::getChildrenArea(){ return gcn::Rectangle(1,1,getWidth(),getHeight()); }
//============================================================================== void Viewport::updateVisibleRegion() { if (contentComp != 0) { const int newVX = -contentComp->getX(); const int newVY = -contentComp->getY(); if (newVX == 0 && newVY == 0 && contentComp->getWidth() <= getWidth() && contentComp->getHeight() <= getHeight()) { horizontalScrollBar->setVisible (false); verticalScrollBar->setVisible (false); } horizontalScrollBar->setRangeLimits (0.0, contentComp->getWidth()); horizontalScrollBar->setCurrentRange (newVX, getMaximumVisibleWidth()); horizontalScrollBar->setSingleStepSize (singleStepX); if (! (contentComp->getWidth() > 0 && showHScrollbar && getHeight() > getScrollBarThickness())) horizontalScrollBar->setVisible (false); verticalScrollBar->setRangeLimits (0.0, contentComp->getHeight()); verticalScrollBar->setCurrentRange (newVY, getMaximumVisibleHeight()); verticalScrollBar->setSingleStepSize (singleStepY); if (! (contentComp->getHeight() > 0 && showVScrollbar && getWidth() > getScrollBarThickness())) verticalScrollBar->setVisible (false); if (verticalScrollBar->isVisible()) { horizontalScrollBar->setCurrentRange (newVX, getMaximumVisibleWidth()); verticalScrollBar->setCurrentRange (newVY, getMaximumVisibleHeight()); verticalScrollBar ->setBounds (getMaximumVisibleWidth(), 0, getScrollBarThickness(), getMaximumVisibleHeight()); } if (horizontalScrollBar->isVisible()) { horizontalScrollBar->setCurrentRange (newVX, getMaximumVisibleWidth()); horizontalScrollBar ->setBounds (0, getMaximumVisibleHeight(), getMaximumVisibleWidth(), getScrollBarThickness()); } contentHolder->setSize (getMaximumVisibleWidth(), getMaximumVisibleHeight()); const int newVW = jmin (contentComp->getRight(), getMaximumVisibleWidth()); const int newVH = jmin (contentComp->getBottom(), getMaximumVisibleHeight()); if (newVX != lastVX || newVY != lastVY || newVW != lastVW || newVH != lastVH) { lastVX = newVX; lastVY = newVY; lastVW = newVW; lastVH = newVH; visibleAreaChanged (newVX, newVY, newVW, newVH); for (int i = viewportListeners.size(); --i >= 0;) { ((ViewportListener*) viewportListeners.getUnchecked (i)) ->visibleAreaChanged (this, newVX, newVY, newVW, newVH); } } horizontalScrollBar->handleUpdateNowIfNeeded(); verticalScrollBar->handleUpdateNowIfNeeded(); } else { horizontalScrollBar->setVisible (false); verticalScrollBar->setVisible (false); } }
int Viewport::getMaximumVisibleHeight() const throw() { return jmax (0, getHeight() - (horizontalScrollBar->isVisible() ? getScrollBarThickness() : 0)); }
int getCenterY() const { return getHeight()>>1; }
void EnviUIMain::resized() { enviUIStatus->setBounds (0,0,getWidth(),getHeight()); enviTabs->setBounds (0,0,getWidth(),getHeight()); }
int getArea() const { return getWidth() * getHeight(); }
Rect Widget::getClientRect() const { return Rect( 0, 0, getWidth(), getHeight() ); }
iRect getRect() const { return iRect(0, 0, getWidth() - 1, getHeight() - 1); }
void Widget::setWidth( unsigned int width ) { const Rect rectangle( getRelativeRect().UpperLeftCorner, Size( width, getHeight() ) ); setGeometry( rectangle ); }
void GuiSliderCtrl::onRender(Point2I offset, const RectI &updateRect) { Point2I pos(offset.x+mShiftPoint, offset.y); Point2I ext(getWidth() - mShiftExtent, getHeight()); RectI thumb = mThumb; if( mHasTexture ) { if(mTicks > 0) { // TODO: tick marks should be positioned based on the bitmap dimensions. Point2I mid(ext.x, ext.y/2); Point2I oldpos = pos; pos += Point2I(1, 0); PrimBuild::color4f( 0.f, 0.f, 0.f, 1.f ); PrimBuild::begin( GFXLineList, ( mTicks + 2 ) * 2 ); // tick marks for (U32 t = 0; t <= (mTicks+1); t++) { S32 x = (S32)(F32(mid.x+1)/F32(mTicks+1)*F32(t)) + pos.x; S32 y = pos.y + mid.y; PrimBuild::vertex2i(x, y + mShiftPoint); PrimBuild::vertex2i(x, y + mShiftPoint*2 + 2); } PrimBuild::end(); // TODO: it would be nice, if the primitive builder were a little smarter, // so that we could change colors midstream. PrimBuild::color4f(0.9f, 0.9f, 0.9f, 1.0f); PrimBuild::begin( GFXLineList, ( mTicks + 2 ) * 2 ); // tick marks for (U32 t = 0; t <= (mTicks+1); t++) { S32 x = (S32)(F32(mid.x+1)/F32(mTicks+1)*F32(t)) + pos.x + 1; S32 y = pos.y + mid.y + 1; PrimBuild::vertex2i(x, y + mShiftPoint ); PrimBuild::vertex2i(x, y + mShiftPoint * 2 + 3); } PrimBuild::end(); pos = oldpos; } S32 index = SliderButtonNormal; if(mMouseOver) index = SliderButtonHighlight; GFX->getDrawUtil()->clearBitmapModulation(); //left border GFX->getDrawUtil()->drawBitmapSR(mProfile->mTextureObject, Point2I(offset.x,offset.y), mBitmapBounds[SliderLineLeft]); //right border GFX->getDrawUtil()->drawBitmapSR(mProfile->mTextureObject, Point2I(offset.x + getWidth() - mBitmapBounds[SliderLineRight].extent.x, offset.y), mBitmapBounds[SliderLineRight]); //draw our center piece to our slider control's border and stretch it RectI destRect; destRect.point.x = offset.x + mBitmapBounds[SliderLineLeft].extent.x; destRect.extent.x = getWidth() - mBitmapBounds[SliderLineLeft].extent.x - mBitmapBounds[SliderLineRight].extent.x; destRect.point.y = offset.y; destRect.extent.y = mBitmapBounds[SliderLineCenter].extent.y; RectI stretchRect; stretchRect = mBitmapBounds[SliderLineCenter]; stretchRect.inset(1,0); GFX->getDrawUtil()->drawBitmapStretchSR(mProfile->mTextureObject, destRect, stretchRect); //draw our control slider button thumb.point += pos; GFX->getDrawUtil()->drawBitmapSR(mProfile->mTextureObject,Point2I(thumb.point.x,offset.y ),mBitmapBounds[index]); } else if (getWidth() >= getHeight()) { Point2I mid(ext.x, ext.y/2); if(mDisplayValue) mid.set(ext.x, mThumbSize.y/2); PrimBuild::color4f( 0.f, 0.f, 0.f, 1.f ); PrimBuild::begin( GFXLineList, ( mTicks + 2 ) * 2 + 2); // horz rule PrimBuild::vertex2i( pos.x, pos.y + mid.y ); PrimBuild::vertex2i( pos.x + mid.x, pos.y + mid.y ); // tick marks for( U32 t = 0; t <= ( mTicks + 1 ); t++ ) { S32 x = (S32)( F32( mid.x - 1 ) / F32( mTicks + 1 ) * F32( t ) ); PrimBuild::vertex2i( pos.x + x, pos.y + mid.y - mShiftPoint ); PrimBuild::vertex2i( pos.x + x, pos.y + mid.y + mShiftPoint ); } PrimBuild::end(); } else { Point2I mid(ext.x/2, ext.y); PrimBuild::color4f( 0.f, 0.f, 0.f, 1.f ); PrimBuild::begin( GFXLineList, ( mTicks + 2 ) * 2 + 2); // horz rule PrimBuild::vertex2i( pos.x + mid.x, pos.y ); PrimBuild::vertex2i( pos.x + mid.x, pos.y + mid.y ); // tick marks for( U32 t = 0; t <= ( mTicks + 1 ); t++ ) { S32 y = (S32)( F32( mid.y - 1 ) / F32( mTicks + 1 ) * F32( t ) ); PrimBuild::vertex2i( pos.x + mid.x - mShiftPoint, pos.y + y ); PrimBuild::vertex2i( pos.x + mid.x + mShiftPoint, pos.y + y ); } PrimBuild::end(); mDisplayValue = false; } // draw the thumb thumb.point += pos; renderRaisedBox(thumb, mProfile); if(mDisplayValue) { char buf[20]; dSprintf(buf,sizeof(buf),"%0.3f",mValue); Point2I textStart = thumb.point; S32 txt_w = mProfile->mFont->getStrWidth((const UTF8 *)buf); textStart.x += (S32)((thumb.extent.x/2.0f)); textStart.y += thumb.extent.y - 2; //19 textStart.x -= (txt_w/2); if(textStart.x < offset.x) textStart.x = offset.x; else if(textStart.x + txt_w > offset.x+getWidth()) textStart.x -=((textStart.x + txt_w) - (offset.x+getWidth())); GFX->getDrawUtil()->setBitmapModulation(mProfile->mFontColor); GFX->getDrawUtil()->drawText(mProfile->mFont, textStart, buf, mProfile->mFontColors); } renderChildControls(offset, updateRect); }
//============================================================================== void DexedAudioProcessorEditor::paint (Graphics& g) { g.setColour(background); g.fillRoundedRectangle(0.0f, 0.0f, (float) getWidth(), (float) getHeight(), 0); }
/** * Do an amount of damage. * @param position The position defines which part of armor and/or bodypart is hit. * @param power * @param type */ void BattleUnit::damage(Position position, int power, ItemDamageType type, bool ignoreArmor) { UnitSide side = SIDE_FRONT; int impactheight; UnitBodyPart bodypart = BODYPART_TORSO; if (power <= 0) { return; } power = (int)floor(power * _armor->getDamageModifier(type)); if (!ignoreArmor) { if (position == Position(0, 0, 0)) { side = SIDE_UNDER; } else { // normalize x and y towards north int x = 8, y = 8; switch(_direction) { case 0: // heading north x = position.x; y = 15 - position.y; break; case 1: // somewhere in between 0 and 2 x = (position.x + position.y)/2; y = ((15 - position.y) + position.x)/2; break; case 2: // heading east x = 15 - position.y; y = 15 - position.x; break; case 3: x = (position.y + (15 - position.x))/2; y = (position.x + position.y)/2; break; case 4: // heading south x = 15 - position.x; y = position.y; break; case 5: x = ((15 - position.x) + (15 - position.y))/2; y = (position.y + (15 - position.x))/2; break; case 6: // heading west x = 15 - position.y; y = 15 - position.x; break; case 7: x = ((15 - position.y) + position.x)/2; y = ((15 - position.x) + (15 - position.y))/2; break; } // determine side if (y > 9) side = SIDE_FRONT; else if (y < 6) side = SIDE_REAR; else if (x < 6) side = SIDE_LEFT; else if (x > 9) side = SIDE_RIGHT; else side = SIDE_FRONT; } impactheight = 10*position.z/getHeight(); if (impactheight > 4 && impactheight < 7) // torso { if (side == SIDE_LEFT) { bodypart = BODYPART_LEFTARM; }else if (side == SIDE_RIGHT) { bodypart = BODYPART_RIGHTARM; }else { bodypart = BODYPART_TORSO; } }else if (impactheight >= 7) //head { bodypart = BODYPART_HEAD; }else if (impactheight <=4) //legs { if (side == SIDE_LEFT || side == SIDE_FRONT) { bodypart = BODYPART_LEFTLEG; }else { bodypart = BODYPART_RIGHTLEG; } } power -= getArmor(side); } if (power > 0) { if (type == DT_STUN) { _stunlevel += power; } else { // health damage _health -= power; if (_health < 0) _health = 0; if (type != DT_IN) { // fatal wounds if (isWoundable()) { if (RNG::generate(0,power) > 2) _fatalWounds[bodypart] += RNG::generate(1,3); if (_fatalWounds[bodypart]) moraleChange(-_fatalWounds[bodypart]); } // armor damage setArmor(getArmor(side) - (power/10) - 1, side); } _needPainKiller = true; } } }
void DrawableButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) { Rectangle imageSpace; if (style == ImageOnButtonBackground) { const int insetX = getWidth() / 4; const int insetY = getHeight() / 4; imageSpace.setBounds (insetX, insetY, getWidth() - insetX * 2, getHeight() - insetY * 2); getLookAndFeel().drawButtonBackground (g, *this, getBackgroundColour(), isMouseOverButton, isButtonDown); } else { g.fillAll (getBackgroundColour()); const int textH = (style == ImageAboveTextLabel) ? jmin (16, proportionOfHeight (0.25f)) : 0; const int indentX = jmin (edgeIndent, proportionOfWidth (0.3f)); const int indentY = jmin (edgeIndent, proportionOfHeight (0.3f)); imageSpace.setBounds (indentX, indentY, getWidth() - indentX * 2, getHeight() - indentY * 2 - textH); if (textH > 0) { g.setFont ((float) textH); g.setColour (Colours::black.withAlpha (isEnabled() ? 1.0f : 0.4f)); g.drawFittedText (getButtonText(), 2, getHeight() - textH - 1, getWidth() - 4, textH, Justification::centred, 1); } } g.setImageResamplingQuality (Graphics::mediumResamplingQuality); g.setOpacity (1.0f); const Drawable* imageToDraw = 0; if (isEnabled()) { imageToDraw = getCurrentImage(); } else { imageToDraw = getToggleState() ? disabledImageOn : disabledImage; if (imageToDraw == 0) { g.setOpacity (0.4f); imageToDraw = getNormalImage(); } } if (imageToDraw != 0) { if (style == ImageRaw) { imageToDraw->draw (g, 1.0f); } else { imageToDraw->drawWithin (g, imageSpace.getX(), imageSpace.getY(), imageSpace.getWidth(), imageSpace.getHeight(), RectanglePlacement::centred, 1.0f); } } }
int main(void) { int height = getHeight(); print_Half_Of_Pyramid(height); }
//==================================================================================== void PositionableWaveDisplay::resized() { const ScopedLock sl (imageLock); cachedImage = Image (Image::RGB, jmax (1, int (getWidth() / zoomRatio)), jmax (1, getHeight()), false); cachedImage.clear (cachedImage.getBounds(), backgroundColour); refreshCachedImage(); audioTransportCursor.setBounds (getLocalBounds()); }
SimpleDistortionAudioProcessorEditor::SimpleDistortionAudioProcessorEditor (SimpleDistortionAudioProcessor& p) : SAFEAudioProcessorEditor (&p), processor (p), title ("", "Distortion") { // Start by setting the size of our editor. Remember to make // it large enough for the extra screens to fit (they are 390 by 295 pixels). int width = 400; int height = 340; setSize (width, height); // Some variables for positioning the sliders. int spacing = 10; int sliderWidth = 80; int sliderHeight = 100; int sliderY = spacing; // Here we loop through our parameter sliders and add them to the interface. for (int i = 0; i < sliders.size(); ++i) { // The sliders all live in the sliders array. // They are in the same order they were added to the processor. SAFESlider *currentSlider = sliders [i]; // Add the slider to the interface. addAndMakeVisible (currentSlider); currentSlider->setBounds (spacing, sliderY, sliderWidth, sliderHeight); currentSlider->setColour (SAFEColours::green); sliderY += spacing + sliderHeight; } // The SAFEAudioProcessorEditor class will automatically label // the sliders with the parameter names you gave. These may be too // long (as with the name 'symmetry') so we can set the text explicitly. // // Note the use of the enum from our processor to index the slider array. // Much more readable than using magic numbers. sliders [SimpleDistortionAudioProcessor::ParamSymmetry]->setText ("Symm"); // Some variables for positioning the load and record buttons. int longButtonWidth = 100; int longButtonHeight = 22; int longButtonY = height - spacing - longButtonHeight; // The loadButton is a protected member of SAFEAudioProcessorEditor which // will bring up an extra screen for loading semantic terms. addAndMakeVisible (loadButton); int loadButtonX = width - spacing - longButtonWidth; loadButton.setBounds (loadButtonX, longButtonY, longButtonWidth, longButtonHeight); // The recordButton is a protected member of SAFEAudioProcessorEditor which // starts the analysis of the audio. addAndMakeVisible (recordButton); int recordButtonX = loadButtonX - spacing - longButtonWidth; recordButton.setBounds (recordButtonX, longButtonY, longButtonWidth, longButtonHeight); // The descriptorBox is a protected member of SAFEAudioProcessorEditor in // which the user will type descriptors to save. Any error messages // for the user are also displayed in this box. addAndMakeVisible (descriptorBox); int descriptorBoxWidth = spacing + 2 * longButtonWidth; int descriptorBoxHeight = 100; int descriptorBoxY = longButtonY - spacing - descriptorBoxHeight; descriptorBox.setBounds (recordButtonX, descriptorBoxY, descriptorBoxWidth, descriptorBoxHeight); // Some variables for positioning the meta data info and file access. int squareButtonWidth = 30; int squareButtonHeight = 30; int squareButtonY = descriptorBoxY - spacing - squareButtonHeight; // The metaDataButton is a protected member of SAFEAudioProcessorEditor which // will bring up an extra screen for the user to enter meta data // about themselves and the track they are working on. addAndMakeVisible (metaDataButton); metaDataButton.setBounds (recordButtonX, squareButtonY, squareButtonWidth, squareButtonHeight); // The infoButton is a protected member of SAFEAudioProcessorEditor which // will bring up an extra screen with instructions on how to // use the SAFE plug-ins. addAndMakeVisible (infoButton); int infoButtonX = recordButtonX + squareButtonWidth + spacing; infoButton.setBounds (infoButtonX, squareButtonY, squareButtonWidth, squareButtonHeight); // The fileAccessButton is a protected member of SAFEAudioProcessorEditor which // toggles between sending data to the server or saving it locally. addAndMakeVisible (fileAccessButton); int fileAccessButtonX = infoButtonX + squareButtonWidth + spacing; fileAccessButton.setBounds (fileAccessButtonX, squareButtonY, squareButtonWidth, squareButtonHeight); // The title of the plug-in. addAndMakeVisible (title); title.setFont (40); title.setJustificationType (Justification::centred); int titleX = spacing + sliderWidth; int titleWidth = width - titleX; title.setBounds (titleX, 0, titleWidth, squareButtonY); // We need to tell the editor where the top left corner of the extra screens // (loading, meta data and information) should be positioned when they // are visible. setExtraScreenPosition ((getWidth() - extraScreenWidth) / 2, (getHeight() - extraScreenHeight) / 2); }
iXY getCenter() const { return iXY(getWidth()>>1, getHeight()>>1); }
void render() override { jassert (OpenGLHelpers::isContextActive()); const float desktopScale = (float) openGLContext.getRenderingScale(); OpenGLHelpers::clear (Colour::greyLevel (0.1f)); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glViewport (0, 0, roundToInt (desktopScale * getWidth()), roundToInt (desktopScale * getHeight())); shader->use(); if (uniforms->projectionMatrix != nullptr) uniforms->projectionMatrix->setMatrix4 (getProjectionMatrix().mat, 1, false); if (uniforms->viewMatrix != nullptr) uniforms->viewMatrix->setMatrix4 (getViewMatrix().mat, 1, false); shape->draw (openGLContext, *attributes); // Reset the element buffers so child Components draw correctly openGLContext.extensions.glBindBuffer (GL_ARRAY_BUFFER, 0); openGLContext.extensions.glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0); }
void UIComponent::resized() { int w = getWidth(); int h = getHeight(); if (editorViewportButton != 0) { editorViewportButton->setBounds(w-230, h-40, 225, 35); if (h < 300 && editorViewportButton->isOpen()) editorViewportButton->toggleState(); if (h < 200) editorViewportButton->setBounds(w-230,h-40+200-h,225,35); //else // editorViewportButton->setVisible(true); } if (editorViewport != 0) { //if (h < 400) // editorViewport->setVisible(false); //else // editorViewport->setVisible(true); if (editorViewportButton->isOpen() && !editorViewport->isVisible()) editorViewport->setVisible(true); else if (!editorViewportButton->isOpen() && editorViewport->isVisible()) editorViewport->setVisible(false); editorViewport->setBounds(6,h-190,w-11,150); } if (controlPanel != 0) { int controlPanelWidth = w-210; int addHeight = 0; int leftBound; if (w >= 460) { leftBound = 202; } else { leftBound = w-258; controlPanelWidth = w-leftBound; } if (controlPanelWidth < 750) { addHeight = 750-controlPanelWidth; if (addHeight > 32) addHeight = 32; } if (controlPanelWidth < 570) { addHeight = 32 + 570-controlPanelWidth; if (addHeight > 64) addHeight = 64; } if (controlPanel->isOpen()) controlPanel->setBounds(leftBound,6,controlPanelWidth,64+addHeight); else controlPanel->setBounds(leftBound,6,controlPanelWidth,32+addHeight); } if (processorList != 0) { if (processorList->isOpen()) { if (editorViewportButton->isOpen()) processorListViewport.setBounds(5,5,195,h-200); else processorListViewport.setBounds(5,5,195,h-50); processorListViewport.setScrollBarsShown(true,false); } else { processorListViewport.setBounds(5,5,195,34); processorListViewport.setScrollBarsShown(false,false); processorListViewport.setViewPosition(0, 0); } if (w < 460) processorListViewport.setBounds(5-460+getWidth(),5,195,processorList->getHeight()); } if (dataViewport != 0) { int left, top, width, height; left = 6; top = 40; if (processorList->isOpen()) left = processorListViewport.getX()+processorListViewport.getWidth()+2; else left = 6; top = controlPanel->getHeight()+8; if (editorViewportButton->isOpen()) height = h - top - 195; else height = h - top - 45; width = w - left - 5; dataViewport->setBounds(left, top, width, height); if (h < 200) dataViewport->setVisible(false); else dataViewport->setVisible(true); } if (messageCenterEditor != 0) { messageCenterEditor->setBounds(6,h-35,w-241,30); if (h < 200) messageCenterEditor->setBounds(6,h-35+200-h,w-241,30); // else // messageCenter->setVisible(true); } // for debugging purposes: if (false) { dataViewport->setVisible(false); editorViewport->setVisible(false); processorList->setVisible(false); messageCenterEditor->setVisible(false); controlPanel->setVisible(false); editorViewportButton->setVisible(false); } }