Skip to content
This repository was archived by the owner on Apr 22, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ ipch/
.vs
**/vc2013/enc_temp_folder/**
**/vc2015/enc_temp_folder/**

samples/Basic/xcode/build
5 changes: 4 additions & 1 deletion include/CinderImGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ namespace ImGui {
//! disconnects window signals from imgui
void disconnectWindow( ci::app::WindowRef window );

//! clear all key events, this should be called after open/save file dialog to reset the events
void clearKeyEvents();

// Cinder Helpers
void Image( const ci::gl::Texture2dRef &texture, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,1), const ImVec2& uv1 = ImVec2(1,0), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0) );
bool ImageButton( const ci::gl::Texture2dRef &texture, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,1), const ImVec2& uv1 = ImVec2(1,0), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,1), const ImVec4& tint_col = ImVec4(1,1,1,1) );
Expand Down Expand Up @@ -451,4 +454,4 @@ namespace ImGui {
}
return false;
}
}
}
38 changes: 26 additions & 12 deletions src/CinderImGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,8 @@ ImFont* Renderer::addFont( const ci::fs::path &font, float size, const ImWchar*
if( merge && ! mFonts.empty() ) {
config.MergeMode = true;
config.PixelSnapH = true;
config.MergeGlyphCenterV = true;
config.MergeMode = true;
// config.MergeGlyphCenterV = true;
//config.OversampleV = 4;
}
/*else if( merge ) {
Expand Down Expand Up @@ -775,7 +776,10 @@ bool Combo( const char* label, int* current_item, const std::vector<std::string>
bool result = Combo( label, current_item, (const char*) &charArray[0], height_in_items );
return result;
}



vector<int> sAccelKeys;

namespace {

//! sets the right mouseDown IO values in imgui
Expand Down Expand Up @@ -827,10 +831,6 @@ namespace {

event.setHandled( io.WantCaptureMouse );
}


vector<int> sAccelKeys;

//! sets the right keyDown IO values in imgui
void keyDown( ci::app::KeyEvent& event )
{
Expand All @@ -848,7 +848,7 @@ namespace {
&& event.isAccelDown()
&& find( sAccelKeys.begin(), sAccelKeys.end(), event.getCode() ) == sAccelKeys.end() ){
sAccelKeys.push_back( event.getCode() );
}
}

io.KeyCtrl = io.KeysDown[KeyEvent::KEY_LCTRL] || io.KeysDown[KeyEvent::KEY_RCTRL] || io.KeysDown[KeyEvent::KEY_LMETA] || io.KeysDown[KeyEvent::KEY_RMETA];
io.KeyShift = io.KeysDown[KeyEvent::KEY_LSHIFT] || io.KeysDown[KeyEvent::KEY_RSHIFT];
Expand All @@ -862,7 +862,7 @@ namespace {
ImGuiIO& io = ImGui::GetIO();

io.KeysDown[event.getCode()] = false;
for( auto key : sAccelKeys ){
io.KeysDown[key] = false;
}
Expand All @@ -874,6 +874,7 @@ namespace {

event.setHandled( io.WantCaptureKeyboard );
}

void resize()
{
ImGuiIO& io = ImGui::GetIO();
Expand Down Expand Up @@ -925,7 +926,19 @@ namespace {
// wrong... and would not work in a multi-windows scenario
static signals::ConnectionList sWindowConnections;


void clearKeyEvents()
{
// bool KeysDown[512]; imgui.h #787
ImGuiIO& io = ImGui::GetIO();
for( size_t k=0; k < 512; k++ ){
io.KeysDown[k] = false;
}
sAccelKeys.clear();

io.KeyCtrl = false;
io.KeyShift = false;
io.KeyAlt = false;
}

void initialize( const Options &options )
{
Expand Down Expand Up @@ -1001,8 +1014,10 @@ void initialize( const Options &options )
renderer->addFont( font.first, font.second, options.getFontGlyphRanges( name ), options.getFontMergeMode() );
}
renderer->initFontTexture();

#ifndef CINDER_LINUX


// #ifndef CINDER_LINUX
#if defined(CINDER_LINUX) && !defined(CINDER_ANDROID)
// clipboard callbacks
io.SetClipboardTextFn = []( void* user_data, const char* text ) {
const char* text_end = text + strlen(text);
Expand Down Expand Up @@ -1053,7 +1068,6 @@ void initialize( const Options &options )
currentContext->makeCurrent();
}


void connectWindow( ci::app::WindowRef window )
{
sWindowConnections += window->getSignalMouseDown().connect( mouseDown );
Expand Down