void _gadget::moveRelativeInternal( _s16 dX , _s16 dY ) { if( !dX && !dY ) return; _pos pos = this->getAbsolutePosition(); this->x += dX; this->y += dY; // Refresh if there is a parent if( this->parent && !this->isHidden() ) { if( max( (_s16)-dX , dX ) < this->getWidth() && max( (_s16)-dY , dY ) < this->getHeight() ) this->redrawParents( _rect( pos.first , pos.second , this->getWidth() , this->getHeight() ).expand( dX , dY ) ); else this->redrawParents( { _rect( pos.first , pos.second , this->getWidth() , this->getHeight() ) , _rect( pos.first + dX , pos.second + dY , this->getWidth() , this->getHeight() ) } ); } // Notify dependent gadgets this->notifyDependentGadgets( onMove ); }
void _gadget::setYInternal( _coord val ) { int diff = val - this->y; if( diff ) { _pos pos = this->getAbsolutePosition(); this->y = val; // Refresh if there is a parent if( this->parent && !this->isHidden() ) { _length width = this->getWidth(); _length height = this->getHeight(); if( max( -diff , diff ) < height ) this->redrawParents( _rect( pos.first , pos.second , width , height ).expandY( diff ) ); else this->redrawParents( { _rect( pos.first , pos.second , width , height ) , _rect( pos.first , pos.second + diff , width , height ) } ); } // Notify dependent gadgets this->notifyDependentGadgets( onMove ); } }
static void calc_node_type(cairo_t *cr, designer_node_type_t *nt) { node_type_data_t *ntd = node_type_data(nt); _rect_t br, ir, or, sr; ntd->is = g_slist_length(nt->input_slot_specs); ntd->os = g_slist_length(nt->output_slot_specs); set_slot_font(cr); sr = text_rect(cr, "Mg"); /* add sep space */ sr.s.h += 3; ir = _rect(0, 0, 10, 0); for (int i=0; i<ntd->is; i++) { designer_slot_spec_t *slot = g_slist_nth_data(nt->input_slot_specs, i); slot_spec_data_t *ssd = slot_spec_data(slot); ssd->offset = _size(3, 5 + sr.s.h * i); ir = _union(ir, text_rect(cr, slot->name)); } /* offset left */ ir = _offset(ir, _size(0, 5)); /* add slot and sep space */ ir.s.w += 5+5; /* height including sep space */ ir.s.h = ntd->is * sr.s.h - 3; or = _rect(0, 0, 10, 0); for (int i=0; i<ntd->os; i++) { designer_slot_spec_t *slot = g_slist_nth_data(nt->output_slot_specs, i); slot_spec_data_t *ssd = slot_spec_data(slot); ssd->offset = _size(3, 5 + sr.s.h * i); or = _union(or, text_rect(cr, slot->name)); } /* move right, including sep space */ or = _offset(or, _size(ir.s.w + 5, 5)); /* add slot and sep space */ or.s.w += 5+5; /* height including sep space */ or.s.h = ntd->os * sr.s.h - 3; br = _union(ir, or); /* reserve space around area */ br = _inset(br, _size(-5, -5)); ntd->br = br; ntd->ir = _splith(&ir, 6); _splith(&or, or.s.w - 6); ntd->or = or; ntd->sr = sr; }
void Tuning::startDrag() { if (!dataModel()) return; if (dataModel()->mode() != Session::Mode::SCREENSETUP) return; QDrag *drag = new QDrag(this); QMimeData *mimeData = new QMimeData; // Generate pixmap for projector QPixmap _pixmap(128, 128); { _pixmap.fill(tuning()->color()); QPainter _p(&_pixmap); QRect _rect(0, 0, 128, 128); QFont _font("Helvetica", 32); _p.setFont(_font); _p.drawRect(_rect.adjusted(1, 1, -2, -2)); _p.drawText(_rect, Qt::AlignCenter, QString("%1").arg(index() + 1)); _p.end(); } drag->setPixmap(_pixmap); mimeData->setText(QString("%1").arg(index())); drag->setMimeData(mimeData); drag->exec(); }
static void fill_rect(DiaRenderer *self, Point *ul_corner, Point *lr_corner, Color *color) { _rect (self, ul_corner, lr_corner, color, TRUE); }
static void draw_rect(DiaRenderer *self, Point *ul_corner, Point *lr_corner, Color *color) { _rect (self, ul_corner, lr_corner, color, FALSE); }
void _gadget::setSizeInternal( _length width , _length height ) { _size size = this->getSize(); // Respect Fixed width/height of the gadget and size limits if( !this->isResizeableX() ) width = this->getWidth(); else width = max( width , this->getMinWidth() ); if( !this->isResizeableY() ) height = this->getHeight(); else height = max( height , this->getMinHeight() ); if( width == this->getWidth() && height == this->getHeight() ) return; // Compute area to redraw _size refreshSize = _size( max<_length>( width , size.first ) , max<_length>( height , size.second ) ); _pos refreshPos = this->getAbsolutePosition(); // Refresh this->bitmap.resize( width , height ); // Notify dependent gadgets this->notifyDependentGadgets( onResize ); // Refresh this->redraw( _rect( refreshPos , refreshSize ) ); }
void _gadget::setDimensionsInternal( _rect rc ) { _pos pos = this->getAbsolutePosition(); _size size = this->getSize(); // Respect Fixed width/height of the gadget if( !this->isResizeableX() ) rc.width = this->getWidth(); if( !this->isResizeableY() ) rc.height = this->getHeight(); // Limit rc.width = max( rc.width , this->getMinWidth() ); rc.height = max( rc.height , this->getMinHeight() ); // Apply Position this->x = rc.x; this->y = rc.y; // Compute new position _pos newPos = this->getAbsolutePosition(); _size newSize = _size( rc.width , rc.height ); if( size != newSize ) { this->bitmap.resize( rc.width , rc.height ); // Notify dependent gadgets this->notifyDependentGadgets( onResize ); if( pos != newPos ) this->notifyDependentGadgets( onMove ); if( !this->parent ) this->redraw(); else this->redraw( _rect( pos , size ).combine( _rect( newPos , newSize ) ) ); } else if( pos != newPos ) { if( !this->isHidden() ) this->redrawParents( _rect( pos , size ).combine( _rect( newPos , size ) ) ); // Notify dependent gadgets this->notifyDependentGadgets( onMove ); } }
static _rect_t text_rect(cairo_t *cr, const char *t) { cairo_text_extents_t extents; cairo_text_extents(cr, t, &extents); return _rect( extents.x_bearing, extents.y_bearing, extents.width, extents.height); }
//----------------------------------------------------------------------------- void CFrame::invalidRect (const CRect& rect) { if (!isVisible () || !platformFrame) return; CRect _rect (rect); getTransform ().transform (_rect); if (collectInvalidRects) collectInvalidRects->addRect (_rect); else platformFrame->invalidRect (_rect); }
static void _rounded_rect (DiaRenderer *self, Point *topleft, Point *bottomright, Color *color, real radius, gboolean fill) { DiaCairoRenderer *renderer = DIA_CAIRO_RENDERER (self); double rv[2]; radius = MIN(radius, (bottomright->x - topleft->x)/2); radius = MIN(radius, (bottomright->y - topleft->y)/2); /* ignore radius if it is smaller than the device unit, avoids anti-aliasing artifacts */ rv[0] = radius; rv[1] = 0.0; cairo_user_to_device_distance (renderer->cr, &rv[0], &rv[1]); if (rv[0] < 1.0 && rv[1] < 1.0) { _rect (self, topleft, bottomright, color, fill); return; } DIAG_NOTE(g_message("%s_rounded_rect %f,%f -> %f,%f, %f", fill ? "fill" : "draw", topleft->x, topleft->y, bottomright->x, bottomright->y, radius)); cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0); cairo_new_path (renderer->cr); cairo_move_to (renderer->cr, /* north-west */ topleft->x + radius, topleft->y); cairo_line_to (renderer->cr, /* north-east */ bottomright->x - radius, topleft->y); cairo_arc (renderer->cr, bottomright->x - radius, topleft->y + radius, radius, -G_PI_2, 0); cairo_line_to (renderer->cr, /* south-east */ bottomright->x, bottomright->y - radius); cairo_arc (renderer->cr, bottomright->x - radius, bottomright->y - radius, radius, 0, G_PI_2); cairo_line_to (renderer->cr, /* south-west */ topleft->x + radius, bottomright->y); cairo_arc (renderer->cr, topleft->x + radius, bottomright->y - radius, radius, G_PI_2, G_PI); cairo_line_to (renderer->cr, /* north-west */ topleft->x, topleft->y + radius); cairo_arc (renderer->cr, topleft->x + radius, topleft->y + radius, radius, G_PI, -G_PI_2); if (fill) cairo_fill (renderer->cr); else cairo_stroke (renderer->cr); DIAG_STATE(renderer->cr) }
WelcomeWidget::WelcomeWidget(const QRectF &rect, QWidget *widget) : PlexyDesk::DesktopWidget(rect, widget), d(new Private) { QRectF _rect(0.0, 0.0, 128.0, 128.0); d->icon1 = new WelcomeItem(QRect(0, 0, 128, 256), this); d->icon1->setName(""); d->icon1->setIcon(fromSvg(_rect, "home")); d->icon1->setPos(60, 70); d->icon2 = new WelcomeItem(QRect(0, 0, 128, 256), this); d->icon2->setName(""); d->icon2->setIcon(fromSvg(_rect, "notifications")); d->icon2->setPos(220, 70); d->icon3 = new WelcomeItem(QRect(0, 0, 128, 256), this); d->icon3->setName(""); d->icon3->setIcon(fromSvg(_rect, "relationships")); d->icon3->setPos(380, 70); }
void RectComponent::RepaintBackground(Painter* painter) { painter->PushAttrib(Painter::kAttrAll); GUIImageManager* i_man = GetImageManager(); PixelCoord pos(GetScreenPos()); PixelCoord size(GetSize()); PixelRect rect(pos, pos + size); PixelRect clipping_rect(rect); clipping_rect.right_++; clipping_rect.bottom_++; //painter->ReduceClippingRect(clipping_rect); if (hollow_ == false) { if (corner_radius_ == 0) { if (image_id_ == Painter::kInvalidImageid) { painter->SetColor(color_[0], 0); painter->SetAlphaValue(color_[0].alpha_); if (shaded_ == true) { painter->SetColor(color_[1], 1); painter->SetColor(color_[2], 2); painter->SetColor(color_[3], 3); painter->FillShadedRect(rect); } else { if (color_[0].alpha_ != 0) { painter->FillRect(rect); } } } else { i_man->DrawImage(image_id_, rect); } } else { // Draw with rounded corners. painter->SetColor(color_[0], 0); painter->SetAlphaValue(color_[0].alpha_); PixelRect _rect(GetScreenPos(), GetScreenPos() + GetSize()); painter->DrawRoundedRect(_rect, corner_radius_, corner_radius_mask_, true); } } painter->PopAttrib(); }
void _gadget::setBitmap( _bitmap bmp ) { _pos pos = this->getAbsolutePosition(); _size size = this->getSize(); _length newWidth = bmp.getWidth(); _length newHeight = bmp.getHeight(); // Respect Fixed width/height of the gadget and size limits if( !this->isResizeableX() ) newWidth = this->getWidth(); else newWidth = max( newWidth , this->getMinWidth() ); if( !this->isResizeableY() ) newHeight = this->getHeight(); else newHeight = max( newHeight , this->getMinHeight() ); // Resize bitmap to applyable size bmp.resize( newWidth , newHeight ); this->bitmap = move(bmp); // Compute area to redraw _size refreshSize = _size( max<_length>( newWidth , size.first ) , max<_length>( newHeight , size.second ) ); // Redraw! this->redraw( _rect( pos , refreshSize ) ); // Notify dependent gadgets if( newWidth != this->getWidth() || newHeight != this->getHeight() ) this->notifyDependentGadgets( onResize ); }
KDvoid CTutorial::Init ( KDvoid ) { const core::dimension2d<u32> tSize = s_pDriver->getScreenSize ( ); s32 w = tSize.Width; s32 h = tSize.Height; m_pGuiEnv->addStaticText ( this->getTitle ( ), _rect ( 20, 20, 120, 15 ), true, false, 0, -1, true ); m_pGuiEnv->addImage ( s_pDriver->getTexture ( "/res/media/irrlichtlogo2.png" ), core::position2d<s32> ( w - 130, 10 ) ); m_pGuiEnv->addButton ( _rect ( w / 2 - 110, h - 60, 100, 50 ), 0, GUI_ID_BUTTON_PREV, L"Prev" ); m_pGuiEnv->addButton ( _rect ( w / 2 + 10, h - 60, 100, 50 ), 0, GUI_ID_BUTTON_NEXT, L"Next" ); if ( !getVirPad ( ) ) { // return; } m_pGuiEnv->addButton ( _rect ( 100, h - 180, 80, 80 ), 0, GUI_ID_BUTTON_UP, L"Up" ); m_pGuiEnv->addButton ( _rect ( 100, h - 90, 80, 80 ), 0, GUI_ID_BUTTON_DOWN, L"Down" ); m_pGuiEnv->addButton ( _rect ( 10, h - 130, 80, 80 ), 0, GUI_ID_BUTTON_LEFT, L"Left" ); m_pGuiEnv->addButton ( _rect ( 190, h - 130, 80, 80 ), 0, GUI_ID_BUTTON_RIGHT, L"Right" ); m_pGuiEnv->addButton ( _rect ( w - 90, h - 90, 80, 80 ), 0, GUI_ID_BUTTON_JUMP, L"Jump" ); }