added additional functions
This commit is contained in:
1 parent
5d5a502976
commit
e5f109327c
2 files changed
+52
No files matched your search
@@ -172,6 +172,8 @@ void rframe(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, QColor cl0, QCo
|
|||||||
// A "double line" bevel effect (one line in cl0, a second offset by one
|
// A "double line" bevel effect (one line in cl0, a second offset by one
|
||||||
// pixel in cl1), e.g. used to separate a label from its value.
|
// pixel in cl1), e.g. used to separate a label from its value.
|
||||||
void dLine(Dpi::Canvas &canvas, int x0, int x1, int y, QColor cl0, QColor cl1);
|
void dLine(Dpi::Canvas &canvas, int x0, int x1, int y, QColor cl0, QColor cl1);
|
||||||
|
// Frame consisting of just the four corners (corner = length of each arm).
|
||||||
|
void cframe(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, int corner, QColor cl);
|
||||||
void btnFrame(Dpi::Canvas &canvas, const QRect &rect, const Texture &texture);
|
void btnFrame(Dpi::Canvas &canvas, const QRect &rect, const Texture &texture);
|
||||||
void editFrame(Dpi::Canvas &canvas, const QRect &rect, const Texture &texture);
|
void editFrame(Dpi::Canvas &canvas, const QRect &rect, const Texture &texture);
|
||||||
// Unimplemented in the original ScreenTools.pas too (body is commented out there).
|
// Unimplemented in the original ScreenTools.pas too (body is commented out there).
|
||||||
@@ -179,6 +181,8 @@ void corner(Dpi::Canvas &canvas, int x, int y, int kind, const Texture &texture)
|
|||||||
|
|
||||||
void fill(Dpi::Canvas &canvas, int left, int top, int width, int height, int xOffset = 0, int yOffset = 0);
|
void fill(Dpi::Canvas &canvas, int left, int top, int width, int height, int xOffset = 0, int yOffset = 0);
|
||||||
void fill(Dpi::Canvas &canvas, const QRect &rect, const QPoint &offset = QPoint());
|
void fill(Dpi::Canvas &canvas, const QRect &rect, const QPoint &offset = QPoint());
|
||||||
|
// Fills the band [y0,y1) from x0 to x1 with the main texture, tiled from xm.
|
||||||
|
void fillLarge(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, int xm);
|
||||||
// Seamlessly tiles `texture` (wrapping at its own width/height) into the
|
// Seamlessly tiles `texture` (wrapping at its own width/height) into the
|
||||||
// given rectangle, offset by (xOffset,yOffset) - e.g. a background that
|
// given rectangle, offset by (xOffset,yOffset) - e.g. a background that
|
||||||
// must look continuous regardless of where the painted rect starts.
|
// must look continuous regardless of where the painted rect starts.
|
||||||
|
|||||||
@@ -389,6 +389,23 @@ void rframe(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, QColor cl0, QCo
|
|||||||
canvas.lineTo(x1, y1);
|
canvas.lineTo(x1, y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cframe(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, int corner, QColor cl)
|
||||||
|
{
|
||||||
|
canvas.pen().setColor(cl);
|
||||||
|
canvas.moveTo(x0, y0 + corner - 1);
|
||||||
|
canvas.lineTo(x0, y0);
|
||||||
|
canvas.lineTo(x0 + corner, y0);
|
||||||
|
canvas.moveTo(x1, y0 + corner - 1);
|
||||||
|
canvas.lineTo(x1, y0);
|
||||||
|
canvas.lineTo(x1 - corner, y0);
|
||||||
|
canvas.moveTo(x1, y1 - corner + 1);
|
||||||
|
canvas.lineTo(x1, y1);
|
||||||
|
canvas.lineTo(x1 - corner, y1);
|
||||||
|
canvas.moveTo(x0, y1 - corner + 1);
|
||||||
|
canvas.lineTo(x0, y1);
|
||||||
|
canvas.lineTo(x0 + corner, y1);
|
||||||
|
}
|
||||||
|
|
||||||
void btnFrame(Dpi::Canvas &canvas, const QRect &rect, const Texture &texture)
|
void btnFrame(Dpi::Canvas &canvas, const QRect &rect, const Texture &texture)
|
||||||
{
|
{
|
||||||
rframe(canvas, rect.left() - 1, rect.top() - 1, rect.right(), rect.bottom(),
|
rframe(canvas, rect.left() - 1, rect.top() - 1, rect.right(), rect.bottom(),
|
||||||
@@ -449,6 +466,37 @@ void fill(Dpi::Canvas &canvas, const QRect &rect, const QPoint &offset)
|
|||||||
fill(canvas, rect.left(), rect.top(), rect.width(), rect.height(), offset.x(), offset.y());
|
fill(canvas, rect.left(), rect.top(), rect.width(), rect.height(), offset.x(), offset.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fillLarge(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, int xm)
|
||||||
|
{
|
||||||
|
if (!MainTexture || MainTexture->width() <= 0 || y1 <= y0)
|
||||||
|
return;
|
||||||
|
const int textureWidth = MainTexture->width();
|
||||||
|
const int textureHeight = MainTexture->height();
|
||||||
|
const int bandHeight = y1 - y0;
|
||||||
|
const auto band = [&](int i) {
|
||||||
|
const int n = ((textureHeight / 2) / bandHeight) * 2;
|
||||||
|
if (n <= 0)
|
||||||
|
return 0;
|
||||||
|
while (textureHeight / 2 + (i + 1) * bandHeight > textureHeight)
|
||||||
|
i -= n;
|
||||||
|
while (textureHeight / 2 + i * bandHeight < 0)
|
||||||
|
i += n;
|
||||||
|
return i;
|
||||||
|
};
|
||||||
|
const auto blit = [&](int xDst, int width, int xSrc, int yBand) {
|
||||||
|
canvas.copyRect(QRect(xDst, y0, width, bandHeight), MainTexture->canvas(),
|
||||||
|
QRect(xSrc, textureHeight / 2 + band(yBand) * bandHeight, width, bandHeight));
|
||||||
|
};
|
||||||
|
const int rightCount = (x1 - xm) / textureWidth;
|
||||||
|
for (int i = 0; i < rightCount; ++i)
|
||||||
|
blit(xm + i * textureWidth, textureWidth, 0, i);
|
||||||
|
blit(xm + rightCount * textureWidth, x1 - (xm + rightCount * textureWidth), 0, rightCount);
|
||||||
|
const int leftCount = (xm - x0) / textureWidth;
|
||||||
|
for (int i = 0; i < leftCount; ++i)
|
||||||
|
blit(xm - (i + 1) * textureWidth, textureWidth, 0, -i - 1);
|
||||||
|
blit(x0, xm - leftCount * textureWidth - x0, (leftCount + 1) * textureWidth - (xm - x0), -leftCount - 1);
|
||||||
|
}
|
||||||
|
|
||||||
void fillSeamless(Dpi::Canvas &canvas, int left, int top, int width, int height, int xOffset, int yOffset,
|
void fillSeamless(Dpi::Canvas &canvas, int left, int top, int width, int height, int xOffset, int yOffset,
|
||||||
Dpi::Bitmap &texture)
|
Dpi::Bitmap &texture)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user