UI improvements

This commit is contained in:
Emmanuel BENOîT 2017-11-21 17:32:52 +01:00
parent 608d08d252
commit e13d0c3638
9 changed files with 88 additions and 19 deletions

6
.gitmodules vendored
View file

@ -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

View file

@ -45,6 +45,8 @@ flags = [
'-x',
'c++',
'-I','.',
'-I','output',
'-I','IconFontCppHeaders',
'-I','imgui',
'-I','glm',
'-I','ebcl/include',

1
IconFontCppHeaders Submodule

@ -0,0 +1 @@
Subproject commit f3f13bdd7ac0a14bfa0dde584936b1cd77250267

View file

@ -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 $@ $<

View file

@ -28,6 +28,9 @@ using std::swap;
// ImGui
#include <imgui.h>
// FontAwesome
#include <IconsFontAwesome.h>
// GLM
#include <glm/mat3x3.hpp>
#include <glm/gtx/euler_angles.hpp>
@ -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; \

1
font-awesome Submodule

@ -0,0 +1 @@
Subproject commit 8e8e659341916ad8a551835c43b30395cd90f489

2
imgui

@ -1 +1 @@
Subproject commit 4faf99eff564d68bef9e43cb293c851fc489afc3
Subproject commit 302757447aa6f0eed177e6cb33de887242a6355e

View file

@ -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( );

View file

@ -3,6 +3,16 @@
#include "imgui_impl_sdl.h"
#include <imgui_internal.h>
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_ );
}
}