Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gorborukov/050f3351c593fda57280c05787e020ba to your computer and use it in GitHub Desktop.
Save gorborukov/050f3351c593fda57280c05787e020ba to your computer and use it in GitHub Desktop.
ImGui responsive 3 columns layout (ofx based example)
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
gui.setup();
backgroundColor = ofColor(0, 0, 0);
}
//--------------------------------------------------------------
void ofApp::update(){
}
//--------------------------------------------------------------
void ofApp::draw(){
ofSetBackgroundColor(backgroundColor);
gui.begin();
ImGui::SetNextWindowPos(ImVec2(0,0));
ImGui::SetNextWindowSize(ImVec2(ofGetWindowWidth()/4.0f, Viewport->Size.y));
if (ImGui::Begin("Left Window", NULL, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize))
{
ImGui::TextUnformatted("Text");
}
ImGui::End();
ImGui::SetNextWindowPos(ImVec2(ofGetWindowWidth()/4.0f,0));
ImGui::SetNextWindowSize(ImVec2(ofGetWindowWidth()/2.0f, Viewport->Size.y));
if (ImGui::Begin("Center Window", NULL, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize))
{
ImGui::TextUnformatted("Text");
}
ImGui::End();
ImGui::SetNextWindowPos(ImVec2((ofGetWindowWidth()/4.0f)*3,0));
ImGui::SetNextWindowSize(ImVec2(ofGetWindowWidth()/4.0f, Viewport->Size.y));
if (ImGui::Begin("Right Window", NULL, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize))
{
ImGui::TextUnformatted("Text");
}
ImGui::End();
gui.end();
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){
}
//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){
}
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){
int minWidth = 1024;
int minHeight = 768;
if(w < minWidth || h < minHeight)
{
ofSetWindowShape(minWidth, minHeight);
}
}
//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment