Skip to content

Commit

Permalink
Merge pull request #774 from Tkachov/the-container-box-pr2
Browse files Browse the repository at this point in the history
GUI: Add ScrollContainerWidget
  • Loading branch information
sev- committed Jul 10, 2016
2 parents 862f12c + 846619f commit 9cec2ee
Show file tree
Hide file tree
Showing 30 changed files with 2,970 additions and 190 deletions.
29 changes: 28 additions & 1 deletion graphics/VectorRenderer.cpp
Expand Up @@ -55,7 +55,34 @@ void VectorRenderer::drawStep(const Common::Rect &area, const DrawStep &step, ui

_dynamicData = extra;

(this->*(step.drawingCall))(area, step);
Common::Rect noClip = Common::Rect(0, 0, 0, 0);
(this->*(step.drawingCall))(area, step, noClip);
}

void VectorRenderer::drawStepClip(const Common::Rect &area, const Common::Rect &clip, const DrawStep &step, uint32 extra) {

if (step.bgColor.set)
setBgColor(step.bgColor.r, step.bgColor.g, step.bgColor.b);

if (step.fgColor.set)
setFgColor(step.fgColor.r, step.fgColor.g, step.fgColor.b);

if (step.bevelColor.set)
setBevelColor(step.bevelColor.r, step.bevelColor.g, step.bevelColor.b);

if (step.gradColor1.set && step.gradColor2.set)
setGradientColors(step.gradColor1.r, step.gradColor1.g, step.gradColor1.b,
step.gradColor2.r, step.gradColor2.g, step.gradColor2.b);

setShadowOffset(_disableShadows ? 0 : step.shadow);
setBevel(step.bevel);
setGradientFactor(step.factor);
setStrokeWidth(step.stroke);
setFillMode((FillMode)step.fillMode);

_dynamicData = extra;

(this->*(step.drawingCall))(area, step, clip);
}

int VectorRenderer::stepGetRadius(const DrawStep &step, const Common::Rect &area) {
Expand Down
60 changes: 38 additions & 22 deletions graphics/VectorRenderer.h
Expand Up @@ -38,7 +38,7 @@ class VectorRenderer;
struct DrawStep;


typedef void (VectorRenderer::*DrawingFunctionCallback)(const Common::Rect &, const Graphics::DrawStep &);
typedef void (VectorRenderer::*DrawingFunctionCallback)(const Common::Rect &, const Graphics::DrawStep &, const Common::Rect &);


struct DrawStep {
Expand Down Expand Up @@ -142,6 +142,7 @@ class VectorRenderer {
* @param y2 Vertical (Y) coordinate for the line end
*/
virtual void drawLine(int x1, int y1, int x2, int y2) = 0;
virtual void drawLineClip(int x1, int y1, int x2, int y2, Common::Rect clipping) = 0;

/**
* Draws a circle centered at (x,y) with radius r.
Expand All @@ -151,6 +152,7 @@ class VectorRenderer {
* @param r Radius of the circle.
*/
virtual void drawCircle(int x, int y, int r) = 0;
virtual void drawCircleClip(int x, int y, int r, Common::Rect clipping) = 0;

/**
* Draws a square starting at (x,y) with the given width and height.
Expand All @@ -161,6 +163,7 @@ class VectorRenderer {
* @param h Height of the square
*/
virtual void drawSquare(int x, int y, int w, int h) = 0;
virtual void drawSquareClip(int x, int y, int w, int h, Common::Rect clipping) = 0;

/**
* Draws a rounded square starting at (x,y) with the given width and height.
Expand All @@ -173,6 +176,7 @@ class VectorRenderer {
* @param r Radius of the corners.
*/
virtual void drawRoundedSquare(int x, int y, int r, int w, int h) = 0;
virtual void drawRoundedSquareClip(int x, int y, int r, int w, int h, Common::Rect clipping) = 0;

/**
* Draws a triangle starting at (x,y) with the given base and height.
Expand All @@ -186,6 +190,7 @@ class VectorRenderer {
* @param orient Orientation of the triangle.
*/
virtual void drawTriangle(int x, int y, int base, int height, TriangleOrientation orient) = 0;
virtual void drawTriangleClip(int x, int y, int base, int height, TriangleOrientation orient, Common::Rect clipping) = 0;

/**
* Draws a beveled square like the ones in the Classic GUI themes.
Expand All @@ -199,6 +204,7 @@ class VectorRenderer {
* @param bevel Amount of bevel. Must be positive.
*/
virtual void drawBeveledSquare(int x, int y, int w, int h, int bevel) = 0;
virtual void drawBeveledSquareClip(int x, int y, int w, int h, int bevel, Common::Rect clipping) = 0;

/**
* Draws a tab-like shape, specially thought for the Tab widget.
Expand All @@ -212,6 +218,7 @@ class VectorRenderer {
* @param r Radius of the corners of the tab (0 for squared tabs).
*/
virtual void drawTab(int x, int y, int r, int w, int h) = 0;
virtual void drawTabClip(int x, int y, int r, int w, int h, Common::Rect clipping) = 0;


/**
Expand All @@ -222,6 +229,11 @@ class VectorRenderer {
drawLine(x + w, y, x, y + h);
}

virtual void drawCrossClip(int x, int y, int w, int h, Common::Rect clipping) {
drawLineClip(x, y, x + w, y + w, clipping);
drawLineClip(x + w, y, x, y + h, clipping);
}

/**
* Set the active foreground painting color for the renderer.
* All the foreground drawing from then on will be done with that color, unless
Expand Down Expand Up @@ -278,6 +290,7 @@ class VectorRenderer {
* Defaults to using the active Foreground color for filling.
*/
virtual void fillSurface() = 0;
virtual void fillSurfaceClip(Common::Rect clipping) = 0;

/**
* Clears the active surface.
Expand Down Expand Up @@ -355,68 +368,68 @@ class VectorRenderer {
/**
* DrawStep callback functions for each drawing feature
*/
void drawCallback_CIRCLE(const Common::Rect &area, const DrawStep &step) {
void drawCallback_CIRCLE(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
uint16 x, y, w, h, radius;

radius = stepGetRadius(step, area);
stepGetPositions(step, area, x, y, w, h);

drawCircle(x + radius, y + radius, radius);
drawCircleClip(x + radius, y + radius, radius, clip);
}

void drawCallback_SQUARE(const Common::Rect &area, const DrawStep &step) {
void drawCallback_SQUARE(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
drawSquare(x, y, w, h);
drawSquareClip(x, y, w, h, clip);
}

void drawCallback_LINE(const Common::Rect &area, const DrawStep &step) {
void drawCallback_LINE(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
drawLine(x, y, x + w, y + w);
drawLineClip(x, y, x + w, y + w, clip);
}

void drawCallback_ROUNDSQ(const Common::Rect &area, const DrawStep &step) {
void drawCallback_ROUNDSQ(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
drawRoundedSquare(x, y, stepGetRadius(step, area), w, h);
drawRoundedSquareClip(x, y, stepGetRadius(step, area), w, h, clip);
}

void drawCallback_FILLSURFACE(const Common::Rect &area, const DrawStep &step) {
fillSurface();
void drawCallback_FILLSURFACE(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
fillSurfaceClip(clip);
}

void drawCallback_TRIANGLE(const Common::Rect &area, const DrawStep &step) {
void drawCallback_TRIANGLE(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
drawTriangle(x, y, w, h, (TriangleOrientation)step.extraData);
drawTriangleClip(x, y, w, h, (TriangleOrientation)step.extraData, clip);
}

void drawCallback_BEVELSQ(const Common::Rect &area, const DrawStep &step) {
void drawCallback_BEVELSQ(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
drawBeveledSquare(x, y, w, h, _bevel);
drawBeveledSquareClip(x, y, w, h, _bevel, clip);
}

void drawCallback_TAB(const Common::Rect &area, const DrawStep &step) {
void drawCallback_TAB(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
drawTab(x, y, stepGetRadius(step, area), w, h);
drawTabClip(x, y, stepGetRadius(step, area), w, h, clip);
}

void drawCallback_BITMAP(const Common::Rect &area, const DrawStep &step) {
void drawCallback_BITMAP(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
blitAlphaBitmap(step.blitSrc, Common::Rect(x, y, x + w, y + h));
blitAlphaBitmapClip(step.blitSrc, Common::Rect(x, y, x + w, y + h), clip);
}

void drawCallback_CROSS(const Common::Rect &area, const DrawStep &step) {
void drawCallback_CROSS(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
drawCross(x, y, w, h);
drawCrossClip(x, y, w, h, clip);
}

void drawCallback_VOID(const Common::Rect &area, const DrawStep &step) {}
void drawCallback_VOID(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {}

/**
* Draws the specified draw step on the screen.
Expand All @@ -426,6 +439,7 @@ class VectorRenderer {
* @param step Pointer to a DrawStep struct.
*/
virtual void drawStep(const Common::Rect &area, const DrawStep &step, uint32 extra = 0);
virtual void drawStepClip(const Common::Rect &area, const Common::Rect &clip, const DrawStep &step, uint32 extra = 0);

/**
* Copies the part of the current frame to the system overlay.
Expand Down Expand Up @@ -466,8 +480,10 @@ class VectorRenderer {
* blitted into the active surface, at the position specified by "r".
*/
virtual void blitSubSurface(const Graphics::Surface *source, const Common::Rect &r) = 0;
virtual void blitSubSurfaceClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping) = 0;

virtual void blitAlphaBitmap(const Graphics::Surface *source, const Common::Rect &r) = 0;
virtual void blitAlphaBitmapClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping) = 0;

/**
* Draws a string into the screen. Wrapper for the Graphics::Font string drawing
Expand Down

0 comments on commit 9cec2ee

Please sign in to comment.