本文整理汇总了C++中Graphics类的典型用法代码示例。如果您正苦于以下问题:C++ Graphics类的具体用法?C++ Graphics怎么用?C++ Graphics使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Graphics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
// Some parameters for testing
int test_w = 800;
int test_h = 600;
int test_phys_w = 400;
int test_phys_h = 300;
Graphics *gr = Graphics::Create(test_w, test_h);
assert(gr);
// Initialization of interface between graphics and physics (GPInterface)
gr->InitGPInterface(test_w, test_h, test_phys_w, test_phys_h);
gr->AddSprite(32, 17, "./gfx/car1.png");
gr->AddSprite(32, 17, "./gfx/car2.png");
// Variable coordinates of car
float cX = 20, cY = 15;
float ang = 0;
gr->SetSpriteCoordinates(0, cX, cY, ang);
gr->SetSpriteCoordinates(1, cX+50, cY, ang);
//
Event new_event;
// printf("%d %d\n", gpi.gr_coordinate_x(cX), gpi.gr_coordinate_y(cY));
while(new_event.running()) {
new_event.CheckEvents();
if(new_event.fullscreen()) {
gr->FullscreenOn();
} else {
gr->FullscreenOff();
}
gr->Render();
cX += 0.1;
cY += 0.1;
ang += 0.01;
gr->SetSpriteCoordinates(0, cX, cY, ang);
gr->SetSpriteCoordinates(1, cX+50, cY, ang);
SDL_Delay(5);
}
gr->CleanUp();
delete gr;
return 0;
}
示例2: paint
void ResourceEditorPanel::paint (Graphics& g)
{
g.fillAll (findColour (secondaryBackgroundColourId));
}
示例3: paintContents
void PoleZeroChart::paintContents (Graphics& g)
{
Colour cPole (0xd0ff0000);
Colour cZero (0xd02020ff);
Rectangle<int> bounds = getLocalBounds();
short size = short ((jmin (getWidth(), getHeight()) + 2) / 3);
// scale the graph down if the pole/zeroes lie outside the unit disc
AffineTransform t = AffineTransform::identity;
{
float margin = 0.2f;
if (m_max > 1 + margin)
{
t = t.scaled (float(1/(m_max-margin)), float(1/(m_max-margin)));
}
}
t = t.scaled (float(size), -float(size));
t = t.translated (float(bounds.getCentreX()), float(bounds.getCentreY()));
g.setColour (m_cAxis);
{
Point<float> p = Point<float>(100000, 0).transformedBy (t);
g.drawLine (-p.getX(), p.getY(), p.getX(), p.getY(), 1);
}
{
Point<float> p = Point<float>(0, 100000).transformedBy (t);
g.drawLine (p.getX(), -p.getY(), p.getX(), p.getY(), 1);
}
{
Point<float> p0 = Point<float>(-1, -1).transformedBy (t);
Point<float> p1 = Point<float>( 1, 1).transformedBy (t);
g.drawEllipse (p0.getX(), p0.getY(),
p1.getX()-p0.getX(), p1.getY()-p0.getY(), 1);
}
const float r = 3.5f;
for (size_t i = 0; i < m_vpz.size(); ++i)
{
const Dsp::PoleZeroPair& pzp = m_vpz[i];
if (!pzp.is_nan())
{
{
Point<float> p (float(pzp.poles.first.real()),
float(pzp.poles.first.imag()));
p = p.transformedBy (t);
g.setColour (cPole);
g.drawLine (p.getX()-r, p.getY()-r, p.getX()+r, p.getY()+r);
g.drawLine (p.getX()+r, p.getY()-r, p.getX()-r, p.getY()+r);
}
{
Point<float> p (float(pzp.zeros.first.real()),
float(pzp.zeros.first.imag()));
p = p.transformedBy (t);
g.setColour (cZero);
g.drawEllipse (p.getX()-r, p.getY()-r, 2*r, 2*r, 1);
}
if (!pzp.isSinglePole())
{
{
Point<float> p (float(pzp.poles.second.real()),
float(pzp.poles.second.imag()));
p = p.transformedBy (t);
g.setColour (cPole);
g.drawLine (p.getX()-r, p.getY()-r, p.getX()+r, p.getY()+r);
g.drawLine (p.getX()+r, p.getY()-r, p.getX()-r, p.getY()+r);
}
{
Point<float> p (float(pzp.zeros.second.real()),
float(pzp.zeros.second.imag()));
p = p.transformedBy (t);
g.setColour (cZero);
g.drawEllipse (p.getX()-r, p.getY()-r, 2*r, 2*r, 1);
}
}
}
}
}
示例4: Scene
void Urho2DPhysicsRope::CreateScene()
{
scene_ = new Scene(context_);
scene_->CreateComponent<Octree>();
scene_->CreateComponent<DebugRenderer>();
// Create camera node
cameraNode_ = scene_->CreateChild("Camera");
// Set camera's position
cameraNode_->SetPosition(Vector3(0.0f, 5.0f, -10.0f));
Camera* camera = cameraNode_->CreateComponent<Camera>();
camera->SetOrthographic(true);
Graphics* graphics = GetSubsystem<Graphics>();
float width = (float)graphics->GetWidth();
float height = (float)graphics->GetHeight();
camera->SetOrthoSize(Vector2(width, height) * 0.05f);
// Create 2D physics world component
PhysicsWorld2D* physicsWorld = scene_->CreateComponent<PhysicsWorld2D>();
physicsWorld->SetDrawJoint(true);
// Create ground
Node* groundNode = scene_->CreateChild("Ground");
// Create 2D rigid body for gound
RigidBody2D* groundBody = groundNode->CreateComponent<RigidBody2D>();
// Create edge collider for ground
CollisionEdge2D* groundShape = groundNode->CreateComponent<CollisionEdge2D>();
groundShape->SetVertices(Vector2(-40.0f, 0.0f), Vector2(40.0f, 0.0f));
const float y = 15.0f;
RigidBody2D* prevBody = groundBody;
for (unsigned i = 0; i < NUM_OBJECTS; ++i)
{
Node* node = scene_->CreateChild("RigidBody");
// Create rigid body
RigidBody2D* body = node->CreateComponent<RigidBody2D>();
body->SetBodyType(BT_DYNAMIC);
// Create box
CollisionBox2D* box = node->CreateComponent<CollisionBox2D>();
// Set friction
box->SetFriction(0.2f);
// Set mask bits.
box->SetMaskBits(0xFFFF & ~0x0002);
if (i == NUM_OBJECTS - 1)
{
node->SetPosition(Vector3(1.0f * i, y, 0.0f));
body->SetAngularDamping(0.4f);
box->SetSize(3.0f, 3.0f);
box->SetDensity(100.0f);
box->SetCategoryBits(0x0002);
}
else
{
node->SetPosition(Vector3(0.5f + 1.0f * i, y, 0.0f));
box->SetSize(1.0f, 0.25f);
box->SetDensity(20.0f);
box->SetCategoryBits(0x0001);
}
ConstraintRevolute2D* joint = node->CreateComponent<ConstraintRevolute2D>();
joint->SetOtherBody(prevBody);
joint->SetAnchor(Vector2(float(i), y));
joint->SetCollideConnected(false);
prevBody = body;
}
ConstraintRope2D* constraintRope = groundNode->CreateComponent<ConstraintRope2D>();
constraintRope->SetOtherBody(prevBody);
constraintRope->SetOwnerBodyAnchor(Vector2(0.0f, y));
constraintRope->SetMaxLength(NUM_OBJECTS - 1.0f + 0.01f);
}
示例5: Prepare
void Batch::Prepare(View* view, Camera* camera, bool setModelTransform, bool allowDepthWrite) const
{
if (!vertexShader_ || !pixelShader_)
return;
Graphics* graphics = view->GetGraphics();
Renderer* renderer = view->GetRenderer();
Node* cameraNode = camera ? camera->GetNode() : 0;
Light* light = lightQueue_ ? lightQueue_->light_ : 0;
Texture2D* shadowMap = lightQueue_ ? lightQueue_->shadowMap_ : 0;
// Set shaders first. The available shader parameters and their register/uniform positions depend on the currently set shaders
graphics->SetShaders(vertexShader_, pixelShader_);
// Set pass / material-specific renderstates
if (pass_ && material_)
{
BlendMode blend = pass_->GetBlendMode();
// Turn additive blending into subtract if the light is negative
if (light && light->IsNegative())
{
if (blend == BLEND_ADD)
blend = BLEND_SUBTRACT;
else if (blend == BLEND_ADDALPHA)
blend = BLEND_SUBTRACTALPHA;
}
graphics->SetBlendMode(blend);
bool isShadowPass = pass_->GetIndex() == Technique::shadowPassIndex;
CullMode effectiveCullMode = pass_->GetCullMode();
// Get cull mode from material if pass doesn't override it
if (effectiveCullMode == MAX_CULLMODES)
effectiveCullMode = isShadowPass ? material_->GetShadowCullMode() : material_->GetCullMode();
renderer->SetCullMode(effectiveCullMode, camera);
if (!isShadowPass)
{
const BiasParameters& depthBias = material_->GetDepthBias();
graphics->SetDepthBias(depthBias.constantBias_, depthBias.slopeScaledBias_);
}
// Use the "least filled" fill mode combined from camera & material
graphics->SetFillMode((FillMode)(Max(camera->GetFillMode(), material_->GetFillMode())));
graphics->SetDepthTest(pass_->GetDepthTestMode());
graphics->SetDepthWrite(pass_->GetDepthWrite() && allowDepthWrite);
}
// Set global (per-frame) shader parameters
if (graphics->NeedParameterUpdate(SP_FRAME, (void*)0))
view->SetGlobalShaderParameters();
// Set camera & viewport shader parameters
unsigned cameraHash = (unsigned)(size_t)camera;
IntRect viewport = graphics->GetViewport();
IntVector2 viewSize = IntVector2(viewport.Width(), viewport.Height());
unsigned viewportHash = (unsigned)(viewSize.x_ | (viewSize.y_ << 16));
if (graphics->NeedParameterUpdate(SP_CAMERA, reinterpret_cast<const void*>(cameraHash + viewportHash)))
{
view->SetCameraShaderParameters(camera);
// During renderpath commands the G-Buffer or viewport texture is assumed to always be viewport-sized
view->SetGBufferShaderParameters(viewSize, IntRect(0, 0, viewSize.x_, viewSize.y_));
}
// Set model or skinning transforms
if (setModelTransform && graphics->NeedParameterUpdate(SP_OBJECT, worldTransform_))
{
if (geometryType_ == GEOM_SKINNED)
{
graphics->SetShaderParameter(VSP_SKINMATRICES, reinterpret_cast<const float*>(worldTransform_),
12 * numWorldTransforms_);
}
else
graphics->SetShaderParameter(VSP_MODEL, *worldTransform_);
// Set the orientation for billboards, either from the object itself or from the camera
if (geometryType_ == GEOM_BILLBOARD)
{
if (numWorldTransforms_ > 1)
graphics->SetShaderParameter(VSP_BILLBOARDROT, worldTransform_[1].RotationMatrix());
else
graphics->SetShaderParameter(VSP_BILLBOARDROT, cameraNode->GetWorldRotation().RotationMatrix());
}
}
// Set zone-related shader parameters
BlendMode blend = graphics->GetBlendMode();
// If the pass is additive, override fog color to black so that shaders do not need a separate additive path
bool overrideFogColorToBlack = blend == BLEND_ADD || blend == BLEND_ADDALPHA;
unsigned zoneHash = (unsigned)(size_t)zone_;
if (overrideFogColorToBlack)
zoneHash += 0x80000000;
if (zone_ && graphics->NeedParameterUpdate(SP_ZONE, reinterpret_cast<const void*>(zoneHash)))
{
graphics->SetShaderParameter(VSP_AMBIENTSTARTCOLOR, zone_->GetAmbientStartColor());
graphics->SetShaderParameter(VSP_AMBIENTENDCOLOR,
zone_->GetAmbientEndColor().ToVector4() - zone_->GetAmbientStartColor().ToVector4());
const BoundingBox& box = zone_->GetBoundingBox();
Vector3 boxSize = box.Size();
Matrix3x4 adjust(Matrix3x4::IDENTITY);
//.........这里部分代码省略.........
示例6: paint
//==========================================================================
// Set and Creates Images and UI
void APlay::paint(Graphics& g)
{
g.setFillType(Colours::darkslategrey);
g.fillAll();
}
示例7: HandleUpdate
void VehicleDemo::HandleUpdate(StringHash eventType, VariantMap& eventData)
{
using namespace Update;
float timeStep = eventData[P_TIMESTEP].GetFloat();
Input* input = GetSubsystem<Input>();
if (vehicle_)
{
UI* ui = GetSubsystem<UI>();
// Get movement controls and assign them to the vehicle component. If UI has a focused element, clear controls
if (!ui->GetFocusElement())
{
vehicle_->controls_.Set(CTRL_FORWARD, input->GetKeyDown('W'));
vehicle_->controls_.Set(CTRL_BACK, input->GetKeyDown('S'));
vehicle_->controls_.Set(CTRL_LEFT, input->GetKeyDown('A'));
vehicle_->controls_.Set(CTRL_RIGHT, input->GetKeyDown('D'));
// Add yaw & pitch from the mouse motion or touch input. Used only for the camera, does not affect motion
if (touchEnabled_)
{
for (unsigned i = 0; i < input->GetNumTouches(); ++i)
{
TouchState* state = input->GetTouch(i);
if (!state->touchedElement_) // Touch on empty space
{
Camera* camera = cameraNode_->GetComponent<Camera>();
if (!camera)
return;
Graphics* graphics = GetSubsystem<Graphics>();
vehicle_->controls_.yaw_ += TOUCH_SENSITIVITY * camera->GetFov() / graphics->GetHeight() * state->delta_.x_;
vehicle_->controls_.pitch_ += TOUCH_SENSITIVITY * camera->GetFov() / graphics->GetHeight() * state->delta_.y_;
}
}
}
else
{
vehicle_->controls_.yaw_ += (float)input->GetMouseMoveX() * YAW_SENSITIVITY;
vehicle_->controls_.pitch_ += (float)input->GetMouseMoveY() * YAW_SENSITIVITY;
}
// Limit pitch
vehicle_->controls_.pitch_ = Clamp(vehicle_->controls_.pitch_, 0.0f, 80.0f);
// Check for loading / saving the scene
if (input->GetKeyPress(KEY_F5))
{
File saveFile(context_, GetSubsystem<FileSystem>()->GetProgramDir() + "Data/Scenes/VehicleDemo.xml",
FILE_WRITE);
scene_->SaveXML(saveFile);
}
if (input->GetKeyPress(KEY_F7))
{
File loadFile(context_, GetSubsystem<FileSystem>()->GetProgramDir() + "Data/Scenes/VehicleDemo.xml", FILE_READ);
scene_->LoadXML(loadFile);
// After loading we have to reacquire the weak pointer to the Vehicle component, as it has been recreated
// Simply find the vehicle's scene node by name as there's only one of them
Node* vehicleNode = scene_->GetChild("Vehicle", true);
if (vehicleNode)
vehicle_ = vehicleNode->GetComponent<Vehicle>();
}
}
else
vehicle_->controls_.Set(CTRL_FORWARD | CTRL_BACK | CTRL_LEFT | CTRL_RIGHT, false);
}
}
示例8: GetGraphics
void ColourPickerActivity::OnDraw()
{
Graphics * g = GetGraphics();
//g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->fillrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3, 0, 0, 0, currentAlpha);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);
g->drawrect(Position.X+4, Position.Y+4, 258, 130, 180, 180, 180, 255);
g->drawrect(Position.X+4, Position.Y+4+4+128, 258, 12, 180, 180, 180, 255);
int offsetX = Position.X+5;
int offsetY = Position.Y+5;
//draw color square
int lastx = -1, currx = 0;
for(int saturation = 0; saturation <= 255; saturation+=2)
{
for(int hue = 0; hue <= 359; hue++)
{
currx = clamp_flt(hue, 0, 359)+offsetX;
if (currx == lastx)
continue;
lastx = currx;
int cr = 0;
int cg = 0;
int cb = 0;
HSV_to_RGB(hue, 255-saturation, currentValue, &cr, &cg, &cb);
g->blendpixel(currx, (saturation/2)+offsetY, cr, cg, cb, currentAlpha);
}
}
//draw brightness bar
for(int value = 0; value <= 255; value++)
for(int i = 0; i < 10; i++)
{
int cr = 0;
int cg = 0;
int cb = 0;
HSV_to_RGB(currentHue, currentSaturation, value, &cr, &cg, &cb);
g->blendpixel(value+offsetX, i+offsetY+127+5, cr, cg, cb, currentAlpha);
}
//draw color square pointer
int currentHueX = clamp_flt(currentHue, 0, 359);
int currentSaturationY = ((255-currentSaturation)/2);
g->xor_line(offsetX+currentHueX, offsetY+currentSaturationY-5, offsetX+currentHueX, offsetY+currentSaturationY-1);
g->xor_line(offsetX+currentHueX, offsetY+currentSaturationY+1, offsetX+currentHueX, offsetY+currentSaturationY+5);
g->xor_line(offsetX+currentHueX-5, offsetY+currentSaturationY, offsetX+currentHueX-1, offsetY+currentSaturationY);
g->xor_line(offsetX+currentHueX+1, offsetY+currentSaturationY, offsetX+currentHueX+5, offsetY+currentSaturationY);
//draw brightness bar pointer
int currentValueX = restrict_flt(currentValue, 0, 254);
g->xor_line(offsetX+currentValueX, offsetY+4+128, offsetX+currentValueX, offsetY+13+128);
g->xor_line(offsetX+currentValueX+1, offsetY+4+128, offsetX+currentValueX+1, offsetY+13+128);
}
示例9: paint
void SpikeDisplayCanvas::paint(Graphics& g)
{
g.fillAll(Colours::darkgrey);
}
示例10: paint
void MainContentComponent::paint (Graphics& g) {
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (Colours::lightgrey);
// You can add your drawing code here!
}
示例11: MyPaint_Mem
void MyPaint_Mem(HDC my_hdc)
{
Graphics *mygraphics;
mygraphics = new Graphics(my_hdc);
mygraphics->SetSmoothingMode(SmoothingModeAntiAlias);
Pen *myRectangle_pen;
Pen * my_inline_pen;
Pen * CurePen;
SolidBrush *BlackBrush;
myRectangle_pen = new Pen(Color(255,0,255,255));
my_inline_pen = new Pen(Color(255,220,220,220));
REAL dashValues[2] = {5, 5};
//Pen blackPen(Color(255, 0, 0, 0), 5);
my_inline_pen->SetDashPattern(dashValues, 2);
CurePen = new Pen(Graphic_Color[1],3.0f);
PointF pointF(0, 0);
BlackBrush =new SolidBrush(Color(255,0,0,0));
mygraphics->FillRectangle(BlackBrush,X_ORIGIN,Y_ORIGIN,X_WIDTH,Y_HIGHT);
mygraphics->DrawRectangle(myRectangle_pen,X_ORIGIN,Y_ORIGIN,X_WIDTH,Y_HIGHT);
SolidBrush *Static_blackground_Brush;
Pen *mystaticRectangle_pen;
mystaticRectangle_pen = new Pen(Color(255,0,0,0),2.0f);
Static_blackground_Brush =new SolidBrush(Color(255,187,187,187));
mygraphics->FillRectangle(Static_blackground_Brush,0,window_hight - 120,window_width,120);
mygraphics->DrawRectangle(mystaticRectangle_pen,2,window_hight - 110,window_width-15,110 -30);
SolidBrush time_brush(Color(255, 225, 225, 225));
FontFamily fontFamily(_T("Times New Roman"));
Gdiplus::Font time_font(&fontFamily, 18, FontStyleRegular, UnitPixel);
for(int i=0;i<x_line_scale;i++) //画网格线
{
mygraphics->DrawLine(my_inline_pen,X_ORIGIN+(X_WIDTH/x_line_scale)*(i+1),Y_ORIGIN,X_ORIGIN+(X_WIDTH/x_line_scale)*(i+1),Y_ORIGIN + Y_HIGHT);
CString strTime ;
wchar_t temp_char[200];
//time_t test = old_early_time;
//CTime timeTest(test);
time_t test ;
CTime timeTest;
switch(scale_type)
{
case _6_min:
break;
case _1_hour:
test = old_early_time + i*600;
timeTest = test ;
strTime = timeTest.Format("%Y/%m/%d\r\n %H:%M:%S");
pointF.X = X_ORIGIN - 40 + i*(X_WIDTH/x_line_scale);
pointF.Y = Y_ORIGIN+Y_HIGHT + 10;
mygraphics->DrawString(strTime, -1, &time_font, pointF, &time_brush);
//old_early_time
break;
case _4_hour:
break;
case _12_hour:
break;
case _1_day:
break;
}
}
SolidBrush unit_brush(Graphic_Color[1]);
FontFamily UnitfontFamily(_T("Times New Roman"));
Gdiplus::Font unitfont(&UnitfontFamily, 18, FontStyleRegular, UnitPixel);
for(int i=0;i<=y_line_scale;i++) //画网格线
{
CString Unit_value;
if(i!=y_line_scale)
mygraphics->DrawLine(my_inline_pen,X_ORIGIN,Y_ORIGIN+(Y_HIGHT/y_line_scale)*(1+i),X_WIDTH + X_ORIGIN,Y_ORIGIN+(Y_HIGHT/y_line_scale)*(1+i));
if(i!=y_line_scale)
Unit_value.Format(_T("%d"),(Total_SCALE/y_line_scale)*(y_line_scale-i));// = timeTest.Format("%Y/%m/%d\r\n %H:%M:%S");
else
Unit_value.Format(_T("%d"),Min_Scale_value);
pointF.X = X_ORIGIN - 30;
pointF.Y = Y_ORIGIN+ i*(Y_HIGHT/y_line_scale);
mygraphics->DrawString(Unit_value, -1, &unitfont, pointF, &unit_brush);
//swprintf_s(temp_char,200,L"%d",i*5);
//mygraphics->DrawString(temp_char, -1, &font, pointF, &brush);
}
for (int i=1;i<=14;i++)
{
CString temp_item;
temp_item.Format(_T("%x"),i);
temp_item = temp_item.MakeUpper();
SolidBrush static_item_brush(Graphic_Color[i]);
FontFamily UnitfontFamily(_T("Arial Black"));
//.........这里部分代码省略.........
示例12: paint
void HomeMenu::paint (Graphics& g)
{
g.fillAll (Colour::fromRGB(49, 49, 49));
}
示例13: paint
//==============================================================================
void Statusbar::paint (Graphics& g)
{
//[UserPrePaint] Add your own custom painting code here..
//[/UserPrePaint]
g.setColour (Colour (0xff181818));
g.fillRoundedRectangle (0.0f, 0.0f, static_cast<float> (getWidth() - 0), static_cast<float> (getHeight() - 0), 10.000f);
g.setColour (Colours::white);
g.drawRoundedRectangle (0.0f, 0.0f, static_cast<float> (getWidth() - 0), static_cast<float> (getHeight() - 0), 10.000f, 1.000f);
g.setColour (Colours::black);
g.fillRoundedRectangle (168.0f, 4.0f, static_cast<float> (getWidth() - 336), 16.0f, 10.000f);
g.setColour (Colours::white);
g.drawRoundedRectangle (168.0f, 4.0f, static_cast<float> (getWidth() - 336), 16.0f, 10.000f, 1.000f);
g.setColour (Colours::black);
g.fillRoundedRectangle (static_cast<float> (getWidth() - 4 - 160), 4.0f, 160.0f, 16.0f, 10.000f);
g.setColour (Colours::white);
g.drawRoundedRectangle (static_cast<float> (getWidth() - 4 - 160), 4.0f, 160.0f, 16.0f, 10.000f, 1.000f);
g.setColour (Colours::black);
g.fillRoundedRectangle (4.0f, 4.0f, 160.0f, 16.0f, 10.000f);
g.setColour (Colours::white);
g.drawRoundedRectangle (4.0f, 4.0f, 160.0f, 16.0f, 10.000f, 1.000f);
//[UserPaint] Add your own custom painting code here..
//[/UserPaint]
}
示例14: paint
void SurfaceComponent::paint (Graphics& g)
{
Colour backgroundColour = Config::getInstance ()->getColour (T("mainBackground"));
g.fillAll (backgroundColour);
}
示例15: drawScrollbar
void mlrVSTLookAndFeel::drawScrollbar (Graphics& g,
ScrollBar& bar,
int x, int y,
int width, int height,
bool isScrollbarVertical,
int thumbStartPosition,
int thumbSize,
bool isMouseOver,
bool isMouseDown)
{
g.fillAll (bar.findColour (ScrollBar::backgroundColourId));
g.setColour (bar.findColour (ScrollBar::thumbColourId)
.withAlpha ((isMouseOver || isMouseDown) ? 0.4f : 0.15f));
if (thumbSize > 0.0f)
{
Rectangle<int> thumb;
if (isScrollbarVertical)
{
width -= 2;
g.fillRect (x + roundToInt (width * 0.35f), y,
roundToInt (width * 0.3f), height);
thumb.setBounds (x + 1, thumbStartPosition,
width - 2, thumbSize);
}
else
{
height -= 2;
g.fillRect (x, y + roundToInt (height * 0.35f),
width, roundToInt (height * 0.3f));
thumb.setBounds (thumbStartPosition, y + 1,
thumbSize, height - 2);
}
g.setColour (bar.findColour (ScrollBar::thumbColourId)
.withAlpha ((isMouseOver || isMouseDown) ? 0.95f : 0.7f));
g.fillRect (thumb);
g.setColour (Colours::black.withAlpha ((isMouseOver || isMouseDown) ? 0.4f : 0.25f));
g.drawRect (thumb.getX(), thumb.getY(), thumb.getWidth(), thumb.getHeight());
if (thumbSize > 16)
{
for (int i = 3; --i >= 0;)
{
const float linePos = thumbStartPosition + thumbSize / 2 + (i - 1) * 4.0f;
g.setColour (Colours::black.withAlpha (0.15f));
if (isScrollbarVertical)
{
g.drawLine (x + width * 0.2f, linePos, width * 0.8f, linePos);
g.setColour (Colours::white.withAlpha (0.15f));
g.drawLine (width * 0.2f, linePos - 1, width * 0.8f, linePos - 1);
}
else
{
g.drawLine (linePos, height * 0.2f, linePos, height * 0.8f);
g.setColour (Colours::white.withAlpha (0.15f));
g.drawLine (linePos - 1, height * 0.2f, linePos - 1, height * 0.8f);
}
}
}
}
}