static void drawBox(SkCanvas* canvas, const IntRect& rect, const SkPaint& paint) { const int right = rect.x() + rect.width() - 1; const int bottom = rect.y() + rect.height() - 1; drawHorizLine(canvas, rect.x(), right, rect.y(), paint); drawVertLine(canvas, right, rect.y(), bottom, paint); drawHorizLine(canvas, rect.x(), right, bottom, paint); drawVertLine(canvas, rect.x(), rect.y(), bottom, paint); }
void Drawable::drawRect(int x, int y, int width, int height) { if (this->beforeDrawing(x, y, x + width - 1, y + height - 1)) { drawHorizLine(x, y, width); drawHorizLine(x, y + height - 1, width); drawVertLine(x, y + 1, height - 2); drawVertLine(x + width - 1, y + 1, height - 2); this->afterDrawing(x, y, x + width - 1, y + height - 1); } }
void ScrollbarThemeChromiumLinux::paintThumb(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect) { const bool hovered = scrollbar->hoveredPart() == ThumbPart; const int midx = rect.x() + rect.width() / 2; const int midy = rect.y() + rect.height() / 2; const bool vertical = scrollbar->orientation() == VerticalScrollbar; SkCanvas* const canvas = gc->platformContext()->canvas(); SkScalar thumb[3]; SkColorToHSV(hovered ? PlatformThemeChromiumGtk::thumbActiveColor() : PlatformThemeChromiumGtk::thumbInactiveColor(), thumb); SkPaint paint; paint.setColor(PlatformThemeChromiumGtk::saturateAndBrighten(thumb, 0, 0.02)); SkIRect skrect; if (vertical) skrect.set(rect.x(), rect.y(), midx + 1, rect.y() + rect.height()); else skrect.set(rect.x(), rect.y(), rect.x() + rect.width(), midy + 1); canvas->drawIRect(skrect, paint); paint.setColor(PlatformThemeChromiumGtk::saturateAndBrighten(thumb, 0, -0.02)); if (vertical) skrect.set(midx + 1, rect.y(), rect.x() + rect.width(), rect.y() + rect.height()); else skrect.set(rect.x(), midy + 1, rect.x() + rect.width(), rect.y() + rect.height()); canvas->drawIRect(skrect, paint); SkScalar track[3]; SkColorToHSV(PlatformThemeChromiumGtk::trackColor(), track); paint.setColor(PlatformThemeChromiumGtk::outlineColor(track, thumb)); drawBox(canvas, rect, paint); if (rect.height() > 10 && rect.width() > 10) { const int grippyHalfWidth = 2; const int interGrippyOffset = 3; if (vertical) { drawHorizLine(canvas, midx - grippyHalfWidth, midx + grippyHalfWidth, midy - interGrippyOffset, paint); drawHorizLine(canvas, midx - grippyHalfWidth, midx + grippyHalfWidth, midy, paint); drawHorizLine(canvas, midx - grippyHalfWidth, midx + grippyHalfWidth, midy + interGrippyOffset, paint); } else { drawVertLine(canvas, midx - interGrippyOffset, midy - grippyHalfWidth, midy + grippyHalfWidth, paint); drawVertLine(canvas, midx, midy - grippyHalfWidth, midy + grippyHalfWidth, paint); drawVertLine(canvas, midx + interGrippyOffset, midy - grippyHalfWidth, midy + grippyHalfWidth, paint); } } }
void Drawable::fillRectangle(int x, int y, int width, int height) { if (this->beforeDrawing(x, y, x + width - 1, y + height - 1)) { for (int l = 0; l < height; l++) { drawHorizLine(x, y + l, width); } this->afterDrawing(x, y, x + width - 1, y + height - 1); } }
bool RenderThemeChromiumSkia::paintSliderThumb(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) { // Make a thumb similar to the scrollbar thumb. const bool hovered = isHovered(o) || toRenderSlider(o->parent())->inDragMode(); const int midx = rect.x() + rect.width() / 2; const int midy = rect.y() + rect.height() / 2; const bool vertical = (o->style()->appearance() == SliderThumbVerticalPart); SkCanvas* const canvas = i.context->platformContext()->canvas(); const SkColor thumbLightGrey = SkColorSetARGB(0xff, 0xf4, 0xf2, 0xef); const SkColor thumbDarkGrey = SkColorSetARGB(0xff, 0xea, 0xe5, 0xe0); SkPaint paint; paint.setColor(hovered ? SK_ColorWHITE : thumbLightGrey); SkIRect skrect; if (vertical) skrect.set(rect.x(), rect.y(), midx + 1, rect.bottom()); else skrect.set(rect.x(), rect.y(), rect.right(), midy + 1); canvas->drawIRect(skrect, paint); paint.setColor(hovered ? thumbLightGrey : thumbDarkGrey); if (vertical) skrect.set(midx + 1, rect.y(), rect.right(), rect.bottom()); else skrect.set(rect.x(), midy + 1, rect.right(), rect.bottom()); canvas->drawIRect(skrect, paint); const SkColor borderDarkGrey = SkColorSetARGB(0xff, 0x9d, 0x96, 0x8e); paint.setColor(borderDarkGrey); drawBox(canvas, rect, paint); if (rect.height() > 10 && rect.width() > 10) { drawHorizLine(canvas, midx - 2, midx + 2, midy, paint); drawHorizLine(canvas, midx - 2, midx + 2, midy - 3, paint); drawHorizLine(canvas, midx - 2, midx + 2, midy + 3, paint); } return false; }