@ -1279,39 +1279,47 @@ void ImDrawList::PathBezierQuadraticCurveTo(const ImVec2& p2, const ImVec2& p3,
}
}
# ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
static inline ImDrawFlags FixDraw CornerFlags ( ImDrawFlags flags )
IM_STATIC_ASSERT ( ImDrawFlags_RoundCornersTopLeft = = ( 1 < < 4 ) ) ;
static inline ImDrawFlags FixRect CornerFlags ( ImDrawFlags flags )
{
// If any of following asserts triggers, please update your code replacing all uses of ImDrawCornerFlags_* with ImDrawFlags_*.
// Legacy Rule 1: Support for hard coded 0x0F or ~0 (used to be equivalent to ImDrawCornerFlags_All)
if ( flags = = ~ 0 | | flags = = 0x0F )
return 0 ;
# ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
// Legacy Support for hard coded ~0 (used to be a suggested equivalent to ImDrawCornerFlags_All)
// ~0 --> ImDrawFlags_RoundCornersAll or 0
if ( flags = = ~ 0 )
return ImDrawFlags_RoundCornersAll ;
// Legacy Support for hard coded 0x01 to 0x0F (matching 15 out of 16 old flags combinations)
// 0x01 --> ImDrawFlags_RoundCornersTopLeft (VALUE 0x01 OVERLAPS ImDrawFlags_Closed but ImDrawFlags_Closed is never valid in this path!)
// 0x02 --> ImDrawFlags_RoundCornersTopRight
// 0x03 --> ImDrawFlags_RoundCornersTopLeft | ImDrawFlags_RoundCornersTopRight
// 0x04 --> ImDrawFlags_RoundCornersBotLeft
// 0x05 --> ImDrawFlags_RoundCornersTopLeft | ImDrawFlags_RoundCornersBotLeft
// ...
// 0x0F --> ImDrawFlags_RoundCornersAll or 0
// (See all values in ImDrawCornerFlags_)
if ( flags > = 0x01 & & flags < = 0x0F )
return ( flags < < 4 ) ;
// We cannot support hard coded 0x00 with 'float rounding > 0.0f' --> replace with ImDrawFlags_RoundCornersNone or use 'float rounding = 0.0f'
# endif
// Legacy Rule 2: if any of old ImDrawCornerFlags flags, move them to corresponding positions of non-legacy flags and invert them.
if ( ( flags & ImDrawCornerFlags_All ) ! = 0 )
{
IM_ASSERT ( ( flags & ~ ImDrawCornerFlags_All ) = = 0 & & " Mixing legacy ImDrawCornerFlags and new ImDrawFlags is not allowed. " ) ;
IM_STATIC_ASSERT ( ( ImDrawCornerFlags_TopLeft > > 20 ) = = ImDrawFlags_NoRoundCornerTL ) ;
return ( flags > > 20 ) ^ ImDrawFlags_NoRoundCorners ;
}
// If this triggers, please update your code replacing hardcoded values with new ImDrawFlags_RoundCorners* values.
// Note that ImDrawFlags_Closed (== 0x01) is an invalid flag for AddRect(), AddRectFilled(), PathRect() etc...
IM_ASSERT ( ( flags & 0x0F ) = = 0 & & " Misuse of legacy hardcoded ImDrawCornerFlags values! " ) ;
if ( ( flags & ImDrawFlags_RoundCornersMask_ ) = = 0 )
flags | = ImDrawFlags_RoundCornersAll ;
// Bits 1..3 are unused, did you use old hard coded values?! In which case, check the old values in ImDrawCornerFlags_ definition.
// If you used ~0 or 0x0F you can now change them to 0 or ImDrawFlags_None.
IM_ASSERT ( ( flags & 0x0E ) = = 0 ) ;
return flags ;
}
# else
// Assert and return same value
# define FixDrawCornerFlags(FLAGS) (IM_ASSERT((FLAGS & 0x0E) == 0), FLAGS)
# endif
void ImDrawList : : PathRect ( const ImVec2 & a , const ImVec2 & b , float rounding , ImDrawFlags flags )
{
flags = FixDraw CornerFlags ( flags ) ;
rounding = ImMin ( rounding , ImFabs ( b . x - a . x ) * ( ( ( flags & ImDrawFlags_No RoundCornerT ) = = 0 ) | | ( ( flags & ImDrawFlags_No RoundCornerB ) = = 0 ) ? 0.5f : 1.0f ) - 1.0f ) ;
rounding = ImMin ( rounding , ImFabs ( b . y - a . y ) * ( ( ( flags & ImDrawFlags_No RoundCornerL ) = = 0 ) | | ( ( flags & ImDrawFlags_No RoundCornerR ) = = 0 ) ? 0.5f : 1.0f ) - 1.0f ) ;
flags = FixRectCornerFlags ( flags ) ;
rounding = ImMin ( rounding , ImFabs ( b . x - a . x ) * ( ( ( flags & ImDrawFlags_RoundCorners Top ) = = ImDrawFlags_RoundCornersTop ) | | ( ( flags & ImDrawFlags_RoundCorners Bottom ) = = ImDrawFlags_RoundCornersBottom ) ? 0.5f : 1.0f ) - 1.0f ) ;
rounding = ImMin ( rounding , ImFabs ( b . y - a . y ) * ( ( ( flags & ImDrawFlags_RoundCorners Left ) = = ImDrawFlags_RoundCornersLeft ) | | ( ( flags & ImDrawFlags_RoundCorners Right ) = = ImDrawFlags_RoundCornersRight ) ? 0.5f : 1.0f ) - 1.0f ) ;
if ( rounding < = 0.0f | | ( flags & ImDrawFlags_No RoundCorners ) = = ImDrawFlags_No RoundCorners )
if ( rounding < = 0.0f | | ( flags & ImDrawFlags_RoundCornersMask_ ) = = ImDrawFlags_RoundCornersNone )
{
PathLineTo ( a ) ;
PathLineTo ( ImVec2 ( b . x , a . y ) ) ;
@ -1320,10 +1328,10 @@ void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, ImDr
}
else
{
const float rounding_tl = ( flags & ImDrawFlags_NoRoundCornerTL ) ? 0.0f : rounding ;
const float rounding_tr = ( flags & ImDrawFlags_NoRoundCornerTR ) ? 0.0f : rounding ;
const float rounding_br = ( flags & ImDrawFlags_No RoundCornerBR ) ? 0.0f : rounding ;
const float rounding_bl = ( flags & ImDrawFlags_NoRoundCornerBL ) ? 0.0f : rounding ;
const float rounding_tl = ( flags & ImDrawFlags_RoundCornersTopLeft ) ? rounding : 0.0f ;
const float rounding_tr = ( flags & ImDrawFlags_RoundCornersTopRight ) ? rounding : 0.0f ;
const float rounding_br = ( flags & ImDrawFlags_RoundCorners Bottom Right ) ? rounding : 0.0f ;
const float rounding_bl = ( flags & ImDrawFlags_RoundCornersBottomLeft ) ? rounding : 0.0f ;
PathArcToFast ( ImVec2 ( a . x + rounding_tl , a . y + rounding_tl ) , rounding_tl , 6 , 9 ) ;
PathArcToFast ( ImVec2 ( b . x - rounding_tr , a . y + rounding_tr ) , rounding_tr , 9 , 12 ) ;
PathArcToFast ( ImVec2 ( b . x - rounding_br , b . y - rounding_br ) , rounding_br , 0 , 3 ) ;
@ -1357,15 +1365,15 @@ void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 c
{
if ( ( col & IM_COL32_A_MASK ) = = 0 )
return ;
if ( rounding > 0.0f & & ( flags & ImDrawFlags_NoRoundCorners ) ! = ImDrawFlags_No RoundCorners )
if ( rounding < = 0.0f | | ( flags & ImDrawFlags_RoundCornersMask_ ) = = ImDrawFlags_RoundCornersNone )
{
PathRect ( p_min , p_max , rounding , flags ) ;
PathFillConvex ( col ) ;
PrimReserve ( 6 , 4 ) ;
PrimRect ( p_min , p_max , col ) ;
}
else
{
PrimReserve ( 6 , 4 ) ;
PrimRect ( p_min , p_max , col ) ;
PathRect ( p_min , p_max , rounding , flags ) ;
PathFillConvex ( col ) ;
}
}
@ -1600,8 +1608,8 @@ void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_mi
if ( ( col & IM_COL32_A_MASK ) = = 0 )
return ;
flags = FixDraw CornerFlags ( flags ) ;
if ( rounding < = 0.0f | | ( flags & ImDrawFlags_No RoundCorners ) = = ImDrawFlags_No RoundCorners )
flags = FixRect CornerFlags ( flags ) ;
if ( rounding < = 0.0f | | ( flags & ImDrawFlags_RoundCornersMask_ ) = = ImDrawFlags_RoundCornersNone )
{
AddImage ( user_texture_id , p_min , p_max , uv_min , uv_max , col ) ;
return ;
@ -3842,14 +3850,14 @@ void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect
const bool fill_R = ( inner . Max . x < outer . Max . x ) ;
const bool fill_U = ( inner . Min . y > outer . Min . y ) ;
const bool fill_D = ( inner . Max . y < outer . Max . y ) ;
if ( fill_L ) draw_list - > AddRectFilled ( ImVec2 ( outer . Min . x , inner . Min . y ) , ImVec2 ( inner . Min . x , inner . Max . y ) , col , rounding , ( fill_U ? ImDrawFlags_NoRoundCornerTL : 0 ) | ( fill_D ? ImDrawFlags_NoRoundCornerBL : 0 ) ) ;
if ( fill_R ) draw_list - > AddRectFilled ( ImVec2 ( inner . Max . x , inner . Min . y ) , ImVec2 ( outer . Max . x , inner . Max . y ) , col , rounding , ( fill_U ? ImDrawFlags_NoRoundCornerTR : 0 ) | ( fill_D ? ImDrawFlags_NoRoundCornerBR : 0 ) ) ;
if ( fill_U ) draw_list - > AddRectFilled ( ImVec2 ( inner . Min . x , outer . Min . y ) , ImVec2 ( inner . Max . x , inner . Min . y ) , col , rounding , ( fill_L ? ImDrawFlags_NoRoundCornerTL : 0 ) | ( fill_R ? ImDrawFlags_NoRoundCornerTR : 0 ) ) ;
if ( fill_D ) draw_list - > AddRectFilled ( ImVec2 ( inner . Min . x , inner . Max . y ) , ImVec2 ( inner . Max . x , outer . Max . y ) , col , rounding , ( fill_L ? ImDrawFlags_NoRoundCornerBL : 0 ) | ( fill_R ? ImDrawFlags_NoRoundCornerBR : 0 ) ) ;
if ( fill_L & & fill_U ) draw_list - > AddRectFilled ( ImVec2 ( outer . Min . x , outer . Min . y ) , ImVec2 ( inner . Min . x , inner . Min . y ) , col , rounding , ImDrawFlags_NoRoundCornerB | ImDrawFlags_NoRoundCornerTR ) ;
if ( fill_R & & fill_U ) draw_list - > AddRectFilled ( ImVec2 ( inner . Max . x , outer . Min . y ) , ImVec2 ( outer . Max . x , inner . Min . y ) , col , rounding , ImDrawFlags_NoRoundCornerB | ImDrawFlags_NoRoundCornerTL ) ;
if ( fill_L & & fill_D ) draw_list - > AddRectFilled ( ImVec2 ( outer . Min . x , inner . Max . y ) , ImVec2 ( inner . Min . x , outer . Max . y ) , col , rounding , ImDrawFlags_NoRoundCornerT | ImDrawFlags_NoRoundCornerBR ) ;
if ( fill_R & & fill_D ) draw_list - > AddRectFilled ( ImVec2 ( inner . Max . x , inner . Max . y ) , ImVec2 ( outer . Max . x , outer . Max . y ) , col , rounding , ImDrawFlags_NoRoundCornerT | ImDrawFlags_NoRoundCornerBL ) ;
if ( fill_L ) draw_list - > AddRectFilled ( ImVec2 ( outer . Min . x , inner . Min . y ) , ImVec2 ( inner . Min . x , inner . Max . y ) , col , rounding , ( fill_U ? 0 : ImDrawFlags_RoundCornersTopLeft ) | ( fill_D ? 0 : ImDrawFlags_RoundCornersBottomLeft ) ) ;
if ( fill_R ) draw_list - > AddRectFilled ( ImVec2 ( inner . Max . x , inner . Min . y ) , ImVec2 ( outer . Max . x , inner . Max . y ) , col , rounding , ( fill_U ? 0 : ImDrawFlags_RoundCornersTopRight ) | ( fill_D ? 0 : ImDrawFlags_RoundCornersBottomRight ) ) ;
if ( fill_U ) draw_list - > AddRectFilled ( ImVec2 ( inner . Min . x , outer . Min . y ) , ImVec2 ( inner . Max . x , inner . Min . y ) , col , rounding , ( fill_L ? 0 : ImDrawFlags_RoundCornersTopLeft ) | ( fill_R ? 0 : ImDrawFlags_RoundCornersTopRight ) ) ;
if ( fill_D ) draw_list - > AddRectFilled ( ImVec2 ( inner . Min . x , inner . Max . y ) , ImVec2 ( inner . Max . x , outer . Max . y ) , col , rounding , ( fill_L ? 0 : ImDrawFlags_RoundCornersBottomLeft ) | ( fill_R ? 0 : ImDrawFlags_RoundCornersBottomRight ) ) ;
if ( fill_L & & fill_U ) draw_list - > AddRectFilled ( ImVec2 ( outer . Min . x , outer . Min . y ) , ImVec2 ( inner . Min . x , inner . Min . y ) , col , rounding , ImDrawFlags_RoundCornersTopLeft ) ;
if ( fill_R & & fill_U ) draw_list - > AddRectFilled ( ImVec2 ( inner . Max . x , outer . Min . y ) , ImVec2 ( outer . Max . x , inner . Min . y ) , col , rounding , ImDrawFlags_RoundCornersTopRight ) ;
if ( fill_L & & fill_D ) draw_list - > AddRectFilled ( ImVec2 ( outer . Min . x , inner . Max . y ) , ImVec2 ( inner . Min . x , outer . Max . y ) , col , rounding , ImDrawFlags_RoundCornersBottomLeft ) ;
if ( fill_R & & fill_D ) draw_list - > AddRectFilled ( ImVec2 ( inner . Max . x , inner . Max . y ) , ImVec2 ( outer . Max . x , outer . Max . y ) , col , rounding , ImDrawFlags_RoundCornersBottomRight ) ;
}
// Helper for ColorPicker4()
@ -3858,10 +3866,12 @@ void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect
// FIXME: uses ImGui::GetColorU32
void ImGui : : RenderColorRectWithAlphaCheckerboard ( ImDrawList * draw_list , ImVec2 p_min , ImVec2 p_max , ImU32 col , float grid_step , ImVec2 grid_off , float rounding , ImDrawFlags flags )
{
if ( ( flags & ImDrawFlags_RoundCornersMask_ ) = = 0 )
flags = ImDrawFlags_RoundCornersDefault_ ;
if ( ( ( col & IM_COL32_A_MASK ) > > IM_COL32_A_SHIFT ) < 0xFF )
{
ImU32 col_bg1 = ImGui : : GetColorU32 ( ImAlphaBlendColors ( IM_COL32 ( 204 , 204 , 204 , 255 ) , col ) ) ;
ImU32 col_bg2 = ImGui : : GetColorU32 ( ImAlphaBlendColors ( IM_COL32 ( 128 , 128 , 128 , 255 ) , col ) ) ;
ImU32 col_bg1 = GetColorU32 ( ImAlphaBlendColors ( IM_COL32 ( 204 , 204 , 204 , 255 ) , col ) ) ;
ImU32 col_bg2 = GetColorU32 ( ImAlphaBlendColors ( IM_COL32 ( 128 , 128 , 128 , 255 ) , col ) ) ;
draw_list - > AddRectFilled ( p_min , p_max , col_bg1 , rounding , flags ) ;
int yi = 0 ;
@ -3875,10 +3885,12 @@ void ImGui::RenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list, ImVec2 p
float x1 = ImClamp ( x , p_min . x , p_max . x ) , x2 = ImMin ( x + grid_step , p_max . x ) ;
if ( x2 < = x1 )
continue ;
ImDrawFlags cell_flags = ImDrawFlags_NoRoundCorners ;
if ( y1 < = p_min . y ) { if ( x1 < = p_min . x ) cell_flags & = ~ ImDrawFlags_NoRoundCornerTL ; if ( x2 > = p_max . x ) cell_flags & = ~ ImDrawFlags_NoRoundCornerTR ; }
if ( y2 > = p_max . y ) { if ( x1 < = p_min . x ) cell_flags & = ~ ImDrawFlags_NoRoundCornerBL ; if ( x2 > = p_max . x ) cell_flags & = ~ ImDrawFlags_NoRoundCornerBR ; }
cell_flags | = flags ;
ImDrawFlags cell_flags = ImDrawFlags_RoundCornersNone ;
if ( y1 < = p_min . y ) { if ( x1 < = p_min . x ) cell_flags | = ImDrawFlags_RoundCornersTopLeft ; if ( x2 > = p_max . x ) cell_flags | = ImDrawFlags_RoundCornersTopRight ; }
if ( y2 > = p_max . y ) { if ( x1 < = p_min . x ) cell_flags | = ImDrawFlags_RoundCornersBottomLeft ; if ( x2 > = p_max . x ) cell_flags | = ImDrawFlags_RoundCornersBottomRight ; }
// Combine flags
cell_flags = ( flags = = ImDrawFlags_RoundCornersNone | | cell_flags = = ImDrawFlags_RoundCornersNone ) ? ImDrawFlags_RoundCornersNone : ( cell_flags & flags ) ;
draw_list - > AddRectFilled ( ImVec2 ( x1 , y1 ) , ImVec2 ( x2 , y2 ) , col_bg2 , rounding , cell_flags ) ;
}
}