Harbour version
// +build OMIT
PROCEDURE Main
LOCAL n
FOR n := 0 TO 27
igText( hb_ntos( n ) ) ; igSameLine( 50 ) ; igText( hb_valToExp( hb_Version( n ) ) )
NEXT
Dear ImGui version
IF igBegin("My version")
igText( os() )
igText( "ImGui " + igGetVersion() )
ENDIF
igEnd()
INIT PROCEDURE Once
OutStd( igGetVersion() + hb_EoL() ) // stdout test, newline needed to flush
Dear ImGui bulit-in demos
// +build OMIT
#include "hbimenum.ch"
igShowDemoWindow()
igShowAboutWindow()
Alternating between fonts
#include "hbimenum.ch"
#include "hbimstru.ch"
STATIC s_hFont, s_hFontDefault
PROCEDURE ImInit
LOCAL cFontBuf
s_hFontDefault := ImGuiIO( ImGui::GetIO() ):FontDefault
#pragma __binarystreaminclude "fonts/UbuntuMono.ttf"|cFontBuf := %s
s_hFont := hb_igAddFontFromMemoryTTF( cFontBuf, 18.0, , "EN", .T., .F. )
/* in this example .ttf is put together in the body of a .hrb or executable */
hb_sokol_imguiFont2Texture()
IF s_hFont == NIL /* fallback */
s_hFont := s_hFontDefault
ENDIF
RETURN
PROCEDURE ImFrame
IF ! s_hFont == NIL
ImGui::PushFont( s_hFont )
ENDIF
IF ImGui::Begin( "TEST" )
ImGui::Text( "UBUNTU Mono font." )
ImGui::PushFont( s_hFontDefault )
ImGui::Text( "a default handle." )
ImGui::PopFont()
ImGui::Text( "back to UBUNTU again." )
ENDIF
ImGui::End()
IF ! s_hFont == NIL
ImGui::PopFont()
ENDIF
ImGui::SetNextWindowPos( { 80, 180 }, ImGuiCond_Once )
ImGui::ShowMetricsWindow()
RETURN
Toolbar attached to the top of a viewport and with glyph fonts
#include "hbimenum.ch"
#include "hbimstru.ch"
#include "fonts/IconsFontAwesome6.ch"
#define TB_SIZE 30
#define TB_FLAGS ImGuiWindowFlags_NoDocking + ImGuiWindowFlags_NoTitleBar + ImGuiWindowFlags_NoResize + ImGuiWindowFlags_NoMove + ImGuiWindowFlags_NoScrollbar + ImGuiWindowFlags_NoNavInputs
#ifndef ImGuiHoveredFlags_DelayNormal
#define ImGuiHoveredFlags_DelayNormal 0
/* FIX for imgui that doesn't respect
* ImGui::PushStyleVarVec2( ImGuiStyleVar_ItemSpacing, { 0, 10 } )
* compatibility between Dear ImGui versions enforced using preprocessor...
*/
#xtranslate TB::SameLine() => igSameLine() ; igText(" ") ; igSameLine()
#xtranslate ImGui::Shortcut( <v>, <r> ) => .F.
#else
#xtranslate TB::SameLine() => igSameLine()
#endif
STATIC s_hFont
PROCEDURE ImInit
LOCAL cFontBuf, cFontABuf
#pragma __binarystreaminclude "fonts/OpenSans-Regular.ttf"|cFontBuf := %s
hb_igAddFontFromMemoryTTF( cFontBuf, 18.0, , "EN", .T., .F. )
#pragma __binarystreaminclude "fonts/fa-solid-900.ttf"|cFontABuf := %s
s_hFont := hb_igAddFontFromMemoryTTF( cFontABuf, 18.0 * ( 3 / 4 ), , { ICON_MIN_FA => ICON_MAX_FA }, .F., .T. )
hb_sokol_imguiFont2Texture()
RETURN
PROCEDURE ImFrame
IF ! s_hFont == NIL
ImGui::PushFont( s_hFont )
ENDIF
__Toolbar()
IF ! s_hFont == NIL
ImGui::PopFont()
ENDIF
RETURN
PROCEDURE NEWFILE()
PROCEDURE OPENFILE()
PROCEDURE SAVEFILE()
PROCEDURE SAVEFILEAS()
PROCEDURE SAVEALL()
PROCEDURE CLONESTYLE()
PROCEDURE SHOWCODE()
STATIC PROCEDURE __Toolbar()
LOCAL pMV := ImGui::GetMainViewPort(), nCX
STATIC a := { 0, 0 }
ImGui::SetNextWindowPos( ImGuiViewport( pMV ):Pos )
ImGui::SetNextWindowSize( { ImGuiViewport( pMV ):Size[ 1 ], TB_SIZE } )
ImGui::SetNextWindowViewport( ImGuiViewport( pMV ):ID )
ImGui::PushStyleVarFloat( ImGuiStyleVar_WindowBorderSize, 0 )
ImGui::Begin( "TOOLBAR",, TB_FLAGS )
ImGui::PopStyleVar()
IF ImGui::Button( ICON_FA_FILE + " " + ICON_FA_CARET_DOWN ) .OR. ;
ImGui::Shortcut( ImGuiMod_Ctrl + ImGuiKey_N, ImGuiInputFlags_RouteGlobal )
ImGui::OpenPopup( "NewMenu" )
ENDIF
IF ImGui::IsItemHovered( ImGuiHoveredFlags_DelayNormal )
ImGui::SetTooltip( "New File (Ctrl+N)" )
ENDIF
ImGui::SetNextWindowPos( ImGui::GetCursorPos( @a ) )
ImGui::PushStyleVarVec2( ImGuiStyleVar_ItemSpacing, { 0, 10 } )
IF ImGui::BeginPopup( "NewMenu" )
IF ImGui::MenuItemBool( "DBFNTX", "\t.dbf" )
NewFile( "DBFNTX" )
ENDIF
IF ImGui::IsItemHovered( ImGuiHoveredFlags_DelayNormal )
ImGui::SetTooltip( "use DBFNTX RDD" )
ENDIF
IF ImGui::MenuItemBool( "DBFCDX", "\t.dbf" )
NewFile( "DBFCDX" )
ENDIF
IF ImGui::IsItemHovered( ImGuiHoveredFlags_DelayNormal )
ImGui::SetTooltip( "use DBFCDX RDD" )
ENDIF
ImGui::EndPopup()
ENDIF
ImGui::PopStyleVar()
TB::SameLine()
IF ImGui::Button( ICON_FA_FOLDER_OPEN ) .OR. ;
ImGui::Shortcut( ImGuiMod_Ctrl + ImGuiKey_O, ImGuiInputFlags_RouteGlobal )
OpenFile()
ENDIF
IF ImGui::IsItemHovered( ImGuiHoveredFlags_DelayNormal )
ImGui::SetTooltip( "Open File (Ctrl+O)" )
ENDIF
ImGui::BeginDisabled( /* activeTab < 0 */ )
TB::SameLine()
nCX := ImGui::GetCursorPosX()
IF ImGui::Button( ICON_FA_FLOPPY_DISK ) .OR. ;
ImGui::Shortcut( ImGuiMod_Ctrl + ImGuiKey_S, ImGuiInputFlags_RouteGlobal )
SaveFile( .F. )
ENDIF
IF ImGui::IsItemHovered( ImGuiHoveredFlags_DelayNormal )
ImGui::SetTooltip( "Save File (Ctrl+S)" )
ENDIF
ImGui::SameLine( 0, 0 )
ImGui::SeparatorEx( ImGuiSeparatorFlags_Vertical )
ImGui::SameLine( 0, 0 )
ImGui::PushStyleVarVec2( ImGuiStyleVar_FramePadding, { 2, ImGuiStyle( ImGui::GetStyle() ):FramePadding[ 2 ] } )
IF ImGui::Button( ICON_FA_CARET_DOWN )
ImGui::OpenPopup( "SaveMenu" )
ENDIF
ImGui::PopStyleVar()
ImGui::SetNextWindowPos( { nCX, ImGui::GetCursorPosY() } )
IF ImGui::BeginPopup( "SaveMenu" )
IF ImGui::MenuItemBool( "Save As..." )
SaveFileAs( .F. )
ENDIF
IF ImGui::MenuItemBool( "Save All", "\tCtrl+Shift+S" )
SaveAll()
ENDIF
ImGui::EndPopup()
ENDIF
IF ImGui::Shortcut( ImGuiMod_Ctrl + ImGuiMod_Shift + ImGuiKey_S, ImGuiInputFlags_RouteGlobal )
SaveAll()
ENDIF
ImGui::SameLine()
ImGui::SeparatorEx( ImGuiSeparatorFlags_Vertical )
ImGui::SameLine()
ImGui::SameLine()
IF ImGui::Button( ICON_FA_CLONE )
CloneStyle()
ENDIF
IF ImGui::IsItemHovered( ImGuiHoveredFlags_DelayNormal )
ImGui::SetTooltip( "Clone Style" )
ENDIF
TB::SameLine()
ImGui::SeparatorEx( ImGuiSeparatorFlags_Vertical )
ImGui::EndDisabled()
TB::SameLine()
ImGui::BeginDisabled( /* activeTab < 0 */ )
IF ImGui::Button( ICON_FA_BOLT ) .OR. ;
ImGui::Shortcut( ImGuiMod_Ctrl + ImGuiKey_P, ImGuiInputFlags_RouteGlobal )
ShowCode()
ENDIF
IF ImGui::IsItemHovered( ImGuiHoveredFlags_DelayNormal )
ImGui::SetTooltip( "Preview Code (Ctrl+P)" )
ENDIF
ImGui::EndDisabled()
TB::SameLine()
IF ImGui::Button( ICON_FA_CUBES )
ENDIF
IF ImGui::IsItemHovered( ImGuiHoveredFlags_DelayNormal )
ImGui::SetTooltip( "Class Wizard" )
ENDIF
TB::SameLine()
ImGui::Text("<-- it's toolbar in here")
ImGui::End()
RETURN