void
LanguageListView::Draw(BRect updateRect)
{
	BOutlineListView::Draw(updateRect);

	if (fDropIndex >= 0 && fDropTargetHighlightFrame.IsValid()) {
		// TODO: decide if drawing of a drop target indicator should be moved
		//       into ControlLook
		BGradientLinear gradient;
		int step = fGlobalDropTargetIndicator ? 64 : 128;
		for (int i = 0; i < 256; i += step)
			gradient.AddColor(i % (step * 2) == 0
				? ViewColor() : ui_color(B_CONTROL_HIGHLIGHT_COLOR), i);
		gradient.AddColor(ViewColor(), 255);
		gradient.SetStart(fDropTargetHighlightFrame.LeftTop());
		gradient.SetEnd(fDropTargetHighlightFrame.RightBottom());
		if (fGlobalDropTargetIndicator) {
			BRegion region(fDropTargetHighlightFrame);
			region.Exclude(fDropTargetHighlightFrame.InsetByCopy(2.0, 2.0));
			ConstrainClippingRegion(&region);
			FillRect(fDropTargetHighlightFrame, gradient);
			ConstrainClippingRegion(NULL);
		} else
			FillRect(fDropTargetHighlightFrame, gradient);
	}
}
示例#2
0
void
GradientsView::DrawLinear(BRect update)
{
	BGradientLinear gradient;
	rgb_color c;
	c.red = 255;
	c.green = 0;
	c.blue = 0;
	gradient.AddColor(c, 0);
	c.red = 0;
	c.green = 255;
	c.blue = 0;
	gradient.AddColor(c, 127);
	c.red = 0;
	c.green = 0;
	c.blue = 255;
	gradient.AddColor(c, 255);

	// RoundRect
	SetHighColor(0, 0, 0);
	FillRoundRect(BRect(10, 10, 110, 110), 5, 5);
	gradient.SetStart(BPoint(120, 10));
	gradient.SetEnd(BPoint(220, 110));
	FillRoundRect(BRect(120, 10, 220, 110), 5, 5, gradient);

	// Rect
	SetHighColor(0, 0, 0);
	FillRect(BRect(10, 120, 110, 220));
	gradient.SetStart(BPoint(120, 120));
	gradient.SetEnd(BPoint(220, 220));
	FillRect(BRect(120, 120, 220, 220), gradient);

	// Triangle
	SetHighColor(0, 0, 0);
	FillTriangle(BPoint(60, 230), BPoint(10, 330), BPoint(110, 330));
	gradient.SetStart(BPoint(60, 230));
	gradient.SetEnd(BPoint(60, 330));
	FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330), 
		gradient);

	// Ellipse
	SetHighColor(0, 0, 0);
	FillEllipse(BPoint(60, 390), 50, 50);
	gradient.SetStart(BPoint(60, 340));
	gradient.SetEnd(BPoint(60, 440));
	FillEllipse(BPoint(170, 390), 50, 50, gradient);
}
示例#3
0
/*!	\brief Draws a rectangle with a gradient.
  \param down The rectangle should be drawn recessed or not
*/
void
MacDecorator::_DrawBlendedRect(DrawingEngine* engine, BRect rect,
                               bool down/*, bool focus*/)
{
    // figure out which colors to use
    rgb_color startColor, endColor;
    if (down) {
        startColor = fButtonLowColor;
        endColor = frame_highcol;
    } else {
        startColor = fButtonHighColor;
        endColor = frame_lowercol;
    }

    // fill
    BGradientLinear gradient;
    gradient.SetStart(rect.LeftTop());
    gradient.SetEnd(rect.RightBottom());
    gradient.AddColor(startColor, 0);
    gradient.AddColor(endColor, 255);

    engine->FillRect(rect, gradient);
}
示例#4
0
void
PlaylistListView::Item::Draw(BView* owner, BRect frame, const font_height& fh,
                             bool tintedLine, uint32 mode, bool active, uint32 playbackState)
{
    rgb_color color = (rgb_color) {
        255, 255, 255, 255
    };
    if (tintedLine)
        color = tint_color(color, 1.04);
    // background
    if (IsSelected())
        color = tint_color(color, B_DARKEN_2_TINT);
    owner->SetLowColor(color);
    owner->FillRect(frame, B_SOLID_LOW);
    // label
    rgb_color black = (rgb_color) {
        0, 0, 0, 255
    };
    owner->SetHighColor(black);
    const char* text = Text();
    switch (mode) {
    case DISPLAY_NAME:
        // TODO
        break;
    case DISPLAY_PATH:
        // TODO
        break;
    default:
        break;
    }

    float playbackMarkSize = playback_mark_size(fh);
    float textOffset = text_offset(fh);

    BString truncatedString(text);
    owner->TruncateString(&truncatedString, B_TRUNCATE_MIDDLE,
                          frame.Width() - playbackMarkSize - textOffset);
    owner->DrawString(truncatedString.String(),
                      BPoint(frame.left + playbackMarkSize + textOffset,
                             floorf(frame.top + frame.bottom + fh.ascent) / 2 - 1));

    // playmark
    if (active) {
        rgb_color green = (rgb_color) {
            0, 255, 0, 255
        };
        if (playbackState != PLAYBACK_STATE_PLAYING)
            green = tint_color(color, B_DARKEN_1_TINT);

        BRect r(0, 0, playbackMarkSize, playbackMarkSize);
        r.OffsetTo(frame.left + 4,
                   ceilf((frame.top + frame.bottom - playbackMarkSize) / 2));

#ifdef __ANTARES__
        uint32 flags = owner->Flags();
        owner->SetFlags(flags | B_SUBPIXEL_PRECISE);

        BShape shape;
        shape.MoveTo(r.LeftTop());
        shape.LineTo(r.LeftBottom());
        shape.LineTo(BPoint(r.right, (r.top + r.bottom) / 2));
        shape.Close();

        owner->MovePenTo(B_ORIGIN);
        owner->FillShape(&shape);

        shape.Clear();
        r.InsetBy(1, 1);
        shape.MoveTo(r.LeftTop());
        shape.LineTo(r.LeftBottom());
        shape.LineTo(BPoint(r.right, (r.top + r.bottom) / 2));
        shape.Close();

        BGradientLinear gradient;
        gradient.SetStart(r.LeftTop());
        gradient.SetEnd(r.LeftBottom());
        gradient.AddColor(tint_color(green, B_LIGHTEN_1_TINT), 0);
        gradient.AddColor(tint_color(green, B_DARKEN_1_TINT), 255.0);

        owner->FillShape(&shape, gradient);

        owner->SetFlags(flags);
#else
        BPoint arrow[3];
        arrow[0] = r.LeftTop();
        arrow[1] = r.LeftBottom();
        arrow[2].x = r.right;
        arrow[2].y = (r.top + r.bottom) / 2;

        rgb_color lightGreen = tint_color(green, B_LIGHTEN_2_TINT);
        rgb_color darkGreen = tint_color(green, B_DARKEN_2_TINT);
        owner->BeginLineArray(6);
        // black outline
        owner->AddLine(arrow[0], arrow[1], black);
        owner->AddLine(BPoint(arrow[1].x + 1.0, arrow[1].y - 1.0),
                       arrow[2], black);
        owner->AddLine(arrow[0], arrow[2], black);
        // inset arrow
        arrow[0].x += 1.0;
        arrow[0].y += 2.0;
        arrow[1].x += 1.0;
        arrow[1].y -= 2.0;
        arrow[2].x -= 2.0;
        // highlights and shadow
        owner->AddLine(arrow[1], arrow[2], darkGreen);
        owner->AddLine(arrow[0], arrow[2], lightGreen);
        owner->AddLine(arrow[0], arrow[1], lightGreen);
        owner->EndLineArray();
        // fill green
        arrow[0].x += 1.0;
        arrow[0].y += 1.0;
        arrow[1].x += 1.0;
        arrow[1].y -= 1.0;
        arrow[2].x -= 2.0;

        owner->SetLowColor(owner->HighColor());
        owner->SetHighColor(green);
        owner->FillPolygon(arrow, 3);
#endif // __ANTARES__
    }
}
void
PlaylistListView::Item::Draw(BView* owner, BRect frame, const font_height& fh,
	bool tintedLine, uint32 mode, bool active, uint32 playbackState)
{
	rgb_color color = (rgb_color){ 255, 255, 255, 255 };
	if (tintedLine)
		color = tint_color(color, 1.04);
	// background
	if (IsSelected())
		color = tint_color(color, B_DARKEN_2_TINT);
	owner->SetLowColor(color);
	owner->FillRect(frame, B_SOLID_LOW);
	// label
	rgb_color black = (rgb_color){ 0, 0, 0, 255 };
	owner->SetHighColor(black);
	const char* text = Text();
	switch (mode) {
		case DISPLAY_NAME:
			// TODO
			break;
		case DISPLAY_PATH:
			// TODO
			break;
		default:
			break;
	}

	float playbackMarkSize = playback_mark_size(fh);
	float textOffset = text_offset(fh);

	BString truncatedString(text);
	owner->TruncateString(&truncatedString, B_TRUNCATE_MIDDLE,
		frame.Width() - playbackMarkSize - textOffset);
	owner->DrawString(truncatedString.String(),
		BPoint(frame.left + playbackMarkSize + textOffset,
			floorf(frame.top + frame.bottom + fh.ascent) / 2 - 1));

	// playmark
	if (active) {
		rgb_color green = (rgb_color){ 0, 255, 0, 255 };
		if (playbackState != PLAYBACK_STATE_PLAYING)
			green = tint_color(color, B_DARKEN_1_TINT);

		BRect r(0, 0, playbackMarkSize, playbackMarkSize);
		r.OffsetTo(frame.left + 4,
			ceilf((frame.top + frame.bottom - playbackMarkSize) / 2));

		uint32 flags = owner->Flags();
		owner->SetFlags(flags | B_SUBPIXEL_PRECISE);

		BShape shape;
		shape.MoveTo(r.LeftTop());
		shape.LineTo(r.LeftBottom());
		shape.LineTo(BPoint(r.right, (r.top + r.bottom) / 2));
		shape.Close();

		owner->MovePenTo(B_ORIGIN);
		owner->FillShape(&shape);

		shape.Clear();
		r.InsetBy(1, 1);
		shape.MoveTo(r.LeftTop());
		shape.LineTo(r.LeftBottom());
		shape.LineTo(BPoint(r.right, (r.top + r.bottom) / 2));
		shape.Close();

		BGradientLinear gradient;
		gradient.SetStart(r.LeftTop());
		gradient.SetEnd(r.LeftBottom());
		gradient.AddColor(tint_color(green, B_LIGHTEN_1_TINT), 0);
		gradient.AddColor(tint_color(green, B_DARKEN_1_TINT), 255.0);

		owner->FillShape(&shape, gradient);

		owner->SetFlags(flags);
	}
}
示例#6
0
void
VolumeSlider::DrawThumb()
{
#if ROUND_KNOB
	// Draw a round thumb
	BRect rect(ThumbFrame());

	rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color frameLightColor;
	rgb_color frameShadowColor;
	rgb_color shadowColor = (rgb_color){ 0, 0, 0, 60 };

	float topTint = 0.49;
	float middleTint1 = 0.62;
	float middleTint2 = 0.76;
	float bottomTint = 0.90;

	if (!IsEnabled()) {
		topTint = (topTint + B_NO_TINT) / 2;
		middleTint1 = (middleTint1 + B_NO_TINT) / 2;
		middleTint2 = (middleTint2 + B_NO_TINT) / 2;
		bottomTint = (bottomTint + B_NO_TINT) / 2;
		shadowColor = (rgb_color){ 0, 0, 0, 30 };
	}

	// Draw shadow
#if !KNOB_EMBEDDED
	rect.left++;
	rect.top++;
	SetDrawingMode(B_OP_ALPHA);
	SetHighColor(shadowColor);
	FillEllipse(rect);

	// Draw thumb shape
	rect.OffsetBy(-1, -1);
#endif

	if (IsFocus()) {
		// focused
		frameLightColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
		frameShadowColor = frameLightColor;
	} else {
		// figure out the tints to be used
		float frameLightTint;
		float frameShadowTint;

		if (!IsEnabled()) {
			frameLightTint = 1.30;
			frameShadowTint = 1.35;
			shadowColor.alpha = 30;
		} else {
			frameLightTint = 1.6;
			frameShadowTint = 1.65;
		}

		frameLightColor = tint_color(base, frameLightTint);
		frameShadowColor = tint_color(base, frameShadowTint);
	}

	BGradientLinear frameGradient;
	frameGradient.AddColor(frameShadowColor, 0);
	frameGradient.AddColor(frameLightColor, 255);
	frameGradient.SetStart(rect.LeftTop());
	frameGradient.SetEnd(rect.RightBottom());

	FillEllipse(rect, frameGradient);
	rect.InsetBy(1, 1);

//	frameGradient.MakeEmpty();
//	frameGradient.AddColor(borderColor, 0);
//	frameGradient.AddColor(tint_color(borderColor, 0.8), 255);
//	view->FillEllipse(rect, frameGradient);
//	rect.InsetBy(1, 1);

	BGradientLinear gradient;
	if (!IsEnabled()) {
		gradient.AddColor(tint_color(base, topTint), 0);
		gradient.AddColor(tint_color(base, bottomTint), 255);
	} else {
		gradient.AddColor(tint_color(base, topTint), 0);
		gradient.AddColor(tint_color(base, middleTint1), 132);
		gradient.AddColor(tint_color(base, middleTint2), 136);
		gradient.AddColor(tint_color(base, bottomTint), 255);
	}
	gradient.SetStart(rect.LeftTop());
	gradient.SetEnd(rect.LeftBottom());
	FillEllipse(rect, gradient);
#else
	BSlider::DrawThumb();
#endif
}