Overrides - Color grading - UI prototype finished

... And it mostly works!
This commit is contained in:
Emmanuel BENOîT 2017-11-19 21:06:03 +01:00
parent 04ebfad3e3
commit 17aecb3693

36
main.cc
View file

@ -308,12 +308,12 @@ bool HueSaturationPad(
char const* const name ,
float* const hue ,
float* const saturation ,
const float size = 180.f ) noexcept
const float size = 0.f ) noexcept
{
using namespace ImGui;
// Check/set bounding box
const auto wSize{ ImMin( size , CalcItemWidth( ) ) };
const auto wSize{ ImMax( size , CalcItemWidth( ) ) };
auto* const win( GetCurrentWindow( ) );
const ImVec2 cPos( win->DC.CursorPos );
const ImRect bb{ cPos , cPos + ImVec2( wSize , wSize ) };
@ -447,29 +447,38 @@ bool ColorGradingControls(
// Mode selection
bool modeChanged{ false };
modeChanged = CGCModeButton_( "Components" , !wheelMode );
modeChanged = CGCModeButton_( "Color wheel" , wheelMode );
SameLine( );
modeChanged = CGCModeButton_( "Color wheel" , wheelMode ) || modeChanged;
modeChanged = CGCModeButton_( "Components" , !wheelMode ) || modeChanged;
if ( modeChanged ) {
storage->SetBool( window->GetID( name ) , !wheelMode );
}
bool changed;
if ( wheelMode ^ modeChanged ) {
changed = false;
const float scRed { ImSaturate( ( *red - base ) / ( unit * 2 ) ) } ,
scGreen{ ImSaturate( ( *green - base ) / ( unit * 2 ) ) } ,
scBlue { ImSaturate( ( *blue - base ) / ( unit * 2 ) ) };
float H , S , V;
ColorConvertRGBtoHSV( scRed , scGreen , scBlue , H , S , V );
float hue , saturation , value;
ColorConvertRGBtoHSV( scRed , scGreen , scBlue , hue , saturation , value );
// FIXME test
static float fh = 0.f , fs = 0.f;
HueSaturationPad( "##wheel" , &fh , &fs , 180.f );
PushMultiItemsWidths( 2 );
changed = HueSaturationPad( "##wheel" , &hue , &saturation , 180.f );
PopItemWidth( );
SameLine( 0 , GetStyle( ).ItemInnerSpacing.x );
ImVec4 updated{ 0 , 0 , 0 , 1 };
ColorConvertHSVtoRGB( hue , saturation * .5f , 1 ,
updated.x , updated.y , updated.z );
changed = CGCComponentBar_( &value , 0 , .5 , updated , "V" ) || changed;
#warning implement the fuck
if ( changed ) {
ColorConvertHSVtoRGB( hue , saturation , value ,
updated.x , updated.y , updated.z );
*red = updated.x * unit * 2 + base;
*green = updated.y * unit * 2 + base;
*blue = updated.z * unit * 2 + base;
}
} else {
PushItemWidth( -1 );
PushMultiItemsWidths( 3 );
changed = CGCComponentBar_( red , base , unit , ImVec4( 1 , 0 , 0 , 0 ) , "R" );
PopItemWidth( );
@ -480,9 +489,8 @@ bool ColorGradingControls(
SameLine( 0 , GetStyle( ).ItemInnerSpacing.x );
changed = CGCComponentBar_( blue , base , unit , ImVec4( .3 , .3 , 1 , 0 ) , "B" )
|| changed;
PopItemWidth( );
PopItemWidth( );
}
PopItemWidth( );
EndGroup( );
PopID( );