UI - Refactoring progress
(see previous log message)
This commit is contained in:
parent
743af1d0d7
commit
6ac2511ce7
12 changed files with 139 additions and 124 deletions
1
Makefile
1
Makefile
|
@ -27,6 +27,7 @@ COMMON = \
|
|||
ui-actions.cc \
|
||||
ui-colorgrading.cc \
|
||||
ui-dialogs.cc \
|
||||
ui-utilities.cc \
|
||||
globals.cc \
|
||||
profiling.cc \
|
||||
shaders.cc \
|
||||
|
|
1
main.cc
1
main.cc
|
@ -10,6 +10,7 @@
|
|||
#include "rendertarget.hh"
|
||||
#include "sync.hh"
|
||||
#include "ui-sequencer.hh"
|
||||
#include "ui-utilities.hh"
|
||||
#include "undo.hh"
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "externals.hh"
|
||||
#include "shaders.hh"
|
||||
#include "globals.hh"
|
||||
#include "ui-utilities.hh"
|
||||
|
||||
#include <ebcl/Sets.hh>
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "externals.hh"
|
||||
#include "utilities.hh"
|
||||
#include "texture.hh"
|
||||
#include "globals.hh"
|
||||
#include "odbg.hh"
|
||||
#include "ui-utilities.hh"
|
||||
|
||||
|
||||
/*==============================================================================*/
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "externals.hh"
|
||||
#include "ui-actions.hh"
|
||||
#include "ui-utilities.hh"
|
||||
|
||||
#include <imgui_internal.h>
|
||||
|
||||
|
@ -60,9 +61,7 @@ void T_UIAction::tbButton( ) const noexcept
|
|||
|
||||
const bool e{ enabled ? enabled( ) : true };
|
||||
if ( !e ) {
|
||||
PushItemFlag( ImGuiItemFlags_Disabled , true );
|
||||
PushStyleVar( ImGuiStyleVar_Alpha ,
|
||||
GetStyle( ).Alpha * .5f );
|
||||
PushDisabled( );
|
||||
}
|
||||
const bool rv{ Button( sb.data( ) , ImVec2{ 20 , 0 } ) };
|
||||
if ( e && IsItemHovered( ) ) {
|
||||
|
@ -79,8 +78,7 @@ void T_UIAction::tbButton( ) const noexcept
|
|||
EndTooltip( );
|
||||
}
|
||||
if ( !e ) {
|
||||
PopItemFlag( );
|
||||
PopStyleVar( );
|
||||
PopDisabled( );
|
||||
}
|
||||
|
||||
if ( rv ) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "externals.hh"
|
||||
#include "ui-colorgrading.hh"
|
||||
#include "ui-utilities.hh"
|
||||
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
#include <imgui_internal.h>
|
||||
|
@ -12,14 +13,11 @@ namespace {
|
|||
const bool disabled )
|
||||
{
|
||||
if ( disabled ) {
|
||||
PushItemFlag( ImGuiItemFlags_Disabled , true );
|
||||
PushStyleVar( ImGuiStyleVar_Alpha ,
|
||||
GetStyle( ).Alpha * 0.5f );
|
||||
PushDisabled( );
|
||||
}
|
||||
const bool rv( Button( name ) );
|
||||
if ( disabled ) {
|
||||
PopItemFlag( );
|
||||
PopStyleVar( );
|
||||
PopDisabled( );
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "externals.hh"
|
||||
#include "ui-dialogs.hh"
|
||||
#include "ui-utilities.hh"
|
||||
|
||||
#include <imgui_internal.h>
|
||||
|
||||
|
||||
|
@ -79,17 +81,14 @@ bool A_ModalDialog::draw( ) noexcept
|
|||
SameLine( 0 );
|
||||
}
|
||||
if ( d ) {
|
||||
PushItemFlag( ImGuiItemFlags_Disabled , true );
|
||||
PushStyleVar( ImGuiStyleVar_Alpha ,
|
||||
GetStyle( ).Alpha * .5f );
|
||||
PushDisabled( );
|
||||
}
|
||||
if ( Button( &buttons_[ i ][ 0 ] , buttonSize ) ) {
|
||||
assert( clicked == -1 );
|
||||
clicked = i;
|
||||
}
|
||||
if ( d ) {
|
||||
PopItemFlag( );
|
||||
PopStyleVar( );
|
||||
PopDisabled( );
|
||||
}
|
||||
}
|
||||
const bool close( clicked != -1 && onButton( clicked ) );
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "globals.hh"
|
||||
#include "window.hh"
|
||||
#include "syncedit.hh"
|
||||
#include "ui-utilities.hh"
|
||||
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
#include <imgui_internal.h>
|
||||
|
@ -21,37 +22,11 @@ bool FakeTab_(
|
|||
{
|
||||
using namespace ImGui;
|
||||
if ( disabled ) {
|
||||
PushItemFlag( ImGuiItemFlags_Disabled , true );
|
||||
PushStyleVar( ImGuiStyleVar_Alpha ,
|
||||
GetStyle( ).Alpha * .5f );
|
||||
PushDisabled( );
|
||||
}
|
||||
const bool rv( Button( name , ImVec2{ width , 0.f } ) );
|
||||
if ( disabled ) {
|
||||
PopItemFlag( );
|
||||
PopStyleVar( );
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
void ToolbarSeparator_( ) noexcept
|
||||
{
|
||||
using namespace ImGui;
|
||||
SameLine( );
|
||||
VerticalSeparator( );
|
||||
SameLine( );
|
||||
}
|
||||
|
||||
bool ToolbarButton_(
|
||||
char const* const string ,
|
||||
ImVec2 const& size ,
|
||||
char const* const tooltip = nullptr ) noexcept
|
||||
{
|
||||
using namespace ImGui;
|
||||
const bool rv{ Button( string , size ) };
|
||||
if ( tooltip && IsItemHovered( ) ) {
|
||||
BeginTooltip( );
|
||||
Text( tooltip );
|
||||
EndTooltip( );
|
||||
PopDisabled( );
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -130,14 +105,11 @@ uint8_t T_ChangeDurationDialog_::drawDialog( ) noexcept
|
|||
}
|
||||
|
||||
if ( uPerMinute0_ == uPerMinute_ ) {
|
||||
PushItemFlag( ImGuiItemFlags_Disabled , true );
|
||||
PushStyleVar( ImGuiStyleVar_Alpha ,
|
||||
GetStyle( ).Alpha * .5f );
|
||||
PushDisabled( );
|
||||
}
|
||||
Checkbox( "Scale curves" , &scale_ );
|
||||
if ( uPerMinute0_ == uPerMinute_ ) {
|
||||
PopItemFlag( );
|
||||
PopStyleVar( );
|
||||
PopDisabled( );
|
||||
}
|
||||
|
||||
const bool eo{ units_ != units0_ || uPerMinute_ != uPerMinute0_ };
|
||||
|
@ -318,18 +290,18 @@ void T_SyncViewImpl_::displayToolbar( ) noexcept
|
|||
using namespace ImGui;
|
||||
auto& sync( Globals::Sync( ) );
|
||||
|
||||
if ( ToolbarButton_( sync.playing( ) ? ICON_FA_STOP : ICON_FA_PLAY , BtSize ,
|
||||
if ( ToolbarButton( sync.playing( ) ? ICON_FA_STOP : ICON_FA_PLAY , BtSize ,
|
||||
sync.playing( ) ? "Stop" : "Play" ) ) {
|
||||
sync.playing( ) = !sync.playing( ) && !sync.finished( );
|
||||
}
|
||||
|
||||
SameLine( );
|
||||
|
||||
if ( ToolbarButton_( ICON_FA_BACKWARD , BtSize , "Rewind to 00:00.000" ) ) {
|
||||
if ( ToolbarButton( ICON_FA_BACKWARD , BtSize , "Rewind to 00:00.000" ) ) {
|
||||
sync.setTime( 0 );
|
||||
}
|
||||
|
||||
ToolbarSeparator_( );
|
||||
ToolbarSeparator( );
|
||||
|
||||
Text( ICON_FA_SEARCH );
|
||||
bool zoomHovered{ IsItemHovered( ) };
|
||||
|
@ -345,22 +317,22 @@ void T_SyncViewImpl_::displayToolbar( ) noexcept
|
|||
|
||||
SameLine( );
|
||||
|
||||
if ( ToolbarButton_( followTime ? ICON_FA_LOCK : ICON_FA_UNLOCK , BtSize ,
|
||||
if ( ToolbarButton( followTime ? ICON_FA_LOCK : ICON_FA_UNLOCK , BtSize ,
|
||||
followTime ? "Follows the current position.\nClick to untie."
|
||||
: "Not tied to the current position.\nClick to follow." ) ) {
|
||||
followTime = !followTime;
|
||||
}
|
||||
|
||||
ToolbarSeparator_( );
|
||||
ToolbarSeparator( );
|
||||
|
||||
if ( ToolbarButton_( ICON_FA_CLOCK_O , BtSize , "Change duration and time units." ) ) {
|
||||
if ( ToolbarButton( ICON_FA_CLOCK_O , BtSize , "Change duration and time units." ) ) {
|
||||
Globals::Window( ).pushDialog( NewOwned< T_ChangeDurationDialog_ >(
|
||||
sync.durationUnits( ) , sync.durationUnitSize( ) ) );
|
||||
}
|
||||
|
||||
ToolbarSeparator_( );
|
||||
ToolbarSeparator( );
|
||||
|
||||
if ( ToolbarButton_( ICON_FA_LINE_CHART , BtSize ,
|
||||
if ( ToolbarButton( ICON_FA_LINE_CHART , BtSize ,
|
||||
"Select curves or sets thereof to display & edit." ) ) {
|
||||
const bool displaySelector{ sub == SW_CURVE_SELECTOR
|
||||
|| sub == SW_OVERRIDE_SELECTOR };
|
||||
|
@ -708,9 +680,7 @@ void T_SyncViewImpl_::displayCurveSelector( ) noexcept
|
|||
const bool overriden{ present && *sCurves.get( n ) };
|
||||
|
||||
if ( overriden ) {
|
||||
PushItemFlag( ImGuiItemFlags_Disabled , true );
|
||||
PushStyleVar( ImGuiStyleVar_Alpha ,
|
||||
GetStyle( ).Alpha * .5f );
|
||||
PushDisabled( );
|
||||
}
|
||||
|
||||
bool select{ present };
|
||||
|
@ -724,8 +694,7 @@ void T_SyncViewImpl_::displayCurveSelector( ) noexcept
|
|||
}
|
||||
|
||||
if ( overriden ) {
|
||||
PopItemFlag( );
|
||||
PopStyleVar( );
|
||||
PopDisabled( );
|
||||
}
|
||||
}
|
||||
EndChild( );
|
||||
|
@ -763,9 +732,7 @@ void T_SyncViewImpl_::displayOverrideSelector( ) noexcept
|
|||
}() };
|
||||
|
||||
if ( hasCurves ) {
|
||||
PushItemFlag( ImGuiItemFlags_Disabled , true );
|
||||
PushStyleVar( ImGuiStyleVar_Alpha ,
|
||||
GetStyle( ).Alpha * .5f );
|
||||
PushDisabled( );
|
||||
}
|
||||
|
||||
bool select{ present };
|
||||
|
@ -784,8 +751,7 @@ void T_SyncViewImpl_::displayOverrideSelector( ) noexcept
|
|||
}
|
||||
|
||||
if ( hasCurves ) {
|
||||
PopItemFlag( );
|
||||
PopStyleVar( );
|
||||
PopDisabled( );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
59
ui-utilities.cc
Normal file
59
ui-utilities.cc
Normal file
|
@ -0,0 +1,59 @@
|
|||
#include "externals.hh"
|
||||
#include "ui-utilities.hh"
|
||||
|
||||
#include <imgui_internal.h>
|
||||
|
||||
|
||||
void ImGui::PushDisabled( ) noexcept
|
||||
{
|
||||
PushItemFlag( ImGuiItemFlags_Disabled , true );
|
||||
PushStyleVar( ImGuiStyleVar_Alpha , GetStyle( ).Alpha * .5f );
|
||||
}
|
||||
|
||||
void ImGui::PopDisabled( ) noexcept
|
||||
{
|
||||
PopItemFlag( );
|
||||
PopStyleVar( );
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
bool ImGui::MenuItemCheckbox(
|
||||
char const* name ,
|
||||
bool* checked ) noexcept
|
||||
{
|
||||
bool rv{ MenuItem( name , "" , *checked , true ) };
|
||||
if ( rv ) {
|
||||
*checked = !*checked;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
bool ImGui::ToolbarButton(
|
||||
char const* const string ,
|
||||
ImVec2 const& size ,
|
||||
char const* const tooltip ,
|
||||
bool enabled ) noexcept
|
||||
{
|
||||
if ( !enabled ) {
|
||||
PushDisabled( );
|
||||
}
|
||||
const bool rv{ Button( string , size ) };
|
||||
if ( !enabled ) {
|
||||
PopDisabled( );
|
||||
} else if ( tooltip && IsItemHovered( ) ) {
|
||||
BeginTooltip( );
|
||||
Text( tooltip );
|
||||
EndTooltip( );
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
void ImGui::ToolbarSeparator( ) noexcept
|
||||
{
|
||||
SameLine( );
|
||||
VerticalSeparator( );
|
||||
SameLine( );
|
||||
}
|
49
ui-utilities.hh
Normal file
49
ui-utilities.hh
Normal file
|
@ -0,0 +1,49 @@
|
|||
#pragma once
|
||||
#ifndef REAL_BUILD
|
||||
# include "externals.hh"
|
||||
#endif
|
||||
|
||||
/*= UI UTILITIES =============================================================*/
|
||||
|
||||
namespace ImGui {
|
||||
|
||||
// Disable next ImGui controls
|
||||
void PushDisabled( ) noexcept;
|
||||
// Re-enable ImGui buttons
|
||||
void PopDisabled( ) noexcept;
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
|
||||
// Display a menu item with a checkbox
|
||||
bool MenuItemCheckbox(
|
||||
char const* name ,
|
||||
bool* checked ) noexcept;
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
|
||||
// Display a separator for the toolbar
|
||||
void ToolbarSeparator( ) noexcept;
|
||||
|
||||
// Display a toolbar button
|
||||
bool ToolbarButton(
|
||||
char const* const string ,
|
||||
ImVec2 const& size ,
|
||||
char const* const tooltip = nullptr ,
|
||||
bool enabled = true ) noexcept;
|
||||
|
||||
} // namespace ImGui
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#define GL_CHECK( FAIL ) \
|
||||
do { \
|
||||
auto err_( glGetError( ) ); \
|
||||
if ( err_ != GL_NO_ERROR ) FAIL; \
|
||||
} while ( 0 )
|
||||
|
||||
#define GL_ASSERT( ) \
|
||||
GL_CHECK({ \
|
||||
fprintf( stderr , "GL error %x in %s:%d\n" , \
|
||||
err_ , __FILE__ , __LINE__ ); \
|
||||
abort( ); \
|
||||
})
|
22
utilities.cc
22
utilities.cc
|
@ -2,15 +2,6 @@
|
|||
#include "utilities.hh"
|
||||
|
||||
|
||||
void disableButton( )
|
||||
{
|
||||
ImGui::PushStyleColor( ImGuiCol_Button , ImVec4( .3 , .3 , .3 , 1 ) );
|
||||
ImGui::PushStyleColor( ImGuiCol_ButtonHovered , ImVec4( .3 , .3 , .3 , 1 ) );
|
||||
ImGui::PushStyleColor( ImGuiCol_ButtonActive , ImVec4( .3 , .3 , .3 , 1 ) );
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
void updateAngle(
|
||||
float& initial ,
|
||||
const float delta
|
||||
|
@ -69,16 +60,3 @@ T_String GetParentPath(
|
|||
free( rp );
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
bool ImGui::MenuItemCheckbox(
|
||||
char const* name ,
|
||||
bool* checked )
|
||||
{
|
||||
bool rv{ MenuItem( name , "" , *checked , true ) };
|
||||
if ( rv ) {
|
||||
*checked = !*checked;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
35
utilities.hh
35
utilities.hh
|
@ -5,31 +5,6 @@
|
|||
|
||||
/*= Utilities ================================================================*/
|
||||
|
||||
// Disable next ImGui button(s)
|
||||
void disableButton( );
|
||||
// Re-enable ImGui buttons
|
||||
inline void reenableButtons( )
|
||||
{
|
||||
ImGui::PopStyleColor( 3 );
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#define GL_CHECK( FAIL ) \
|
||||
do { \
|
||||
auto err_( glGetError( ) ); \
|
||||
if ( err_ != GL_NO_ERROR ) FAIL; \
|
||||
} while ( 0 )
|
||||
|
||||
#define GL_ASSERT( ) \
|
||||
GL_CHECK({ \
|
||||
fprintf( stderr , "GL error %x in %s:%d\n" , \
|
||||
err_ , __FILE__ , __LINE__ ); \
|
||||
abort( ); \
|
||||
})
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Add some value to an angle, keeping it in [-180;180]
|
||||
void updateAngle(
|
||||
float& initial ,
|
||||
|
@ -76,13 +51,3 @@ std::string GetAbsolutePath(
|
|||
// Get the absolute parent path for a (possibly relative) path
|
||||
std::string GetParentPath(
|
||||
std::string const& path );
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
namespace ImGui {
|
||||
|
||||
bool MenuItemCheckbox(
|
||||
char const* name ,
|
||||
bool* checked );
|
||||
|
||||
} // namespace ImGui
|
||||
|
|
Loading…
Reference in a new issue