@ -4777,24 +4777,24 @@ 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_ _ DisplayMask) ) | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_NoOptions ;
flags = ( flags & ( ~ ImGuiColorEditFlags_ DisplayMask_ ) ) | ImGuiColorEditFlags_DisplayRGB | 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_ _ DisplayMask) )
flags | = ( g . ColorEditOptions & ImGuiColorEditFlags_ _ DisplayMask) ;
if ( ! ( flags & ImGuiColorEditFlags_ _ DataTypeMask) )
flags | = ( g . ColorEditOptions & ImGuiColorEditFlags_ _ DataTypeMask) ;
if ( ! ( flags & ImGuiColorEditFlags_ _ PickerMask) )
flags | = ( g . ColorEditOptions & ImGuiColorEditFlags_ _ PickerMask) ;
if ( ! ( flags & ImGuiColorEditFlags_ _ InputMask) )
flags | = ( g . ColorEditOptions & ImGuiColorEditFlags_ _ InputMask) ;
flags | = ( g . ColorEditOptions & ~ ( ImGuiColorEditFlags_ _ DisplayMask | ImGuiColorEditFlags_ _ DataTypeMask | ImGuiColorEditFlags_ _ PickerMask | ImGuiColorEditFlags_ _ InputMask) ) ;
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiColorEditFlags_ _ DisplayMask) ) ; // Check that only 1 is selected
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiColorEditFlags_ _ InputMask) ) ; // Check that only 1 is selected
if ( ! ( flags & ImGuiColorEditFlags_ DisplayMask_ ) )
flags | = ( g . ColorEditOptions & ImGuiColorEditFlags_ DisplayMask_ ) ;
if ( ! ( flags & ImGuiColorEditFlags_ DataTypeMask_ ) )
flags | = ( g . ColorEditOptions & ImGuiColorEditFlags_ DataTypeMask_ ) ;
if ( ! ( flags & ImGuiColorEditFlags_ PickerMask_ ) )
flags | = ( g . ColorEditOptions & ImGuiColorEditFlags_ PickerMask_ ) ;
if ( ! ( flags & ImGuiColorEditFlags_ InputMask_ ) )
flags | = ( g . ColorEditOptions & ImGuiColorEditFlags_ InputMask_ ) ;
flags | = ( g . ColorEditOptions & ~ ( ImGuiColorEditFlags_ DisplayMask_ | ImGuiColorEditFlags_ DataTypeMask_ | ImGuiColorEditFlags_ PickerMask_ | ImGuiColorEditFlags_ InputMask_ ) ) ;
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiColorEditFlags_ DisplayMask_ ) ) ; // Check that only 1 is selected
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiColorEditFlags_ InputMask_ ) ) ; // Check that only 1 is selected
const bool alpha = ( flags & ImGuiColorEditFlags_NoAlpha ) = = 0 ;
const bool hdr = ( flags & ImGuiColorEditFlags_HDR ) ! = 0 ;
@ -4923,8 +4923,8 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
TextEx ( label , label_display_end ) ;
Spacing ( ) ;
}
ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags_ _ DataTypeMask | ImGuiColorEditFlags _ _PickerMask | ImGuiColorEditFlags_ _ InputMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar ;
ImGuiColorEditFlags picker_flags = ( flags_untouched & picker_flags_to_forward ) | ImGuiColorEditFlags_ _ DisplayMask | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf ;
ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags_ DataTypeMask_ | ImGuiColorEditFlags _PickerMask_ | ImGuiColorEditFlags_ InputMask_ | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar ;
ImGuiColorEditFlags picker_flags = ( flags_untouched & picker_flags_to_forward ) | ImGuiColorEditFlags_ DisplayMask_ | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf ;
SetNextItemWidth ( square_sz * 12.0f ) ; // Use 256 + bar sizes?
value_changed | = ColorPicker4 ( " ##picker " , col , picker_flags , & g . ColorPickerRef . x ) ;
EndPopup ( ) ;
@ -5044,12 +5044,12 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
ColorPickerOptionsPopup ( col , flags ) ;
// Read stored options
if ( ! ( flags & ImGuiColorEditFlags_ _ PickerMask) )
flags | = ( ( g . ColorEditOptions & ImGuiColorEditFlags_ _ PickerMask) ? g . ColorEditOptions : ImGuiColorEditFlags_ _Options Default) & ImGuiColorEditFlags_ _ PickerMask;
if ( ! ( flags & ImGuiColorEditFlags_ _ InputMask) )
flags | = ( ( g . ColorEditOptions & ImGuiColorEditFlags_ _ InputMask) ? g . ColorEditOptions : ImGuiColorEditFlags_ _Options Default) & ImGuiColorEditFlags_ _ InputMask;
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiColorEditFlags_ _ PickerMask) ) ; // Check that only 1 is selected
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiColorEditFlags_ _ InputMask) ) ; // Check that only 1 is selected
if ( ! ( flags & ImGuiColorEditFlags_ PickerMask_ ) )
flags | = ( ( g . ColorEditOptions & ImGuiColorEditFlags_ PickerMask_ ) ? g . ColorEditOptions : ImGuiColorEditFlags_ DefaultOptions_ ) & ImGuiColorEditFlags_ PickerMask_ ;
if ( ! ( flags & ImGuiColorEditFlags_ InputMask_ ) )
flags | = ( ( g . ColorEditOptions & ImGuiColorEditFlags_ InputMask_ ) ? g . ColorEditOptions : ImGuiColorEditFlags_ DefaultOptions_ ) & ImGuiColorEditFlags_ InputMask_ ;
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiColorEditFlags_ PickerMask_ ) ) ; // Check that only 1 is selected
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiColorEditFlags_ InputMask_ ) ) ; // Check that only 1 is selected
if ( ! ( flags & ImGuiColorEditFlags_NoOptions ) )
flags | = ( g . ColorEditOptions & ImGuiColorEditFlags_AlphaBar ) ;
@ -5195,7 +5195,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
if ( ( flags & ImGuiColorEditFlags_NoLabel ) )
Text ( " Current " ) ;
ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags_ _ InputMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf | ImGuiColorEditFlags_NoTooltip ;
ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags_ InputMask_ | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf | ImGuiColorEditFlags_NoTooltip ;
ColorButton ( " ##current " , col_v4 , ( flags & sub_flags_to_forward ) , ImVec2 ( square_sz * 3 , square_sz * 2 ) ) ;
if ( ref_col ! = NULL )
{
@ -5234,9 +5234,9 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
if ( ( flags & ImGuiColorEditFlags_NoInputs ) = = 0 )
{
PushItemWidth ( ( alpha_bar ? bar1_pos_x : bar0_pos_x ) + bars_width - picker_pos . x ) ;
ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags_ _ DataTypeMask | ImGuiColorEditFlags_ _ InputMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoSmallPreview | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf ;
ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags_ DataTypeMask_ | ImGuiColorEditFlags_ InputMask_ | 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_DisplayRGB | | ( flags & ImGuiColorEditFlags_ _ DisplayMask) = = 0 )
if ( flags & ImGuiColorEditFlags_DisplayRGB | | ( flags & ImGuiColorEditFlags_ DisplayMask_ ) = = 0 )
if ( ColorEdit4 ( " ##rgb " , col , sub_flags | ImGuiColorEditFlags_DisplayRGB ) )
{
// FIXME: Hackily differentiating using the DragInt (ActiveId != 0 && !ActiveIdAllowOverlap) vs. using the InputText or DropTarget.
@ -5244,9 +5244,9 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
value_changed_fix_hue_wrap = ( g . ActiveId ! = 0 & & ! g . ActiveIdAllowOverlap ) ;
value_changed = true ;
}
if ( flags & ImGuiColorEditFlags_DisplayHSV | | ( flags & ImGuiColorEditFlags_ _ DisplayMask) = = 0 )
if ( flags & ImGuiColorEditFlags_DisplayHSV | | ( flags & ImGuiColorEditFlags_ DisplayMask_ ) = = 0 )
value_changed | = ColorEdit4 ( " ##hsv " , col , sub_flags | ImGuiColorEditFlags_DisplayHSV ) ;
if ( flags & ImGuiColorEditFlags_DisplayHex | | ( flags & ImGuiColorEditFlags_ _ DisplayMask) = = 0 )
if ( flags & ImGuiColorEditFlags_DisplayHex | | ( flags & ImGuiColorEditFlags_ DisplayMask_ ) = = 0 )
value_changed | = ColorEdit4 ( " ##hex " , col , sub_flags | ImGuiColorEditFlags_DisplayHex ) ;
PopItemWidth ( ) ;
}
@ -5476,7 +5476,7 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
// Tooltip
if ( ! ( flags & ImGuiColorEditFlags_NoTooltip ) & & hovered )
ColorTooltip ( desc_id , & col . x , flags & ( ImGuiColorEditFlags_ _ InputMask | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf ) ) ;
ColorTooltip ( desc_id , & col . x , flags & ( ImGuiColorEditFlags_ InputMask_ | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf ) ) ;
return pressed ;
}
@ -5485,18 +5485,18 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
void ImGui : : SetColorEditOptions ( ImGuiColorEditFlags flags )
{
ImGuiContext & g = * GImGui ;
if ( ( flags & ImGuiColorEditFlags_ _ DisplayMask) = = 0 )
flags | = ImGuiColorEditFlags_ _Options Default & ImGuiColorEditFlags_ _ DisplayMask;
if ( ( flags & ImGuiColorEditFlags_ _ DataTypeMask) = = 0 )
flags | = ImGuiColorEditFlags_ _Options Default & ImGuiColorEditFlags_ _ DataTypeMask;
if ( ( flags & ImGuiColorEditFlags_ _ PickerMask) = = 0 )
flags | = ImGuiColorEditFlags_ _Options Default & ImGuiColorEditFlags_ _ PickerMask;
if ( ( flags & ImGuiColorEditFlags_ _ InputMask) = = 0 )
flags | = ImGuiColorEditFlags_ _Options Default & ImGuiColorEditFlags_ _ InputMask;
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiColorEditFlags_ _ DisplayMask) ) ; // Check only 1 option is selected
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiColorEditFlags_ _ DataTypeMask) ) ; // Check only 1 option is selected
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiColorEditFlags_ _ PickerMask) ) ; // Check only 1 option is selected
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiColorEditFlags_ _ InputMask) ) ; // Check only 1 option is selected
if ( ( flags & ImGuiColorEditFlags_ DisplayMask_ ) = = 0 )
flags | = ImGuiColorEditFlags_ DefaultOptions_ & ImGuiColorEditFlags_ DisplayMask_ ;
if ( ( flags & ImGuiColorEditFlags_ DataTypeMask_ ) = = 0 )
flags | = ImGuiColorEditFlags_ DefaultOptions_ & ImGuiColorEditFlags_ DataTypeMask_ ;
if ( ( flags & ImGuiColorEditFlags_ PickerMask_ ) = = 0 )
flags | = ImGuiColorEditFlags_ DefaultOptions_ & ImGuiColorEditFlags_ PickerMask_ ;
if ( ( flags & ImGuiColorEditFlags_ InputMask_ ) = = 0 )
flags | = ImGuiColorEditFlags_ DefaultOptions_ & ImGuiColorEditFlags_ InputMask_ ;
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiColorEditFlags_ DisplayMask_ ) ) ; // Check only 1 option is selected
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiColorEditFlags_ DataTypeMask_ ) ) ; // Check only 1 option is selected
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiColorEditFlags_ PickerMask_ ) ) ; // Check only 1 option is selected
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiColorEditFlags_ InputMask_ ) ) ; // Check only 1 option is selected
g . ColorEditOptions = flags ;
}
@ -5516,9 +5516,9 @@ void ImGui::ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags
ImVec2 sz ( g . FontSize * 3 + g . Style . FramePadding . y * 2 , g . FontSize * 3 + g . Style . FramePadding . y * 2 ) ;
ImVec4 cf ( col [ 0 ] , col [ 1 ] , col [ 2 ] , ( flags & ImGuiColorEditFlags_NoAlpha ) ? 1.0f : col [ 3 ] ) ;
int cr = IM_F32_TO_INT8_SAT ( col [ 0 ] ) , cg = IM_F32_TO_INT8_SAT ( col [ 1 ] ) , cb = IM_F32_TO_INT8_SAT ( col [ 2 ] ) , ca = ( flags & ImGuiColorEditFlags_NoAlpha ) ? 255 : IM_F32_TO_INT8_SAT ( col [ 3 ] ) ;
ColorButton ( " ##preview " , cf , ( flags & ( ImGuiColorEditFlags_ _ InputMask | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf ) ) | ImGuiColorEditFlags_NoTooltip , sz ) ;
ColorButton ( " ##preview " , cf , ( flags & ( ImGuiColorEditFlags_ InputMask_ | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf ) ) | ImGuiColorEditFlags_NoTooltip , sz ) ;
SameLine ( ) ;
if ( ( flags & ImGuiColorEditFlags_InputRGB ) | | ! ( flags & ImGuiColorEditFlags_ _ InputMask) )
if ( ( flags & ImGuiColorEditFlags_InputRGB ) | | ! ( flags & ImGuiColorEditFlags_ InputMask_ ) )
{
if ( flags & ImGuiColorEditFlags_NoAlpha )
Text ( " #%02X%02X%02X \n R: %d, G: %d, B: %d \n (%.3f, %.3f, %.3f) " , cr , cg , cb , cr , cg , cb , col [ 0 ] , col [ 1 ] , col [ 2 ] ) ;
@ -5537,23 +5537,23 @@ void ImGui::ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags
void ImGui : : ColorEditOptionsPopup ( const float * col , ImGuiColorEditFlags flags )
{
bool allow_opt_inputs = ! ( flags & ImGuiColorEditFlags_ _ DisplayMask) ;
bool allow_opt_datatype = ! ( flags & ImGuiColorEditFlags_ _ DataTypeMask) ;
bool allow_opt_inputs = ! ( flags & ImGuiColorEditFlags_ DisplayMask_ ) ;
bool allow_opt_datatype = ! ( flags & ImGuiColorEditFlags_ DataTypeMask_ ) ;
if ( ( ! allow_opt_inputs & & ! allow_opt_datatype ) | | ! BeginPopup ( " context " ) )
return ;
ImGuiContext & g = * GImGui ;
ImGuiColorEditFlags opts = g . ColorEditOptions ;
if ( allow_opt_inputs )
{
if ( RadioButton ( " RGB " , ( opts & ImGuiColorEditFlags_DisplayRGB ) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags_ _ DisplayMask) | ImGuiColorEditFlags_DisplayRGB ;
if ( RadioButton ( " HSV " , ( opts & ImGuiColorEditFlags_DisplayHSV ) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags_ _ DisplayMask) | ImGuiColorEditFlags_DisplayHSV ;
if ( RadioButton ( " Hex " , ( opts & ImGuiColorEditFlags_DisplayHex ) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags_ _ DisplayMask) | ImGuiColorEditFlags_DisplayHex ;
if ( RadioButton ( " RGB " , ( opts & ImGuiColorEditFlags_DisplayRGB ) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags_ DisplayMask_ ) | ImGuiColorEditFlags_DisplayRGB ;
if ( RadioButton ( " HSV " , ( opts & ImGuiColorEditFlags_DisplayHSV ) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags_ DisplayMask_ ) | ImGuiColorEditFlags_DisplayHSV ;
if ( RadioButton ( " Hex " , ( opts & ImGuiColorEditFlags_DisplayHex ) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags_ DisplayMask_ ) | ImGuiColorEditFlags_DisplayHex ;
}
if ( allow_opt_datatype )
{
if ( allow_opt_inputs ) Separator ( ) ;
if ( RadioButton ( " 0..255 " , ( opts & ImGuiColorEditFlags_Uint8 ) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags_ _ DataTypeMask) | ImGuiColorEditFlags_Uint8 ;
if ( RadioButton ( " 0.00..1.00 " , ( opts & ImGuiColorEditFlags_Float ) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags_ _ DataTypeMask) | ImGuiColorEditFlags_Float ;
if ( RadioButton ( " 0..255 " , ( opts & ImGuiColorEditFlags_Uint8 ) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags_ DataTypeMask_ ) | ImGuiColorEditFlags_Uint8 ;
if ( RadioButton ( " 0.00..1.00 " , ( opts & ImGuiColorEditFlags_Float ) ! = 0 ) ) opts = ( opts & ~ ImGuiColorEditFlags_ DataTypeMask_ ) | ImGuiColorEditFlags_Float ;
}
if ( allow_opt_inputs | | allow_opt_datatype )
@ -5588,7 +5588,7 @@ void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags)
void ImGui : : ColorPickerOptionsPopup ( const float * ref_col , ImGuiColorEditFlags flags )
{
bool allow_opt_picker = ! ( flags & ImGuiColorEditFlags_ _ PickerMask) ;
bool allow_opt_picker = ! ( flags & ImGuiColorEditFlags_ PickerMask_ ) ;
bool allow_opt_alpha_bar = ! ( flags & ImGuiColorEditFlags_NoAlpha ) & & ! ( flags & ImGuiColorEditFlags_AlphaBar ) ;
if ( ( ! allow_opt_picker & & ! allow_opt_alpha_bar ) | | ! BeginPopup ( " context " ) )
return ;
@ -5607,7 +5607,7 @@ void ImGui::ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags fl
if ( picker_type = = 1 ) picker_flags | = ImGuiColorEditFlags_PickerHueWheel ;
ImVec2 backup_pos = GetCursorScreenPos ( ) ;
if ( Selectable ( " ##selectable " , false , 0 , picker_size ) ) // By default, Selectable() is closing popup
g . ColorEditOptions = ( g . ColorEditOptions & ~ ImGuiColorEditFlags_ _ PickerMask) | ( picker_flags & ImGuiColorEditFlags_ _ PickerMask) ;
g . ColorEditOptions = ( g . ColorEditOptions & ~ ImGuiColorEditFlags_ PickerMask_ ) | ( picker_flags & ImGuiColorEditFlags_ PickerMask_ ) ;
SetCursorScreenPos ( backup_pos ) ;
ImVec4 previewing_ref_col ;
memcpy ( & previewing_ref_col , ref_col , sizeof ( float ) * ( ( picker_flags & ImGuiColorEditFlags_NoAlpha ) ? 3 : 4 ) ) ;