void CAActivityIndicatorView::setActivityBackView(CrossApp::CAView *var) { this->removeSubview(m_pBackView); CC_SAFE_RELEASE_NULL(m_pBackView); CC_SAFE_RETAIN(var); m_pBackView = var; if (m_pBackView) { m_pBackView->setCenterOrigin(getBounds().size/2); this->insertSubview(m_pBackView, 0); } }
//============================================================================== void MainContentComponent::resized() { #if DEBUG_FLAG test.setBounds(500, 500, 600, 200); #endif //> menu bar Rectangle<int> area(getBounds()); mMenuBar->setBounds(area.removeFromTop(LookAndFeel::getDefaultLookAndFeel().getDefaultMenuBarHeight())); //> make a list of our child components that we want to reposition Component *comps[] = { &mFileTree, &mResizerBar, &mImgViewer }; //> this will position the components to fit //> horizontally into the rectangle provided. const int pxShift = 4; Rectangle<int> r(getBounds().reduced(pxShift)); mStretchableManager.layOutComponents(comps, numElementsInArray(comps), r.getX(), r.getY() + LookAndFeel::getDefaultLookAndFeel().getDefaultMenuBarHeight(), r.getWidth(), r.getHeight() - LookAndFeel::getDefaultLookAndFeel().getDefaultMenuBarHeight(), false, true); }
int Entry::getCaretFromMouse(MouseMessage* mousemsg) { base::utf8_const_iterator utf8_begin = base::utf8_const_iterator(getText().begin()); base::utf8_const_iterator utf8_end = base::utf8_const_iterator(getText().end()); int c, x, w, mx, caret = m_caret; int textlen = base::utf8_length(getText()); mx = mousemsg->position().x; mx = MID(getBounds().x+this->border_width.l, mx, getBounds().x2()-this->border_width.r-1); x = getBounds().x + this->border_width.l; base::utf8_const_iterator utf8_it = (m_scroll < textlen ? utf8_begin + m_scroll: utf8_end); for (c=m_scroll; utf8_it != utf8_end; ++c, ++utf8_it) { w = getFont()->charWidth(*utf8_it); if (x+w >= getBounds().x2()-this->border_width.r) break; if ((mx >= x) && (mx < x+w)) { caret = c; break; } x += w; } if (utf8_it == utf8_end) { if ((mx >= x) && (mx <= getBounds().x2()-this->border_width.r-1)) { caret = c; } } return caret; }
void JUCESplashScreen::timerCallback() { #if JUCE_DISPLAY_SPLASH_SCREEN if (isVisible() && ! hasStartedFading) { hasStartedFading = true; fader.animateComponent (this, getBounds(), 0.0f, splashScreenFadeOutTime, false, 0, 0); } if (hasStartedFading && ! fader.isAnimating()) #endif delete this; }
bool GuiGradientCtrl::onAdd() { Parent::onAdd(); RectI bounds = getBounds(); S32 l = bounds.point.x + mSwatchFactor, r = bounds.point.x + bounds.extent.x - mSwatchFactor; S32 t = bounds.point.y, b = bounds.point.y + bounds.extent.y - mSwatchFactor; mBlendRangeBox = RectI( Point2I(l, t), Point2I(r, b) ); setupDefaultRange(); reInitSwatches( mDisplayMode ); return true; }
void UserInterface::updateSelection(ScrCategory category, int newIndex, int *idx) { Game &game = *_vm->_game; Common::Array<int> &invList = game._objects._inventoryList; Common::Rect bounds; if (category == CAT_INV_LIST && _inventoryChanged) { *idx = newIndex; bounds = Common::Rect(90, 3, 90 + 69, 3 + 40); _uiSlots.add(bounds); _uiSlots.draw(false, false); drawInventoryList(); updateRect(bounds); _inventoryChanged = false; if (invList.size() < 2) { _scrollbarElevator = 0; } else { int v = _inventoryTopIndex * 18 / (invList.size() - 1); _scrollbarElevator = MIN(v, 17); } } else { int oldIndex = *idx; *idx = newIndex; if (oldIndex >= 0) { writeVocab(category, oldIndex); if (getBounds(category, oldIndex, bounds)) updateRect(bounds); } if (newIndex >= 0) { writeVocab(category, newIndex); if (getBounds(category, newIndex, bounds)) updateRect(bounds); } } }
void PaintElement::applyBoundsToComponent (Component*, const Rectangle<int>& newBounds) { if (getBounds() != newBounds) { getDocument()->getUndoManager().undoCurrentTransactionOnly(); jassert (dynamic_cast<PaintRoutineEditor*> (getParentComponent()) != nullptr); setCurrentBounds (newBounds.expanded (-borderThickness, -borderThickness), ((PaintRoutineEditor*) getParentComponent())->getComponentArea(), true); } }
D3D11_VIEWPORT D3D11Demo::getViewport (float x_ratio, float y_ratio, float w_ratio, float h_ratio, float minz, float maxz) { auto bounds = getBounds(); D3D11_VIEWPORT ret; ret.Width = bounds.getWidth() * w_ratio; ret.Height = bounds.getHeight() * h_ratio; ret.TopLeftX = bounds.getWidth() * x_ratio; ret.TopLeftY = bounds.getHeight() * y_ratio; ret.MinDepth = minz; ret.MaxDepth = maxz; return ret; }
AffineTransform Path::getTransformToScaleToFit (const float x, const float y, const float w, const float h, const bool preserveProportions, Justification justification) const { Rectangle<float> boundsRect (getBounds()); if (preserveProportions) { if (w <= 0 || h <= 0 || boundsRect.isEmpty()) return AffineTransform::identity; float newW, newH; const float srcRatio = boundsRect.getHeight() / boundsRect.getWidth(); if (srcRatio > h / w) { newW = h / srcRatio; newH = h; } else { newW = w; newH = w * srcRatio; } float newXCentre = x; float newYCentre = y; if (justification.testFlags (Justification::left)) newXCentre += newW * 0.5f; else if (justification.testFlags (Justification::right)) newXCentre += w - newW * 0.5f; else newXCentre += w * 0.5f; if (justification.testFlags (Justification::top)) newYCentre += newH * 0.5f; else if (justification.testFlags (Justification::bottom)) newYCentre += h - newH * 0.5f; else newYCentre += h * 0.5f; return AffineTransform::translation (boundsRect.getWidth() * -0.5f - boundsRect.getX(), boundsRect.getHeight() * -0.5f - boundsRect.getY()) .scaled (newW / boundsRect.getWidth(), newH / boundsRect.getHeight()) .translated (newXCentre, newYCentre); } else { return AffineTransform::translation (-boundsRect.getX(), -boundsRect.getY()) .scaled (w / boundsRect.getWidth(), h / boundsRect.getHeight()) .translated (x, y); } }
void renderOpenGL2D() { LeapUtilGL::GLAttribScope attribScope( GL_ENABLE_BIT ); // when enabled text draws poorly. glDisable(GL_CULL_FACE); ScopedPointer<LowLevelGraphicsContext> glRenderer (createOpenGLGraphicsContext (m_openGLContext, getWidth(), getHeight())); if (glRenderer != nullptr) { Graphics g(glRenderer); int iMargin = 10; int iFontSize = static_cast<int>(m_fixedFont.getHeight()); int iLineStep = iFontSize + (iFontSize >> 2); int iBaseLine = 20; Font origFont = g.getCurrentFont(); const Rectangle<int>& rectBounds = getBounds(); if ( m_bShowHelp ) { g.setColour( Colours::seagreen ); g.setFont( static_cast<float>(iFontSize) ); if ( !m_bPaused ) { g.drawSingleLineText( m_strUpdateFPS, iMargin, iBaseLine ); } g.drawSingleLineText( m_strRenderFPS, iMargin, iBaseLine + iLineStep ); g.setFont( m_fixedFont ); g.setColour( Colours::slateblue ); g.drawMultiLineText( m_strHelp, iMargin, iBaseLine + iLineStep * 3, rectBounds.getWidth() - iMargin*2 ); } g.setFont( origFont ); g.setFont( static_cast<float>(iFontSize) ); g.setColour( Colours::salmon ); g.drawMultiLineText( m_strPrompt, iMargin, rectBounds.getBottom() - (iFontSize + iFontSize + iLineStep), rectBounds.getWidth()/4 ); }
void CAPageControl::ccTouchEnded(CATouch *pTouch, CAEvent *pEvent) { if (getBounds().containsPoint(convertToNodeSpace(pTouch->getLocation()))) { // m_currentPage++; // if (m_currentPage == m_numberOfPages) { // m_currentPage = 0; // } // if (!m_bDefersCurrentPageDisplay) { // updateCurrentPageDisplay(); // } // // if (m_pTarget[CAControlEventTouchValueChanged] && m_selTouch[CAControlEventTouchValueChanged]) { // (m_pTarget[CAControlEventTouchValueChanged]->*m_selTouch[CAControlEventTouchValueChanged])(this, CCPointZero); // } // find touched dot float width = getBounds().size.width/m_numberOfPages; CCRect rect = getBounds(); for (int i=0; i<m_numberOfPages; i++) { rect.size.width = width * i + width; if (rect.containsPoint(convertToNodeSpace(pTouch->getLocation()))) { if (m_currentPage != i) { m_currentPage = i; if (!m_bDefersCurrentPageDisplay) { updateCurrentPageDisplay(); } if (m_pTarget[CAControlEventTouchValueChanged] && m_selTouch[CAControlEventTouchValueChanged]) { (m_pTarget[CAControlEventTouchValueChanged]->*m_selTouch[CAControlEventTouchValueChanged])(this, CCPointZero); } } break; } } } }
void CATextField::setMarginImageLeft(const DSize& imgSize, const std::string& filePath) { setMarginLeft(imgSize.width); CAImageView* ima = (CAImageView*)this->getSubviewByTag(1010); if (!ima) { ima = CAImageView::create(); ima->setTag(1010); this->addSubview(ima); } ima->setCenter(DRect(imgSize.width / 2, getBounds().size.height / 2, imgSize.width, imgSize.height)); ima->setImage(CAImage::create(filePath)); }
void Player::init(int texture, const Controls &controls, Map *map) { textureId_ = texture; controls_ = controls; position_ = map->getSpawnPoint(); FloatRect bounds = getBounds(); Vector2f origin = -(Vector2f(bounds.left, bounds.top) - position_); Vector2f size = Vector2f(bounds.width, bounds.height); mapCollision_.setMap(map); mapCollision_.setObjectOrigin(origin); mapCollision_.setObjectSize(size); }
void MenuBar::updateLayout(void) { //Determine the Max Preferred Height of my MenuItems Real32 MaxHeight(0); Real32 TotalWidth(0); for(UInt32 i(0) ; i<getMFChildren()->size() ; ++i) { if(MaxHeight < getChildren(i)->getPreferredSize().y()) { MaxHeight = getChildren(i)->getPreferredSize().y(); } TotalWidth += getChildren(i)->getPreferredSize().x(); } //Set My preferred Size Pnt2f TopLeft, BottomRight; Pnt2f InsetsTopLeft, InsetsBottomRight; getBounds(TopLeft, BottomRight); getInsideInsetsBounds(InsetsTopLeft, InsetsBottomRight); Vec2f InsetSize( (BottomRight-TopLeft) - (InsetsBottomRight-InsetsTopLeft) ); Vec2f NewSize( TotalWidth+InsetSize.x(), MaxHeight+InsetSize.y()); if(getPreferredSize() != NewSize) { setPreferredSize(NewSize); } getInsideInsetsBounds(InsetsTopLeft, InsetsBottomRight); //Now position and size the Items Real32 LeftOffset(InsetsTopLeft.x()); Vec2f Size; Pnt2f Pos; for(UInt32 i(0) ; i<getMFChildren()->size() ; ++i) { Size.setValues(getChildren(i)->getPreferredSize().x(), MaxHeight); if(getChildren(i)->getSize() != Size) { getChildren(i)->setSize(Size); } Pos.setValues(LeftOffset, InsetsTopLeft.y()); if(getChildren(i)->getPosition() != Pos) { getChildren(i)->setPosition(Pos); } LeftOffset += getChildren(i)->getPreferredSize().x(); } }
void setFullScreen (bool shouldBeFullScreen) override { Rectangle<int> r (shouldBeFullScreen ? Desktop::getInstance().getDisplays().getMainDisplay().userArea : lastNonFullscreenBounds); if ((! shouldBeFullScreen) && r.isEmpty()) r = getBounds(); // (can't call the component's setBounds method because that'll reset our fullscreen flag) if (! r.isEmpty()) setBounds (r, shouldBeFullScreen); component.repaint(); }
void ChildAlias::mouseDown (const MouseEvent& e) { toFront (true); if (e.eventComponent == resizer) { } else { dragger.startDraggingComponent (this,0); } userAdjusting = true; startBounds = getBounds (); userStartedChangingBounds (); }
void EnemyProjectile::update(float elapsed) { sprite.move(velocity.x * elapsed, velocity.y * elapsed); sf::Vector2f moved = sprite.getPosition() - origin; float distance = sqrtf(moved.x * moved.x + moved.y * moved.y); if(distance >= range) dead = true; if(getBounds().intersects(player->getBounds())) { float magnitude = sqrtf(velocity.x * velocity.x + velocity.y * velocity.y); player->hit(velocity / magnitude, (float)(damage)); dead = true; } }
void label_t::update() { g_rectangle thisBounds(0, 0, getBounds().width, getBounds().height); // Check if the component was ever layouted, otherwise set to a high value if (thisBounds.width == 0 && thisBounds.height == 0) { thisBounds.width = 9999; thisBounds.height = 9999; } // get text bounds auto cr = graphics.getContext(); cairo_set_font_face(cr, font->getFace()); cairo_set_font_size(cr, fontSize); cairo_text_extents(cr, this->text.c_str(), &lastExtents); g_dimension newPreferred(lastExtents.width + 3, lastExtents.height + 3); // Set new preferred size if (getPreferredSize() != newPreferred) { setPreferredSize(newPreferred); } markFor(COMPONENT_REQUIREMENT_PAINT); }
bool CAScrollView::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) { do { CCPoint point = this->convertTouchToNodeSpace(pTouch); CC_BREAK_IF(m_bscrollEnabled == false); CC_BREAK_IF(!this->isVisible()); CC_BREAK_IF(!getBounds().containsPoint(point)); CC_BREAK_IF(m_pTouches->count() > 2); if (!m_pTouches->containsObject(pTouch)) { m_pTouches->addObject(pTouch); } if (m_pTouches->count() == 1) { CCDirector::sharedDirector()->getScheduler()->unscheduleSelector(schedule_selector(CAScrollView::deaccelerateScrolling), this); m_tInertia = CCPointZero; CCDirector::sharedDirector()->getScheduler()->unscheduleSelector(schedule_selector(CAScrollView::closeToPoint), this); m_tCloseToPoint = CCPoint(-1, -1); m_pContainer->setAnchorPoint(CCPoint(0.5f, 0.5f)); } else if (m_pTouches->count() == 2) { CCTouch* touch0 = dynamic_cast<CCTouch*>(m_pTouches->objectAtIndex(0)); CCTouch* touch1 = dynamic_cast<CCTouch*>(m_pTouches->objectAtIndex(1)); m_fTouchLength = ccpDistance(touch0->getLocation(), touch1->getLocation()); CCPoint mid_point = ccpMidpoint(touch0->getLocation(), touch1->getLocation()); CCPoint p = m_pContainer->convertToNodeSpace(mid_point); m_pContainer->setAnchorPointInPoints(p); if (m_pScrollViewDelegate) { m_pScrollViewDelegate->scrollViewDidZoom(this); } m_bZooming = true; } return true; } while (0); return false; }
void CASwitch::ccTouchEnded(CrossApp::CATouch *pTouch, CrossApp::CAEvent *pEvent) { if (!this->isTouchClick()) return; CCPoint point = pTouch->getLocation(); point = this->convertToNodeSpace(point); if (getBounds().containsPoint(point)) { this->setControlState(CAControlStateNormal); m_isOn = !m_isOn; this->updateSwitchState(true, true); } }
// Setup the scroll to center the selected item in the viewport void ListBox::centerScroll() { View* view = View::getView(this); Widget* item = getSelectedChild(); if (view && item) { gfx::Rect vp = view->getViewportBounds(); gfx::Point scroll = view->getViewScroll(); scroll.y = ((item->getBounds().y - getBounds().y) - vp.h/2 + item->getBounds().h/2); view->setViewScroll(scroll); } }
void FullInterface::resized() { logo_button_->setBounds(10, 8, 64, 64); patch_selector_->setBounds(84, 8, 244, 2 * TOP_HEIGHT / 3); global_tool_tip_->setBounds(patch_selector_->getRight() + 8, 8, 200, TOP_HEIGHT); oscilloscope_->setBounds(global_tool_tip_->getRight() + 8, 8, 112, TOP_HEIGHT); arp_section_->setBounds(oscilloscope_->getRight() + 8, 8, 320, TOP_HEIGHT); synthesis_interface_->setBounds(0, TOP_HEIGHT + 12, getWidth(), getHeight() - TOP_HEIGHT - 8); beats_per_minute_->setBounds(133, patch_selector_->getBottom(), 200, TOP_HEIGHT - patch_selector_->getHeight()); modulation_manager_->setBounds(getBounds()); about_section_->setBounds(getBounds()); update_check_section_->setBounds(getBounds()); save_section_->setBounds(getBounds()); delete_section_->setBounds(getBounds()); patch_browser_->setBounds(synthesis_interface_->getX() + 8.0f, synthesis_interface_->getY(), arp_section_->getRight() - synthesis_interface_->getX() - 8.0f, synthesis_interface_->getHeight() - 8.0f); SynthSection::resized(); }
void Picture::draw(const Common::Rect &r) { Common::Rect surfaceBounds; getSurfaceBounds(surfaceBounds); Common::Rect r1 = r; Common::Rect bounds; getBounds(bounds); surfaceBounds.moveTo(bounds.left, bounds.top); r1 = r1.findIntersectingRect(surfaceBounds); getSurfaceBounds(surfaceBounds); Common::Rect r2 = r1; r2.translate(surfaceBounds.left - bounds.left, surfaceBounds.top - bounds.top); drawImage(r2, r1); }
CGameObject* CGameObject::onTouch(cocos2d::CCPoint point) { float zoomFactor = 1.0f;//cocos2d::CCEGLView::sharedOpenGLView()->getFrameZoomFactor(); cocos2d::CCRect bound( getScreenPosition().x - getBounds().size.width / (2.0f * zoomFactor), getScreenPosition().y - getBounds().size.height / (2.0f * zoomFactor), getBounds().size.width / zoomFactor, getBounds().size.height / zoomFactor); if (selected) { selection->removeFromParent(); } else if (bound.containsPoint(point)) { selection = cocos2d::CCSprite::createWithSpriteFrameName("select-tile2.png"); selection->setPosition(getScreenPosition()); selection->setAnchorPoint(cocos2d::CCPoint(0.5f, 0.5f)); selection->setScale(1.2f); scene->addChild(selection); selected = true; return this; } selected = false; return NULL; }
void CtrlrEditor::resized() { if (menuBar->isVisible()) { menuBar->setBounds (0, 0, getWidth(), CTRLR_MENUBAR_HEIGHT); owner.getCtrlrDocumentPanel().setBounds (0, CTRLR_MENUBAR_HEIGHT, getWidth(), getHeight() - (CTRLR_MENUBAR_HEIGHT)); } else { owner.getCtrlrDocumentPanel().setBounds (0, 0, getWidth(), getHeight()); } resizer.setBounds (getWidth()-24, getHeight()-24, 24, 24); owner.setProperty (Ids::ctrlrEditorBounds, getBounds().toString()); }
void InterpolationSpacePreset::mouseUp (const MouseEvent& e) { if (! e.mouseWasClicked()) { endBounds = getBounds(); if(dragging && startBounds != endBounds) { audioEngine.getDoc().beginTransaction(); audioEngine.getDoc().perform(new MovePresetAction(dynamic_cast<PMixInterpolationSpaceLayout*>(getParentComponent()), getComponentID(), startBounds, endBounds), TRANS("change preset bounds")); } } dragging = false; }
Widget* Widget::pick(const gfx::Point& pt) { Widget* inside, *picked = NULL; if (!(this->flags & JI_HIDDEN) && // Is visible getBounds().contains(pt)) { // The point is inside the bounds picked = this; UI_FOREACH_WIDGET(m_children, it) { inside = (*it)->pick(pt); if (inside) { picked = inside; break; } }
void TextBox::draw() { layout(); fill.draw(getBounds()); /* * TODO: BEGIN CLIP */ drawText(); /* * TODO: END CLIP */ }
void StatusBar::showTip(int msecs, const char *format, ...) { char buf[256]; // TODO warning buffer overflow va_list ap; int x, y; va_start(ap, format); vsprintf(buf, format, ap); va_end(ap); if (m_tipwindow == NULL) { m_tipwindow = new CustomizedTipWindow(buf); } else { m_tipwindow->setText(buf); } m_tipwindow->setInterval(msecs); if (m_tipwindow->isVisible()) m_tipwindow->closeWindow(NULL); m_tipwindow->openWindow(); m_tipwindow->remapWindow(); x = getBounds().x2() - m_tipwindow->getBounds().w; y = getBounds().y - m_tipwindow->getBounds().h; m_tipwindow->positionWindow(x, y); m_tipwindow->startTimer(); // Set the text in status-bar (with inmediate timeout) m_timeout = ji_clock; setText(buf); invalidate(); }
void SettingsPanel::setOutputOptions(MainController* mc){ mMainController = mc; Gwen::Controls::Base* pSlider; Gwen::Controls::Base* pCheckBox; Gwen::Controls::Base* pLabel; // pLabel = addProperty(mLaserCat, getBounds(mLaserCatElements), "Main speed", mMainController->getDataManager()->getMainSpeed()); // mLaserCatElements.push_back(pLabel); pSlider = addSlider(mLaserCat, getBounds(mLaserCatElements), "Main speed", mMainController->getDataManager()->getMainSpeed()*100, 50, 1000 ); mLaserCatElements.push_back(pSlider); }