@ -1285,39 +1285,47 @@ void ImDrawList::PathBezierQuadraticCurveTo(const ImVec2& p2, const ImVec2& p3,
}
}
}
}
# ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
IM_STATIC_ASSERT ( ImDrawFlags_RoundCornersTopLeft = = ( 1 < < 4 ) ) ;
static inline ImDrawFlags Fix Draw CornerFlags( ImDrawFlags flags )
static inline ImDrawFlags Fix Rect CornerFlags( ImDrawFlags flags )
{
{
// If any of following asserts triggers, please update your code replacing all uses of ImDrawCornerFlags_* with ImDrawFlags_*.
# ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
// Legacy Rule 1: Support for hard coded 0x0F or ~0 (used to be equivalent to ImDrawCornerFlags_All)
// Legacy Support for hard coded ~0 (used to be a suggested equivalent to ImDrawCornerFlags_All)
if ( flags = = ~ 0 | | flags = = 0x0F )
// ~0 --> ImDrawFlags_RoundCornersAll or 0
return 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 this triggers, please update your code replacing hardcoded values with new ImDrawFlags_RoundCorners* values.
if ( ( flags & ImDrawCornerFlags_All ) ! = 0 )
// 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! " ) ;
IM_ASSERT ( ( flags & ~ ImDrawCornerFlags_All ) = = 0 & & " Mixing legacy ImDrawCornerFlags and new ImDrawFlags is not allowed. " ) ;
IM_STATIC_ASSERT ( ( ImDrawCornerFlags_TopLeft > > 20 ) = = ImDrawFlags_NoRoundCornerTL ) ;
if ( ( flags & ImDrawFlags_RoundCornersMask_ ) = = 0 )
return ( flags > > 20 ) ^ ImDrawFlags_NoRoundCorners ;
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 ;
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 )
void ImDrawList : : PathRect ( const ImVec2 & a , const ImVec2 & b , float rounding , ImDrawFlags flags )
{
{
flags = Fix Draw CornerFlags( flags ) ;
flags = FixRectCornerFlags ( flags ) ;
rounding = ImMin ( rounding , ImFabs ( b . x - a . x ) * ( ( ( flags & ImDrawFlags_ NoRoundCornerT) = = 0 ) | | ( ( flags & ImDrawFlags_NoRoundCornerB ) = = 0 ) ? 0.5f : 1.0f ) - 1.0f ) ;
rounding = ImMin ( rounding , ImFabs ( b . x - a . x ) * ( ( ( flags & ImDrawFlags_ RoundCornersTop) = = ImDrawFlags_RoundCornersTop ) | | ( ( flags & ImDrawFlags_RoundCornersBottom ) = = ImDrawFlags_RoundCornersBottom ) ? 0.5f : 1.0f ) - 1.0f ) ;
rounding = ImMin ( rounding , ImFabs ( b . y - a . y ) * ( ( ( flags & ImDrawFlags_ NoRoundCornerL) = = 0 ) | | ( ( flags & ImDrawFlags_NoRoundCornerR ) = = 0 ) ? 0.5f : 1.0f ) - 1.0f ) ;
rounding = ImMin ( rounding , ImFabs ( b . y - a . y ) * ( ( ( flags & ImDrawFlags_ RoundCornersLeft) = = ImDrawFlags_RoundCornersLeft ) | | ( ( flags & ImDrawFlags_RoundCornersRight ) = = 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 ( a ) ;
PathLineTo ( ImVec2 ( b . x , a . y ) ) ;
PathLineTo ( ImVec2 ( b . x , a . y ) ) ;
@ -1326,10 +1334,10 @@ void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, ImDr
}
}
else
else
{
{
const float rounding_tl = ( flags & ImDrawFlags_ NoRoundCornerTL) ? 0.0f : rounding ;
const float rounding_tl = ( flags & ImDrawFlags_ RoundCornersTopLeft) ? rounding : 0.0f ;
const float rounding_tr = ( flags & ImDrawFlags_ NoRoundCornerTR) ? 0.0f : rounding ;
const float rounding_tr = ( flags & ImDrawFlags_ RoundCornersTopRight) ? rounding : 0.0f ;
const float rounding_br = ( flags & ImDrawFlags_ NoRoundCornerBR) ? 0.0f : rounding ;
const float rounding_br = ( flags & ImDrawFlags_ RoundCornersBottomRight) ? rounding : 0.0f ;
const float rounding_bl = ( flags & ImDrawFlags_ NoRoundCornerBL) ? 0.0f : rounding ;
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 ( 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_tr , a . y + rounding_tr ) , rounding_tr , 9 , 12 ) ;
PathArcToFast ( ImVec2 ( b . x - rounding_br , b . y - rounding_br ) , rounding_br , 0 , 3 ) ;
PathArcToFast ( ImVec2 ( b . x - rounding_br , b . y - rounding_br ) , rounding_br , 0 , 3 ) ;
@ -1363,15 +1371,15 @@ void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 c
{
{
if ( ( col & IM_COL32_A_MASK ) = = 0 )
if ( ( col & IM_COL32_A_MASK ) = = 0 )
return ;
return ;
if ( rounding > 0.0f & & ( flags & ImDrawFlags_NoRoundCorners ) ! = ImDrawFlags_NoRoundCorners )
if ( rounding <= 0.0f | | ( flags & ImDrawFlags_RoundCornersMask_ ) = = ImDrawFlags_RoundCornersNone )
{
{
P athRect( p_min , p_max , rounding , flags ) ;
P rimReserve( 6 , 4 ) ;
P athFillConvex( col ) ;
P rimRect( p_min , p_max , col ) ;
}
}
else
else
{
{
P rimReserve( 6 , 4 ) ;
P athRect( p_min , p_max , rounding , flags ) ;
P rimRect( p_min , p_max , col ) ;
P athFillConvex( col ) ;
}
}
}
}
@ -1606,8 +1614,8 @@ void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_mi
if ( ( col & IM_COL32_A_MASK ) = = 0 )
if ( ( col & IM_COL32_A_MASK ) = = 0 )
return ;
return ;
flags = Fix Draw CornerFlags( flags ) ;
flags = Fix Rect CornerFlags( flags ) ;
if ( rounding < = 0.0f | | ( flags & ImDrawFlags_ No RoundCorners) = = ImDrawFlags_ No RoundCorners)
if ( rounding < = 0.0f | | ( flags & ImDrawFlags_ RoundCornersMask_ ) = = ImDrawFlags_ RoundCornersNone )
{
{
AddImage ( user_texture_id , p_min , p_max , uv_min , uv_max , col ) ;
AddImage ( user_texture_id , p_min , p_max , uv_min , uv_max , col ) ;
return ;
return ;
@ -3858,14 +3866,14 @@ void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect
const bool fill_R = ( inner . Max . x < outer . Max . x ) ;
const bool fill_R = ( inner . Max . x < outer . Max . x ) ;
const bool fill_U = ( inner . Min . y > outer . Min . y ) ;
const bool fill_U = ( inner . Min . y > outer . Min . y ) ;
const bool fill_D = ( inner . Max . y < outer . Max . 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_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 ? ImDrawFlags_NoRoundCornerTR : 0 ) | ( fill_D ? ImDrawFlags_NoRoundCornerBR : 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 ? 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 ? ImDrawFlags_NoRoundCornerTL : 0 ) | ( fill_R ? ImDrawFlags_NoRoundCornerTR : 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 ? 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 ? ImDrawFlags_NoRoundCornerBL : 0 ) | ( fill_R ? ImDrawFlags_NoRoundCornerBR : 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 ? 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_ NoRoundCornerB | ImDrawFlags_NoRoundCornerTR ) ;
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_ NoRoundCornerB | ImDrawFlags_NoRoundCornerTL ) ;
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_ NoRoundCornerT | ImDrawFlags_NoRoundCornerBR ) ;
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_ NoRoundCornerT | ImDrawFlags_NoRoundCornerBL ) ;
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()
// Helper for ColorPicker4()
@ -3874,10 +3882,12 @@ void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect
// FIXME: uses ImGui::GetColorU32
// 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 )
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 )
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_bg1 = GetColorU32( ImAlphaBlendColors ( IM_COL32 ( 204 , 204 , 204 , 255 ) , col ) ) ;
ImU32 col_bg2 = ImGui: : GetColorU32( ImAlphaBlendColors ( IM_COL32 ( 128 , 128 , 128 , 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 ) ;
draw_list - > AddRectFilled ( p_min , p_max , col_bg1 , rounding , flags ) ;
int yi = 0 ;
int yi = 0 ;
@ -3891,10 +3901,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 ) ;
float x1 = ImClamp ( x , p_min . x , p_max . x ) , x2 = ImMin ( x + grid_step , p_max . x ) ;
if ( x2 < = x1 )
if ( x2 < = x1 )
continue ;
continue ;
ImDrawFlags cell_flags = ImDrawFlags_NoRoundCorners ;
ImDrawFlags cell_flags = ImDrawFlags_RoundCornersNone ;
if ( y1 < = p_min . y ) { if ( x1 < = p_min . x ) cell_flags & = ~ ImDrawFlags_NoRoundCornerTL ; if ( x2 > = p_max . x ) cell_flags & = ~ ImDrawFlags_NoRoundCornerTR ; }
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_NoRoundCornerBL ; if ( x2 > = p_max . x ) cell_flags & = ~ ImDrawFlags_NoRoundCornerBR ; }
if ( y2 > = p_max . y ) { if ( x1 < = p_min . x ) cell_flags | = ImDrawFlags_RoundCornersBottomLeft ; if ( x2 > = p_max . x ) cell_flags | = ImDrawFlags_RoundCornersBottomRight ; }
cell_flags | = flags ;
// 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 ) ;
draw_list - > AddRectFilled ( ImVec2 ( x1 , y1 ) , ImVec2 ( x2 , y2 ) , col_bg2 , rounding , cell_flags ) ;
}
}
}
}