Esempio n. 1
0
void LoginView::Draw(BRect rect)
{
	BRect r = Bounds();
	BRect iconRect(13.0, 5.0, 45.0, 37.0);
	rgb_color black = { 0, 0, 0, 255 };
	rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);

	SetViewColor(gray);
	SetLowColor(gray);
	FillRect(r, B_SOLID_LOW);

	SetHighColor(black);
	SetFont(be_bold_font);
	SetFontSize(11);
	MovePenTo(55, 15);
	DrawString("Login Required");

	SetFont(be_plain_font);
	SetFontSize(10);
	MovePenTo(55, 28);
	DrawString("The resource you've specified requires");
	MovePenTo(55, 40);
	DrawString("permission to access it.");

	MovePenTo(13, 61);
	DrawString("Resource:");
	MovePenTo(70, 61);
	DrawString(resource);

	SetDrawingMode(B_OP_ALPHA); 
	SetHighColor(0, 0, 0, 180);       
	SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
	DrawBitmap(icon, iconRect);
}
Esempio n. 2
0
void Sprite::Render()
{
    if (!ShouldDraw())
        return;

    UpdateTexture();

    SetBlendingMode(BlendingMode);

    // Assign our matrix.
    SetShaderParameters(ColorInvert, AffectedByLightning, Centered, false, BlackToTransparent);

    Mat4 Mat = GetMatrix();
    WindowFrame.SetUniform(U_MVP, &(Mat[0][0]));

    // Set the color.
    WindowFrame.SetUniform(U_COLOR, Red, Green, Blue, Alpha);

    SetTexturedQuadVBO(UvBuffer);
    DoQuadDraw();

    DrawLighten();

    FinalizeDraw();
}
Esempio n. 3
0
void DrawTexturedQuad(Image* ToDraw, const AABB& TextureCrop, const Transformation& QuadTransformation,
    const EBlendMode &Mode, const ColorRGB &InColor)
{
    if (ToDraw)
        ToDraw->Bind();
    else return;

    WindowFrame.SetUniform(U_COLOR, InColor.Red, InColor.Green, InColor.Blue, InColor.Alpha);

    SetBlendingMode(Mode);

    float CropPositions[8] = {
        // topright
        TextureCrop.P2.X / (float)ToDraw->w,
        TextureCrop.P2.Y / (float)ToDraw->h,
        // bottom right
        TextureCrop.P2.X / (float)ToDraw->w,
        TextureCrop.P1.Y / (float)ToDraw->h,
        // bottom left
        TextureCrop.P1.X / (float)ToDraw->w,
        TextureCrop.P1.Y / (float)ToDraw->h,
        // topleft
        TextureCrop.P1.X / (float)ToDraw->w,
        TextureCrop.P2.Y / (float)ToDraw->h,
    };

    TextureBuffer->AssignData(CropPositions);
    SetTexturedQuadVBO(TextureBuffer);

    DoQuadDraw();

    FinalizeDraw();
}
Esempio n. 4
0
// constructor
ObjectView::ObjectView(BRect frame, const char* name,
					 uint32 resizeFlags, uint32 flags)
	: BView(frame, name, resizeFlags, flags),
	  fState(NULL),
	  fObjectType(OBJECT_LINE),
	  fStateList(20),
	  fColor((rgb_color){ 0, 80, 255, 100 }),
	  fDrawingMode(B_OP_ALPHA),
	  fFill(false),
	  fPenSize(10.0),
	  fScrolling(false),
	  fInitiatingDrag(false),
	  fLastMousePos(0.0, 0.0)
{

	SetLowColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_1_TINT));

//	BFont font;
//	GetFont(&font);
//	font.SetFamilyAndStyle("Bitstream Vera Serif", "Roman");
//	font.SetSize(20.0);
////	font.SetRotation(6.0);
//	SetFont(&font, B_FONT_FAMILY_AND_STYLE | B_FONT_ROTATION | B_FONT_SIZE);

//	State* state = State::StateFor(OBJECT_ROUND_RECT, fColor, B_OP_COPY,
//								   false, 50.0);
//	state->MouseDown(BPoint(15, 15));
//	state->MouseMoved(BPoint(255, 305));
//	state->MouseUp();
//
//	AddObject(state);

	SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
}
Esempio n. 5
0
		void Draw(BRect rect)
		{
			BRect r = Bounds();
			BRect iconRect(13.0, 5.0, 45.0, 37.0);
			rgb_color black = { 0, 0, 0, 255 };
			rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);

			SetViewColor(gray);
			SetLowColor(gray);
			FillRect(r, B_SOLID_LOW);

			SetHighColor(black);
			SetFont(be_bold_font);
			SetFontSize(11);
			MovePenTo(55, 15);
			DrawString("Connect to Internet Host");

			SetFont(be_plain_font);
			SetFontSize(10);
			MovePenTo(55, 28);
			DrawString("Specify the name or address of a computer located");
			MovePenTo(55, 40);
			DrawString("outside your network, such as on the Internet.");

			SetDrawingMode(B_OP_ALPHA); 
			SetHighColor(0, 0, 0, 180);       
			SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
			DrawBitmap(icon, iconRect);
		}
Esempio n. 6
0
void GroupPropertiesView::Draw(BRect rect)
{
    BRect r = Bounds();
    BRect iconRect(13.0, 5.0, 45.0, 37.0);
    rgb_color black = { 0, 0, 0, 255 };
    rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);

    SetViewColor(gray);
    SetLowColor(gray);
    FillRect(r, B_SOLID_LOW);

    SetHighColor(black);
    SetFont(be_bold_font);
    SetFontSize(11);
    MovePenTo(55, 15);
    BString string(group);
    string += " Properties";
    DrawString(string.String());

    SetFont(be_plain_font);
    SetFontSize(10);
    MovePenTo(55, 28);
    DrawString("Groups are collections of users that will share certain properties,");
    MovePenTo(55, 40);
    DrawString("such as access to files or network resources.");

    MovePenTo(13, 121);
    DrawString("Current Members:");

    SetDrawingMode(B_OP_ALPHA);
    SetHighColor(0, 0, 0, 180);
    SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
    DrawBitmap(icon, iconRect);
}
void ConsoleHeaderView::Draw(BRect rect)
{
	BRect r = Bounds();
	BRect iconRect(13.0, 5.0, 45.0, 37.0);
	rgb_color black = { 0, 0, 0, 255 };
	rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);

	SetViewColor(gray);
	SetLowColor(gray);
	FillRect(r, B_SOLID_LOW);

	SetHighColor(black);
	SetFont(be_bold_font);
	SetFontSize(11);
	MovePenTo(55, 15);
	DrawString("BeServed Domain Management Console");

	SetFont(be_plain_font);
	SetFontSize(10);
	MovePenTo(55, 28);
	DrawString("Version 1.2.6");
	MovePenTo(55, 40);
	DrawString("");

	SetDrawingMode(B_OP_ALPHA); 
	SetHighColor(0, 0, 0, 180);       
	SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
	DrawBitmap(icon, iconRect);
}
Esempio n. 8
0
// Draw
void
IconValueView::Draw(BRect updateRect)
{
	BRect r;
	BRegion originalClippingRegion;
	GetClippingRegion(&originalClippingRegion);
	if (fIcon) {
		BRect b(Bounds());
		// layout icon in the center
		r = fIcon->Bounds();
		r.OffsetTo(floorf(b.left + b.Width() / 2.0 - r.Width() / 2.0),
				   floorf(b.top + b.Height() / 2.0 - r.Height() / 2.0));
		if (fIcon->ColorSpace() == B_RGBA32 || fIcon->ColorSpace() == B_RGBA32_BIG) {
			// set up transparent drawing and let
			// the base class draw the entire background
			SetHighColor(255, 255, 255, 255);
			SetDrawingMode(B_OP_ALPHA);
			SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
		} else {
			// constrain clipping region to exclude bitmap
			BRegion region = originalClippingRegion;
			region.Exclude(r);
			ConstrainClippingRegion(&region);
		}
	}
	// draw surrouing area (and possibly background for bitmap)
	PropertyEditorView::Draw(updateRect);

	ConstrainClippingRegion(&originalClippingRegion);
	if (fIcon) {
		DrawBitmap(fIcon, r.LeftTop());
	}
}
Esempio n. 9
0
void MyNetHeaderView::Draw(BRect rect)
{
	BRect r = Bounds();
	BRect iconRect(13.0, 5.0, 45.0, 37.0);
	rgb_color black = { 0, 0, 0, 255 };
	rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);

	SetViewColor(gray);
	SetLowColor(gray);
	FillRect(r, B_SOLID_LOW);

	SetHighColor(black);
	SetFont(be_bold_font);
	SetFontSize(11);
	MovePenTo(55, 15);
	DrawString("My Network Browser");

	SetFont(be_plain_font);
	SetFontSize(10);
	MovePenTo(55, 28);
	DrawString("This utility allows you to connect to remote computers and access");
	MovePenTo(55, 40);
	DrawString("resources, such as files and printers, that others have chosen to share.");

	SetDrawingMode(B_OP_ALPHA); 
	SetHighColor(0, 0, 0, 180);       
	SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
	DrawBitmap(icon, iconRect);
}
Esempio n. 10
0
	PageIconView()
		:
		BView("page icon view", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
		fIcon(NULL)
	{
		SetDrawingMode(B_OP_ALPHA);
		SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
	}
Esempio n. 11
0
	virtual void Draw(BRect updateRect)
	{
		if (fDimmedIcon) {
			SetDrawingMode(B_OP_ALPHA);
			SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
			SetHighColor(0, 0, 0, 100);
		}
		DrawBitmapAsync(&fIconBitmap);
	}
Esempio n. 12
0
void
PictureView::Draw(BRect frame)
{
	if (fBitmap) {
		SetDrawingMode(B_OP_ALPHA);
		SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
		DrawBitmap(fBitmap, fBitmap->Bounds(),
			Bounds(), B_FILTER_BITMAP_BILINEAR);
	}
}
Esempio n. 13
0
// Draw
void
BitmapView::Draw(BRect updateRect)
{
	if (fBitmap) {
		if (fBitmap->ColorSpace() == B_RGBA32) {
			// draw the bitmap with pixel alpha
			// against a red background
			FillRect(updateRect);
			SetDrawingMode(B_OP_ALPHA);
			SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
		}
		DrawBitmap(fBitmap, Bounds().LeftTop());
	}
}
Esempio n. 14
0
void DrawPrimitiveQuad(Transformation &QuadTransformation, const EBlendMode &Mode, const ColorRGB &Color)
{
    Image::BindNull();
    WindowFrame.SetUniform(U_COLOR, Color.Red, Color.Green, Color.Blue, Color.Alpha);

    SetBlendingMode(Mode);

    Mat4 Mat = QuadTransformation.GetMatrix();
    WindowFrame.SetUniform(U_MVP, &(Mat[0][0]));

    // Assign position attrib. pointer
    SetPrimitiveQuadVBO();
    DoQuadDraw();
    FinalizeDraw();

    Image::ForceRebind();
}
Esempio n. 15
0
// SetDrawData
void
Painter::SetDrawData(const DrawData* data)
{
	// for now...
	SetHighColor(data->highcolor.GetColor32());
	SetLowColor(data->lowcolor.GetColor32());
	SetScale(data->scale);
	SetPenSize(data->pensize);
//	fOrigin = data->coordOrigin;
	SetDrawingMode(data->draw_mode);
	SetBlendingMode(data->alphaSrcMode, data->alphaFncMode);
	SetPenLocation(data->penlocation);
	SetFont(data->font);
//	if (data->clipReg) {
//		ConstrainClipping(*data->clipReg);
//	}
	fPatternHandler->SetPattern(data->patt);
}
Esempio n. 16
0
void
TAlertView::Draw(BRect updateRect)
{
	if (fIconBitmap == NULL)
		return;

	// Here's the fun stuff
	BRect stripeRect = Bounds();
	int32 iconLayoutScale = icon_layout_scale();
	stripeRect.right = kIconStripeWidth * iconLayoutScale;
	SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
	FillRect(stripeRect);

	SetDrawingMode(B_OP_ALPHA);
	SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
	DrawBitmapAsync(fIconBitmap, BPoint(18 * iconLayoutScale,
		6 * iconLayoutScale));
}
Esempio n. 17
0
void
GearsView::Draw(BRect updateRect)
{
	SetHighColor(ViewColor());
	FillRect(updateRect);

	BRect stripeRect = Bounds();
	stripeRect.right = kStripeWidth;
	SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
	FillRect(stripeRect);

	if (fGears == NULL)
		return;

	SetDrawingMode(B_OP_ALPHA);
	SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
	DrawBitmapAsync(fGears, BPoint(5.0, 10.0));
}
Esempio n. 18
0
void
ConflictView::Draw(BRect updateRect)
{
	// Draw background
	if (Parent())
		SetLowColor(Parent()->ViewColor());
	else
		SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	FillRect(updateRect, B_SOLID_LOW);

	if (fIcon == NULL)
		return;

	// Draw icon
	SetDrawingMode(B_OP_ALPHA);
	SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
	DrawBitmapAsync(fIcon, BPoint(0, 0));
}
Esempio n. 19
0
ToolBar::ToolBar(void)
    :
    BView(BRect(), "toolbar", B_FOLLOW_NONE, B_WILL_DRAW |
        B_FULL_UPDATE_ON_RESIZE),
    fSpacing(0),
    fIconSpace(2),
    fButtonHighlight(-1),
    fButtonPressed(false),
    fFontSize(14)
{
    fTargetHandler = NULL;
    fTargetLooper = NULL;

    SetViewColor(B_TRANSPARENT_32_BIT);
    SetDrawingMode(B_OP_ALPHA);
    SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);

	SetFontSize(fFontSize);    
}
Esempio n. 20
0
FireEffect::FireEffect(const Vector3f& position) {

    constexpr float minV = 0.886f;
    constexpr float maxV = minV + 0.2f;

    constexpr float range = 1.305f;

    SetMinVelocity(Vector3f(-range,minV,-range) );
    SetMaxVelocity(Vector3f(+range,maxV,+range));

    SetBaseParticleLifetime(1.5f);
    SetParticleLifetimeVariance(1.5f);

    SetBaseStartSize(0.70f);
    SetBaseEndSize(0.38f);
    SetStartSizeVariance(0.22f);
    SetEndSizeVariance(0.16f);

    SetStartColor(Color(1.0f,0.2f,0.0f,0.6f));
    SetEndColor(Color(1.0f,0.2f,0.0f,0.0f));

    SetBlendingMode(ADDITIVE_BLENDING_MODE);

    SetEmitPosition(position);
    SetEmitPositionVariance(Vector3f(0.05f));

    Texture* texture = Texture2D::Load("img/particle_post2.png");

    if(!texture) {
	PrintErrorExit();
    }

    texture->Bind();
    texture->SetTextureRepeat();
    texture->GenerateMipmap();
    texture->SetMinFilter(GL_LINEAR_MIPMAP_LINEAR);
    texture->SetMagFilter(GL_LINEAR);
    texture->Unbind();

    SetTexture(texture);

}
Esempio n. 21
0
void
RemoteDrawingEngine::SetDrawState(const DrawState* state, int32 xOffset,
	int32 yOffset)
{
	SetPenSize(state->PenSize());
	SetDrawingMode(state->GetDrawingMode());
	SetBlendingMode(state->AlphaSrcMode(), state->AlphaFncMode());
	SetPattern(state->GetPattern().GetPattern());
	SetStrokeMode(state->LineCapMode(), state->LineJoinMode(),
		state->MiterLimit());
	SetHighColor(state->HighColor());
	SetLowColor(state->LowColor());
	SetFont(state->Font());

	RemoteMessage message(NULL, fHWInterface->SendBuffer());
	message.Start(RP_SET_OFFSETS);
	message.Add(fToken);
	message.Add(xOffset);
	message.Add(yOffset);
}
Esempio n. 22
0
bool Sprite::RenderMinimalSetup()
{
    if (!ShouldDraw())
        return false;

    UpdateTexture();

    SetBlendingMode(BlendingMode);

    UvBuffer->Bind();
    glVertexAttribPointer(WindowFrame.EnableAttribArray(A_UV), 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, nullptr);

    // Set the color.
    WindowFrame.SetUniform(U_COLOR, Red, Green, Blue, Alpha);
    DoQuadDraw();

    DrawLighten();

    return true;
}
Esempio n. 23
0
void
BIconButton::Draw(BRect updateRect)
{
	rgb_color background;
	if (fCustomBackground)
		background = {120,120,120};
	else
		background = LowColor();

	BRect r(Bounds());

	uint32 flags = 0;
	BBitmap* bitmap = fNormalBitmap;
	if (!IsEnabled()) {
		flags |= BControlLook::B_DISABLED;
		bitmap = fDisabledBitmap;
	}
	if (_HasFlags(STATE_PRESSED) || _HasFlags(STATE_FORCE_PRESSED))
		flags |= BControlLook::B_ACTIVATED;

	if (ShouldDrawBorder()) {
		DrawBorder(r, updateRect, background, flags);
		DrawBackground(r, updateRect, background, flags);
	} else {
		SetHighColor(background);
		FillRect(r);
	}

	if (bitmap && bitmap->IsValid()) {
		if (bitmap->ColorSpace() == B_RGBA32
			|| bitmap->ColorSpace() == B_RGBA32_BIG) {
			SetDrawingMode(B_OP_ALPHA);
			SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
		}
		float x = r.left + floorf((r.Width()
			- bitmap->Bounds().Width()) / 2.0 + 0.5);
		float y = r.top + floorf((r.Height()
			- bitmap->Bounds().Height()) / 2.0 + 0.5);
		DrawBitmap(bitmap, BPoint(x, y));
	}
}
Esempio n. 24
0
        // Called by Rocket when it wants to render application-compiled geometry.
        void RenderInterface::RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry, const Rocket::Core::Vector2f& translation)
        {
            InternalGeometryHandle *Handle = (InternalGeometryHandle*)geometry;
            Mat4 tMatrix = glm::translate(Mat4(), Vec3(translation.x, translation.y, 0));

            glDisable(GL_DEPTH_TEST);
            glDepthMask(GL_FALSE);
            SetBlendingMode(BLEND_ALPHA);

            // bind texture
            if (Handle->tex)
                Handle->tex->Bind();
			else {
				Image::BindNull();
			}

            SetShaderParameters(false, false, false, false, false, Handle->tex == nullptr);
            WindowFrame.SetUniform(U_COLOR, 1, 1, 1, 1);
            WindowFrame.SetUniform(U_MVP, &(tMatrix[0][0]));

            // bind VBOs
            Handle->vert->Bind();
            glVertexAttribPointer(WindowFrame.EnableAttribArray(A_POSITION), 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, 0);

            Handle->uv->Bind();
            glVertexAttribPointer(WindowFrame.EnableAttribArray(A_UV), 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, 0);

            Handle->color->Bind();
            glVertexAttribPointer(WindowFrame.EnableAttribArray(A_COLOR), 4, GL_FLOAT, GL_FALSE, sizeof(float) * 4, 0);

            Handle->indices->Bind();
            glDrawElements(GL_TRIANGLES, Handle->num_indices, GL_UNSIGNED_INT, 0);

            FinalizeDraw();

            glEnable(GL_DEPTH_TEST);
            glDepthMask(GL_TRUE);
        }
Esempio n. 25
0
void ArpTwoStateButton::Draw(BRect clip)
{
	inherited::Draw(clip);
	drawing_mode	mode = DrawingMode();
	SetDrawingMode(B_OP_ALPHA);
	SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);

	bool	state = (mDrawFromSwitched) ? mSwitched : mPressed;
	if( state && mBmPressed ) {
		BRect	r( clip );
		BRect	b( mBmPressed->Bounds() );
		if( r.right > b.right ) r.right = b.right;
		if( r.bottom > b.bottom ) r.bottom = b.bottom;
		DrawBitmapAsync( mBmPressed, r, r );
	} else if( !state && mBmNormal ) {
		BRect	r( clip );
		BRect	b( mBmNormal->Bounds() );
		if( r.right > b.right ) r.right = b.right;
		if( r.bottom > b.bottom ) r.bottom = b.bottom;
		DrawBitmapAsync( mBmNormal, r, r );
	}
	if (Window()) Sync();
	SetDrawingMode(mode);
}
Esempio n. 26
0
void
CalcView::Draw(BRect updateRect)
{
	bool drawBackground = !_IsEmbedded();

	SetHighColor(fBaseColor);
	BRect expressionRect(_ExpressionRect());
	if (updateRect.Intersects(expressionRect)) {
		if (fOptions->keypad_mode == KEYPAD_MODE_COMPACT
			&& expressionRect.Height() >= fCalcIcon->Bounds().Height()) {
			// render calc icon
			expressionRect.left = fExpressionTextView->Frame().right + 2;
			if (drawBackground) {
				SetHighColor(fBaseColor);
				FillRect(updateRect & expressionRect);
			}

			if (fCalcIcon->ColorSpace() == B_RGBA32) {
				SetDrawingMode(B_OP_ALPHA);
				SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
			} else {
				SetDrawingMode(B_OP_OVER);
			}

			BPoint iconPos;
			iconPos.x = expressionRect.right - (expressionRect.Width()
				+ fCalcIcon->Bounds().Width()) / 2.0;
			iconPos.y = expressionRect.top + (expressionRect.Height()
				- fCalcIcon->Bounds().Height()) / 2.0;
			DrawBitmap(fCalcIcon, iconPos);

			SetDrawingMode(B_OP_COPY);
		}

		// render border around expression text view
		expressionRect = fExpressionTextView->Frame();
		expressionRect.InsetBy(-2, -2);
		if (fOptions->keypad_mode != KEYPAD_MODE_COMPACT && drawBackground) {
			expressionRect.InsetBy(-2, -2);
			StrokeRect(expressionRect);
			expressionRect.InsetBy(1, 1);
			StrokeRect(expressionRect);
			expressionRect.InsetBy(1, 1);
		}

		uint32 flags = 0;
		if (!drawBackground)
			flags |= BControlLook::B_BLEND_FRAME;
		be_control_look->DrawTextControlBorder(this, expressionRect,
			updateRect, fBaseColor, flags);
	}

	if (fOptions->keypad_mode == KEYPAD_MODE_COMPACT)
		return;

	// calculate grid sizes
	BRect keypadRect(_KeypadRect());

	if (be_control_look != NULL) {
		if (drawBackground)
			StrokeRect(keypadRect);
		keypadRect.InsetBy(1, 1);
	}

	float sizeDisp = keypadRect.top;
	float sizeCol = (keypadRect.Width() + 1) / (float)fColumns;
	float sizeRow = (keypadRect.Height() + 1) / (float)fRows;

	if (!updateRect.Intersects(keypadRect))
		return;

	SetFontSize(min_c(sizeRow * kFontScaleY, sizeCol * kFontScaleX));

	CalcKey* key = fKeypad;
	for (int row = 0; row < fRows; row++) {
		for (int col = 0; col < fColumns; col++) {
			BRect frame;
			frame.left = keypadRect.left + col * sizeCol;
			frame.right = keypadRect.left + (col + 1) * sizeCol - 1;
			frame.top = sizeDisp + row * sizeRow;
			frame.bottom = sizeDisp + (row + 1) * sizeRow - 1;

			if (drawBackground) {
				SetHighColor(fBaseColor);
				StrokeRect(frame);
			}
			frame.InsetBy(1, 1);

			uint32 flags = 0;
			if (!drawBackground)
				flags |= BControlLook::B_BLEND_FRAME;
			if (key->flags != 0)
				flags |= BControlLook::B_ACTIVATED;
			flags |= BControlLook::B_IGNORE_OUTLINE;

			be_control_look->DrawButtonFrame(this, frame, updateRect,
				fBaseColor, fBaseColor, flags);

			be_control_look->DrawButtonBackground(this, frame, updateRect,
				fBaseColor, flags);

			be_control_look->DrawLabel(this, key->label, frame, updateRect,
				fBaseColor, flags, BAlignment(B_ALIGN_HORIZONTAL_CENTER,
					B_ALIGN_VERTICAL_CENTER), &fButtonTextColor);

			key++;
		}
	}
}
Esempio n. 27
0
void
CalcView::Draw(BRect updateRect)
{
	bool drawBackground = true;
	if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) {
		// CalcView is embedded somewhere, most likely the Tracker Desktop
		// shelf.
		drawBackground = false;
	}

	SetHighColor(fBaseColor);
	BRect expressionRect(_ExpressionRect());
	if (updateRect.Intersects(expressionRect)) {
		if (fOptions->keypad_mode == KEYPAD_MODE_COMPACT
			&& expressionRect.Height() >= fCalcIcon->Bounds().Height()) {
			// render calc icon
			expressionRect.left = fExpressionTextView->Frame().right + 2;
			if (drawBackground) {
				SetHighColor(fBaseColor);
				FillRect(updateRect & expressionRect);
			}

			if (fCalcIcon->ColorSpace() == B_RGBA32) {
				SetDrawingMode(B_OP_ALPHA);
				SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
			} else {
				SetDrawingMode(B_OP_OVER);
			}

			BPoint iconPos;
			iconPos.x = expressionRect.right - (expressionRect.Width()
				+ fCalcIcon->Bounds().Width()) / 2.0;
			iconPos.y = expressionRect.top + (expressionRect.Height()
				- fCalcIcon->Bounds().Height()) / 2.0;
			DrawBitmap(fCalcIcon, iconPos);

			SetDrawingMode(B_OP_COPY);
		}

		// render border around expression text view
		expressionRect = fExpressionTextView->Frame();
		expressionRect.InsetBy(-2, -2);
		if (fOptions->keypad_mode != KEYPAD_MODE_COMPACT && drawBackground) {
			expressionRect.InsetBy(-2, -2);
			StrokeRect(expressionRect);
			expressionRect.InsetBy(1, 1);
			StrokeRect(expressionRect);
			expressionRect.InsetBy(1, 1);
		}

		if (be_control_look != NULL) {
			uint32 flags = 0;
			if (!drawBackground)
				flags |= BControlLook::B_BLEND_FRAME;
			be_control_look->DrawTextControlBorder(this, expressionRect,
				updateRect, fBaseColor, flags);
		} else {
			BeginLineArray(8);

			rgb_color lightShadow = tint_color(fBaseColor, B_DARKEN_1_TINT);
			rgb_color darkShadow = tint_color(fBaseColor, B_DARKEN_3_TINT);

			AddLine(BPoint(expressionRect.left, expressionRect.bottom),
					BPoint(expressionRect.left, expressionRect.top),
					lightShadow);
			AddLine(BPoint(expressionRect.left + 1, expressionRect.top),
					BPoint(expressionRect.right, expressionRect.top),
					lightShadow);
			AddLine(BPoint(expressionRect.right, expressionRect.top + 1),
					BPoint(expressionRect.right, expressionRect.bottom),
					fLightColor);
			AddLine(BPoint(expressionRect.left + 1, expressionRect.bottom),
					BPoint(expressionRect.right - 1, expressionRect.bottom),
					fLightColor);

			expressionRect.InsetBy(1, 1);
			AddLine(BPoint(expressionRect.left, expressionRect.bottom),
					BPoint(expressionRect.left, expressionRect.top),
					darkShadow);
			AddLine(BPoint(expressionRect.left + 1, expressionRect.top),
					BPoint(expressionRect.right, expressionRect.top),
					darkShadow);
			AddLine(BPoint(expressionRect.right, expressionRect.top + 1),
					BPoint(expressionRect.right, expressionRect.bottom),
					fBaseColor);
			AddLine(BPoint(expressionRect.left + 1, expressionRect.bottom),
					BPoint(expressionRect.right - 1, expressionRect.bottom),
					fBaseColor);

			EndLineArray();
		}
	}

	if (fOptions->keypad_mode == KEYPAD_MODE_COMPACT)
		return;

	// calculate grid sizes
	BRect keypadRect(_KeypadRect());

	if (be_control_look != NULL) {
		if (drawBackground)
			StrokeRect(keypadRect);
		keypadRect.InsetBy(1, 1);
	}

	float sizeDisp = keypadRect.top;
	float sizeCol = (keypadRect.Width() + 1) / (float)fColumns;
	float sizeRow = (keypadRect.Height() + 1) / (float)fRows;

	if (!updateRect.Intersects(keypadRect))
		return;

	SetFontSize(min_c(sizeRow * kFontScaleY, sizeCol * kFontScaleX));

	if (be_control_look != NULL) {
		CalcKey* key = fKeypad;
		for (int row = 0; row < fRows; row++) {
			for (int col = 0; col < fColumns; col++) {
				BRect frame;
				frame.left = keypadRect.left + col * sizeCol;
				frame.right = keypadRect.left + (col + 1) * sizeCol - 1;
				frame.top = sizeDisp + row * sizeRow;
				frame.bottom = sizeDisp + (row + 1) * sizeRow - 1;

				if (drawBackground) {
					SetHighColor(fBaseColor);
					StrokeRect(frame);
				}
				frame.InsetBy(1, 1);

				uint32 flags = 0;
				if (!drawBackground)
					flags |= BControlLook::B_BLEND_FRAME;
				if (key->flags != 0)
					flags |= BControlLook::B_ACTIVATED;
				flags |= BControlLook::B_IGNORE_OUTLINE;

				be_control_look->DrawButtonFrame(this, frame, updateRect,
					fBaseColor, fBaseColor, flags);

				be_control_look->DrawButtonBackground(this, frame, updateRect,
					fBaseColor, flags);

				be_control_look->DrawLabel(this, key->label, frame, updateRect,
					fBaseColor, flags, BAlignment(B_ALIGN_HORIZONTAL_CENTER,
						B_ALIGN_VERTICAL_CENTER));

				key++;
			}
		}
		return;
	}

	// TODO: support pressed keys

	// paint keypad b/g
	SetHighColor(fBaseColor);
	FillRect(updateRect & keypadRect);

	// render key main grid
	BeginLineArray(((fColumns + fRows) << 1) + 1);

	// render cols
	AddLine(BPoint(0.0, sizeDisp),
			BPoint(0.0, fHeight),
			fLightColor);
	for (int col = 1; col < fColumns; col++) {
		AddLine(BPoint(col * sizeCol - 1.0, sizeDisp),
				BPoint(col * sizeCol - 1.0, fHeight),
				fDarkColor);
		AddLine(BPoint(col * sizeCol, sizeDisp),
				BPoint(col * sizeCol, fHeight),
				fLightColor);
	}
	AddLine(BPoint(fColumns * sizeCol, sizeDisp),
			BPoint(fColumns * sizeCol, fHeight),
			fDarkColor);

	// render rows
	for (int row = 0; row < fRows; row++) {
		AddLine(BPoint(0.0, sizeDisp + row * sizeRow - 1.0),
				BPoint(fWidth, sizeDisp + row * sizeRow - 1.0),
				fDarkColor);
		AddLine(BPoint(0.0, sizeDisp + row * sizeRow),
				BPoint(fWidth, sizeDisp + row * sizeRow),
				fLightColor);
	}
	AddLine(BPoint(0.0, sizeDisp + fRows * sizeRow),
			BPoint(fWidth, sizeDisp + fRows * sizeRow),
			fDarkColor);

	// main grid complete
	EndLineArray();

	// render key symbols
	float halfSizeCol = sizeCol * 0.5f;
	SetHighColor(fButtonTextColor);
	SetLowColor(fBaseColor);
	SetDrawingMode(B_OP_COPY);

	float baselineOffset = ((fHeight - sizeDisp) / (float)fRows)
							* (1.0 - kFontScaleY) * 0.5;
	CalcKey* key = fKeypad;
	for (int row = 0; row < fRows; row++) {
		for (int col = 0; col < fColumns; col++) {
			float halfSymbolWidth = StringWidth(key->label) * 0.5f;
			DrawString(key->label,
				BPoint(col * sizeCol + halfSizeCol - halfSymbolWidth,
				sizeDisp + (row + 1) * sizeRow - baselineOffset));
			key++;
		}
	}
}
Esempio n. 28
0
void
NotificationView::Draw(BRect updateRect)
{
	BRect progRect;

	SetDrawingMode(B_OP_ALPHA);
	SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);

	// Icon size
	float iconSize = (float)fParent->IconSize();

	BRect stripeRect = Bounds();
	stripeRect.right = kIconStripeWidth;
	SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
		B_DARKEN_1_TINT));
	FillRect(stripeRect);

	SetHighColor(fStripeColor);
	stripeRect.right = 2;
	FillRect(stripeRect);

	SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
	// Rectangle for icon and overlay icon
	BRect iconRect(0, 0, 0, 0);

	// Draw icon
	if (fBitmap) {
		float ix = 18;
		float iy = (Bounds().Height() - iconSize) / 4.0;
			// Icon is vertically centered in view

		if (fNotification->Type() == B_PROGRESS_NOTIFICATION)
		{
			// Move icon up by half progress bar height if it's present
			iy -= (progRect.Height() + kEdgePadding);
		}

		iconRect.Set(ix, iy, ix + iconSize - 1.0, iy + iconSize - 1.0);
		DrawBitmapAsync(fBitmap, fBitmap->Bounds(), iconRect);
	}

	// Draw content
	LineInfoList::iterator lIt;
	for (lIt = fLines.begin(); lIt != fLines.end(); lIt++) {
		LineInfo *l = (*lIt);

		SetFont(&l->font);
		// Truncate the string. We have already line-wrapped the text but if
		// there is a very long 'word' we can only truncate it.
		TruncateString(&(l->text), B_TRUNCATE_END,
			Bounds().Width() - l->location.x);
		DrawString(l->text.String(), l->text.Length(), l->location);
	}

	rgb_color detailCol = ui_color(B_CONTROL_BORDER_COLOR);
	detailCol = tint_color(detailCol, B_LIGHTEN_2_TINT);

	AppGroupView* groupView = dynamic_cast<AppGroupView*>(Parent());
	if (groupView != NULL && groupView->ChildrenCount() > 1)
		_DrawCloseButton(updateRect);

	SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
	BPoint left(Bounds().left, Bounds().top);
	BPoint right(Bounds().right, Bounds().top);
	StrokeLine(left, right);

	Sync();
}
Esempio n. 29
0
void TruetypeFont::Render(const std::string &In, const Vec2 &Position, const Mat4 &Transform)
{
    const char* Text = In.c_str();
    int Line = 0;
    glm::vec3 vOffs(Position.x, Position.y + scale, 0);

    if (!IsValid)
        return;

    UpdateWindowScale();

    SetBlendingMode(BLEND_ALPHA);

    SetShaderParameters(false, false, false, false, false, true);
    WindowFrame.SetUniform(U_COLOR, Red, Green, Blue, Alpha);
    SetPrimitiveQuadVBO();

    try
    {
        utf8::iterator<const char*> it(Text, Text, Text + In.length());
        utf8::iterator<const char*> itend(Text + In.length(), Text, Text + In.length());
        for (; it != itend; ++it)
        {
            CheckCodepoint(*it); // Force a regeneration of this if necessary
            codepdata &cp = GetTexFromCodepoint(*it);
            unsigned char* tx = cp.tex;
            glm::vec3 trans = vOffs + glm::vec3(cp.xofs, cp.yofs, 0);
            glm::mat4 dx;

            if (*it == 10) // utf-32 line feed
            {
                Line++;
                vOffs.x = Position.x;
                vOffs.y = Position.y + scale * (Line + 1);
                continue;
            }

            dx = Transform * glm::translate(Mat4(), trans) * glm::scale(Mat4(), glm::vec3(cp.w, cp.h, 1));

            // do the actual draw?
            if (cp.gltx == 0)
            {
                glGenTextures(1, &cp.gltx);
                glBindTexture(GL_TEXTURE_2D, cp.gltx);

                glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);

                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

                glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, cp.tw, cp.th, 0, GL_ALPHA, GL_UNSIGNED_BYTE, tx);
            }
            else
                glBindTexture(GL_TEXTURE_2D, cp.gltx);

            WindowFrame.SetUniform(U_MVP, &(dx[0][0]));

            DoQuadDraw();

            utf8::iterator<const char*> next = it;
            next++;
            if (next != itend)
            {
                float aW = stbtt_GetCodepointKernAdvance(info.get(), *it, *next);
                int bW;
                stbtt_GetCodepointHMetrics(info.get(), *it, &bW, NULL);
                vOffs.x += aW * virtualscale + bW * virtualscale;
            }
        }
    }
#ifndef NDEBUG
    catch (utf8::exception &ex)
    {
        Utility::DebugBreak();
        Log::Logf("Invalid UTF-8 string %s was passed. Error type: %s\n", ex.what());
    }
#else
    catch (...)
    {
        // nothing
    }
#endif

    FinalizeDraw();
    Image::ForceRebind();
}
Esempio n. 30
0
void
NotificationView::Draw(BRect updateRect)
{
	BRect progRect;

	// Draw progress background
	if (fType == B_PROGRESS_NOTIFICATION) {
		PushState();

		font_height fh;
		be_plain_font->GetHeight(&fh);
		float fontHeight = fh.ascent + fh.descent + fh.leading;

		progRect = Bounds();
		progRect.InsetBy(kEdgePadding, kEdgePadding);
		progRect.top = progRect.bottom - (kSmallPadding * 2) - fontHeight;
		StrokeRect(progRect);

		BRect barRect = progRect;		
		barRect.InsetBy(1.0, 1.0);
		barRect.right *= fProgress;
		SetHighColor(ui_color(B_CONTROL_HIGHLIGHT_COLOR));
		FillRect(barRect);

		SetHighColor(ui_color(B_PANEL_TEXT_COLOR));

		BString label = "";
		label << (int)(fProgress * 100) << " %";

		float labelWidth = be_plain_font->StringWidth(label.String());
		float labelX = progRect.left + (progRect.IntegerWidth() / 2) - (labelWidth / 2);

		SetLowColor(B_TRANSPARENT_COLOR);
		SetDrawingMode(B_OP_ALPHA);
		DrawString(label.String(), label.Length(),
			BPoint(labelX, progRect.top + fh.ascent + fh.leading + kSmallPadding));

		PopState();
	}

	SetDrawingMode(B_OP_ALPHA);
	SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);

	// Icon size
	float iconSize = (float)fParent->IconSize();

	// Rectangle for icon and overlay icon
	BRect iconRect(0, 0, 0, 0);

	// Draw icon
	if (fBitmap) {
		LineInfo* appLine = fLines.back();
		font_height fh;
		appLine->font.GetHeight(&fh);

		float title_bottom = appLine->location.y + fh.descent;

		float ix = kEdgePadding;
		float iy = 0;
		if (fParent->Layout() == TitleAboveIcon)
			iy = title_bottom + kEdgePadding + (Bounds().Height() - title_bottom
				- kEdgePadding * 2 - iconSize) / 2;
		else
			iy = (Bounds().Height() - iconSize) / 2.0;

		if (fType == B_PROGRESS_NOTIFICATION)
			// Move icon up by half progress bar height if it's present
			iy -= (progRect.Height() + kEdgePadding) / 2.0;

		iconRect.left = ix;
		iconRect.top = iy;
		iconRect.right = ix + iconSize;
		iconRect.bottom = iy + iconSize;

		DrawBitmapAsync(fBitmap, fBitmap->Bounds(),
			iconRect, B_FILTER_BITMAP_BILINEAR);
	}

	// Draw content
	LineInfoList::iterator lIt;
	for (lIt = fLines.begin(); lIt != fLines.end(); lIt++) {
		LineInfo *l = (*lIt);
	
		SetFont(&l->font);
		DrawString(l->text.String(), l->text.Length(), l->location);
	}

	rgb_color detailCol = ui_color(B_CONTROL_BORDER_COLOR);
	detailCol = tint_color(detailCol, B_LIGHTEN_2_TINT);

	// Draw the close widget
	BRect closeRect = Bounds();
	closeRect.InsetBy(kEdgePadding, kEdgePadding);
	closeRect.left = closeRect.right - kCloseSize;
	closeRect.bottom = closeRect.top + kCloseSize;

	PushState();
		SetHighColor(detailCol);
		StrokeRoundRect(closeRect, kSmallPadding, kSmallPadding);
		BRect closeCross = closeRect.InsetByCopy(kSmallPadding, kSmallPadding);
		StrokeLine(closeCross.LeftTop(), closeCross.RightBottom());
		StrokeLine(closeCross.LeftBottom(), closeCross.RightTop());
	PopState();

	Sync();
}