Add DrawBitmapTable to Canvas class

This commit is contained in:
scawful
2023-07-09 10:35:44 -04:00
parent 931560cfb1
commit 585413e6d6
2 changed files with 16 additions and 0 deletions

View File

@@ -163,6 +163,20 @@ void Canvas::DrawBitmap(const Bitmap &bitmap, int x_offset, int y_offset) {
canvas_p0_.y + y_offset + scrolling_.y + (bitmap.GetHeight())));
}
// TODO: Add parameters for sizing and positioning
void Canvas::DrawBitmapTable(const BitmapTable gfx_bin) {
for (const auto &[key, value] : gfx_bin) {
int offset = 0x40 * (key + 1);
int top_left_y = canvas_p0_.y + 2;
if (key >= 1) {
top_left_y = canvas_p0_.y + 0x40 * key;
}
draw_list_->AddImage((void *)value.GetTexture(),
ImVec2(canvas_p0_.x + 2, top_left_y),
ImVec2(canvas_p0_.x + 0x100, canvas_p0_.y + offset));
}
}
void Canvas::DrawOutline(int x, int y, int w, int h) {
ImVec2 origin(canvas_p0_.x + scrolling_.x + x,
canvas_p0_.y + scrolling_.y + y);

View File

@@ -13,6 +13,7 @@ namespace yaze {
namespace gui {
using app::gfx::Bitmap;
using app::gfx::BitmapTable;
class Canvas {
public:
@@ -29,6 +30,7 @@ class Canvas {
void DrawBitmap(const Bitmap& bitmap, int border_offset = 0,
bool ready = true);
void DrawBitmap(const Bitmap& bitmap, int x_offset, int y_offset);
void DrawBitmapTable(const BitmapTable gfx_bin);
void DrawOutline(int x, int y, int w, int h);
void DrawRect(int x, int y, int w, int h, ImVec4 color);
void DrawText(std::string text, int x, int y);