//--------------------------------------------------------------
void ofxFileDialog::draw() {
	if(!m_active) {return;}
	
	// default size if not set
	if(m_width == 0 || m_height == 0) {
		resize(ofGetWidth(), ofGetHeight());
	}

	ofPushStyle();
	ofPushView();
		ofEnableAlphaBlending(); // for fontstash
		ofViewport(0, 0, m_width, m_height);
		ofFill();
	
		// font color
		s_font->setColor(m_settings->getTextColor(), m_settings->getAlpha());
		s_font->setShadowColor(m_settings->getTextShadowColor(), m_settings->getAlpha());
	
		// draw current path
		int pathWidth = s_font->stringWidth(m_path);
		if(pathWidth > m_visibleWidth) { // make sure right side is visible
			s_font->drawString(m_path, m_visibleWidth-pathWidth, s_charHeight);
		}
		else {
			s_font->drawString(m_path, 0, s_charHeight);
		}
	
		// indent and draw dialogs
		ofTranslate(s_charWidth*4, 0);
		switch(m_mode) {
			case SAVEAS:
				drawSaveAs();
				break;
			case OPEN:
				drawOpen();
				break;
			case NEWFOLDER:
				drawNewFolder();
				break;
		}
	
	ofPopView();
	ofPopStyle();

	// update animation timestamps
	updateTimestamps();
}
Esempio n. 2
0
  void Arrow::draw ( const Point& from, const Point& to ) const
  {
    Vector v = to - from;
    double length = v.length();
    Vector n = v;
    n.normalize();
    Vector x( 1, 0, 0 );	// Canonical direction for drawing the arrow
    double theta = n * x;
    Vector r = x.cross( v ); // Rotation vector
    double rl = r.length();
    if ( fabs( rl ) > 1e-6 )
      r.normalize();
    else
      r = Vector( 0, 0, 1 );	// theta == 0 anyway

    // Also, figure out how to rotate the arrow head so that it is
    // normal to the view normal, i.e., so you can always see the side
    // of the arrow head. Start by applying the orienting rotation to
    // the canonical arrow head normal.
    Matrix m( Matrix::ROTATION, r[X], r[Y], r[Z], -acos( theta ) );
    Vector z( 0, 0, 1 );// Canonical arrow head normal
    Vector zr = m * z;
    Vector y( 0, 1, 0 );//The "other" direction (in the plane of n)
    Vector yr = m * y;
    double dz = zr * view_normal_;
    double dy = yr * view_normal_;
    double phi = atan2( dy, dz );

    glPushMatrix();

    glTranslated( from[X], from[Y], from[Z] );
    glRotated( -180 * phi / M_PI, n[X], n[Y], n[Z] );
    glRotated( 180 * acos( theta ) / M_PI, r[X], r[Y], r[Z] );

    switch ( style_ ) {
    case lC::OPEN:
      drawOpen( length ); break;
    case lC::HOLLOW:
      drawHollow( length ); break;
    case lC::FILLED:
      drawFilled( length ); break;
    }

    glPopMatrix();
  }
Esempio n. 3
0
  void Arrow::draw ( const Point& from, const Point& to ) const
  {
    Vector v = to - from;
    double theta = v.orientation();
    double length = v.length();

    glPushMatrix();

    glTranslated( from.p_[X], from.p_[Y], 0. );
    glRotated( theta, 0., 0., 1. );

    switch ( style_ ) {
    case lC::OPEN:
      drawOpen( length ); break;
    case lC::HOLLOW:
      drawHollow( length ); break;
    case lC::FILLED:
      drawFilled( length ); break;
    }

    glPopMatrix();
  }