demotool/ui-utilities.cc
2017-11-23 14:43:15 +01:00

59 lines
1.1 KiB
C++

#include "externals.hh"
#include "ui-utilities.hh"
#include <imgui_internal.h>
void ImGui::PushDisabled( ) noexcept
{
PushItemFlag( ImGuiItemFlags_Disabled , true );
PushStyleVar( ImGuiStyleVar_Alpha , GetStyle( ).Alpha * .5f );
}
void ImGui::PopDisabled( ) noexcept
{
PopItemFlag( );
PopStyleVar( );
}
/*------------------------------------------------------------------------------*/
bool ImGui::MenuItemCheckbox(
char const* name ,
bool* checked ) noexcept
{
bool rv{ MenuItem( name , "" , *checked , true ) };
if ( rv ) {
*checked = !*checked;
}
return rv;
}
/*------------------------------------------------------------------------------*/
bool ImGui::ToolbarButton(
char const* const string ,
ImVec2 const& size ,
char const* const tooltip ,
bool enabled ) noexcept
{
if ( !enabled ) {
PushDisabled( );
}
const bool rv{ Button( string , size ) };
if ( !enabled ) {
PopDisabled( );
} else if ( tooltip && IsItemHovered( ) ) {
BeginTooltip( );
Text( tooltip );
EndTooltip( );
}
return rv;
}
void ImGui::ToolbarSeparator( ) noexcept
{
SameLine( );
VerticalSeparator( );
SameLine( );
}