Ejemplo n.º 1
0
// FrameResized
void
ColorField::FrameResized(float width, float height)
{
	BRect r = _BitmapRect();
	_AllocBitmap(r.IntegerWidth() + 1, r.IntegerHeight() + 1);
	Invalidate();
}
Ejemplo n.º 2
0
// FrameResized
void
AlphaSlider::FrameResized(float width, float height)
{
	BRect r = _BitmapRect();
	_AllocBitmap(r.IntegerWidth() + 1, r.IntegerHeight() + 1);
	_UpdateColors();
	Invalidate();
	
}
Ejemplo n.º 3
0
// PositionMarkerAt
void
ColorField::PositionMarkerAt(BPoint where)
{
	BRect rect = _BitmapRect();
	where.ConstrainTo(rect);
	where -= rect.LeftTop();

	fLastMarkerPosition = fMarkerPosition;
	fMarkerPosition = where;
	Invalidate();
}
Ejemplo n.º 4
0
// _ValueFor
int32
AlphaSlider::_ValueFor(BPoint where) const
{
	BRect r = _BitmapRect();

	int32 value;
	if (fOrientation == B_HORIZONTAL)
		value = (int32)(255 * (where.x - r.left) / r.Width() + 0.5);
	else
		value = (int32)(255 * (where.y - r.top) / r.Height() + 0.5);

	value = max_c(0, value);
	value = min_c(255, value);

	return value;
}
Ejemplo n.º 5
0
// Draw
void
AlphaSlider::Draw(BRect updateRect)
{
	BRect b = _BitmapRect();
	b.InsetBy(-2.0, -2.0);

	bool isFocus = IsFocus() && Window()->IsActive();

	rgb_color bg = LowColor();
	rgb_color shadow;
	rgb_color darkShadow;
	rgb_color light;
	rgb_color black;

	if (IsEnabled()) {
		shadow = tint_color(bg, B_DARKEN_1_TINT);
		darkShadow = tint_color(bg, B_DARKEN_3_TINT);
		light = tint_color(bg, B_LIGHTEN_MAX_TINT);
		black = tint_color(bg, B_DARKEN_MAX_TINT);
	} else {
		shadow = bg;
		darkShadow = tint_color(bg, B_DARKEN_1_TINT);
		light = tint_color(bg, B_LIGHTEN_2_TINT);
		black = tint_color(bg, B_DARKEN_2_TINT);
	}

	rgb_color focus = isFocus ? ui_color(B_KEYBOARD_NAVIGATION_COLOR)
							  : black;

	stroke_frame(this, b, shadow, shadow, light, light);
	b.InsetBy(1.0, 1.0);
	if (isFocus)
		stroke_frame(this, b, focus, focus, focus, focus);
	else
		stroke_frame(this, b, darkShadow, darkShadow, bg, bg);
	b.InsetBy(1.0, 1.0);

	DrawBitmap(fBitmap, b.LeftTop());

	// value marker
	if (fOrientation == B_HORIZONTAL) {
		float pos = floorf(b.left + Value() * b.Width() / 255.0 + 0.5);
	
		if (pos - 2 >= b.left) {
			SetHighColor(kWhite);
			StrokeLine(BPoint(pos - 2, b.top), BPoint(pos - 2, b.bottom));
		}
		if (pos - 1 >= b.left) {
			SetHighColor(kBlack);
			StrokeLine(BPoint(pos - 1, b.top), BPoint(pos - 1, b.bottom));
		}
		if (pos + 1 <= b.right) {
			SetHighColor(kBlack);
			StrokeLine(BPoint(pos + 1, b.top), BPoint(pos + 1, b.bottom));
		}
		if (pos + 2 <= b.right) {
			SetHighColor(kWhite);
			StrokeLine(BPoint(pos + 2, b.top), BPoint(pos + 2, b.bottom));
		}
	} else {
		float pos = floorf(b.top + Value() * b.Height() / 255.0 + 0.5);
	
		if (pos - 2 >= b.top) {
			SetHighColor(kWhite);
			StrokeLine(BPoint(b.left, pos - 2), BPoint(b.right, pos - 2));
		}
		if (pos - 1 >= b.top) {
			SetHighColor(kBlack);
			StrokeLine(BPoint(b.left, pos - 1), BPoint(b.right, pos - 1));
		}
		if (pos + 1 <= b.bottom) {
			SetHighColor(kBlack);
			StrokeLine(BPoint(b.left, pos + 1), BPoint(b.right, pos + 1));
		}
		if (pos + 2 <= b.bottom) {
			SetHighColor(kWhite);
			StrokeLine(BPoint(b.left, pos + 2), BPoint(b.right, pos + 2));
		}
	}
}
Ejemplo n.º 6
0
// Height
float
ColorField::Height() const
{
	return _BitmapRect().IntegerHeight() + 1;
}
Ejemplo n.º 7
0
// Width
float
ColorField::Width() const
{
	return _BitmapRect().IntegerWidth() + 1;
}