Example #1
0
void AppBase::privateUpdate__()
{
	mFrameCount++;

	// service asio::io_service
	mIo->poll();

	if( getNumWindows() > 0 ) {
		WindowRef mainWin = getWindowIndex( 0 );
		if( mainWin )
			mainWin->getRenderer()->makeCurrentContext();
	}

	mSignalUpdate.emit();

	update();

	mTimeline->stepTo( static_cast<float>( getElapsedSeconds() ) );

	double now = mTimer.getSeconds();
	if( now > mFpsLastSampleTime + mFpsSampleInterval ) {
		//calculate average Fps over sample interval
		uint32_t framesPassed = mFrameCount - mFpsLastSampleFrame;
		mAverageFps = (float)(framesPassed / (now - mFpsLastSampleTime));

		mFpsLastSampleTime = now;
		mFpsLastSampleFrame = mFrameCount;
	}
}
void ImageRetargetingApp::seamCarvingWindowResize()
{
    if(seamCarvingState != SeamCarvingState::SeamCarving)
    {
        seamCarver->newWidth = seamCarvingWindow->getWidth();
        seamCarver->newHeight = seamCarvingWindow->getHeight();
    }
}
void SlingshotSmokeApp::setup()
{
	mVolumeMult = 5.0;

	mLastTime = 0;

	getWindowIndex(0)->getSignalDraw().connect([=]() { drawRender(); });

	mAudioSource = AudioSource();
	mAudioSource.setup();

	vec2 fluidResolution = vec2(512);
	vec2 smokeResolution = app::getWindowSize();

	mFluid = Fluid(fluidResolution);
	mSmokers.reserve(2);
	mSmokers.push_back(shared_ptr<FakeSmoker>(new FakeSmoker(fluidResolution, smokeResolution)));
	mSmokers.push_back(shared_ptr<PositionSmoker>(new PositionSmoker(fluidResolution, smokeResolution)));
	mSmokers.push_back(shared_ptr<TransitionSmoker>(new TransitionSmoker(fluidResolution, smokeResolution)));
	mSmokers.push_back(shared_ptr<BottomSmoker>(new BottomSmoker(fluidResolution, smokeResolution)));
	mCurrentSmoker = 0;

	mSmokers[mCurrentSmoker]->light(vec2(0.5, 0.2), mParams);


	gl::GlslProg::Format renderFormat;
	renderFormat.vertex(app::loadAsset("passthru.vert"));
	renderFormat.fragment(app::loadAsset("Smokers/smoke_draw.frag"));
	mRenderProg = gl::GlslProg::create(renderFormat);
	mRenderProg->uniform("i_resolution", smokeResolution);

	gl::Texture2d::Format texFmt;
	texFmt.setInternalFormat(GL_RGBA32F);
	texFmt.setDataType(GL_FLOAT);
	texFmt.setTarget(GL_TEXTURE_2D);
	texFmt.setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
	gl::Fbo::Format fmt;
	fmt.disableDepth()
		.setColorTextureFormat(texFmt);
	mSmokeField = PingPongFBO(fmt, smokeResolution, 4);


	// Do params last so that all the FBOs are in the right context
	vec2 paramsSize = vec2(255, 512);
	auto format = Window::Format();
	format.setSize(paramsSize + vec2(40, 20));
	format.setPos(ivec2(100));
	WindowRef paramsWindow = createWindow(format);
	paramsWindow->getSignalDraw().connect([=]() { drawParams(); });
	mParams = params::InterfaceGl::create(paramsWindow, "Options", paramsSize);

	mParams->addParam("Volume", &mVolumeMult)
		.max(10.0)
		.min(0.0)
		.step(0.1);
}
void ImageRetargetingApp::meshWarpingWindowResize()
{
    meshWarpRetargetter->resizeWidth = meshWarpingWindow->getWidth();
    meshWarpRetargetter->resizeHeight = meshWarpingWindow->getHeight();
    if(meshWarpRetargetter->getNumVertices() < 500)
    {
        meshWarpRetargetter->resizeMeshRect(meshWarpRetargetter->resizeWidth , meshWarpRetargetter->resizeHeight);
        meshWarpingState = MeshWarpingState::ShowMeshWarping;
    }
}
	bool initialize( const WindowRef& window ) override
	{
		// Make sure our window is positioned and sized correctly.
		window->setBorderless( true );
		window->setPos( mRift->getNativeWindowPos() );
		window->setSize( mRift->getNativeWindowResolution() );
		// Create or resize the frame buffer.
		mRift->initializeFrameBuffer();
		initializeDistortion();
		return true;
	}
void ImageRetargetingApp::drawSeamCarvingWindow()
{
    gl::clear( Color( 0.f, 0.f, 0.f ) );
    switch(seamCarvingState)
    {
        case SeamCarvingState::ShowImage:
            if( seamCarvedTexture ) {
                gl::draw(seamCarvedTexture);
            }
            break;
            
        case SeamCarvingState::ShowGradient:
            if( gradientTexture ) {
                gl::draw(gradientTexture);
            }
            break;
            
        case SeamCarvingState::SeamCarving:
            if(seamCarvedTexture){
                int dw = seamCarver->newWidth - seamCarvedImage.getWidth();
                int dh = seamCarver->newHeight - seamCarvedImage.getHeight();
                
                if (dw<0 && dh<0){
                    seamCarvingWindow->setSize(seamCarvedTexture.getWidth()-1, seamCarvedTexture.getHeight());
                    seamCarvedImage = seamCarver->deleteVerticalSeam(seamCarvedImage);
                }
                else if (dw<0){
                    seamCarvingWindow->setSize(seamCarvedTexture.getWidth()-1, seamCarvedTexture.getHeight());
                    seamCarvedImage = seamCarver->deleteVerticalSeam(seamCarvedImage);
                }
                else if (dh<0){
                    seamCarvingWindow->setSize(seamCarvedTexture.getWidth(), seamCarvedTexture.getHeight()-1);
                    seamCarvedImage = seamCarver->deleteHorizontalSeam(seamCarvedImage);
                }
                //TODO:: Add Seam
                else if (dw>=0 && dh>=0) {
                    seamCarvingState = SeamCarvingState::ShowImage;
                    seamCarver->stopCarveTimer();
                }
                seamCarvedTexture = gl::Texture(seamCarvedImage);
                gl::draw(seamCarvedTexture);
            }
            
            break;
        case SeamCarvingState::Undefined:
            break;
    }
    seamCarvingParams->draw();
}
void ImageRetargetingApp::resizeMeshRect()
{
    meshWarpRetargetter->startTimer();
    meshWarpRetargetter->resizeMeshRect(meshWarpRetargetter->resizeWidth , meshWarpRetargetter->resizeHeight);
    meshWarpRetargetter->stopTimer();
    meshWarpingState = MeshWarpingState::ShowMeshWarping;
    meshWarpingWindow->setSize(meshWarpRetargetter->resizeWidth , meshWarpRetargetter->resizeHeight);
}
	bool initialize( const WindowRef& window ) override
	{
		// Attach to window.
		if( ! ovrHmd_AttachToWindow( mRift->mHmd, window->getNative(), nullptr, nullptr ) ) {
			return false;
		}
		// Create or resize the frame buffer.
		mRift->initializeFrameBuffer();
		return true;
	}
void ImageRetargetingApp::meshWarperResetButtonClick()
{
    meshWarpingState = MeshWarpingState::ShowImage;
    saliencyImage = saliencySegmentor->getSaliencyMap(originalImage.clone(), SaliencySegmentor::SaliencyMethod::Sobel);
    saliencyImage = saliencySegmentor->getSegmentedSalientImage(saliencyImage);
    saliencyTexture = gl::Texture(saliencyImage);
    
    meshWarpRetargetter->initMesh(originalImage.getWidth(), originalImage.getHeight(), saliencySegmentor);
    meshWarpingWindow->setSize(originalImage.getWidth(), originalImage.getHeight());
}
Example #10
0
void TouchUi::connect( const WindowRef& window, int signalPriority )
{
	mSignalPriority	= signalPriority;
	mWindow			= window;
	if ( window ) {
		mConnectionTouchesBegan = window->getSignalTouchesBegan().connect( signalPriority,
			[ this ]( app::TouchEvent &event ) { touchesBegan( event ); } );
		mConnectionTouchesEnded = window->getSignalTouchesEnded().connect( signalPriority,
			[ this ]( app::TouchEvent &event ) { touchesEnded( event ); } );
		mConnectionTouchesMoved = window->getSignalTouchesMoved().connect( signalPriority,
			[ this ]( app::TouchEvent &event ) { touchesMoved( event ); } );
		mConnectionUpdate = app::App::get()->getSignalUpdate().connect( signalPriority,
			[ this ]() { update(); } );
		if ( mMask.empty() ) {
			setMask( Area( ivec2( 0 ), window->getSize() ) );
		}
	} else {
		disconnect();
	}
}
void ImageRetargetingApp::initWindows()
{
    linearScaleWindow = this->getWindow();
    linearScaleWindow->setTitle("Linear Scaling");
    linearScaleWindow->connectDraw(&ImageRetargetingApp::drawLinearScaleWindow, this);
    linearScaleWindow->connectResize(&ImageRetargetingApp::linearResizeWindowResize, this);
    linearScalingParams = params::InterfaceGl::create( linearScaleWindow, "Original Image Data", toPixels( ci::Vec2i( 200, 400 ) ) );
    
    seamCarvingWindow = createWindow();
    seamCarvingWindow->setTitle("Seam Carving");
    seamCarvingWindow->connectDraw(&ImageRetargetingApp::drawSeamCarvingWindow, this);
    seamCarvingWindow->connectResize(&ImageRetargetingApp::seamCarvingWindowResize, this);
    seamCarvingParams = params::InterfaceGl::create( seamCarvingWindow, "Seam Carving", toPixels( ci::Vec2i( 200, 400 ) ) );
    
    meshWarpingWindow = createWindow();
    meshWarpingWindow->setTitle("Mesh Warping");
    meshWarpingWindow->connectDraw(&ImageRetargetingApp::drawMeshWarpingWindow, this);
    meshWarpingWindow->connectResize(&ImageRetargetingApp::meshWarpingWindowResize, this);
    meshWarpingParams = params::InterfaceGl::create( meshWarpingWindow, "Mesh Warping", toPixels( ci::Vec2i( 200, 400 ) ) );
}
Example #12
0
TouchUi::TouchUi( const WindowRef& window, int signalPriority )
{
	mEnabled			= true;
	mEnabledConstrain	= true;
	mEnabledPan			= true;
	mEnabledRotation	= true;
	mEnabledScale		= true;
	mEnabledTap			= true;
	mInterpolationSpeed	= 0.33f;
	mNumTouchPointsMax	= numeric_limits<int32_t>::max();
	mNumTouchPointsMin	= 1;
	mPan				= vec2( 0.0f );
	mPanMax				= vec2( numeric_limits<float>::max() );
	mPanMin				= vec2( -numeric_limits<float>::max() );
	mPanSpeed			= vec2( 1.0f );
	mPanTarget			= mPan;
	mPanThreshold		= vec2( 1.0f );
	mRotationSpeed		= -2.5f;
	mRotationThreshold	= 0.005f;
	mScale				= vec2( 1.0f );
	mScaleMax			= vec2( numeric_limits<float>::max() );
	mScaleMin			= vec2( 0.0f );
	mScaleSpeed			= vec2( 0.0067f );
	mScaleSymmetry		= true;
	mScaleTarget		= mScale;
	mScaleThreshold		= vec2( 1.0f );
	mTapDelay			= 0.07;
	mTapPosition		= vec2( numeric_limits<float>::min() );
	mTapTime			= 0.0;
	mTapThreshold		= 15.0f;
	mTouchDelay			= 0.07;
	mTouchTime			= 0.0;

	if ( window != nullptr ) {
		setMask( Area( ivec2( 0 ), window->getSize() ) );
	}
	connect( window, signalPriority );
}
void ImageRetargetingApp::resetWindowOriginalSize(WindowRef window)
{
    window->setSize(originalTexture.getWidth(), originalTexture.getHeight());
}
Example #14
0
void View::create (WindowRef & ciWindow, const fs::path & assetFolder)
{
   try
   {
      initGraph (&fps, GRAPH_RENDER_FPS, "Frame Time");
      initGraph (&cpuGraph, GRAPH_RENDER_MS, "CPU Time");

      setSize (ciWindow->getSize());

      nanogui::Window * window = new nanogui::Window (this, "Button demo");
      window->setPosition (ivec2 (15, 15));
      window->setLayout (new GroupLayout());
      /* No need to store a pointer, the data structure will be automatically
         freed when the parent window is deleted */
      new Label (window, "Push buttons", "sans-bold");
      Button * b = new Button (window, "Plain button");
      b->setCallback ([] { cout << "pushed!" << endl; });
      b = new Button (window, "Styled", ENTYPO_ICON_ROCKET);
      b->setBackgroundColor (Colour (0, 0, 255, 25));
      b->setCallback ([] { cout << "pushed!" << endl; });
      new Label (window, "Toggle buttons", "sans-bold");
      b = new Button (window, "Toggle me");
      b->setFlags (Button::ToggleButton);
      b->setChangeCallback ([] (bool state)
      {
         cout << "Toggle button state: " << state << endl;
      });
      new Label (window, "Radio buttons", "sans-bold");
      b = new Button (window, "Radio button 1");
      b->setFlags (Button::RadioButton);
      b = new Button (window, "Radio button 2");
      b->setFlags (Button::RadioButton);
      new Label (window, "A tool palette", "sans-bold");
      Widget * tools = new Widget (window);
      tools->setLayout (new BoxLayout (Orientation::Horizontal,
                                       Alignment::Middle, 0, 6));
      b = new ToolButton (tools, ENTYPO_ICON_CLOUD);
      b = new ToolButton (tools, ENTYPO_ICON_FF);
      b = new ToolButton (tools, ENTYPO_ICON_COMPASS);
      b = new ToolButton (tools, ENTYPO_ICON_INSTALL);
      new Label (window, "Popup buttons", "sans-bold");
      PopupButton * popupBtn = new PopupButton (window, "Popup", ENTYPO_ICON_EXPORT);
      Popup * popup = popupBtn->popup();
      popup->setLayout (new GroupLayout());
      new Label (popup, "Arbitrary widgets can be placed here");
      new CheckBox (popup, "A check box");
      popupBtn = new PopupButton (popup, "Recursive popup", ENTYPO_ICON_FLASH);
      popup = popupBtn->popup();
      popup->setLayout (new GroupLayout());
      new CheckBox (popup, "Another check box");
      window = new nanogui::Window (this, "Basic widgets");
      window->setPosition (ivec2 (200, 15));
      window->setLayout (new GroupLayout());
      new Label (window, "Message dialog", "sans-bold");
      tools = new Widget (window);
      tools->setLayout (new BoxLayout (Orientation::Horizontal,
                                       Alignment::Middle, 0, 6));
      b = new Button (tools, "Info");
      b->setCallback ([&]
      {
         auto dlg = new MessageDialog (this, MessageDialog::Type::Information, "Title", "This is an information message");
         dlg->setCallback ([] (int result)
         {
            cout << "Dialog result: " << result << endl;
         });
      });
      b = new Button (tools, "Warn");
      b->setCallback ([&]
      {
         auto dlg = new MessageDialog (this, MessageDialog::Type::Warning, "Title", "This is a warning message");
         dlg->setCallback ([] (int result)
         {
            cout << "Dialog result: " << result << endl;
         });
      });
      b = new Button (tools, "Ask");
      b->setCallback ([&]
      {
         auto dlg = new MessageDialog (this, MessageDialog::Type::Warning, "Title", "This is a question message", "Yes", "No", true);
         dlg->setCallback ([] (int result)
         {
            cout << "Dialog result: " << result << endl;
         });
      });

	  std::string iconPath = assetFolder.string();
	  iconPath += "/icons";
     
      std::vector<std::pair<int, std::string>> icons = NanoUtil::loadImageDirectory (getContext(), iconPath);
      new Label (window, "Image panel & scroll panel", "sans-bold");
      PopupButton * imagePanelBtn = new PopupButton (window, "Image Panel");
      imagePanelBtn->setIcon (ENTYPO_ICON_FOLDER);
      popup = imagePanelBtn->popup();
      VScrollPanel * vscroll = new VScrollPanel (popup);
      ImagePanel * imgPanel = new ImagePanel (vscroll);
      imgPanel->setImages (icons);
      popup->setFixedSize (ivec2 (245, 150));
      new Label (window, "Selected image", "sans-bold");
      auto img = new ImageView (window);
      img->setFixedSize (ivec2 (40, 40));
      img->setImage (icons[0].first);
      imgPanel->setCallback ([ &, img, imgPanel, imagePanelBtn] (int i)
      {
         img->setImage (imgPanel->images()[i].first);
         cout << "Selected item " << i << endl;
      });
      new Label (window, "Combo box", "sans-bold");
      new ComboBox (window, { "Combo box item 1", "Combo box item 2", "Combo box item 3" });
      new Label (window, "Check box", "sans-bold");
      CheckBox * cb = new CheckBox (window, "Flag 1",
                                    [] (bool state)
      {
         cout << "Check box 1 state: " << state << endl;
      }
                                   );
      cb->setChecked (true);
      cb = new CheckBox (window, "Flag 2",
                         [] (bool state)
      {
         cout << "Check box 2 state: " << state << endl;
      }
                        );
      new Label (window, "Progress bar", "sans-bold");
      mProgress = new ProgressBar (window);
      new Label (window, "Slider and text box", "sans-bold");
      Widget * panel = new Widget (window);
      panel->setLayout (new BoxLayout (Orientation::Horizontal,
                                       Alignment::Middle, 0, 20));
      Slider * slider = new Slider (panel);
      slider->setValue (0.5f);
      slider->setFixedWidth (80);
      TxtBox * textBox = new TxtBox (panel);
      textBox->setFixedSize (ivec2 (60, 25));
      textBox->setValue ("50");
      textBox->setUnits ("%");
      slider->setCallback ([textBox] (float value)
      {
         textBox->setValue (std::to_string ((int) (value * 100)));
      });
      slider->setFinalCallback ([&] (float value)
      {
         cout << "Final slider value: " << (int) (value * 100) << endl;
      });
      textBox->setFixedSize (ivec2 (60, 25));
      textBox->setFontSize (20);
      textBox->setAlignment (TxtBox::Alignment::Right);


	  window = new nanogui::Window(this, "Misc. widgets");
	  window->setPosition(ivec2(425, 15));
	  window->setLayout(new GroupLayout());
	  new Label(window, "Color wheel", "sans-bold");
	  new ColorWheel(window);
	  new Label(window, "Function graph", "sans-bold");
	  Graph *graph = new Graph(window, "Some function");
	  graph->setHeader("E = 2.35e-3");
	  graph->setFooter("Iteration 89");
	  std::vector<float> &func = graph->values();
	  func.resize(100);
	  for (int i = 0; i < 100; ++i)
		  func[i] = 0.5f * (0.5f * std::sin(i / 10.f) +
			  0.5f * std::cos(i / 23.f) + 1);

	  window = new nanogui::Window(this, "Grid of small widgets");
	  window->setPosition(ivec2(425, 288));
	  GridLayout *layout =
		  new GridLayout(Orientation::Horizontal, 2,
			  Alignment::Middle, 15, 5);
	  layout->setColAlignment(
	  { Alignment::Maximum, Alignment::Fill });
	  layout->setSpacing(0, 10);
	  window->setLayout(layout);

	  {
		  new Label(window, "Floating point :", "sans-bold");
		  textBox = new TxtBox(window);
		  textBox->setEditable(true);
		  textBox->setFixedSize(ivec2(100, 20));
		  textBox->setValue("50");
		  textBox->setUnits("GiB");
		  textBox->setDefaultValue("0.0");
		  textBox->setFontSize(16);
		  textBox->setFormat("[-]?[0-9]*\\.?[0-9]+");
	  }

	  {
		  new Label(window, "Positive integer :", "sans-bold");
		  textBox = new TxtBox(window);
		  textBox->setEditable(true);
		  textBox->setFixedSize(ivec2(100, 20));
		  textBox->setValue("50");
		  textBox->setUnits("Mhz");
		  textBox->setDefaultValue("0.0");
		  textBox->setFontSize(16);
		  textBox->setFormat("[1-9][0-9]*");
	  }

	  {
		  new Label(window, "Checkbox :", "sans-bold");

		  cb = new CheckBox(window, "Check me");
		  cb->setFontSize(16);
		  cb->setChecked(true);
	  }

	  new Label(window, "Combo box :", "sans-bold");
	  ComboBox *cobo =
		  new ComboBox(window, { "Item 1", "Item 2", "Item 3" });
	  cobo->setFontSize(16);
	  cobo->setFixedSize(ivec2(100, 20));

	  new Label(window, "Color button :", "sans-bold");
	  popupBtn = new PopupButton(window, "", 0);
	  popupBtn->setBackgroundColor(Colour(255, 120, 0, 255));
	  popupBtn->setFontSize(16);
	  popupBtn->setFixedSize(ivec2(100, 20));
	  popup = popupBtn->popup();
	  popup->setLayout(new GroupLayout());

	  ColorWheel *colorwheel = new ColorWheel(popup);
	  colorwheel->setColor(popupBtn->backgroundColor());

	  Button *colorBtn = new Button(popup, "Pick");
	  colorBtn->setFixedSize(ivec2(100, 25));
	  Colour c = colorwheel->color();
	  colorBtn->setBackgroundColor(c);

	  colorwheel->setCallback([colorBtn](const Colour &value) {
		  colorBtn->setBackgroundColor(value);
	  });

	  colorBtn->setChangeCallback([colorBtn, popupBtn](bool pushed) {
		  if (pushed) {
			  popupBtn->setBackgroundColor(colorBtn->backgroundColor());
			  popupBtn->setPushed(false);
		  }
	  });

      performLayout (mNVGContext);
   }
   catch (const std::exception & e)
   {
      std::cout << e.what() << std::endl;
   }
}
Example #15
0
void View::create (WindowRef & ciWindow)
{
   try
   {
      initGraph (&fps, GRAPH_RENDER_FPS, "Frame Time");
      initGraph (&cpuGraph, GRAPH_RENDER_MS, "CPU Time");

      setSize (ciWindow->getSize());

      nanogui::Window * window = new nanogui::Window (this, "Button demo");
      window->setPosition (ivec2 (15, 15));
      window->setLayout (new GroupLayout());
      /* No need to store a pointer, the data structure will be automatically
         freed when the parent window is deleted */
      new Label (window, "Push buttons", "sans-bold");
      Button * b = new Button (window, "Plain button");
      b->setCallback ([] { cout << "pushed!" << endl; });
      b = new Button (window, "Styled", ENTYPO_ICON_ROCKET);
      b->setBackgroundColor (Colour (0, 0, 255, 25));
      b->setCallback ([] { cout << "pushed!" << endl; });
      new Label (window, "Toggle buttons", "sans-bold");
      b = new Button (window, "Toggle me");
      b->setFlags (Button::ToggleButton);
      b->setChangeCallback ([] (bool state)
      {
         cout << "Toggle button state: " << state << endl;
      });
      new Label (window, "Radio buttons", "sans-bold");
      b = new Button (window, "Radio button 1");
      b->setFlags (Button::RadioButton);
      b = new Button (window, "Radio button 2");
      b->setFlags (Button::RadioButton);
      new Label (window, "A tool palette", "sans-bold");
      Widget * tools = new Widget (window);
      tools->setLayout (new BoxLayout (Orientation::Horizontal,
                                       Alignment::Middle, 0, 6));
      b = new ToolButton (tools, ENTYPO_ICON_CLOUD);
      b = new ToolButton (tools, ENTYPO_ICON_FF);
      b = new ToolButton (tools, ENTYPO_ICON_COMPASS);
      b = new ToolButton (tools, ENTYPO_ICON_INSTALL);
      new Label (window, "Popup buttons", "sans-bold");
      PopupButton * popupBtn = new PopupButton (window, "Popup", ENTYPO_ICON_EXPORT);
      Popup * popup = popupBtn->popup();
      popup->setLayout (new GroupLayout());
      new Label (popup, "Arbitrary widgets can be placed here");
      new CheckBox (popup, "A check box");
      popupBtn = new PopupButton (popup, "Recursive popup", ENTYPO_ICON_FLASH);
      popup = popupBtn->popup();
      popup->setLayout (new GroupLayout());
      new CheckBox (popup, "Another check box");
      window = new nanogui::Window (this, "Basic widgets");
      window->setPosition (ivec2 (200, 15));
      window->setLayout (new GroupLayout());
      new Label (window, "Message dialog", "sans-bold");
      tools = new Widget (window);
      tools->setLayout (new BoxLayout (Orientation::Horizontal,
                                       Alignment::Middle, 0, 6));
      b = new Button (tools, "Info");
      b->setCallback ([&]
      {
         auto dlg = new MessageDialog (this, MessageDialog::Type::Information, "Title", "This is an information message");
         dlg->setCallback ([] (int result)
         {
            cout << "Dialog result: " << result << endl;
         });
      });
      b = new Button (tools, "Warn");
      b->setCallback ([&]
      {
         auto dlg = new MessageDialog (this, MessageDialog::Type::Warning, "Title", "This is a warning message");
         dlg->setCallback ([] (int result)
         {
            cout << "Dialog result: " << result << endl;
         });
      });
      b = new Button (tools, "Ask");
      b->setCallback ([&]
      {
         auto dlg = new MessageDialog (this, MessageDialog::Type::Warning, "Title", "This is a question message", "Yes", "No", true);
         dlg->setCallback ([] (int result)
         {
            cout << "Dialog result: " << result << endl;
         });
      });
      std::string iconPath ("E:/Code4/nanofish/projects/qdemos/cinder/ciNanogui/assets/icons");
      std::vector<std::pair<int, std::string>> icons = NanoUtil::loadImageDirectory (getContext(), iconPath);
      new Label (window, "Image panel & scroll panel", "sans-bold");
      PopupButton * imagePanelBtn = new PopupButton (window, "Image Panel");
      imagePanelBtn->setIcon (ENTYPO_ICON_FOLDER);
      popup = imagePanelBtn->popup();
      VScrollPanel * vscroll = new VScrollPanel (popup);
      ImagePanel * imgPanel = new ImagePanel (vscroll);
      imgPanel->setImages (icons);
      popup->setFixedSize (ivec2 (245, 150));
      new Label (window, "Selected image", "sans-bold");
      auto img = new ImageView (window);
      img->setFixedSize (ivec2 (40, 40));
      img->setImage (icons[0].first);
      imgPanel->setCallback ([ &, img, imgPanel, imagePanelBtn] (int i)
      {
         img->setImage (imgPanel->images()[i].first);
         cout << "Selected item " << i << endl;
      });
      new Label (window, "Combo box", "sans-bold");
      new ComboBox (window, { "Combo box item 1", "Combo box item 2", "Combo box item 3" });
      new Label (window, "Check box", "sans-bold");
      CheckBox * cb = new CheckBox (window, "Flag 1",
                                    [] (bool state)
      {
         cout << "Check box 1 state: " << state << endl;
      }
                                   );
      cb->setChecked (true);
      cb = new CheckBox (window, "Flag 2",
                         [] (bool state)
      {
         cout << "Check box 2 state: " << state << endl;
      }
                        );
      new Label (window, "Progress bar", "sans-bold");
      mProgress = new ProgressBar (window);
      performLayout (mNVGContext);
   }
   catch (const std::exception & e)
   {
      std::cout << e.what() << std::endl;
   }
}
void ImageRetargetingApp::resizeMeshEllipse()
{
    meshWarpRetargetter->resizeMeshEllipse(meshWarpRetargetter->resizeWidth , meshWarpRetargetter->resizeHeight);
    meshWarpingState = MeshWarpingState::ShowMeshWarping;
    meshWarpingWindow->setSize(meshWarpRetargetter->resizeWidth , meshWarpRetargetter->resizeHeight);
}
Example #17
0
inline ManagerRef getManager(WindowRef id) {
	return getManager(id.get());
}
void ImageRetargetingApp::linearResizeResetButtonClick()
{
    linearScaleRec->set(0,0,originalImage.getWidth(),originalImage.getHeight());
    linearScaleWindow->setSize(originalImage.getWidth(),originalImage.getHeight());
}
bool OculusRift::isValid( const WindowRef& window )
{
	return window && window->isValid();
}
void ImageRetargetingApp::linearResizeButtonClick()
{
    linearScaleRec->set(0,0,linearScaleWidth,linearScaleHeight);
    linearScaleWindow->setSize(linearScaleWidth,linearScaleHeight);
}
void ImageRetargetingApp::linearResizeWindowResize()
{
    linearScaleWidth = linearScaleWindow->getWidth();
    linearScaleHeight = linearScaleWindow->getHeight();
    linearScaleRec->set(0,0,linearScaleWidth,linearScaleHeight);
}