minor refactor
This commit is contained in:
@@ -14,7 +14,6 @@ Image::Image(std::string texture, glm::vec2 size) : UINode(size), texture(textur
|
||||
|
||||
void Image::draw(const DrawContext* pctx, Assets* assets) {
|
||||
glm::vec2 pos = calcPos();
|
||||
glm::vec4 color = getColor();
|
||||
auto batch = pctx->getBatch2D();
|
||||
|
||||
auto texture = assets->getTexture(this->texture);
|
||||
@@ -22,13 +21,10 @@ void Image::draw(const DrawContext* pctx, Assets* assets) {
|
||||
setSize(glm::vec2(texture->getWidth(), texture->getHeight()));
|
||||
}
|
||||
batch->texture(texture);
|
||||
if (isEnabled()) {
|
||||
batch->setColor(isPressed() ? pressedColor : (hover ? hoverColor : color));
|
||||
} else {
|
||||
batch->setColor({color.r, color.g, color.b, color.a * 0.5f});
|
||||
}
|
||||
batch->rect(pos.x, pos.y, size.x, size.y,
|
||||
0, 0, 0, UVRegion(), false, true, batch->getColor());
|
||||
batch->rect(
|
||||
pos.x, pos.y, size.x, size.y,
|
||||
0, 0, 0, UVRegion(), false, true, calcColor()
|
||||
);
|
||||
}
|
||||
|
||||
void Image::setAutoResize(bool flag) {
|
||||
|
||||
Reference in New Issue
Block a user