void TextBox::drawBorder(Graphics* graphics) { int width = getWidth() + getBorderSize() * 2 - 1; int height = getHeight() + getBorderSize() * 2 - 1; graphics->setColor(getBackgroundColor()); unsigned int i; for (i = 0; i < getBorderSize(); ++i) { graphics->drawLine(i,i, width - i, i); graphics->drawLine(i,i + 1, i, height - i - 1); graphics->drawLine(width - i,i + 1, width - i, height - i); graphics->drawLine(i,height - i, width - i - 1, height - i); } }
void CallOutBox::updatePosition (const Rectangle<int>& newAreaToPointTo, const Rectangle<int>& newAreaToFitIn) { targetArea = newAreaToPointTo; availableArea = newAreaToFitIn; const int borderSpace = getBorderSize(); Rectangle<int> newBounds (content.getWidth() + borderSpace * 2, content.getHeight() + borderSpace * 2); const int hw = newBounds.getWidth() / 2; const int hh = newBounds.getHeight() / 2; const float hwReduced = (float) (hw - borderSpace * 2); const float hhReduced = (float) (hh - borderSpace * 2); const float arrowIndent = borderSpace - arrowSize; Point<float> targets[4] = { Point<float> ((float) targetArea.getCentreX(), (float) targetArea.getBottom()), Point<float> ((float) targetArea.getRight(), (float) targetArea.getCentreY()), Point<float> ((float) targetArea.getX(), (float) targetArea.getCentreY()), Point<float> ((float) targetArea.getCentreX(), (float) targetArea.getY()) }; Line<float> lines[4] = { Line<float> (targets[0].translated (-hwReduced, hh - arrowIndent), targets[0].translated (hwReduced, hh - arrowIndent)), Line<float> (targets[1].translated (hw - arrowIndent, -hhReduced), targets[1].translated (hw - arrowIndent, hhReduced)), Line<float> (targets[2].translated (-(hw - arrowIndent), -hhReduced), targets[2].translated (-(hw - arrowIndent), hhReduced)), Line<float> (targets[3].translated (-hwReduced, -(hh - arrowIndent)), targets[3].translated (hwReduced, -(hh - arrowIndent))) }; const Rectangle<float> centrePointArea (newAreaToFitIn.reduced (hw, hh).toFloat()); const Point<float> targetCentre (targetArea.getCentre().toFloat()); float nearest = 1.0e9f; for (int i = 0; i < 4; ++i) { Line<float> constrainedLine (centrePointArea.getConstrainedPoint (lines[i].getStart()), centrePointArea.getConstrainedPoint (lines[i].getEnd())); const Point<float> centre (constrainedLine.findNearestPointTo (targetCentre)); float distanceFromCentre = centre.getDistanceFrom (targets[i]); if (! centrePointArea.intersects (lines[i])) distanceFromCentre += 1000.0f; if (distanceFromCentre < nearest) { nearest = distanceFromCentre; targetPoint = targets[i]; newBounds.setPosition ((int) (centre.x - hw), (int) (centre.y - hh)); } } setBounds (newBounds); }
/* * toString * * return - std::string */ std::string Volume::toString() { return "w " + Stringify::toString(getWidth()) + " h " + Stringify::toString(getHeight()) + " d " + Stringify::toString( getDepth()) + "\n border size " + Stringify::toString(getBorderSize()) + " number of voxes " + Stringify::toString( getNumberOfVoxels()) + "\n increments " + Stringify::toString(increments[0]) + " " + Stringify::toString(increments[1]) + " " + Stringify::toString(increments[2]) + "\n size " + Stringify::toString(size[0]) + " " + Stringify::toString( size[1]) + " " + Stringify::toString(size[2]) + "\n origin " + Stringify::toString(origin[0]) + " " + Stringify::toString(origin[1]) + " " + Stringify::toString(origin[2]) + "\n center " + Stringify::toString(center[0]) + " " + Stringify::toString(center[1]) + " " + Stringify::toString(center[2]) + "\n extent " + Stringify::toString( extent[0]) + " " + Stringify::toString(extent[1]) + " " + Stringify::toString(extent[2]) + "\n scale " + Stringify::toString(scale[0]) + " " + Stringify::toString(scale[1]) + " " + Stringify::toString(scale[2]); } // end toString()
Rectangle<int> PaintElementPath::getCurrentBounds (const Rectangle<int>& parentArea) const { updateStoredPath (getDocument()->getComponentLayout(), parentArea); Rectangle<float> bounds (path.getBounds()); const int borderSize = getBorderSize(); return Rectangle<int> ((int) bounds.getX() - borderSize, (int) bounds.getY() - borderSize, (int) bounds.getWidth() + borderSize * 2, (int) bounds.getHeight() + borderSize * 2); }
void CheckBox::drawBorder(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; int width = getWidth() + getBorderSize() * 2 - 1; int height = getHeight() + getBorderSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; for (i = 0; i < getBorderSize(); ++i) { graphics->setColor(shadowColor); graphics->drawLine(i,i, width - i, i); graphics->drawLine(i,i + 1, i, height - i - 1); graphics->setColor(highlightColor); graphics->drawLine(width - i,i + 1, width - i, height - i); graphics->drawLine(i,height - i, width - i - 1, height - i); } }
bool GUIProgressBar::gatherGeometry(GeometryGather& gather) { if (shouldProcessGather(gather)) { auto fullMaterialName = getMaterialRoot() + material_; gather.changePriority(getRenderPriority()); gather.changeTransformation(getWorldTransform()); if (material_.length()) { auto overrideParameters = getMaterialOverrideParameters(fullMaterialName); gather.changeMaterial(fullMaterialName, overrideParameters); gather.addRectangle(getWidth() * fraction_, getHeight()); } else queueWindow(gather, getWidth() * fraction_, getHeight(), getBorderSize(), getFillColor(), getBorderColor()); auto fullBackgroundMaterialName = getMaterialRoot() + backgroundMaterial_; gather.changeTransformation(localToWorld(Vec3(getWidth() * fraction_, 0.0f)), getWorldOrientation()); if (backgroundMaterial_.length()) { auto overrideParameters = getMaterialOverrideParameters(fullBackgroundMaterialName); gather.changeMaterial(fullBackgroundMaterialName, overrideParameters); gather.addRectangle(getWidth() * (1.0f - fraction_), getHeight()); } else { queueWindow(gather, getWidth() * (1.0f - fraction_), getHeight(), getBorderSize(), getFillColor(), getBorderColor()); } } return true; }
bool TileCachedRecastMeshManager::addWater(const osg::Vec2i& cellPosition, const int cellSize, const btTransform& transform) { const auto border = getBorderSize(mSettings); auto& tilesPositions = mWaterTilesPositions[cellPosition]; bool result = false; if (cellSize == std::numeric_limits<int>::max()) { const auto tiles = mTiles.lock(); for (auto& tile : *tiles) { if (tile.second.addWater(cellPosition, cellSize, transform)) { tilesPositions.push_back(tile.first); result = true; } } } else { getTilesPositions(cellSize, transform, mSettings, [&] (const TilePosition& tilePosition) { const auto tiles = mTiles.lock(); auto tile = tiles->find(tilePosition); if (tile == tiles->end()) { auto tileBounds = makeTileBounds(mSettings, tilePosition); tileBounds.mMin -= osg::Vec2f(border, border); tileBounds.mMax += osg::Vec2f(border, border); tile = tiles->insert(std::make_pair(tilePosition, CachedRecastMeshManager(mSettings, tileBounds))).first; } if (tile->second.addWater(cellPosition, cellSize, transform)) { tilesPositions.push_back(tilePosition); result = true; } }); } if (result) ++mRevision; return result; }
void Tab::updateShape(const ivec2& window_size) { int border_size = getBorderSize(); int scrollbar_width = g_lamp_settings.getScrollbarWidth(); m_window_size = window_size; Rectf scrollbar_rect((float)m_window_size.x - scrollbar_width, 0, (float)m_window_size.x, (float)m_window_size.y); m_scrollbar->AsScrollbar()->setShape(scrollbar_rect); Rectf post_rect(0, 0, (float)m_window_size.x, (float)m_window_size.y); post_rect.x1 += border_size; post_rect.y1 += border_size; post_rect.x2 -= std::max(border_size, scrollbar_width); for(std::list<PostRef>::iterator it = m_threads.begin(); it != m_threads.end(); it++) { float thread_height = 0; (*it)->updateShape(post_rect, thread_height); post_rect.offset(vec2(0, thread_height + border_size)); } gl::Texture2dRef crest_image = g_skin.getImage(image_type::SHACK_CREST); if(crest_image) { m_crest_rect.y1 = post_rect.y1; float tab_width = m_window_size.x - (float)scrollbar_width; float mid_width = tab_width / 2.0f; float image_width = (float)crest_image->getWidth(); float image_height = (float)crest_image->getHeight(); if(image_width > tab_width) { float scale = tab_width / image_width; image_width *= scale; image_height *= scale; } m_crest_rect.x1 = mid_width - (image_width / 2.0f); m_crest_rect.x2 = m_crest_rect.x1 + image_width; m_crest_rect.y2 = m_crest_rect.y1 + image_height; } updateScrollbar(); }
DropdownView(ATDropdownList *dl){ twWndStyle style=getStyle(); style.border=twBS_panel; setStyle(style); m_dropdownList=dl; m_rowHeight=13; // set size. twRect rt; rt.x=0; rt.y=0; rt.w=dl->getRect().w; rt.h=getBorderSize().h+m_rowHeight*(int)items().size(); setRect(rt); m_drag=-1; m_hover=false; }
Rect ViewerWindow::calculateDefaultSize() { // Get work area. Rect defaultRect; HMONITOR hmon = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST); MONITORINFO mi; mi.cbSize = sizeof(mi); if (!!GetMonitorInfo(hmon, &mi)) { defaultRect.fromWindowsRect(&mi.rcWork); } else { m_logWriter.debug(_T("Get monitor info is failed. Use second method (no multi-screen).")); RECT desktopRc; if (!m_sysinf.getDesktopArea(&desktopRc)) { m_sysinf.getDesktopAllArea(&desktopRc); } defaultRect.fromWindowsRect(&desktopRc); } int widthDesktop = defaultRect.getWidth(); int heightDesktop = defaultRect.getHeight(); Rect viewerRect = m_dsktWnd.getViewerGeometry(); int serverWidth = viewerRect.getWidth(); int serverHeight = viewerRect.getHeight(); if (serverWidth < widthDesktop && serverHeight < heightDesktop) { int borderWidth, borderHeight; getBorderSize(&borderWidth, &borderHeight); int totalWidth = serverWidth + borderWidth; int totalHeight = serverHeight + borderHeight + 1; if (m_toolbar.isVisible()) { totalHeight += m_toolbar.getHeight(); } defaultRect.setHeight(totalHeight); defaultRect.setWidth(totalWidth); defaultRect.move((widthDesktop - totalWidth) / 2, (heightDesktop - totalHeight) / 2); } return defaultRect; }
void Label::componentMovedOrResized (Component& component, bool /*wasMoved*/, bool /*wasResized*/) { const Font f (getLookAndFeel().getLabelFont (*this)); if (leftOfOwnerComp) { setSize (jmin (roundToInt (f.getStringWidthFloat (textValue.toString()) + 0.5f) + getBorderSize().getLeftAndRight(), component.getX()), component.getHeight()); setTopRightPosition (component.getX(), component.getY()); } else { setSize (component.getWidth(), getBorderSize().getTopAndBottom() + 6 + roundToInt (f.getHeight() + 0.5f)); setTopLeftPosition (component.getX(), component.getY() - getHeight()); } }
bool TileCachedRecastMeshManager::addObject(const ObjectId id, const btCollisionShape& shape, const btTransform& transform, const AreaType areaType) { bool result = false; auto& tilesPositions = mObjectsTilesPositions[id]; const auto border = getBorderSize(mSettings); { auto tiles = mTiles.lock(); getTilesPositions(shape, transform, mSettings, [&] (const TilePosition& tilePosition) { if (addTile(id, shape, transform, areaType, tilePosition, border, tiles.get())) { tilesPositions.insert(tilePosition); result = true; } }); } if (result) ++mRevision; return result; }
void PaintElementPath::setCurrentBounds (const Rectangle<int>& b, const Rectangle<int>& parentArea, const bool /*undoable*/) { Rectangle<int> newBounds (b); newBounds.setSize (jmax (1, newBounds.getWidth()), jmax (1, newBounds.getHeight())); const Rectangle<int> current (getCurrentBounds (parentArea)); if (newBounds != current) { const int borderSize = getBorderSize(); const int dx = newBounds.getX() - current.getX(); const int dy = newBounds.getY() - current.getY(); const double scaleStartX = current.getX() + borderSize; const double scaleStartY = current.getY() + borderSize; const double scaleX = (newBounds.getWidth() - borderSize * 2) / (double) (current.getWidth() - borderSize * 2); const double scaleY = (newBounds.getHeight() - borderSize * 2) / (double) (current.getHeight() - borderSize * 2); for (int i = 0; i < points.size(); ++i) { PathPoint* const destPoint = points.getUnchecked(i); PathPoint p (*destPoint); for (int j = p.getNumPoints(); --j >= 0;) rescalePoint (p.pos[j], dx, dy, scaleX, scaleY, scaleStartX, scaleStartY, parentArea); perform (new ChangePointAction (destPoint, i, p), "Move path"); } } }
std::vector<TilePosition> TileCachedRecastMeshManager::updateObject(const ObjectId id, const btCollisionShape& shape, const btTransform& transform, const AreaType areaType) { const auto object = mObjectsTilesPositions.find(id); if (object == mObjectsTilesPositions.end()) return std::vector<TilePosition>(); auto& currentTiles = object->second; const auto border = getBorderSize(mSettings); std::vector<TilePosition> changedTiles; std::set<TilePosition> newTiles; { auto tiles = mTiles.lock(); const auto onTilePosition = [&] (const TilePosition& tilePosition) { if (currentTiles.count(tilePosition)) { newTiles.insert(tilePosition); if (updateTile(id, transform, areaType, tilePosition, tiles.get())) changedTiles.push_back(tilePosition); } else if (addTile(id, shape, transform, areaType, tilePosition, border, tiles.get())) { newTiles.insert(tilePosition); changedTiles.push_back(tilePosition); } }; getTilesPositions(shape, transform, mSettings, onTilePosition); for (const auto& tile : currentTiles) if (!newTiles.count(tile) && removeTile(id, tile, tiles.get())) changedTiles.push_back(tile); } std::swap(currentTiles, newTiles); if (!changedTiles.empty()) ++mRevision; return changedTiles; }
void CallOutBox::resized() { const int borderSpace = getBorderSize(); content.setTopLeftPosition (borderSpace, borderSpace); refreshPath(); }