UI Widget Enhancements: - Add texture support to UICheckbox (box and checkmark textures) - Add texture support to UISlider (track and handle textures) - Add texture support to UIPanel (background texture) - Add texture support to UIProgressBar (background and fill textures) - Add texture support to UIScrollPanel (background and scrollbar textures) - All widgets now support textureId with tint color for flexible styling BgfxRenderer: - Add texture loading helpers for widget texturing - Update RHI device for texture management - Add ResourceCache texture ID support Maintenance: - Add tmpclaude-* to .gitignore (temporary Claude Code directories) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
50 lines
1.5 KiB
C++
50 lines
1.5 KiB
C++
#include "UIPanel.h"
|
|
#include "../Core/UIContext.h"
|
|
#include "../Core/UILayout.h"
|
|
#include "../Rendering/UIRenderer.h"
|
|
#include <spdlog/spdlog.h>
|
|
|
|
namespace grove {
|
|
|
|
void UIPanel::update(UIContext& ctx, float deltaTime) {
|
|
// Apply layout if this panel has a non-absolute layout mode
|
|
if (layoutProps.mode != LayoutMode::Absolute) {
|
|
// Measure and layout children
|
|
UILayout::measure(this);
|
|
UILayout::layout(this, width, height);
|
|
}
|
|
|
|
// Update children
|
|
updateChildren(ctx, deltaTime);
|
|
}
|
|
|
|
void UIPanel::render(UIRenderer& renderer) {
|
|
// Register with renderer on first render
|
|
if (!m_registered) {
|
|
m_renderId = renderer.registerEntry();
|
|
m_registered = true;
|
|
// Set destroy callback to unregister
|
|
setDestroyCallback([&renderer](uint32_t id) {
|
|
renderer.unregisterEntry(id);
|
|
});
|
|
}
|
|
|
|
// Retained mode: only publish if changed
|
|
int layer = renderer.nextLayer();
|
|
|
|
// Check if fully transparent (alpha channel = 0)
|
|
bool isFullyTransparent = (bgColor & 0xFF) == 0;
|
|
|
|
// Render background (texture or solid color) - skip if fully transparent
|
|
if (useTexture && textureId > 0) {
|
|
renderer.updateSprite(m_renderId, absX, absY, width, height, textureId, tintColor, layer);
|
|
} else if (!isFullyTransparent) {
|
|
renderer.updateRect(m_renderId, absX, absY, width, height, bgColor, layer);
|
|
}
|
|
|
|
// Render children on top
|
|
renderChildren(renderer);
|
|
}
|
|
|
|
} // namespace grove
|