Overrides - Color grading - UI prototype finished
... And it mostly works!
This commit is contained in:
parent
04ebfad3e3
commit
17aecb3693
1 changed files with 22 additions and 14 deletions
36
main.cc
36
main.cc
|
@ -308,12 +308,12 @@ bool HueSaturationPad(
|
||||||
char const* const name ,
|
char const* const name ,
|
||||||
float* const hue ,
|
float* const hue ,
|
||||||
float* const saturation ,
|
float* const saturation ,
|
||||||
const float size = 180.f ) noexcept
|
const float size = 0.f ) noexcept
|
||||||
{
|
{
|
||||||
using namespace ImGui;
|
using namespace ImGui;
|
||||||
|
|
||||||
// Check/set bounding box
|
// Check/set bounding box
|
||||||
const auto wSize{ ImMin( size , CalcItemWidth( ) ) };
|
const auto wSize{ ImMax( size , CalcItemWidth( ) ) };
|
||||||
auto* const win( GetCurrentWindow( ) );
|
auto* const win( GetCurrentWindow( ) );
|
||||||
const ImVec2 cPos( win->DC.CursorPos );
|
const ImVec2 cPos( win->DC.CursorPos );
|
||||||
const ImRect bb{ cPos , cPos + ImVec2( wSize , wSize ) };
|
const ImRect bb{ cPos , cPos + ImVec2( wSize , wSize ) };
|
||||||
|
@ -447,29 +447,38 @@ bool ColorGradingControls(
|
||||||
|
|
||||||
// Mode selection
|
// Mode selection
|
||||||
bool modeChanged{ false };
|
bool modeChanged{ false };
|
||||||
modeChanged = CGCModeButton_( "Components" , !wheelMode );
|
modeChanged = CGCModeButton_( "Color wheel" , wheelMode );
|
||||||
SameLine( );
|
SameLine( );
|
||||||
modeChanged = CGCModeButton_( "Color wheel" , wheelMode ) || modeChanged;
|
modeChanged = CGCModeButton_( "Components" , !wheelMode ) || modeChanged;
|
||||||
if ( modeChanged ) {
|
if ( modeChanged ) {
|
||||||
storage->SetBool( window->GetID( name ) , !wheelMode );
|
storage->SetBool( window->GetID( name ) , !wheelMode );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changed;
|
bool changed;
|
||||||
if ( wheelMode ^ modeChanged ) {
|
if ( wheelMode ^ modeChanged ) {
|
||||||
changed = false;
|
|
||||||
const float scRed { ImSaturate( ( *red - base ) / ( unit * 2 ) ) } ,
|
const float scRed { ImSaturate( ( *red - base ) / ( unit * 2 ) ) } ,
|
||||||
scGreen{ ImSaturate( ( *green - base ) / ( unit * 2 ) ) } ,
|
scGreen{ ImSaturate( ( *green - base ) / ( unit * 2 ) ) } ,
|
||||||
scBlue { ImSaturate( ( *blue - base ) / ( unit * 2 ) ) };
|
scBlue { ImSaturate( ( *blue - base ) / ( unit * 2 ) ) };
|
||||||
float H , S , V;
|
float hue , saturation , value;
|
||||||
ColorConvertRGBtoHSV( scRed , scGreen , scBlue , H , S , V );
|
ColorConvertRGBtoHSV( scRed , scGreen , scBlue , hue , saturation , value );
|
||||||
|
|
||||||
// FIXME test
|
PushMultiItemsWidths( 2 );
|
||||||
static float fh = 0.f , fs = 0.f;
|
changed = HueSaturationPad( "##wheel" , &hue , &saturation , 180.f );
|
||||||
HueSaturationPad( "##wheel" , &fh , &fs , 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 {
|
} else {
|
||||||
PushItemWidth( -1 );
|
|
||||||
PushMultiItemsWidths( 3 );
|
PushMultiItemsWidths( 3 );
|
||||||
changed = CGCComponentBar_( red , base , unit , ImVec4( 1 , 0 , 0 , 0 ) , "R" );
|
changed = CGCComponentBar_( red , base , unit , ImVec4( 1 , 0 , 0 , 0 ) , "R" );
|
||||||
PopItemWidth( );
|
PopItemWidth( );
|
||||||
|
@ -480,9 +489,8 @@ bool ColorGradingControls(
|
||||||
SameLine( 0 , GetStyle( ).ItemInnerSpacing.x );
|
SameLine( 0 , GetStyle( ).ItemInnerSpacing.x );
|
||||||
changed = CGCComponentBar_( blue , base , unit , ImVec4( .3 , .3 , 1 , 0 ) , "B" )
|
changed = CGCComponentBar_( blue , base , unit , ImVec4( .3 , .3 , 1 , 0 ) , "B" )
|
||||||
|| changed;
|
|| changed;
|
||||||
PopItemWidth( );
|
|
||||||
PopItemWidth( );
|
|
||||||
}
|
}
|
||||||
|
PopItemWidth( );
|
||||||
|
|
||||||
EndGroup( );
|
EndGroup( );
|
||||||
PopID( );
|
PopID( );
|
||||||
|
|
Loading…
Reference in a new issue