Files
c-evo-evo/widget/include/Cevo/CevoScreenTools.h
T

96 lines
4.4 KiB
C++

#pragma once
#include "Dpi/DpiGraphics.h"
#include <QColor>
#include <QPoint>
#include <QRect>
#include <QString>
#include <array>
namespace Cevo {
class Texture;
class GraphicSet;
class GraphicSetItem;
// Delphi/VCL TColor ints are packed as $00BBGGRR (red in the low byte, the
// reverse of Qt's QRgb/QColor byte order). Convert ported color literals
// (e.g. ButtonA's $0000FF placeholder color) with this helper rather than
// constructing QColor from the raw hex value directly.
QColor colorFromDelphi(int value);
enum class FontType { Normal, Small, Tiny, Caption, Button, Count };
// Fonts, the main background texture and the system sprite sheets are
// populated by the application's asset-loading step (ScreenTools.pas's
// UnitInit/LoadAssets in the original, not ported here); null/default until
// the application assigns them.
extern std::array<Dpi::Font, static_cast<size_t>(FontType::Count)> UniFont;
extern Texture *MainTexture;
extern GraphicSet *HGrSystem;
extern GraphicSet *HGrSystem2;
extern GraphicSet *Templates;
extern Dpi::Bitmap *Colors; // palette lookup bitmap, indexed by clkAge0/cli* below
// Colors palette row/column indices (Colors->image().pixelColor(col, row)).
constexpr int clkAge0 = 1;
constexpr int cliTexture = 0;
constexpr int cliBevelLight = 1;
constexpr int cliBevelShade = 2;
constexpr int cliTextLight = 3;
constexpr int cliTextShade = 4;
constexpr int cliLitText = 5;
constexpr int cliMark = 6;
constexpr int cliDimmedText = 7;
constexpr int cliRoad = 8;
constexpr int cliHouse = 9;
constexpr int cliImp = 10;
constexpr int cliImpProject = 11;
constexpr int cliPage = 13;
constexpr int cliCover = 14;
enum class RasterOp { Copy, And, Paint, Invert };
// Mirrors ScreenTools.pas's BitBltBitmap raster-op blit (classic AND-mask +
// OR-data sprite compositing) and UnshareBitmap (a no-op here: QImage is
// already copy-on-write safe, so there is no shared-handle cache to break).
void bitBltBitmap(Dpi::Bitmap &dest, int x, int y, int width, int height,
Dpi::Bitmap &src, int xSrc, int ySrc, RasterOp rop = RasterOp::Copy);
void unshareBitmap(Dpi::Bitmap &bitmap);
// Draws a masked sprite (AND then OR, via an internal scratch buffer since
// Qt's QPainter has no raster-op compositing against the live canvas).
void sprite(Dpi::Canvas &canvas, GraphicSet &graphicSet, int xDst, int yDst,
int width, int height, int xGr, int yGr);
void sprite(Dpi::Canvas &canvas, int xDst, int yDst, const GraphicSetItem &item);
void frame(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, QColor cl0, QColor cl1);
void rframe(Dpi::Canvas &canvas, int x0, int y0, int x1, int y1, QColor cl0, QColor cl1);
void btnFrame(Dpi::Canvas &canvas, const QRect &rect, const Texture &texture);
// Unimplemented in the original ScreenTools.pas too (body is commented out there).
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, const QRect &rect, const QPoint &offset = QPoint());
void paintBackground(Dpi::Canvas &canvas, int left, int top, int width, int height,
int formWidth = 0, int formHeight = 0);
void biColorTextOut(Dpi::Canvas &canvas, QColor mainColor, QColor backColor, int x, int y, const QString &text);
int biColorTextWidth(Dpi::Canvas &canvas, const QString &text);
void risedTextOut(Dpi::Canvas &canvas, int x, int y, const QString &text);
// cl == -2: mixed bevel colors; cl < 0: texture's text shade/light pair; cl >= 0: explicit color.
void loweredTextOut(Dpi::Canvas &canvas, int cl, const Texture &texture, int x, int y, const QString &text);
// Template-based color blending (Src is a greyscale "template" bitmap whose
// channels encode per-pixel blend amplitudes). color0/color1/color2 use the
// Delphi $BBGGRR byte order, like colorFromDelphi's input.
void imageOpB(Dpi::Bitmap &dst, Dpi::Bitmap &src, int xDst, int yDst, int xSrc, int ySrc, int width, int height);
void imageOpBCC(Dpi::Bitmap &dst, Dpi::Bitmap &src, int xDst, int yDst, int xSrc, int ySrc,
int width, int height, int color1, int color2);
void imageOpCBC(Dpi::Bitmap &dst, Dpi::Bitmap &src, int xDst, int yDst, int xSrc, int ySrc,
int width, int height, int color0, int color2);
void imageOpCCC(Dpi::Bitmap &bmp, int x, int y, int width, int height, int color0, int color1, int color2);
} // namespace Cevo