diff --git a/.gitmodules b/.gitmodules index d81c7b0..2ba0046 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,9 @@ [submodule "ebcl"] path = ebcl url = ssh://git@git.nocternity.net:44/u/tseeker/libs/corelib +[submodule "font-awesome"] + path = font-awesome + url = https://github.com/FortAwesome/Font-Awesome.git +[submodule "IconFontCppHeaders"] + path = IconFontCppHeaders + url = https://github.com/juliettef/IconFontCppHeaders.git diff --git a/.vim.local/ycm_extra_conf.py b/.vim.local/ycm_extra_conf.py index 3fb74bd..4b7d666 100644 --- a/.vim.local/ycm_extra_conf.py +++ b/.vim.local/ycm_extra_conf.py @@ -45,6 +45,8 @@ flags = [ '-x', 'c++', '-I','.', + '-I','output', + '-I','IconFontCppHeaders', '-I','imgui', '-I','glm', '-I','ebcl/include', diff --git a/IconFontCppHeaders b/IconFontCppHeaders new file mode 160000 index 0000000..f3f13bd --- /dev/null +++ b/IconFontCppHeaders @@ -0,0 +1 @@ +Subproject commit f3f13bdd7ac0a14bfa0dde584936b1cd77250267 diff --git a/Makefile b/Makefile index f613211..10c358b 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ OUTDIR = output CXXFLAGS += $(shell sdl2-config --cflags) -std=c++14 -Wall -g CFLAGS += $(shell sdl2-config --cflags) CPPFLAGS += -I. -I$(OUTDIR) \ - -Iimgui -Iglm -Iebcl/include \ + -Iimgui -Iglm -IIconFontCppHeaders -Iebcl/include \ -DREAL_BUILD -DGLM_ENABLE_EXPERIMENTAL LIBS += $(shell sdl2-config --libs) -lGL -lGLEW -ldl \ $(LIBEBCL) -latomic @@ -130,3 +130,14 @@ $(LIBEBCL): ebcl-config $(PCH): externals.hh $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< + +#------------------------------------------------------------------------------- + +$(OUTDIR)/window.o: window.cc $(OUTDIR)/font-awesome.inl + +$(OUTDIR)/font-awesome.inl: font-awesome/fonts/fontawesome-webfont.ttf $(OUTDIR)/font-to-c + $(OUTDIR)/font-to-c -base85 font-awesome/fonts/fontawesome-webfont.ttf \ + FontAwesome_ >$@ + +$(OUTDIR)/font-to-c: imgui/extra_fonts/binary_to_compressed_c.cpp + $(CXX) -o $@ $< diff --git a/externals.hh b/externals.hh index 3381f3f..c033479 100644 --- a/externals.hh +++ b/externals.hh @@ -28,6 +28,9 @@ using std::swap; // ImGui #include +// FontAwesome +#include + // GLM #include #include @@ -59,11 +62,6 @@ using ebcl::T_HashIndex; using ebcl::T_ObjectTable; using ebcl::T_KeyValueTable; -// Silly decoration macros I use everywhere -#define __rd__ -#define __wr__ -#define __rw__ - // Macros that enable/disable copying/moving #define NO_COPY( CLS ) \ CLS( CLS const& ) = delete; \ diff --git a/font-awesome b/font-awesome new file mode 160000 index 0000000..8e8e659 --- /dev/null +++ b/font-awesome @@ -0,0 +1 @@ +Subproject commit 8e8e659341916ad8a551835c43b30395cd90f489 diff --git a/imgui b/imgui index 4faf99e..3027574 160000 --- a/imgui +++ b/imgui @@ -1 +1 @@ -Subproject commit 4faf99eff564d68bef9e43cb293c851fc489afc3 +Subproject commit 302757447aa6f0eed177e6cb33de887242a6355e diff --git a/syncview.cc b/syncview.cc index ae866a6..d31a6c3 100644 --- a/syncview.cc +++ b/syncview.cc @@ -22,6 +22,7 @@ struct T_SyncViewImpl_ const uint32_t ColHeaderText{ ImGui::GetColorU32( ImVec4{ 0 , 0 , 0 , 1 } ) }; const uint32_t ColMain{ ImGui::GetColorU32( ImVec4{ .4 , .4 , .4 , .8 } ) }; const uint32_t ColSelection{ ImGui::GetColorU32( ImVec4{ .8 , 1 , .8 , .2 } ) }; + const ImVec2 BtSize{ 20 , 0 }; float zoomLevel{ 0.f }; float startPos{ 0.f }; @@ -69,28 +70,51 @@ bool T_SyncViewImpl_::display( ) noexcept return false; } + if ( Button( sync.playing( ) ? ICON_FA_STOP : ICON_FA_PLAY , BtSize ) ) { + sync.playing( ) = !sync.playing( ) && !sync.finished( ); + } + if ( IsItemHovered( ) ) { + BeginTooltip( ); + Text( sync.playing( ) ? "Stop" : "Play" ); + EndTooltip( ); + } + + SameLine( ); + + if ( Button( ICON_FA_BACKWARD , BtSize ) ) { + sync.setTime( 0 ); + } + if ( IsItemHovered( ) ) { + BeginTooltip( ); + Text( "Rewind to 00:00.000" ); + EndTooltip( ); + } + + SameLine( ); + + Text( ICON_FA_SEARCH ); + bool zoomHovered{ IsItemHovered( ) }; + SameLine( ); PushItemWidth( 100 ); SliderFloat( "##zoom" , &zoomLevel , 0 , 1 , "%.2f" ); - if ( IsItemHovered( ) ) { + if ( zoomHovered || IsItemHovered( ) ) { BeginTooltip( ); Text( "Zoom level" ); EndTooltip( ); } PopItemWidth( ); - SameLine( ); - Checkbox( "##follow" , &followTime ); - if ( IsItemHovered( ) ) { - BeginTooltip( ); - Text( "Follow cursor" ); - EndTooltip( ); - } + SameLine( ); - PushID( "playing" ); - if ( Button( sync.playing( ) ? "Stop" : "Play" ) ) { - sync.playing( ) = !sync.playing( ) && !sync.finished( ); + if ( Button( followTime ? ICON_FA_LOCK : ICON_FA_UNLOCK , BtSize ) ) { + followTime = !followTime; + } + if ( IsItemHovered( ) ) { + BeginTooltip( ); + Text( followTime ? "Follows the current position.\nClick to untie." + : "Not tied to the current position.\nClick to follow." ); + EndTooltip( ); } - PopID( ); PushItemWidth( -1 ); sequencerWidget( ); diff --git a/window.cc b/window.cc index b4dd571..26808ea 100644 --- a/window.cc +++ b/window.cc @@ -3,6 +3,16 @@ #include "imgui_impl_sdl.h" #include +namespace { +#include "font-awesome.inl" + +static const ImWchar IconsRanges_[] = { + ICON_MIN_FA , + ICON_MAX_FA , + 0 +}; +} + T_Window::T_Window( ) { @@ -30,16 +40,32 @@ T_Window::T_Window( ) ImGui_ImplSdl_Init( window ); using namespace ImGui; + StyleColorsDark( ); ImGuiIO& io{ GetIO( ) }; { ImFontConfig cfg; cfg.SizePixels = 13.0f; defaultFont_ = io.Fonts->AddFontDefault( &cfg ); + + ImFontConfig icons; + icons.MergeMode = true; + icons.PixelSnapH = true; + io.Fonts->AddFontFromMemoryCompressedBase85TTF( + FontAwesome__compressed_data_base85 , 13.f , + &icons , IconsRanges_ ); } { ImFontConfig cfg; cfg.SizePixels = 9.0f; smallFont_ = io.Fonts->AddFontDefault( &cfg ); + + ImFontConfig icons; + icons.MergeMode = true; + icons.PixelSnapH = true; + icons.DstFont = smallFont_; + io.Fonts->AddFontFromMemoryCompressedBase85TTF( + FontAwesome__compressed_data_base85 , 9.f , + &icons , IconsRanges_ ); } }