Created
November 22, 2020 19:22
-
-
Save cyrstem/a5f619ec100bb87ae9868426d3f35a9e to your computer and use it in GitHub Desktop.
noizu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "cinder/app/App.h" | |
#include "cinder/app/RendererGl.h" | |
#include "cinder/gl/gl.h" | |
using namespace ci; | |
using namespace ci::app; | |
using namespace std; | |
// A really basic button class | |
class BasicButton { | |
public: | |
BasicButton( const string &name, const Rectf &rect ); | |
void draw(); | |
protected: | |
string mName; | |
Rectf mBounds; | |
}; | |
class noizu : public App { | |
public: | |
void update() override; | |
void draw() override; | |
auto window = App::getWindow(); | |
window->getSignalDraw().connect( [this]{ | |
gl::clear(Color::gray( 0.5f ) ); | |
}); | |
}; | |
// The BasicButton class implementation | |
BasicButton::BasicButton( const std::string &name, const ci::Rectf &rect ) | |
: mName( name ), mBounds( rect ) | |
{ | |
// subscribe to mouse down event of the app window | |
ci::app::getWindow()->getSignalMouseDown().connect( [this]( ci::app::MouseEvent event ) { | |
// Check if the mouse is inside the bounds of this button | |
if( mBounds.contains( event.getPos() ) ) { | |
ci::app::console() << mName << " clicked!" << std::endl; | |
} | |
}); | |
} | |
void noizu::update( ) | |
{ | |
} | |
void noizu::draw( ) | |
{ | |
gl::clear( Color( 0, 0, 0 ) ); | |
} | |
// This line tells Cinder to actually create and run the application. | |
CINDER_APP( noizu, RendererGl, []( App::Settings *settings ){ | |
settings->setWindowSize(1200,700); | |
settings->setTitle("Noizu"); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment