@ -3898,20 +3898,20 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
// If we're not showing any slider there's no point in doing any HSV conversions
const ImGuiColorEditFlags flags_untouched = flags ;
if ( flags & ImGuiColorEditFlags_NoInputs )
flags = ( flags & ( ~ ImGuiColorEditFlags__ Inputs Mask) ) | ImGuiColorEditFlags_ RGB | ImGuiColorEditFlags_NoOptions ;
flags = ( flags & ( ~ ImGuiColorEditFlags__ Show Mask) ) | ImGuiColorEditFlags_ Show RGB | ImGuiColorEditFlags_NoOptions ;
// Context menu: display and modify options (before defaults are applied)
if ( ! ( flags & ImGuiColorEditFlags_NoOptions ) )
ColorEditOptionsPopup ( col , flags ) ;
// Read stored options
if ( ! ( flags & ImGuiColorEditFlags__ Inputs Mask) )
flags | = ( g . ColorEditOptions & ImGuiColorEditFlags__ Inputs Mask) ;
if ( ! ( flags & ImGuiColorEditFlags__ Show Mask) )
flags | = ( g . ColorEditOptions & ImGuiColorEditFlags__ Show Mask) ;
if ( ! ( flags & ImGuiColorEditFlags__DataTypeMask ) )
flags | = ( g . ColorEditOptions & ImGuiColorEditFlags__DataTypeMask ) ;
if ( ! ( flags & ImGuiColorEditFlags__PickerMask ) )
flags | = ( g . ColorEditOptions & ImGuiColorEditFlags__PickerMask ) ;
flags | = ( g . ColorEditOptions & ~ ( ImGuiColorEditFlags__ Inputs Mask | ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask ) ) ;
flags | = ( g . ColorEditOptions & ~ ( ImGuiColorEditFlags__ Show Mask | ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask ) ) ;
const bool alpha = ( flags & ImGuiColorEditFlags_NoAlpha ) = = 0 ;
const bool hdr = ( flags & ImGuiColorEditFlags_HDR ) ! = 0 ;
@ -3919,14 +3919,14 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
// Convert to the formats we need
float f [ 4 ] = { col [ 0 ] , col [ 1 ] , col [ 2 ] , alpha ? col [ 3 ] : 1.0f } ;
if ( flags & ImGuiColorEditFlags_ HSV)
if ( flags & ImGuiColorEditFlags_ Show HSV)
ColorConvertRGBtoHSV ( f [ 0 ] , f [ 1 ] , f [ 2 ] , f [ 0 ] , f [ 1 ] , f [ 2 ] ) ;
int i [ 4 ] = { IM_F32_TO_INT8_UNBOUND ( f [ 0 ] ) , IM_F32_TO_INT8_UNBOUND ( f [ 1 ] ) , IM_F32_TO_INT8_UNBOUND ( f [ 2 ] ) , IM_F32_TO_INT8_UNBOUND ( f [ 3 ] ) } ;
bool value_changed = false ;
bool value_changed_as_float = false ;
if ( ( flags & ( ImGuiColorEditFlags_ RGB | ImGuiColorEditFlags_ HSV) ) ! = 0 & & ( flags & ImGuiColorEditFlags_NoInputs ) = = 0 )
if ( ( flags & ( ImGuiColorEditFlags_ Show RGB | ImGuiColorEditFlags_ Show HSV) ) ! = 0 & & ( flags & ImGuiColorEditFlags_NoInputs ) = = 0 )
{
// RGB/HSV 0..255 Sliders
const float w_item_one = ImMax ( 1.0f , ( float ) ( int ) ( ( w_items_all - ( style . ItemInnerSpacing . x ) * ( components - 1 ) ) / ( float ) components ) ) ;
@ -3946,7 +3946,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
{ " R:%0.3f " , " G:%0.3f " , " B:%0.3f " , " A:%0.3f " } , // Long display for RGBA
{ " H:%0.3f " , " S:%0.3f " , " V:%0.3f " , " A:%0.3f " } // Long display for HSVA
} ;
const int fmt_idx = hide_prefix ? 0 : ( flags & ImGuiColorEditFlags_ HSV) ? 2 : 1 ;
const int fmt_idx = hide_prefix ? 0 : ( flags & ImGuiColorEditFlags_ Show HSV) ? 2 : 1 ;
PushItemWidth ( w_item_one ) ;
for ( int n = 0 ; n < components ; n + + )
@ -3970,7 +3970,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
PopItemWidth ( ) ;
PopItemWidth ( ) ;
}
else if ( ( flags & ImGuiColorEditFlags_ HEX) ! = 0 & & ( flags & ImGuiColorEditFlags_NoInputs ) = = 0 )
else if ( ( flags & ImGuiColorEditFlags_ Show HEX) ! = 0 & & ( flags & ImGuiColorEditFlags_NoInputs ) = = 0 )
{
// RGB Hexadecimal Input
char buf [ 64 ] ;
@ -4025,7 +4025,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
Spacing ( ) ;
}
ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar ;
ImGuiColorEditFlags picker_flags = ( flags_untouched & picker_flags_to_forward ) | ImGuiColorEditFlags__ Inputs Mask | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf ;
ImGuiColorEditFlags picker_flags = ( flags_untouched & picker_flags_to_forward ) | ImGuiColorEditFlags__ Show Mask | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf ;
PushItemWidth ( square_sz * 12.0f ) ; // Use 256 + bar sizes?
value_changed | = ColorPicker4 ( " ##picker " , col , picker_flags , & g . ColorPickerRef . x ) ;
PopItemWidth ( ) ;
@ -4045,7 +4045,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
if ( ! value_changed_as_float )
for ( int n = 0 ; n < 4 ; n + + )
f [ n ] = i [ n ] / 255.0f ;
if ( flags & ImGuiColorEditFlags_ HSV)
if ( flags & ImGuiColorEditFlags_ Show HSV)
ColorConvertHSVtoRGB ( f [ 0 ] , f [ 1 ] , f [ 2 ] , f [ 0 ] , f [ 1 ] , f [ 2 ] ) ;
if ( value_changed )
{
@ -4330,18 +4330,18 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
PushItemWidth ( ( alpha_bar ? bar1_pos_x : bar0_pos_x ) + bars_width - picker_pos . x ) ;
ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoSmallPreview | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf ;
ImGuiColorEditFlags sub_flags = ( flags & sub_flags_to_forward ) | ImGuiColorEditFlags_NoPicker ;
if ( flags & ImGuiColorEditFlags_ RGB | | ( flags & ImGuiColorEditFlags__ Inputs Mask) = = 0 )
if ( ColorEdit4 ( " ##rgb " , col , sub_flags | ImGuiColorEditFlags_ RGB) )
if ( flags & ImGuiColorEditFlags_ Show RGB | | ( flags & ImGuiColorEditFlags__ Show Mask) = = 0 )
if ( ColorEdit4 ( " ##rgb " , col , sub_flags | ImGuiColorEditFlags_ Show RGB) )
{
// FIXME: Hackily differenciating using the DragInt (ActiveId != 0 && !ActiveIdAllowOverlap) vs. using the InputText or DropTarget.
// For the later we don't want to run the hue-wrap canceling code. If you are well versed in HSV picker please provide your input! (See #2050)
value_changed_fix_hue_wrap = ( g . ActiveId ! = 0 & & ! g . ActiveIdAllowOverlap ) ;
value_changed = true ;
}
if ( flags & ImGuiColorEditFlags_ HSV | | ( flags & ImGuiColorEditFlags__ Inputs Mask) = = 0 )
value_changed | = ColorEdit4 ( " ##hsv " , col , sub_flags | ImGuiColorEditFlags_ HSV) ;
if ( flags & ImGuiColorEditFlags_ HEX | | ( flags & ImGuiColorEditFlags__ Inputs Mask) = = 0 )
value_changed | = ColorEdit4 ( " ##hex " , col , sub_flags | ImGuiColorEditFlags_ HEX) ;
if ( flags & ImGuiColorEditFlags_ Show HSV | | ( flags & ImGuiColorEditFlags__ Show Mask) = = 0 )
value_changed | = ColorEdit4 ( " ##hsv " , col , sub_flags | ImGuiColorEditFlags_ Show HSV) ;
if ( flags & ImGuiColorEditFlags_ Show HEX | | ( flags & ImGuiColorEditFlags__ Show Mask) = = 0 )
value_changed | = ColorEdit4 ( " ##hex " , col , sub_flags | ImGuiColorEditFlags_ Show HEX) ;
PopItemWidth ( ) ;
}
@ -4539,13 +4539,13 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
void ImGui : : SetColorEditOptions ( ImGuiColorEditFlags flags )
{
ImGuiContext & g = * GImGui ;
if ( ( flags & ImGuiColorEditFlags__ Inputs Mask) = = 0 )
flags | = ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__ Inputs Mask;
if ( ( flags & ImGuiColorEditFlags__ Show Mask) = = 0 )
flags | = ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__ Show Mask;
if ( ( flags & ImGuiColorEditFlags__DataTypeMask ) = = 0 )
flags | = ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__DataTypeMask ;
if ( ( flags & ImGuiColorEditFlags__PickerMask ) = = 0 )
flags | = ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__PickerMask ;
IM_ASSERT ( ImIsPowerOfTwo ( ( int ) ( flags & ImGuiColorEditFlags__ Inputs Mask) ) ) ; // Check only 1 option is selected
IM_ASSERT ( ImIsPowerOfTwo ( ( int ) ( flags & ImGuiColorEditFlags__ Show Mask) ) ) ; // Check only 1 option is selected
IM_ASSERT ( ImIsPowerOfTwo ( ( int ) ( flags & ImGuiColorEditFlags__DataTypeMask ) ) ) ; // Check only 1 option is selected
IM_ASSERT ( ImIsPowerOfTwo ( ( int ) ( flags & ImGuiColorEditFlags__PickerMask ) ) ) ; // Check only 1 option is selected
g . ColorEditOptions = flags ;
@ -4578,7 +4578,7 @@ void ImGui::ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags
void ImGui : : ColorEditOptionsPopup ( const float * col , ImGuiColorEditFlags flags )
{
bool allow_opt_inputs = ! ( flags & ImGuiColorEditFlags__ Inputs Mask) ;
bool allow_opt_inputs = ! ( flags & ImGuiColorEditFlags__ Show Mask) ;
bool allow_opt_datatype = ! ( flags & ImGuiColorEditFlags__DataTypeMask ) ;
if ( ( ! allow_opt_inputs & & ! allow_opt_datatype ) | | ! BeginPopup ( " context " ) )
return ;
@ -4586,9 +4586,9 @@ void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags)
ImGuiColorEditFlags opts = g . ColorEditOptions ;
if ( allow_opt_inputs )
{
if ( RadioButton ( " RGB " , ( opts & ImGuiColorEditFlags_ RGB) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags__ Inputs Mask) | ImGuiColorEditFlags_ RGB;
if ( RadioButton ( " HSV " , ( opts & ImGuiColorEditFlags_ HSV) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags__ Inputs Mask) | ImGuiColorEditFlags_ HSV;
if ( RadioButton ( " HEX " , ( opts & ImGuiColorEditFlags_ HEX) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags__ Inputs Mask) | ImGuiColorEditFlags_ HEX;
if ( RadioButton ( " RGB " , ( opts & ImGuiColorEditFlags_ Show RGB) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags__ Show Mask) | ImGuiColorEditFlags_ Show RGB;
if ( RadioButton ( " HSV " , ( opts & ImGuiColorEditFlags_ Show HSV) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags__ Show Mask) | ImGuiColorEditFlags_ Show HSV;
if ( RadioButton ( " HEX " , ( opts & ImGuiColorEditFlags_ Show HEX) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags__ Show Mask) | ImGuiColorEditFlags_ Show HEX;
}
if ( allow_opt_datatype )
{