void CPopUp::draw()

in layer4/PopUp.cpp [601:969]


void CPopUp::draw(CGO* orthoCGO)
{
  CPopUp *I = this; // TODO: Remove I during PopUp refactor
  PyMOLGlobals *G = m_G;
  int x, y, a, xx;
  char *c;

  if(G->HaveGUI && G->ValidContext) {

    if((I->Child) && (I->Selected != I->ChildLine))
      PyMOL_NeedFakeDrag(G->PyMOL);

    /* put raised border around pop-up menu */

    if (orthoCGO){
      CGOColor(orthoCGO, 0.2F, 0.2F, 0.4F);
      CGOBegin(orthoCGO, GL_TRIANGLE_STRIP);
      CGOVertex(orthoCGO, rect.left - 2, rect.bottom - 2, 0.f);
      CGOVertex(orthoCGO, rect.right + 2, rect.bottom - 2, 0.f);
      CGOVertex(orthoCGO, rect.left - 2, rect.bottom + 1, 0.f);
      CGOVertex(orthoCGO, rect.right + 2, rect.bottom + 1, 0.f);
      CGOEnd(orthoCGO);
    } else {
      glColor3f(0.2F, 0.2F, 0.4F);
      glBegin(GL_POLYGON);
      glVertex2i(rect.left - 2, rect.bottom - 2);
      glVertex2i(rect.right + 2, rect.bottom - 2);
      glVertex2i(rect.right + 2, rect.bottom + 1);
      glVertex2i(rect.left - 2, rect.bottom + 1);
      glEnd();
    }

    if (orthoCGO){
      CGOColor(orthoCGO, 0.4F, 0.4F, 0.6F);
      CGOBegin(orthoCGO, GL_TRIANGLE_STRIP);
      CGOVertex(orthoCGO, rect.left - 1, rect.bottom - 1, 0.f);
      CGOVertex(orthoCGO, rect.right + 1, rect.bottom - 1, 0.f);
      CGOVertex(orthoCGO, rect.left - 1, rect.bottom + 1, 0.f);
      CGOVertex(orthoCGO, rect.right + 1, rect.bottom + 1, 0.f);
      CGOEnd(orthoCGO);
    } else {
      glColor3f(0.4F, 0.4F, 0.6F);
      glBegin(GL_POLYGON);
      glVertex2i(rect.left - 1, rect.bottom - 1);
      glVertex2i(rect.right + 1, rect.bottom - 1);
      glVertex2i(rect.right + 1, rect.bottom + 1);
      glVertex2i(rect.left - 1, rect.bottom + 1);
      glEnd();
    }
    /* right */

    if (orthoCGO){
      CGOColor(orthoCGO, 0.2F, 0.2F, 0.4F);
      CGOBegin(orthoCGO, GL_TRIANGLE_STRIP);
      CGOVertex(orthoCGO, rect.right, rect.bottom - 2, 0.f);
      CGOVertex(orthoCGO, rect.right + 2, rect.bottom - 2, 0.f);
      CGOVertex(orthoCGO, rect.right, rect.top, 0.f);
      CGOVertex(orthoCGO, rect.right + 2, rect.top, 0.f);
      CGOEnd(orthoCGO);
    } else {
      glColor3f(0.2F, 0.2F, 0.4F);
      glBegin(GL_POLYGON);
      glVertex2i(rect.right, rect.bottom - 2);
      glVertex2i(rect.right + 2, rect.bottom - 2);
      glVertex2i(rect.right + 2, rect.top);
      glVertex2i(rect.right, rect.top);
      glEnd();
    }

    if (orthoCGO){
      CGOColor(orthoCGO, 0.4F, 0.4F, 0.6F);
      CGOBegin(orthoCGO, GL_TRIANGLE_STRIP);
      CGOVertex(orthoCGO, rect.right, rect.bottom - 1, 0.f);
      CGOVertex(orthoCGO, rect.right + 1, rect.bottom - 1, 0.f);
      CGOVertex(orthoCGO, rect.right, rect.top, 0.f);
      CGOVertex(orthoCGO, rect.right + 1, rect.top, 0.f);
      CGOEnd(orthoCGO);
    } else {
      glColor3f(0.4F, 0.4F, 0.6F);
      glBegin(GL_POLYGON);
      glVertex2i(rect.right, rect.bottom - 1);
      glVertex2i(rect.right + 1, rect.bottom - 1);
      glVertex2i(rect.right + 1, rect.top);
      glVertex2i(rect.right, rect.top);
      glEnd();
    }
    /* top */

    if (orthoCGO){
      CGOColor(orthoCGO, 0.5F, 0.5F, 0.7F);
      CGOBegin(orthoCGO, GL_TRIANGLE_STRIP);
      CGOVertex(orthoCGO, rect.left - 2, rect.top + 2, 0.f);
      CGOVertex(orthoCGO, rect.right + 2, rect.top + 2, 0.f);
      CGOVertex(orthoCGO, rect.left - 2, rect.top, 0.f);
      CGOVertex(orthoCGO, rect.right + 2, rect.top, 0.f);
      CGOEnd(orthoCGO);
    } else {
      glColor3f(0.5F, 0.5F, 0.7F);
      glBegin(GL_POLYGON);
      glVertex2i(rect.left - 2, rect.top + 2);
      glVertex2i(rect.right + 2, rect.top + 2);
      glVertex2i(rect.right + 2, rect.top);
      glVertex2i(rect.left - 2, rect.top);
      glEnd();
    }

    if (orthoCGO){
      CGOColor(orthoCGO, 0.6F, 0.6F, 0.8F);
      CGOBegin(orthoCGO, GL_TRIANGLE_STRIP);
      CGOVertex(orthoCGO, rect.left - 1, rect.top + 1, 0.f);
      CGOVertex(orthoCGO, rect.right + 1, rect.top + 1, 0.f);
      CGOVertex(orthoCGO, rect.left - 1, rect.top, 0.f);
      CGOVertex(orthoCGO, rect.right + 1, rect.top, 0.f);
      CGOEnd(orthoCGO);
    } else {
      glColor3f(0.6F, 0.6F, 0.8F);
      glBegin(GL_POLYGON);
      glVertex2i(rect.left - 1, rect.top + 1);
      glVertex2i(rect.right + 1, rect.top + 1);
      glVertex2i(rect.right + 1, rect.top);
      glVertex2i(rect.left - 1, rect.top);
      glEnd();
    }

    /* left */
    if (orthoCGO){
      CGOColor(orthoCGO, 0.5F, 0.5F, 0.7F);
      CGOBegin(orthoCGO, GL_TRIANGLE_STRIP);
      CGOVertex(orthoCGO, rect.left - 2, rect.bottom - 2, 0.f);
      CGOVertex(orthoCGO, rect.left, rect.bottom, 0.f);
      CGOVertex(orthoCGO, rect.left - 2, rect.top, 0.f);
      CGOVertex(orthoCGO, rect.left, rect.top, 0.f);
      CGOEnd(orthoCGO);
    } else {
      glColor3f(0.5F, 0.5F, 0.7F);
      glBegin(GL_POLYGON);
      glVertex2i(rect.left - 2, rect.bottom - 2);
      glVertex2i(rect.left, rect.bottom);
      glVertex2i(rect.left, rect.top);
      glVertex2i(rect.left - 2, rect.top);
      glEnd();
    }

    if (orthoCGO){
      CGOColor(orthoCGO, 0.6F, 0.6F, 0.8F);
      CGOBegin(orthoCGO, GL_TRIANGLE_STRIP);
      CGOVertex(orthoCGO, rect.left - 1, rect.bottom - 1, 0.f);
      CGOVertex(orthoCGO, rect.left, rect.bottom - 1, 0.f);
      CGOVertex(orthoCGO, rect.left, rect.top, 0.f);
      CGOVertex(orthoCGO, rect.left - 1, rect.top, 0.f);
      CGOEnd(orthoCGO);
    } else {
      glColor3f(0.6F, 0.6F, 0.8F);
      glBegin(GL_POLYGON);
      glVertex2i(rect.left - 1, rect.bottom - 1);
      glVertex2i(rect.left, rect.bottom - 1);
      glVertex2i(rect.left, rect.top);
      glVertex2i(rect.left - 1, rect.top);
      glEnd();
    }

    if (orthoCGO)
      CGOColorv(orthoCGO, BackColor);
#ifndef PURE_OPENGL_ES_2
    else
      glColor3fv(BackColor);
#endif
    fill(orthoCGO);

    if (orthoCGO)
      CGOColorv(orthoCGO, TextColor);
#ifndef PURE_OPENGL_ES_2
    else
      glColor3fv(TextColor);
#endif

    if(I->Selected >= 0) {

      x = rect.left;
      y = rect.top - PopUpConvertY(I, I->Selected, true) - cPopUpCharMargin;

      y += 2;
    if (orthoCGO){
      CGOBegin(orthoCGO, GL_TRIANGLE_STRIP);
      CGOVertex(orthoCGO, x, y, 0.f);
      CGOVertex(orthoCGO, x + I->Width - 1, y, 0.f);
      CGOVertex(orthoCGO, x, y - (cPopUpLineHeight + 3), 0.f);
      CGOVertex(orthoCGO, x + I->Width - 1, y - (cPopUpLineHeight + 3), 0.f);
      CGOEnd(orthoCGO);
    } else {
      glBegin(GL_POLYGON);
      glVertex2i(x, y);
      glVertex2i(x + I->Width - 1, y);
      glVertex2i(x + I->Width - 1, y - (cPopUpLineHeight + 3));
      glVertex2i(x, y - (cPopUpLineHeight + 3));
      glEnd();
    }
    }
    if(I->Code[0] == 2) {       /* menu name */

      if(!SettingGetGlobal_i(G, cSetting_internal_gui_mode)) {
	if (orthoCGO)
	  CGOColor(orthoCGO, 0.3F, 0.3F, 0.6F);
	else
	  glColor3f(0.3F, 0.3F, 0.6F);
      } else {
	if (orthoCGO)
	  CGOColor(orthoCGO, 1.0F, 1.0F, 1.0F);
	else
	  glColor3f(1.0F, 1.0F, 1.0F);
      }
      x = rect.left;
      y = rect.top;

      if (orthoCGO){
	CGOBegin(orthoCGO, GL_TRIANGLE_STRIP);
	CGOVertex(orthoCGO, x, y, 0.f);
	CGOVertex(orthoCGO, x + I->Width, y, 0.f);
	CGOVertex(orthoCGO, x, y - (cPopUpLineHeight + cPopUpCharMargin), 0.f);
	CGOVertex(orthoCGO, x + I->Width, y - (cPopUpLineHeight + cPopUpCharMargin), 0.f);
	CGOEnd(orthoCGO);
      } else {
	glBegin(GL_POLYGON);
	glVertex2i(x, y);
	glVertex2i(x + I->Width, y);
	glVertex2i(x + I->Width, y - (cPopUpLineHeight + cPopUpCharMargin));
	glVertex2i(x, y - (cPopUpLineHeight + cPopUpCharMargin));
	glEnd();
      }

      if (orthoCGO){
	CGOColor(orthoCGO, 0.2F, 0.2F, 0.4F);
	CGOBegin(orthoCGO, GL_TRIANGLE_STRIP);
	CGOVertex(orthoCGO, x + I->Width - 1, y - (cPopUpLineHeight + cPopUpCharMargin), 0.f);
	CGOVertex(orthoCGO, x + I->Width - 1, y - (cPopUpLineHeight + cPopUpCharMargin) - 1.f, 0.f);
	CGOVertex(orthoCGO, x, y - (cPopUpLineHeight + cPopUpCharMargin), 0.f);
	CGOVertex(orthoCGO, x, y - (cPopUpLineHeight + cPopUpCharMargin) - 1.f, 0.f);
	CGOEnd(orthoCGO);
      } else {
	glColor3f(0.2F, 0.2F, 0.4F);
	glBegin(GL_LINES);
	glVertex2i(x + I->Width - 1, y - (cPopUpLineHeight + cPopUpCharMargin));
	glVertex2i(x, y - (cPopUpLineHeight + cPopUpCharMargin));
	glEnd();
      }
    }

    x = rect.left + cPopUpCharMargin;
    y = (rect.top - cPopUpLineHeight) - cPopUpCharMargin + 2;

    for(a = 0; a < I->NLine; a++) {
      auto text_color = (a == I->Selected) ? BackColor : TextColor;
      TextSetColor(G, text_color);
      if(I->Code[a]) {
        c = I->Text[a];
        xx = x;
        while(*c) {
          // note: previously also supported "\\+++red", but was never used
          if(TextSetColorFromCode(G, c, text_color)) {
            c += 4;
          }

          TextSetPos2i(G, xx, y + cPopUpCharLift);
          TextDrawChar(G, *(c++) ORTHOCGOARGVAR);
          xx = xx + DIP2PIXEL(8);
        }

        if(I->Sub[a]) {

	  if (orthoCGO){
	    CGOBegin(orthoCGO, GL_TRIANGLE_STRIP);
	    CGOColor(orthoCGO, 0.4F, 0.4F, 0.4F);
	    CGOVertex(orthoCGO, rect.left - 3, y + ((cPopUpLineHeight)) - 4, 0.f);
	    CGOColor(orthoCGO, 0.4F, 0.4F, 0.4F);
	    CGOVertex(orthoCGO, rect.left - 3, y + 1, 0.f);
	    CGOColor(orthoCGO, 0.1F, 0.1F, 0.1F);
	    CGOVertex(orthoCGO, rect.left, y + ((cPopUpLineHeight)) - 4, 0.f);
	    CGOColor(orthoCGO, 0.1F, 0.1F, 0.1F);
	    CGOVertex(orthoCGO, rect.left, y + 1, 0.f);
	    CGOEnd(orthoCGO);
	  } else {
	    glBegin(GL_POLYGON);
	    glColor3f(0.4F, 0.4F, 0.4F);
	    glVertex2i(rect.left - 3, y + 1);
	    glColor3f(0.1F, 0.1F, 0.1F);
	    glVertex2i(rect.left, y + 1);
	    glVertex2i(rect.left, y + ((cPopUpLineHeight)) - 4);
	    glColor3f(0.4F, 0.4F, 0.4F);
	    glVertex2i(rect.left - 3, y + ((cPopUpLineHeight)) - 4);
	    glEnd();
	  }
	  if (orthoCGO){
	    CGOBegin(orthoCGO, GL_TRIANGLE_STRIP);
	    CGOColor(orthoCGO, 0.1F, 0.2F, 0.2F);
	    CGOVertex(orthoCGO, rect.right, y + 1, 0.f);
	    CGOColor(orthoCGO, 0.4F, 0.4F, 0.4F);
	    CGOVertex(orthoCGO, rect.right + 3, y + 1, 0.f);
	    CGOColor(orthoCGO, 0.1F, 0.2F, 0.2F);
	    CGOVertex(orthoCGO, rect.right, y + ((cPopUpLineHeight)) - 4, 0.f);
	    CGOColor(orthoCGO, 0.4F, 0.4F, 0.4F);
	    CGOVertex(orthoCGO, rect.right + 3, y + ((cPopUpLineHeight)) - 4, 0.f);
	    CGOEnd(orthoCGO);
	  } else {
	    glBegin(GL_POLYGON);
	    glColor3f(0.1F, 0.2F, 0.2F);
	    glVertex2i(rect.right, y + 1);
	    glColor3f(0.4F, 0.4F, 0.4F);
	    glVertex2i(rect.right + 3, y + 1);
	    glVertex2i(rect.right + 3, y + ((cPopUpLineHeight)) - 4);
	    glColor3f(0.1F, 0.2F, 0.2F);
	    glVertex2i(rect.right, y + ((cPopUpLineHeight)) - 4);
	    glEnd();
	  }
        }

        y -= cPopUpLineHeight;
        if(I->Code[a] == 2)
          y -= 2;
      } else {
	  if (orthoCGO){
	    /* two lines between sections in the menu, one light, one dark */
	    CGOColor(orthoCGO, 0.3F, 0.3F, 0.5F);
	    CGOBegin(orthoCGO, GL_TRIANGLE_STRIP);
	    CGOVertex(orthoCGO, rect.right,
		      y + ((cPopUpLineHeight + cPopUpCharMargin) / 2) + 4, 0.f);
	    CGOVertex(orthoCGO, rect.right,
		      y + ((cPopUpLineHeight + cPopUpCharMargin) / 2) + 3, 0.f);
	    CGOVertex(orthoCGO, rect.left,
		      y + ((cPopUpLineHeight + cPopUpCharMargin) / 2) + 4, 0.f);
	    CGOVertex(orthoCGO, rect.left,
		      y + ((cPopUpLineHeight + cPopUpCharMargin) / 2) + 3, 0.f);
	    CGOEnd(orthoCGO);
	    CGOColor(orthoCGO, 0.6F, 0.6F, 0.8F);
	    CGOBegin(orthoCGO, GL_TRIANGLE_STRIP);
	    CGOVertex(orthoCGO, rect.right,
		      y + ((cPopUpLineHeight + cPopUpCharMargin) / 2) + 5, 0.f);
	    CGOVertex(orthoCGO, rect.right,
		      y + ((cPopUpLineHeight + cPopUpCharMargin) / 2) + 4, 0.f);
	    CGOVertex(orthoCGO, rect.left,
		      y + ((cPopUpLineHeight + cPopUpCharMargin) / 2) + 5, 0.f);
	    CGOVertex(orthoCGO, rect.left,
		      y + ((cPopUpLineHeight + cPopUpCharMargin) / 2) + 4, 0.f);
	    CGOEnd(orthoCGO);
	  } else {
	    glBegin(GL_LINES);
	    glColor3f(0.3F, 0.3F, 0.5F);
	    glVertex2i(rect.left,
		       y + ((cPopUpLineHeight + cPopUpCharMargin) / 2) + 3);
	    glVertex2i(rect.right,
		       y + ((cPopUpLineHeight + cPopUpCharMargin) / 2) + 3);
	    glColor3f(0.6F, 0.6F, 0.8F);
	    glVertex2i(rect.left,
		       y + ((cPopUpLineHeight + cPopUpCharMargin) / 2) + 4);
	    glVertex2i(rect.right,
		       y + ((cPopUpLineHeight + cPopUpCharMargin) / 2) + 4);
	    glEnd();
	  }
        y -= cPopUpBarHeight;
      }
    }
    if (orthoCGO)
      CGOColorv(orthoCGO, TextColor);
#ifndef PURE_OPENGL_ES_2
    else
      glColor3fv(TextColor);
#endif
    /*    BlockOutline(block); */
  }
}