@ -9281,15 +9281,18 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
ImVec4 col_without_alpha ( col . x , col . y , col . z , 1.0f ) ;
ImVec4 col_without_alpha ( col . x , col . y , col . z , 1.0f ) ;
float grid_step = ImMin ( size . x , size . y ) / 2.99f ;
float grid_step = ImMin ( size . x , size . y ) / 2.99f ;
float rounding = ImMin ( g . Style . FrameRounding , grid_step * 0.5f ) ;
float rounding = ImMin ( g . Style . FrameRounding , grid_step * 0.5f ) ;
ImRect bb_inner = bb ;
float off = - 0.75f ; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middleground to reduce those artefacts.
bb_inner . Expand ( off ) ;
if ( ( flags & ImGuiColorEditFlags_AlphaPreviewHalf ) & & col . w < 1.0f )
if ( ( flags & ImGuiColorEditFlags_AlphaPreviewHalf ) & & col . w < 1.0f )
{
{
float mid_x = ( float ) ( int ) ( ( bb . Min . x + bb . Max . x ) * 0.5f + 0.5f ) ;
float mid_x = ( float ) ( int ) ( ( bb _inner . Min . x + bb _inner . Max . x ) * 0.5f + 0.5f ) ;
RenderColorRectWithAlphaCheckerboard ( ImVec2 ( bb . Min . x + grid_step , bb . Min . y ) , bb . Max , GetColorU32 ( col ) , grid_step , ImVec2 ( - grid_step , 0.0 f) , rounding , ImGuiCorner_TopRight | ImGuiCorner_BotRight ) ;
RenderColorRectWithAlphaCheckerboard ( ImVec2 ( bb _inner . Min . x + grid_step , bb _inner . Min . y ) , bb _inner . Max , GetColorU32 ( col ) , grid_step , ImVec2 ( - grid_step + off , of f) , rounding , ImGuiCorner_TopRight | ImGuiCorner_BotRight ) ;
window - > DrawList - > AddRectFilled ( bb . Min , ImVec2 ( mid_x , bb . Max . y ) , GetColorU32 ( col_without_alpha ) , rounding , ImGuiCorner_TopLeft | ImGuiCorner_BotLeft ) ;
window - > DrawList - > AddRectFilled ( bb _inner . Min , ImVec2 ( mid_x , bb _inner . Max . y ) , GetColorU32 ( col_without_alpha ) , rounding , ImGuiCorner_TopLeft | ImGuiCorner_BotLeft ) ;
}
}
else
else
{
{
RenderColorRectWithAlphaCheckerboard ( bb . Min , bb . Max , GetColorU32 ( ( flags & ImGuiColorEditFlags_AlphaPreview ) ? col : col_without_alpha ) , grid_step , ImVec2 ( 0 , 0 ) , rounding ) ;
RenderColorRectWithAlphaCheckerboard ( bb _inner . Min , bb _inner . Max , GetColorU32 ( ( flags & ImGuiColorEditFlags_AlphaPreview ) ? col : col_without_alpha ) , grid_step , ImVec2 ( off , off ) , rounding ) ;
}
}
if ( window - > Flags & ImGuiWindowFlags_ShowBorders )
if ( window - > Flags & ImGuiWindowFlags_ShowBorders )
RenderFrameBorder ( bb . Min , bb . Max , rounding ) ;
RenderFrameBorder ( bb . Min , bb . Max , rounding ) ;