示例#1
0
void CheckBox::createTexture(void) {
   Kernel *kernel = Kernel::getInstance();

   if ((_cTexture = kernel->getWidgetTexture(CHECKBOX)) != NULL) return;

   ColorRGBA  pColor1(183,191,213,255);
   ColorRGBA  pColor2( 71, 92,148,255);
   ColorRGBA  pColor3(100,118,165,255);
   ColorRGBA  pColor4(207,212,226,255);

   ColorRGBA colorClick(170,220,255,60);
   ColorRGBA colorOver(colorClick[0] - 100,colorClick[1] - 80,colorClick[2] - 40, colorClick[3]);

   ColorRGBA BackgroundColor(112,112,112,0);

   // create texture object
   _cTexture = new ComponentTexture(32, 16);
   kernel->setWidgetTexture(CHECKBOX, _cTexture);

   _cTexture->setTextureEnvMode(GL_MODULATE);

   // !selected
   _cTexture->addTexture(Point(0,0), 13, 13, data::CheckBox);

   // selected
   _cTexture->addTexture(Point(13,0), 13, 13, data::CheckBoxPressed);

   // over
   MatrixTemplate<ColorRGBA> over(1, 1, ColorRGBA(0,0,0,0));
   Texture2D::drawPoint(over, Point(0,0), colorOver);
   _cTexture->addTexture(Point(0,13), over);

   // hold
   MatrixTemplate<ColorRGBA> hold(1, 1, ColorRGBA(0,0,0,0));
   Texture2D::drawPoint(hold, Point(0,0), colorClick);
   _cTexture->addTexture(Point(1,13), hold);

   _cTexture->createTexture();
}
示例#2
0
void Button::createTexture(void) {
   Kernel *kernel = Kernel::getInstance();

   if ((_cTexture = kernel->getWidgetTexture(BUTTON)) != NULL) return;

   ColorRGBA colorBotao1(250, 250, 250, 255);
   ColorRGBA colorBotao2(210, 210, 210, 255);

   ColorRGBA colorOver(220, 220, 220, 100);
   ColorRGBA colorClick(colorOver[0] - 100, colorOver[1] - 100, colorOver[2] - 100, colorOver[3]);

   // create texture object
   _cTexture = new ComponentTexture(8, 16);
   kernel->setWidgetTexture(BUTTON, _cTexture);

   _cTexture->setTextureEnvMode(GL_MODULATE);

   // left up
   MatrixTemplate<ColorRGBA> lUp(3, 3, ColorRGBA(0,0,0,0));
   Texture2D::drawPoint(lUp, Point(0,1), ColorRGBA(144,144,144,230));
   Texture2D::drawPoint(lUp, Point(1,1), ColorRGBA(144,144,144,230));
   Texture2D::drawPoint(lUp, Point(1,0), ColorRGBA(144,144,144,230));

   Texture2D::drawPoint(lUp, Point(1,2), ColorRGBA(202,202,202,200));
   Texture2D::drawPoint(lUp, Point(2,2), ColorRGBA(240,240,240,240));
   Texture2D::drawPoint(lUp, Point(2,1), ColorRGBA(202,202,202,200));

   _cTexture->addTexture(Point(0,0), lUp);

   // right up
   MatrixTemplate<ColorRGBA> rUp(3, 3, ColorRGBA(0,0,0,0));
   Texture2D::drawPoint(rUp, Point(1, 1), ColorRGBA(144,144,144,230));
   Texture2D::drawPoint(rUp, Point(1, 0), ColorRGBA(144,144,144,230));
   Texture2D::drawPoint(rUp, Point(2, 1), ColorRGBA(144,144,144,230));

   Texture2D::drawPoint(rUp, Point(1, 2), ColorRGBA(202,202,202,200));
   Texture2D::drawPoint(rUp, Point(0, 2), ColorRGBA(240,240,240,240));
   Texture2D::drawPoint(rUp, Point(0, 1), ColorRGBA(202,202,202,200));

   _cTexture->addTexture(Point(0,3), rUp);

   // left down
   MatrixTemplate<ColorRGBA> lDown(3, 3, ColorRGBA(0,0,0,0));
   Texture2D::drawPoint(lDown, Point(0,1), ColorRGBA(144,144,144,230));
   Texture2D::drawPoint(lDown, Point(1,1), ColorRGBA(144,144,144,230));
   Texture2D::drawPoint(lDown, Point(1,2), ColorRGBA(144,144,144,230));

   Texture2D::drawPoint(lDown, Point(1,0), ColorRGBA(202,202,202,200));
   Texture2D::drawPoint(lDown, Point(2,0), ColorRGBA(240,240,240,240));
   Texture2D::drawPoint(lDown, Point(2,1), ColorRGBA(202,202,202,200));

   _cTexture->addTexture(Point(0,6), lDown);

   // right down
   MatrixTemplate<ColorRGBA> rDown(3, 3, ColorRGBA(0,0,0,0));
   Texture2D::drawPoint(rDown, Point(1,2), ColorRGBA(144,144,144,230));
   Texture2D::drawPoint(rDown, Point(2,1), ColorRGBA(144,144,144,230));
   Texture2D::drawPoint(rDown, Point(1,1), ColorRGBA(144,144,144,230));

   Texture2D::drawPoint(rDown, Point(1,0), ColorRGBA(202,202,202,200));
   Texture2D::drawPoint(rDown, Point(0,0), ColorRGBA(240,240,240,240));
   Texture2D::drawPoint(rDown, Point(0,1), ColorRGBA(202,202,202,200));

   _cTexture->addTexture(Point(0,9), rDown);

   // normal middle
   MatrixTemplate<ColorRGBA> nMiddle(1, 16, ColorRGBA(0,0,0,0));
   for (int i = 0, j = 15; i < 8; i++, j--) {
      Texture2D::drawPoint(nMiddle, Point(0,i), colorBotao1 - i * 2);
      Texture2D::drawPoint(nMiddle, Point(0,j), colorBotao2 - i * 2);
   }
   _cTexture->addTexture(Point(3,0), nMiddle);

   // over middle
   MatrixTemplate<ColorRGBA> oMiddle(1, 1, ColorRGBA(0,0,0,0));
   Texture2D::drawPoint(oMiddle, Point(0,0), colorOver);

   _cTexture->addTexture(Point(4,0), oMiddle);

   // click middle
   MatrixTemplate<ColorRGBA> cMiddle(1, 1, ColorRGBA(0,0,0,0));
   Texture2D::drawPoint(cMiddle, Point(0,0), colorClick);

   _cTexture->addTexture(Point(5,0), cMiddle);

   // up line
   MatrixTemplate<ColorRGBA> uLine(1, 2, ColorRGBA(0,0,0,0));
   Texture2D::drawPoint(uLine, Point(0,0), ColorRGBA(112,112,112,255));
   Texture2D::drawPoint(uLine, Point(0,1), ColorRGBA(255,255,255,255));

   _cTexture->addTexture(Point(6,0), uLine);

   // down line
   MatrixTemplate<ColorRGBA> dLine(1, 2, ColorRGBA(0,0,0,0));
   Texture2D::drawPoint(dLine, Point(0,0), ColorRGBA(255,255,255,255));
   Texture2D::drawPoint(dLine, Point(0,1), ColorRGBA(112,112,112,255));

   _cTexture->addTexture(Point(7,0), dLine);

   // left line
   MatrixTemplate<ColorRGBA> lLine(2, 1, ColorRGBA(0,0,0,0));
   Texture2D::drawPoint(lLine, Point(0,0), ColorRGBA(112,112,112,255));
   Texture2D::drawPoint(lLine, Point(1,0), ColorRGBA(255,255,255,255));

   _cTexture->addTexture(Point(6,2), lLine);

   // right line
   MatrixTemplate<ColorRGBA> rLine(2, 1, ColorRGBA(0,0,0,0));
   Texture2D::drawPoint(rLine, Point(1,0), ColorRGBA(112,112,112,255));
   Texture2D::drawPoint(rLine, Point(0,0), ColorRGBA(255,255,255,255));

   _cTexture->addTexture(Point(6,3), rLine);

   // generate texture
   _cTexture->createTexture();
}