mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
Added click event for imguiImage().
This commit is contained in:
parent
9605583491
commit
ea4d52ff46
2 changed files with 32 additions and 18 deletions
|
@ -1547,8 +1547,9 @@ struct Imgui
|
||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void image(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align, bool _originBottomLeft)
|
bool image(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align, bool _originBottomLeft)
|
||||||
{
|
{
|
||||||
|
const uint32_t id = getId();
|
||||||
Area& area = getCurrentArea();
|
Area& area = getCurrentArea();
|
||||||
|
|
||||||
int32_t xx;
|
int32_t xx;
|
||||||
|
@ -1576,6 +1577,10 @@ struct Imgui
|
||||||
const int32_t yy = area.m_widgetY;
|
const int32_t yy = area.m_widgetY;
|
||||||
area.m_widgetY += _height + DEFAULT_SPACING;
|
area.m_widgetY += _height + DEFAULT_SPACING;
|
||||||
|
|
||||||
|
const bool enabled = isEnabled(m_areaId);
|
||||||
|
const bool over = enabled && inRect(xx, yy, _width, _height);
|
||||||
|
const bool res = buttonLogic(id, over);
|
||||||
|
|
||||||
screenQuad(xx, yy, _width, _height, _originBottomLeft);
|
screenQuad(xx, yy, _width, _height, _originBottomLeft);
|
||||||
bgfx::setUniform(u_imageLod, &_lod);
|
bgfx::setUniform(u_imageLod, &_lod);
|
||||||
bgfx::setTexture(0, s_texColor, bgfx::isValid(_image) ? _image : m_missingTexture);
|
bgfx::setTexture(0, s_texColor, bgfx::isValid(_image) ? _image : m_missingTexture);
|
||||||
|
@ -1583,20 +1588,23 @@ struct Imgui
|
||||||
bgfx::setProgram(m_imageProgram);
|
bgfx::setProgram(m_imageProgram);
|
||||||
setCurrentScissor();
|
setCurrentScissor();
|
||||||
bgfx::submit(m_view);
|
bgfx::submit(m_view);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void image(bgfx::TextureHandle _image, float _lod, float _width, float _aspect, ImguiAlign::Enum _align, bool _originBottomLeft)
|
bool image(bgfx::TextureHandle _image, float _lod, float _width, float _aspect, ImguiAlign::Enum _align, bool _originBottomLeft)
|
||||||
{
|
{
|
||||||
const float width = _width*float(getCurrentArea().m_widgetW);
|
const float width = _width*float(getCurrentArea().m_widgetW);
|
||||||
const float height = width/_aspect;
|
const float height = width/_aspect;
|
||||||
|
|
||||||
image(_image, _lod, int32_t(width), int32_t(height), _align, _originBottomLeft);
|
return image(_image, _lod, int32_t(width), int32_t(height), _align, _originBottomLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
void imageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align)
|
bool imageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align)
|
||||||
{
|
{
|
||||||
BX_CHECK(_channel < 4, "Channel param must be from 0 to 3!");
|
BX_CHECK(_channel < 4, "Channel param must be from 0 to 3!");
|
||||||
|
|
||||||
|
const uint32_t id = getId();
|
||||||
Area& area = getCurrentArea();
|
Area& area = getCurrentArea();
|
||||||
|
|
||||||
int32_t xx;
|
int32_t xx;
|
||||||
|
@ -1624,6 +1632,10 @@ struct Imgui
|
||||||
const int32_t yy = area.m_widgetY;
|
const int32_t yy = area.m_widgetY;
|
||||||
area.m_widgetY += _height + DEFAULT_SPACING;
|
area.m_widgetY += _height + DEFAULT_SPACING;
|
||||||
|
|
||||||
|
const bool enabled = isEnabled(m_areaId);
|
||||||
|
const bool over = enabled && inRect(xx, yy, _width, _height);
|
||||||
|
const bool res = buttonLogic(id, over);
|
||||||
|
|
||||||
screenQuad(xx, yy, _width, _height);
|
screenQuad(xx, yy, _width, _height);
|
||||||
bgfx::setUniform(u_imageLod, &_lod);
|
bgfx::setUniform(u_imageLod, &_lod);
|
||||||
|
|
||||||
|
@ -1636,14 +1648,16 @@ struct Imgui
|
||||||
bgfx::setProgram(m_imageSwizzProgram);
|
bgfx::setProgram(m_imageSwizzProgram);
|
||||||
setCurrentScissor();
|
setCurrentScissor();
|
||||||
bgfx::submit(m_view);
|
bgfx::submit(m_view);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void imageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, float _width, float _aspect, ImguiAlign::Enum _align)
|
bool imageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, float _width, float _aspect, ImguiAlign::Enum _align)
|
||||||
{
|
{
|
||||||
const float width = _width*float(getCurrentArea().m_widgetW);
|
const float width = _width*float(getCurrentArea().m_widgetW);
|
||||||
const float height = width/_aspect;
|
const float height = width/_aspect;
|
||||||
|
|
||||||
imageChannel(_image, _channel, _lod, int32_t(width), int32_t(height), _align);
|
return imageChannel(_image, _channel, _lod, int32_t(width), int32_t(height), _align);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cubeMap(bgfx::TextureHandle _cubemap, float _lod, bool _cross, ImguiAlign::Enum _align)
|
bool cubeMap(bgfx::TextureHandle _cubemap, float _lod, bool _cross, ImguiAlign::Enum _align)
|
||||||
|
@ -3288,24 +3302,24 @@ void imguiColorWheel(const char* _text, float _rgb[3], bool& _activated, bool _e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void imguiImage(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align, bool _originBottomLeft)
|
bool imguiImage(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align, bool _originBottomLeft)
|
||||||
{
|
{
|
||||||
s_imgui.image(_image, _lod, _width, _height, _align, _originBottomLeft);
|
return s_imgui.image(_image, _lod, _width, _height, _align, _originBottomLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
void imguiImage(bgfx::TextureHandle _image, float _lod, float _width, float _aspect, ImguiAlign::Enum _align, bool _originBottomLeft)
|
bool imguiImage(bgfx::TextureHandle _image, float _lod, float _width, float _aspect, ImguiAlign::Enum _align, bool _originBottomLeft)
|
||||||
{
|
{
|
||||||
s_imgui.image(_image, _lod, _width, _aspect, _align, _originBottomLeft);
|
return s_imgui.image(_image, _lod, _width, _aspect, _align, _originBottomLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
void imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align)
|
bool imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align)
|
||||||
{
|
{
|
||||||
s_imgui.imageChannel(_image, _channel, _lod, _width, _height, _align);
|
return s_imgui.imageChannel(_image, _channel, _lod, _width, _height, _align);
|
||||||
}
|
}
|
||||||
|
|
||||||
void imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, float _width, float _aspect, ImguiAlign::Enum _align)
|
bool imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, float _width, float _aspect, ImguiAlign::Enum _align)
|
||||||
{
|
{
|
||||||
s_imgui.imageChannel(_image, _channel, _lod, _width, _aspect, _align);
|
return s_imgui.imageChannel(_image, _channel, _lod, _width, _aspect, _align);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool imguiCube(bgfx::TextureHandle _cubemap, float _lod, bool _cross, ImguiAlign::Enum _align)
|
bool imguiCube(bgfx::TextureHandle _cubemap, float _lod, bool _cross, ImguiAlign::Enum _align)
|
||||||
|
|
|
@ -174,10 +174,10 @@ uint32_t imguiChooseUseMacroInstead(uint32_t _selected, ...);
|
||||||
void imguiColorWheel(float _rgb[3], bool _respectIndentation = false, bool _enabled = true);
|
void imguiColorWheel(float _rgb[3], bool _respectIndentation = false, bool _enabled = true);
|
||||||
void imguiColorWheel(const char* _str, float _rgb[3], bool& _activated, bool _enabled = true);
|
void imguiColorWheel(const char* _str, float _rgb[3], bool& _activated, bool _enabled = true);
|
||||||
|
|
||||||
void imguiImage(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align = ImguiAlign::LeftIndented, bool _originBottomLeft = false);
|
bool imguiImage(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align = ImguiAlign::LeftIndented, bool _originBottomLeft = false);
|
||||||
void imguiImage(bgfx::TextureHandle _image, float _lod, float _scale, float _aspect, ImguiAlign::Enum _align = ImguiAlign::LeftIndented, bool _originBottomLeft = false);
|
bool imguiImage(bgfx::TextureHandle _image, float _lod, float _scale, float _aspect, ImguiAlign::Enum _align = ImguiAlign::LeftIndented, bool _originBottomLeft = false);
|
||||||
void imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align = ImguiAlign::LeftIndented);
|
bool imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align = ImguiAlign::LeftIndented);
|
||||||
void imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, float _scale, float _aspect, ImguiAlign::Enum _align = ImguiAlign::LeftIndented);
|
bool imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, float _scale, float _aspect, ImguiAlign::Enum _align = ImguiAlign::LeftIndented);
|
||||||
bool imguiCube(bgfx::TextureHandle _cubemap, float _lod = 0.0f, bool _cross = true, ImguiAlign::Enum _align = ImguiAlign::LeftIndented);
|
bool imguiCube(bgfx::TextureHandle _cubemap, float _lod = 0.0f, bool _cross = true, ImguiAlign::Enum _align = ImguiAlign::LeftIndented);
|
||||||
|
|
||||||
float imguiGetTextLength(const char* _text, ImguiFontHandle _handle);
|
float imguiGetTextLength(const char* _text, ImguiFontHandle _handle);
|
||||||
|
|
Loading…
Reference in a new issue