Exemple #1
0
//Interface handling of mouse click
void Interface::MouseClick(int x, int y, bool left)
{
    if(inRect(x,y,60,160,80,105) && stage == STAGE_MENU)
    {
        //Nova hra
        pNetwork->DoConnect();
    }
    if(inRect(x,y,60,160,130,155) && stage == STAGE_MENU)
    {
        //Konec
        exit(0);
    }
    if(inRect(x,y,10+2,10+2+2+40*(2+15),45+2,45+2+40*(2+15)) && stage == STAGE_GAME)
    {
        //Tah
        if(!gStore.IsMyTurn())
            return;

        unsigned char field_x, field_y;

        field_x = (unsigned char)(int(x-10) / int(2+15));
        field_y = (unsigned char)(int(y-45) / int(2+15));

        GamePacket data(CMSG_TURN);
        data << field_x;
        data << field_y;
        SendToServer(&data);
    }
}
void ServerDialog::mousePressEvent(QMouseEvent *event) {
    QPoint point(event->x(), event->y());
    QRect rect1(170,90,123,20), rect2(170,140,123,20);
    if (inRect(point,rect1)) {
        keyboard->setNo(1);
        keyboard->show();
    } else if (inRect(point,rect2)) {
        keyboard->setNo(2);
        keyboard->show();
    } else {
        QDialog::mousePressEvent(event);
    }

}
void ofxFourUpDisplay::setCentre(float x, float y) {
	
	// resize all the viewports
	ofRectangle r = ofRectangle(this->x, this->y, this->width, this->height);
	if(!inRect(ofPoint(x, y), r)) return;
	
	viewports[0]->width = x - this->x;
	viewports[0]->height = y - this->y;
	
	viewports[1]->x = x;
	viewports[1]->y = viewports[0]->y;
	viewports[1]->width = width - (x - this->x);
	viewports[1]->height = y - this->y;
	
	
	viewports[2]->width = x - this->x;
	viewports[2]->y = y;
	viewports[2]->height = height - viewports[0]->height;
	
	viewports[3]->x = x;
	viewports[3]->y = y;
	viewports[3]->height = viewports[2]->height;
	viewports[3]->width = viewports[1]->width;
	centre = ofPoint(viewports[3]->x, viewports[3]->y);
	
}
Exemple #4
0
bool imguiBeginScrollArea(const char* name, int x, int y, int w, int h, int* scroll)
{
	g_state.areaId++;
	g_state.widgetId = 0;
	g_scrollId = (g_state.areaId<<16) | g_state.widgetId;

	g_state.widgetX = x + SCROLL_AREA_PADDING;
	g_state.widgetY = y+h-AREA_HEADER + (*scroll);
	g_state.widgetW = w - SCROLL_AREA_PADDING*4;
	g_scrollTop = y-AREA_HEADER+h;
	g_scrollBottom = y+SCROLL_AREA_PADDING;
	g_scrollRight = x+w - SCROLL_AREA_PADDING*3;
	g_scrollVal = scroll;

	g_scrollAreaTop = g_state.widgetY;

	g_focusTop = y-AREA_HEADER;
	g_focusBottom = y-AREA_HEADER+h;

	g_insideScrollArea = inRect(x, y, w, h, false);
	g_state.insideCurrentScroll = g_insideScrollArea;

	addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, 6, imguiRGBA(0,0,0,192));

	addGfxCmdText(x+AREA_HEADER/2, y+h-AREA_HEADER/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, name, imguiRGBA(255,255,255,128));

	addGfxCmdScissor(x+SCROLL_AREA_PADDING, y+SCROLL_AREA_PADDING, w-SCROLL_AREA_PADDING*4, h-AREA_HEADER-SCROLL_AREA_PADDING);

	return g_insideScrollArea;
}
// -----------------------------------------------------------------------------
// CTestSDKSkins::TestFBCCSetFrameRectsL
// -----------------------------------------------------------------------------
TInt CTestSDKSkins::TestFBCCSetFrameRectsL( CStifItemParser& /*aItem*/ )
{
    TAknsItemID itemID;

    TPoint pointTL( 0, 0 );
    TPoint pointBR( KLength, KLength );
    const TInt KOutPoint = 50;
    TPoint outPoint( KOutPoint, KOutPoint );
    const TInt KInPoint = 40;
    TPoint inPoint( KInPoint, KInPoint );
    TRect outRect( pointTL, outPoint );
    TRect inRect( pointBR, inPoint );

    CAknsFrameBackgroundControlContext* context =
        CAknsFrameBackgroundControlContext::NewL( itemID,
                outRect,
                inRect,
                ETrue );
    CleanupStack::PushL( context );
    STIF_ASSERT_NOT_NULL( context );

    context->SetFrameRects( outRect, inRect );

    CleanupStack::PopAndDestroy( context );

    return KErrNone;

}
Exemple #6
0
  bool UIPanel::begin(Vector2 const& mousePos, bool mouseDown, float mouseScroll)
  {
    _faceMesh->geometry->clear();
    _fontMesh->geometry->clear();

    // Update input with panel normalized mouse coords
    updateInput(_state, mousePos - Vector2(position.x, position.y), mouseDown, mouseScroll);

    _state.hot = _state.toBeHot;
    _state.toBeHot = 0;

    _state.wentActive = false;
    _state.isActive = false;
    _state.isHot = false;
    _state.insidePanel = inRect(_state, position.x, position.y, size.x, size.y, false);

    _state.widgetX = SCROLL_AREA_PADDING;
    _state.widgetY = SCROLL_AREA_PADDING - _state.scroll;
    _state.widgetW = size.x - SCROLL_AREA_PADDING * 3;

    _state.widgetId = 1;

    addRoundedRectangle(_faceMesh->geometry, Vector2(0, 0), size, 8.0f, Color(0, 0, 0, 0.75));
    return _state.insidePanel;
  }
Exemple #7
0
bool imguiCollapse(const char* text, const char* subtext, bool checked, bool enabled)
{
	g_state.widgetId++;
	unsigned int id = (g_state.areaId<<16) | g_state.widgetId;
	
	int x = g_state.widgetX;
	int y = g_state.widgetY - BUTTON_HEIGHT;
	int w = g_state.widgetW;
	int h = BUTTON_HEIGHT;
	g_state.widgetY -= BUTTON_HEIGHT; // + DEFAULT_SPACING;

	const int cx = x+BUTTON_HEIGHT/2-CHECK_SIZE/2;
	const int cy = y+BUTTON_HEIGHT/2-CHECK_SIZE/2;

	bool over = enabled && inRect(x, y, w, h);
	bool res = buttonLogic(id, over);
	
	if (checked)
		addGfxCmdTriangle(cx, cy, CHECK_SIZE, CHECK_SIZE, 2, imguiRGBA(255,255,255,isActive(id)?255:200));
	else
		addGfxCmdTriangle(cx, cy, CHECK_SIZE, CHECK_SIZE, 1, imguiRGBA(255,255,255,isActive(id)?255:200));

	if (enabled)
		addGfxCmdText(x+BUTTON_HEIGHT, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, isHot(id) ? imguiRGBA(255,196,0,255) : imguiRGBA(255,255,255,200));
	else
		addGfxCmdText(x+BUTTON_HEIGHT, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, imguiRGBA(128,128,128,200));

	if (subtext)
		addGfxCmdText(x+w-BUTTON_HEIGHT/2, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_RIGHT, subtext, imguiRGBA(255,255,255,128));
	
	return res;
}
Exemple #8
0
/////////////////////////////////////////////////////////////////////
//  Mouse Event overrides
/////////////////////////////////////////////////////////////////////
void CFreqCtrl::mouseMoveEvent(QMouseEvent * event)
{
QPoint pt = event->pos();
    //find which digit is to be edited
    if (isActiveWindow())
    {
        if (!hasFocus())
            setFocus(Qt::MouseFocusReason);

        for (int i = m_DigStart; i < m_NumDigits; i++)
        {
            if (inRect(m_DigitInfo[i].dQRect, pt))
            {
                if (!m_DigitInfo[i].editmode)
                {
                    m_DigitInfo[i].editmode = TRUE;
                    m_ActiveEditDigit = i;
                }
            }
            else
            {       //un-highlight the previous digit if moved off it
                if (m_DigitInfo[i].editmode)
                {
                    m_DigitInfo[i].editmode = FALSE;
                    m_DigitInfo[i].modified = TRUE;
                }
            }
        }

        updateCtrl(FALSE);
    }
}
Exemple #9
0
  bool UIPanel::button(const char * str, bool enabled)
  {
    _state.widgetId++;
    uint32_t id = _state.widgetId;

    const float x = _state.widgetX;
    const float y = _state.widgetY;
    const float w = _state.widgetW;
    const float h = BUTTON_HEIGHT;
    _state.widgetY += BUTTON_HEIGHT + DEFAULT_SPACING;

    bool over = enabled && inRect(_state, x, y, w, h);
    bool result = buttonLogic(_state, id, over);

    addRoundedRectangle(_faceMesh->geometry, Vector2(x, y), Vector2(w, h), BUTTON_HEIGHT * 0.5f - 1.0f, Color(0.5, 0.5, 0.5, isActive(_state, id) ? 0.75 : 0.35));

    const float textLength = font->textLength(str);
    const float textX = x + BUTTON_HEIGHT * 0.5f + (w - BUTTON_HEIGHT) * 0.5f - textLength * 0.5f;

    if (enabled)
      font->buildTextGeometry(str, Vector2(textX, y + BUTTON_HEIGHT * 0.5f + TEXT_HEIGHT * 0.5f), _fontMesh->geometry, isHot(_state, id) ? Color(1, 0.75, 0, 1) : Color(1, 1, 1, 0.8));
    else
      font->buildTextGeometry(str, Vector2(textX, y + BUTTON_HEIGHT * 0.5f + TEXT_HEIGHT * 0.5f), _fontMesh->geometry, isHot(_state, id) ? Color(1, 0.75, 0, 1) : Color(0.5, 0.5, 0.5, 0.8));

    return result;
  }
Exemple #10
0
  bool UIPanel::checkbox(const char * str, bool checked, bool enabled)
  {
    _state.widgetId++;
    uint32_t id = _state.widgetId;

    float x = _state.widgetX;
    float y = _state.widgetY; // + BUTTON_HEIGHT;
    float w = _state.widgetW;
    float h = BUTTON_HEIGHT;
    _state.widgetY += BUTTON_HEIGHT + DEFAULT_SPACING;

    bool over = enabled && inRect(_state, x, y, w, h);
    bool result = buttonLogic(_state, id, over);

    const float cx = x + BUTTON_HEIGHT * 0.5f - CHECK_SIZE * 0.5f;
    const float cy = y + BUTTON_HEIGHT * 0.5f - CHECK_SIZE * 0.5f;

    addRoundedRectangle(_faceMesh->geometry, Vector2(cx - 3.0f, cy - 3.0f), Vector2(CHECK_SIZE + 6.0f, CHECK_SIZE + 6.0f), 4.0f, Color(0.5, 0.5, 0.5, isActive(_state, id) ? 0.75 : 0.35));

    if (checked)
    {
      if (enabled)
        addRoundedRectangle(_faceMesh->geometry, Vector2(cx, cy), Vector2(CHECK_SIZE, CHECK_SIZE), CHECK_SIZE * 0.5f - 1.0f, Color(1, 1, 1, isActive(_state, id) ? 1 : 0.8));
      else
        addRoundedRectangle(_faceMesh->geometry, Vector2(cx, cy), Vector2(CHECK_SIZE, CHECK_SIZE), CHECK_SIZE * 0.5f - 1.0f, Color(0.5, 0.5, 0.5, 0.8));
    }

    if (enabled)
      font->buildTextGeometry(str, Vector2(x + BUTTON_HEIGHT, y + BUTTON_HEIGHT * 0.5f + TEXT_HEIGHT * 0.5f), _fontMesh->geometry, isHot(_state, id) ? Color(1, 0.75, 0, 1) : Color(1, 1, 1, 0.8));
    else
      font->buildTextGeometry(str, Vector2(x + BUTTON_HEIGHT, y + BUTTON_HEIGHT * 0.5f + TEXT_HEIGHT * 0.5f), _fontMesh->geometry, Color(0.5, 0.5, 0.5, 0.8));

    return result;
  }
Exemple #11
0
bool imguiCheck(const char* text, bool checked, bool enabled)
{
	g_state.widgetId++;
	unsigned int id = (g_state.areaId<<16) | g_state.widgetId;
	
	int x = g_state.widgetX;
	int y = g_state.widgetY - BUTTON_HEIGHT;
	int w = g_state.widgetW;
	int h = BUTTON_HEIGHT;
	g_state.widgetY -= BUTTON_HEIGHT + DEFAULT_SPACING;

	bool over = enabled && inRect(x, y, w, h);
	bool res = buttonLogic(id, over);
	
	const int cx = x+BUTTON_HEIGHT/2-CHECK_SIZE/2;
	const int cy = y+BUTTON_HEIGHT/2-CHECK_SIZE/2;
	addGfxCmdRoundedRect((float)cx-3, (float)cy-3, (float)CHECK_SIZE+6, (float)CHECK_SIZE+6, 4, imguiRGBA(128,128,128, isActive(id)?196:96));
	if (checked)
	{
		if (enabled)
			addGfxCmdRoundedRect((float)cx, (float)cy, (float)CHECK_SIZE, (float)CHECK_SIZE, (float)CHECK_SIZE/2-1, imguiRGBA(255,255,255,isActive(id)?255:200));
		else
			addGfxCmdRoundedRect((float)cx, (float)cy, (float)CHECK_SIZE, (float)CHECK_SIZE, (float)CHECK_SIZE/2-1, imguiRGBA(128,128,128,200));
	}

	if (enabled)
		addGfxCmdText(x+BUTTON_HEIGHT, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, isHot(id) ? imguiRGBA(255,196,0,255) : imguiRGBA(255,255,255,200));
	else
		addGfxCmdText(x+BUTTON_HEIGHT, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, imguiRGBA(128,128,128,200));

	return res;
}
bool Server::insideArea(Point* tp) {
    std::list<Rectangle*>::iterator it;
    for (it = this->cell.rect.begin(); it != cell.rect.end();it++) {
        if (inRect(tp,(*it))) {
            return true;
        }
    }
    return false;
}
Exemple #13
0
//////////////////////////////////////////////////////////////////////////////
//  Service mouse button clicks to inc or dec the selected frequency
//////////////////////////////////////////////////////////////////////////////
void CFreqCtrl::mousePressEvent(QMouseEvent * event)
{
    QPoint pt = event->pos();
    if (event->button() == Qt::LeftButton)
    {
        for (int i = m_DigStart; i < m_NumDigits; i++)
        {
            if (inRect(m_DigitInfo[i].dQRect, pt))    //if in i'th digit
            {
                if (m_LRMouseFreqSel)
                {
                    incFreq();
                }
                else
                {
                    if (pt.y() < m_DigitInfo[i].dQRect.bottom()/2)   //top half?
                        incFreq();
                    else
                        decFreq();          //bottom half
                }
            }
        }
    }
    else if (event->button() == Qt::RightButton)
    {
        for (int i = m_DigStart; i < m_NumDigits; i++)
        {
            if (inRect(m_DigitInfo[i].dQRect, pt))    //if in i'th digit
            {
                if (m_LRMouseFreqSel)
                {
                    decFreq();
                }
                else
                {
                    if (pt.y() < m_DigitInfo[i].dQRect.bottom()/2)   //top half?
                        incFreq();//IncDigit();
                    else
                        decFreq();//DecDigit();         //botom half
                }
            }
        }
    }
}
Exemple #14
0
		void FallbackFontRenderer::Draw(uint32_t unicode, spades::Vector2 offset,
										float size, spades::Vector4 color) {
			renderer->SetColorAlphaPremultiplied(color);
			float x = offset.x;
			float y = offset.y;
			
			auto glyph = FindGlyph(unicode);
			if(glyph.img == nullptr) {
				// no glyph found! draw box in the last resort
				IImage *img = whiteImage;
				renderer->DrawImage(img, AABB2(x, y, size, 1.f));
				renderer->DrawImage(img, AABB2(x, y + size - 1.f, size, 1.f));
				renderer->DrawImage(img, AABB2(x, y + 1.f, 1.f, size - 2.f));
				renderer->DrawImage(img, AABB2(x + size - 1.f, y + 1.f, 1.f, size - 2.f));
				return;
			}
			
			if(glyph.w == 0) {
				// null glyph.
				return;
			}
			
			float scale = size * glyph.sizeInverse;
			if(roundSize || scale < 1.f) {
				float newScale = std::max(1.f, floorf(scale));
				// vertical-align: baseline
				offset.y += (scale - newScale) * glyph.size;
				scale = newScale;
			}
			
			AABB2 inRect(glyph.x, glyph.y, glyph.w, glyph.h);
			AABB2 outRect(glyph.offX, glyph.offY, glyph.w, glyph.h);
			
			// margin to make the border completely transparent
			// (considering the OpenGL's linear interpolation)
			if(!roundSize){
				inRect.min.x -= 0.5f;
				inRect.min.y -= 0.5f;
				outRect.min.x -= 0.5f;
				outRect.min.y -= 0.5f;
				inRect.max.x += 0.5f;
				inRect.max.y += 0.5f;
				outRect.max.x += 0.5f;
				outRect.max.y += 0.5f;
			}
			
			outRect.min *= scale;
			outRect.max *= scale;
			
			outRect.min += offset;
			outRect.max += offset;
			
			renderer->DrawImage(glyph.img, outRect, inRect);
		}
Exemple #15
0
void button::draw(Drawer *pDrawer) {
   cout << "in the draw function" << endl;
	int x, y;
	SDL_GetMouseState(&x, &y);

	if(inRect(x, y)) {
		pDrawer->apply_box(offset, pressed_button_color);
	} else {
		pDrawer->apply_box(offset, button_color);
	}	
   cout << "drawed" << endl;
}
Exemple #16
0
/////////////////////////////////////////////////////////////////////
//  Mouse Wheel Event overrides
/////////////////////////////////////////////////////////////////////
void CFreqCtrl::wheelEvent(QWheelEvent * event)
{
    QPoint pt = event->pos();
    int numDegrees = event->delta() / 8;
    int numSteps = numDegrees / 15;

    for (int i = m_DigStart; i < m_NumDigits; i++)
    {
        if (inRect(m_DigitInfo[i].dQRect, pt))    //if in i'th digit
        {
            if (numSteps > 0)
                incFreq();
            else if (numSteps < 0)
                decFreq();
        }
    }
}
void ofxFourUpDisplay::mousePressed(ofMouseEventArgs &m) {
	if(!enabled) return;
	prevMouse = ofPoint(m.x, m.y);
	if(ofDist(m.x, m.y, centre.x, centre.y)<10) {
		movingCentre = true;
		return;
	}
	
	for(int i = 0; i < viewports.size(); i++) {
		if(inRect(prevMouse, *viewports[i])) {
			prevViewport = viewports[i];
			return;
		}
	}
	prevViewport = NULL;
	
}
Exemple #18
0
bool imguiButton(const char* text, bool enabled)
{
	g_state.widgetId++;
	unsigned int id = (g_state.areaId<<16) | g_state.widgetId;
	
	int x = g_state.widgetX;
	int y = g_state.widgetY - BUTTON_HEIGHT;
	int w = g_state.widgetW;
	int h = BUTTON_HEIGHT;
	g_state.widgetY -= BUTTON_HEIGHT + DEFAULT_SPACING;

	bool over = enabled && inRect(x, y, w, h);
	bool res = buttonLogic(id, over);

	addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, (float)BUTTON_HEIGHT/2-1, imguiRGBA(128,128,128, isActive(id)?196:96));
	if (enabled)
		addGfxCmdText(x+BUTTON_HEIGHT/2, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, isHot(id) ? imguiRGBA(255,196,0,255) : imguiRGBA(255,255,255,200));
	else
		addGfxCmdText(x+BUTTON_HEIGHT/2, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, imguiRGBA(128,128,128,200));

	return res;
}
Exemple #19
0
bool imguiItem(const char* text, bool enabled)
{
	s_state.widgetId++;
	unsigned int id = (s_state.areaId << 16) | s_state.widgetId;

	int x = s_state.widgetX;
	int y = s_state.widgetY - BUTTON_HEIGHT;
	int w = s_state.widgetW;
	int h = BUTTON_HEIGHT;
	s_state.widgetY -= BUTTON_HEIGHT + DEFAULT_SPACING;

	bool over = enabled && inRect(x, y, w, h);
	bool res = buttonLogic(id, over);

	if (isHot(id))
		AddGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, 2.0f, SetRGBA(255, 196, 0, isActive(id) ? 196 : 96));

	if (enabled)
		AddGfxCmdText(x + BUTTON_HEIGHT / 2, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, TEXT_ALIGN_LEFT, text, SetRGBA(255, 255, 255, 200));
	else
		AddGfxCmdText(x + BUTTON_HEIGHT / 2, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, TEXT_ALIGN_LEFT, text, SetRGBA(128, 128, 128, 200));

	return res;
}
Exemple #20
0
bool imguiTextInput(const char* text, char* buffer, unsigned int bufferLength)
{
	bool res = true;
	//--
	//Handle label
	g_state.widgetId++;
	unsigned int id = (g_state.areaId<<16) | g_state.widgetId;
	int x = g_state.widgetX;
	int y = g_state.widgetY - BUTTON_HEIGHT;
	addGfxCmdText(x, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, imguiRGBA(255,255,255,255));
	unsigned int textLen = unsigned int(strlen(text)*6.5);
	//--
	//Handle keyboard input if any
	unsigned int L = strlen(buffer);
	if(isInputable(id) && g_state.ascii == 0x08 && g_state.ascii!=g_state.lastAscii)//backspace
		buffer[L-1]=0;
	else if(isInputable(id) && g_state.ascii == 0x0D && g_state.ascii!=g_state.lastAscii)//enter
		g_state.inputable = 0;
	else if(isInputable(id) && L < bufferLength-1 && g_state.ascii!=0 && g_state.ascii!=g_state.lastAscii){
		++L;
		buffer[L-1] = g_state.ascii;
		buffer[L] = 0;
	}
	//--
	//Handle buffer data
	x+=textLen;
	int w = g_state.widgetW-textLen;
	int h = BUTTON_HEIGHT;
	bool over = inRect(x, y, w, h);
	res = textInputLogic(id, over);
	addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, (float)BUTTON_HEIGHT/2-1, isInputable(id)?imguiRGBA(255,196,0,255):imguiRGBA(128,128,128,96));
	addGfxCmdText(x+7, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, buffer, isInputable(id)?imguiRGBA(0, 0, 0, 255):imguiRGBA(255,255,255,255));
	//--
	g_state.widgetY -= BUTTON_HEIGHT + DEFAULT_SPACING;
	return res;		
}
Exemple #21
0
ofPixels_<unsigned char> ImageUtils::scaleAndCropTo(const ofPixels_<unsigned char>& pixels,
                                                    int width,
                                                    int height,
                                                    ofScaleMode scaleMode)
{
    ofRectangle inRect(0,0,pixels.getWidth(),pixels.getHeight());
    ofRectangle outRect(0,0,width,height);

    inRect.scaleTo(outRect,scaleMode);

    ofPixels_<unsigned char> inPixels = pixels;

    inPixels.resize(inRect.getWidth(),inRect.getHeight());

    ofPixels_<unsigned char> outPixels;

    inPixels.cropTo(outPixels,
                    outRect.x - inRect.x,
                    0,
                    outRect.width,
                    outRect.height);

    return outPixels;
}
Exemple #22
0
void imguiEndScrollArea()
{
	// Disable scissoring.
	addGfxCmdScissor(-1,-1,-1,-1);

	// Draw scroll bar
	int x = g_scrollRight+SCROLL_AREA_PADDING/2;
	int y = g_scrollBottom;
	int w = SCROLL_AREA_PADDING*2;
	int h = g_scrollTop - g_scrollBottom;

	int stop = g_scrollAreaTop;
	int sbot = g_state.widgetY;
	int sh = stop - sbot; // The scrollable area height.

	float barHeight = (float)h/(float)sh;
	
	if (barHeight < 1)
	{
		float barY = (float)(y - sbot)/(float)sh;
		if (barY < 0) barY = 0;
		if (barY > 1) barY = 1;
		
		// Handle scroll bar logic.
		unsigned int hid = g_scrollId;
		int hx = x;
		int hy = y + (int)(barY*h);
		int hw = w;
		int hh = (int)(barHeight*h);
		
		const int range = h - (hh-1);
		bool over = inRect(hx, hy, hw, hh);
		buttonLogic(hid, over);
		if (isActive(hid))
		{
			float u = (float)(hy-y) / (float)range;
			if (g_state.wentActive)
			{
				g_state.dragY = g_state.my;
				g_state.dragOrig = u;
			}
			if (g_state.dragY != g_state.my)
			{
				u = g_state.dragOrig + (g_state.my - g_state.dragY) / (float)range;
				if (u < 0) u = 0;
				if (u > 1) u = 1;
				*g_scrollVal = (int)((1-u) * (sh - h));
			}
		}
		
		// BG
		addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, (float)w/2-1, imguiRGBA(0,0,0,196));
		// Bar
		if (isActive(hid))
			addGfxCmdRoundedRect((float)hx, (float)hy, (float)hw, (float)hh, (float)w/2-1, imguiRGBA(255,196,0,196));
		else
			addGfxCmdRoundedRect((float)hx, (float)hy, (float)hw, (float)hh, (float)w/2-1, isHot(hid) ? imguiRGBA(255,196,0,96) : imguiRGBA(255,255,255,64));

		// Handle mouse scrolling.
		if (g_insideScrollArea) // && !anyActive())
		{
			if (g_state.scroll)
			{
				*g_scrollVal += 20*g_state.scroll;
				if (*g_scrollVal < 0) *g_scrollVal = 0;
				if (*g_scrollVal > (sh - h)) *g_scrollVal = (sh - h);
			}
		}
	}
	g_state.insideCurrentScroll = false;
}
Exemple #23
0
		void MapView::Draw(){
			World *world = client->GetWorld();
			if(!world)
				return;
			
			Player *player = world->GetLocalPlayer();
			if(client->IsFollowing()){
				player = world->GetPlayer(client->followingPlayerId);
			}
			if(!player)
				return;
			
			if(largeMap)
				if(zoomState < .0001f)
					return;
			
			GameMap *map = world->GetMap();
			Vector2 mapSize = MakeVector2(map->Width(), map->Height());
			
			Vector3 pos = player->GetPosition();;
			if(player->GetTeamId() >= 2){
				pos = client->followPos;
			}
			Vector2 center = {pos.x, pos.y};
			float cfgMapSize = cg_minimapSize;
			if(cfgMapSize < 32) cfgMapSize = 32;
			if(cfgMapSize > 256) cfgMapSize = 256;
			Vector2 mapWndSize = {cfgMapSize, cfgMapSize};
			float scale = actualScale;
			
			center = Mix(center,
						 mapSize * .5f,
						 zoomState);
			
			Vector2 zoomedSize = {512, 512};
			if(renderer->ScreenWidth() < 512.f ||
			   renderer->ScreenHeight() < 512.f)
				zoomedSize = MakeVector2(256, 256);
			if(largeMap){
				float per = zoomState;
				per = 1.f - per;
				per *= per;
				per = 1.f - per;
				per = Mix(.7f, 1.f, per);
				zoomedSize = Mix(MakeVector2(0, 0),
								 zoomedSize,
								 per);
				mapWndSize = zoomedSize;
			}
			
			Vector2 inRange = mapWndSize * .5f * scale;
			AABB2 inRect(center - inRange, center + inRange);
			if(largeMap){
				inRect.min = MakeVector2(0, 0);
				inRect.max = mapSize;
			}else{
				if(inRect.GetMinX() < 0.f)
					inRect = inRect.Translated(-inRect.GetMinX(), 0.f);
				if(inRect.GetMinY() < 0.f)
					inRect = inRect.Translated(0, -inRect.GetMinY());
				if(inRect.GetMaxX() > mapSize.x)
					inRect = inRect.Translated(mapSize.x - inRect.GetMaxX(), 0.f);
				if(inRect.GetMaxY() > mapSize.y)
					inRect = inRect.Translated(0, mapSize.y - inRect.GetMaxY());
			}
			
			
			AABB2 outRect(renderer->ScreenWidth() - mapWndSize.x - 16.f, 16.f,
						  mapWndSize.x,
						  mapWndSize.y);
			if(largeMap){
				outRect.min = MakeVector2((renderer->ScreenWidth() - zoomedSize.x) * .5f,
										  (renderer->ScreenHeight() - zoomedSize.y) * .5f);
				outRect.max =MakeVector2((renderer->ScreenWidth() + zoomedSize.x) * .5f,
										 (renderer->ScreenHeight() + zoomedSize.y) * .5f);
			}
			
			float alpha = 1.f;
			if(largeMap){
				alpha = zoomState;
			}
			
			// fades bg
			if(largeMap) {
				Handle<IImage> bg = renderer->RegisterImage("Gfx/MapBg.png");
				Vector2 scrSize = {renderer->ScreenWidth(),
				renderer->ScreenHeight()};
				float size = std::max(scrSize.x, scrSize.y);
				renderer->SetColorAlphaPremultiplied(MakeVector4(0, 0, 0,alpha * .5f));
				renderer->DrawImage(bg,
									AABB2((scrSize.x - size) * .5f,
										  (scrSize.y - size) * .5f,
										  size, size));
			}
			
			// draw border
			Handle<IImage> border;
			float borderWidth;
			AABB2 borderRect = outRect;
			if(largeMap) {
				border = renderer->RegisterImage("Gfx/MapBorder.png");
				borderWidth = 3.f * outRect.GetHeight() / zoomedSize.y;
			}else{
				border = renderer->RegisterImage("Gfx/MinimapBorder.png");
				borderWidth = 2.f;
			}
			borderRect = borderRect.Inflate(borderWidth - 8.f);
			
			renderer->SetColorAlphaPremultiplied(MakeVector4(alpha,alpha,alpha,alpha));
			renderer->DrawImage(border,
								AABB2(borderRect.GetMinX()-16,
									  borderRect.GetMinY()-16,
									  16, 16),
								AABB2(0, 0, 16, 16));
			renderer->DrawImage(border,
								AABB2(borderRect.GetMaxX(),
									  borderRect.GetMinY()-16,
									  16, 16),
								AABB2(16, 0, 16, 16));
			renderer->DrawImage(border,
								AABB2(borderRect.GetMinX()-16,
									  borderRect.GetMaxY(),
									  16, 16),
								AABB2(0, 16, 16, 16));
			renderer->DrawImage(border,
								AABB2(borderRect.GetMaxX(),
									  borderRect.GetMaxY(),
									  16, 16),
								AABB2(16, 16, 16, 16));
			renderer->DrawImage(border,
								AABB2(borderRect.GetMinX(),
									  borderRect.GetMinY()-16,
									  borderRect.GetWidth(), 16),
								AABB2(16, 0, 0, 16));
			renderer->DrawImage(border,
								AABB2(borderRect.GetMinX(),
									  borderRect.GetMaxY(),
									  borderRect.GetWidth(), 16),
								AABB2(16, 16, 0, 16));
			renderer->DrawImage(border,
								AABB2(borderRect.GetMinX()-16,
									  borderRect.GetMinY(),
									  16, borderRect.GetHeight()),
								AABB2(0, 16, 16, 0));
			renderer->DrawImage(border,
								AABB2(borderRect.GetMaxX(),
									  borderRect.GetMinY(),
									  16, borderRect.GetHeight()),
								AABB2(16, 16, 16, 0));
			
			// draw map
			renderer->SetColorAlphaPremultiplied(MakeVector4(alpha,alpha,alpha,alpha));
			renderer->DrawFlatGameMap(outRect, inRect);
			
			this->inRect = inRect;
			this->outRect = outRect;
			
			// draw grid
			
			renderer->SetColorAlphaPremultiplied(MakeVector4(0,0,0,0.8f*alpha));
			Handle<IImage> dashLine = renderer->RegisterImage("Gfx/DashLine.tga");
			for(float x = 64.f; x < map->Width(); x += 64.f){
				float wx = (x - inRect.GetMinX()) / inRect.GetWidth();
				if(wx < 0.f || wx >= 1.f)
					continue;
				wx = (wx * outRect.GetWidth()) + outRect.GetMinX();
				wx = roundf(wx);
				renderer->DrawImage(dashLine,
									MakeVector2(wx, outRect.GetMinY()),
									AABB2(0, 0, 1.f, outRect.GetHeight()));
			}
			for(float y = 64.f; y < map->Height(); y += 64.f){
				float wy = (y - inRect.GetMinY()) / inRect.GetHeight();
				if(wy < 0.f || wy >= 1.f)
					continue;
				wy = (wy * outRect.GetHeight()) + outRect.GetMinY();
				wy = roundf(wy);
				renderer->DrawImage(dashLine,
									MakeVector2(outRect.GetMinX(), wy),
									AABB2(0, 0, outRect.GetWidth(), 1.f));
			}
			
			// draw grid label
			renderer->SetColorAlphaPremultiplied(MakeVector4(1,1,1,1)*(0.8f*alpha));
			Handle<IImage> mapFont = renderer->RegisterImage("Gfx/Fonts/MapFont.tga");
			for(int i = 0; i < 8; i++){
				float startX = (float)i * 64.f;
				float endX = startX + 64.f;
				if(startX > inRect.GetMaxX() ||
				   endX < inRect.GetMinX())
					continue;
				float fade = std::min((std::min(endX, inRect.GetMaxX()) -
									   std::max(startX, inRect.GetMinX())) /
									  (endX - startX) * 2.f, 1.f);
				renderer->SetColorAlphaPremultiplied(MakeVector4(1,1,1,1)*(fade * .8f * alpha));
				
				float center = std::max(startX, inRect.GetMinX());
				center = .5f * (center + std::min(endX, inRect.GetMaxX()));
				
				float wx = (center - inRect.GetMinX()) / inRect.GetWidth();
				wx = (wx * outRect.GetWidth()) + outRect.GetMinX();
				wx = roundf(wx);
				
				float fntX = static_cast<float>((i & 3) * 8);
				float fntY = static_cast<float>((i >> 2) * 8);
				renderer->DrawImage(mapFont,
									MakeVector2(wx - 4.f, outRect.GetMinY() + 4),
									AABB2(fntX, fntY, 8, 8));
			}
			for(int i = 0; i < 8; i++){
				float startY = (float)i * 64.f;
				float endY = startY + 64.f;
				if(startY > inRect.GetMaxY() ||
				   endY < inRect.GetMinY())
					continue;
				float fade = std::min((std::min(endY, inRect.GetMaxY()) -
									   std::max(startY, inRect.GetMinY())) /
									  (endY - startY) * 2.f, 1.f);
				renderer->SetColorAlphaPremultiplied(MakeVector4(1,1,1,1)*(fade * .8f * alpha));
				
				float center = std::max(startY, inRect.GetMinY());
				center = .5f * (center + std::min(endY, inRect.GetMaxY()));
				
				float wy = (center - inRect.GetMinY()) / inRect.GetHeight();
				wy = (wy * outRect.GetHeight()) + outRect.GetMinY();
				wy = roundf(wy);
				
				int fntX = (i & 3) * 8;
				int fntY = (i >> 2) * 8 + 16;
				renderer->DrawImage(mapFont,
									MakeVector2(outRect.GetMinX() + 4, wy - 4.f),
									AABB2(fntX, fntY, 8, 8));
			}			
			//draw objects
			
			std::string iconmode = cg_Minimap_Player_Icon;//import variable from configuration file
			std::string colormode = cg_Minimap_Player_Color;//import variable from configuration file
			
			Handle<IImage> playerSMG = renderer->RegisterImage("Gfx/Map/SMG.png");
			Handle<IImage> playerRifle = renderer->RegisterImage("Gfx/Map/Rifle.png");
			Handle<IImage> playerShotgun = renderer->RegisterImage("Gfx/Map/Shotgun.png");
			Handle<IImage> playerIcon = renderer->RegisterImage("Gfx/Map/Player.png");
			
			{
				
				IntVector3 teamColor =
				world->GetLocalPlayer()->GetTeamId() >= 2 ?
				IntVector3::Make(200, 200, 200) :
				world->GetTeam(world->GetLocalPlayer()->GetTeamId()).color;
				Vector4 teamColorF = ModifyColor(teamColor);
				teamColorF *= alpha;
				
				// draw local player's view
				{
					Player *p = player;
					Handle<IImage> viewIcon = renderer->RegisterImage("Gfx/Map/View.png");
					if(p->IsAlive()) {
						Vector3 front = p->GetFront2D();
						float ang = atan2(front.x, -front.y);
						if(player->GetTeamId() >= 2){
							ang = client->followYaw - static_cast<float>(M_PI) * .5f;
						}
						
						renderer->SetColorAlphaPremultiplied(teamColorF * 0.9f);
						
						DrawIcon(player->GetTeamId() >= 2 ?
								 client->followPos :
								 p->GetPosition(), viewIcon, ang);
					}
				}
				
				// draw player's icon
				for(int i = 0; i < world->GetNumPlayerSlots(); i++){
					Player * p = world->GetPlayer(i);
					if(p == nullptr ||
					   p->GetTeamId() != world->GetLocalPlayer()->GetTeamId() ||
					   !p->IsAlive())
						continue;
					
					Vector3 front = p->GetFront2D();
					float ang = atan2(front.x, -front.y);
					if(player->GetTeamId() >= 2){
						ang = client->followYaw - static_cast<float>(M_PI) * .5f;
					}
					
					//use a spec color for each player
					if ( colormode=="1"){
						IntVector3 Colorplayer=IntVector3::Make(palette[i][0],palette[i][1],palette[i][2]);
						Vector4 ColorplayerF = ModifyColor(Colorplayer);
						ColorplayerF *=1.0f;
						renderer->SetColorAlphaPremultiplied(ColorplayerF);
					}	
					else {
						renderer->SetColorAlphaPremultiplied(teamColorF);
					}
					
					//use a different icon in minimap according to weapon of player
					if( iconmode=="1"){
						WeaponType weapon=world->GetPlayer(i)->GetWeaponType();
						if (weapon == WeaponType::SMG_WEAPON){
							DrawIcon(player->GetTeamId() >= 2 ?
									client->followPos :
									p->GetPosition(),playerSMG , ang);
						}
						
						else if (weapon == WeaponType::RIFLE_WEAPON){
							DrawIcon(player->GetTeamId() >= 2 ?
									client->followPos :
									p->GetPosition(), playerRifle, ang);
						}
						
						else if (weapon == WeaponType::SHOTGUN_WEAPON){
							DrawIcon(player->GetTeamId() >= 2 ?
									client->followPos :
									p->GetPosition(), playerShotgun, ang);
						}
					}
					else{//draw normal color	
						DrawIcon(player->GetTeamId() >= 2 ?
								client->followPos :
								p->GetPosition(), playerIcon, ang);
					}
				}
			}
			
			IGameMode* mode = world->GetMode();
			if( mode && IGameMode::m_CTF == mode->ModeType() ) {
				CTFGameMode *ctf = static_cast<CTFGameMode *>(mode);
				Handle<IImage> intelIcon = renderer->RegisterImage("Gfx/Map/Intel.png");
				Handle<IImage> baseIcon = renderer->RegisterImage("Gfx/Map/CommandPost.png");
				for(int tId = 0; tId < 2; tId++){
					CTFGameMode::Team& team = ctf->GetTeam(tId);
					IntVector3 teamColor = world->GetTeam(tId).color;
					Vector4 teamColorF = ModifyColor(teamColor);
					teamColorF *= alpha;
					
					// draw base
					renderer->SetColorAlphaPremultiplied(teamColorF);
					DrawIcon(team.basePos, baseIcon, 0.f);
					
					
					// draw flag
					if(!ctf->GetTeam(1-tId).hasIntel){
						renderer->SetColorAlphaPremultiplied(teamColorF);
						DrawIcon(team.flagPos, intelIcon, 0.f);
					}else if(world->GetLocalPlayer()->GetTeamId() == 1-tId){
						// local player's team is carrying
						int cId = ctf->GetTeam(1-tId).carrier;
						
						// in some game modes, carrier becomes invalid
						if(cId < world->GetNumPlayerSlots()){
							Player * carrier= world->GetPlayer(cId);
							if(carrier && carrier->GetTeamId() ==
							   world->GetLocalPlayer()->GetTeamId()){
								
								Vector4 col = teamColorF;
								col *= fabsf(sinf(world->GetTime() * 4.f));
								renderer->SetColorAlphaPremultiplied(col);
								DrawIcon(carrier->GetPosition(), intelIcon, 0.f);
							}
						}
					}
				}
			} else if( mode && IGameMode::m_TC == mode->ModeType() ) {
				TCGameMode *tc = static_cast<TCGameMode *>(mode);
				Handle<IImage> icon = renderer->RegisterImage("Gfx/Map/CommandPost.png");
				int cnt = tc->GetNumTerritories();
				for(int i = 0; i < cnt; i++){
					TCGameMode::Territory *t = tc->GetTerritory(i);
					IntVector3 teamColor = {128,128,128};
					if(t->ownerTeamId < 2){
						teamColor = world->GetTeam(t->ownerTeamId).color;
					}
					Vector4 teamColorF = ModifyColor(teamColor);
					teamColorF *= alpha;
					
					// draw base
					renderer->SetColorAlphaPremultiplied(teamColorF);
					DrawIcon(t->pos, icon, 0.f);
					
				}
			}
		}
Exemple #24
0
void moveonBullet(int idx, int dt)
{
	// Make sure that this function is invoked properly
	assert(idx >=0 && idx < bullets.size());

	float *p = bullets.at(idx).pos;
	float a  = bullets.at(idx).angle;
	float v  = bullets.at(idx).speed;

	// Detect Collsion first
	bool hit = false;
	// Collision detection with the wall
	for(int i = 0; i < numberHeight; i++)
	{
		for(int j = 0; j < numberWidth; j++)
		{
			if(wall[i][j]==0) continue; // If there is no wall, pass

			Rect wRc = getWallRect(i,j); // Else, get the rectangle of this wall
			if(inRect(wRc, p)) // If the bullet is in the wall
			{
				hit = true; // Hit
				// Calculate the point where the bullet entered the wall
				float trace[][2] = {
					{p[0],p[1]}, {p[0]-10*v*dt*cos(a),p[1]-10*v*dt*sin(a)}
				};
				float wallV[4][2];
				float inter[2];
				getVertices(wRc,wallV); // Get the vertices of the wall
				bool c =
				lineCollide(wallV[0],wallV[1],trace[0],trace[1],inter) ||
				lineCollide(wallV[1],wallV[2],trace[0],trace[1],inter) ||
				lineCollide(wallV[2],wallV[3],trace[0],trace[1],inter) ||
				lineCollide(wallV[3],wallV[0],trace[0],trace[1],inter);
				// Emit the hit message
				if(c)
					emitHitWallMessage(idx, i, j, inter[0], inter[1]); 
				else
					emitHitWallMessage(idx, i, j, p[0], p[1]); 
			}
			if(hit) break; // If already hit, break the loop
		}
		if(hit) break;
	}
	// Collision with tanks
	for(int i = 0; i < tanks.size(); i++)
	{
		if(tanks.at(i).HP <= 0) continue;
		Rect tRc = tanks.at(i).rect;
		if(inRect(tRc, p))
		{
			hit = true;
			emitHitTankMessage(idx, i, p[0], p[1]); // Emit the hit message
			break; // Break the loop
		}
	}
	// Collision with boundary, treated as hitting wall
	if(!inRect(boundary, p)) emitHitWallMessage(idx, -1, -1, p[0], p[1]);

	// Move the bullet
	p[0] += v * dt * cos(a);
	p[1] += v * dt * sin(a);
}
Exemple #25
0
  bool UIPanel::slider(const char * text, float * value, float valueMin, float valueMax, float valueInc, bool enabled)
  {
    _state.widgetId++;
    uint32_t id = _state.widgetId;

    const float x = _state.widgetX;
    const float y = _state.widgetY;
    const float w = _state.widgetW;
    const float h = SLIDER_HEIGHT;
    _state.widgetY += SLIDER_HEIGHT + DEFAULT_SPACING;

    addRoundedRectangle(_faceMesh->geometry, Vector2(x, y), Vector2(w, h), 4.0f, Color(0, 0, 0, 0.5));

    const float range = w - SLIDER_MARKER_WIDTH;

    float u = (*value - valueMin) / (valueMax - valueMin);
    if (u < 0.0f) u = 0.0f;
    if (u > 1.0f) u = 1.0f;
    float m = u * range;

    bool over = enabled && inRect(_state, x + m, y, SLIDER_MARKER_WIDTH, SLIDER_HEIGHT);
    bool result = buttonLogic(_state, id, over);
    bool valueChanged = false;

    if (isActive(_state, id))
    {
      if (_state.wentActive)
      {
        _state.mouseDrag.x = _state.mousePos.x;
        _state.dragOrigin = u;
      }

      if (_state.mouseDrag.x != _state.mousePos.x)
      {
        u = _state.dragOrigin + (float)(_state.mousePos.x - _state.mouseDrag.x) / (float)range;
        if (u < 0) u = 0;
        if (u > 1) u = 1;
        *value = valueMin + u * (valueMax - valueMin);
        *value = std::floor(*value / valueInc + 0.5f) * valueInc;
        m = u * range;
        valueChanged = true;
      }
    }

    if (isActive(_state, id))
      addRoundedRectangle(_faceMesh->geometry, Vector2(x + m, y), Vector2(SLIDER_MARKER_WIDTH, SLIDER_HEIGHT), 4.0f, Color(1, 1, 1, 1));
    else
      addRoundedRectangle(_faceMesh->geometry, Vector2(x + m, y), Vector2(SLIDER_MARKER_WIDTH, SLIDER_HEIGHT), 4.0f, isHot(_state, id) ? Color(1, 0.75, 0, 1) : Color(1, 1, 1, 0.25));

    char valueStr[16];
    sprintf(valueStr, "%d%%", (int)std::ceil((*value - valueMin) / (valueMax - valueMin) * 100.0));
    const float valueLength = font->textLength(valueStr);

    Color fontColor = isHot(_state, id) ? Color(1, 0.75, 0, 1) : Color(1, 1, 1, 0.8);

    if (!enabled)
      fontColor = Color(0.5, 0.5, 0.5, 0.8);

    font->buildTextGeometry(text, Vector2(x + SLIDER_HEIGHT * 0.5f, y + SLIDER_HEIGHT * 0.5f + TEXT_HEIGHT * 0.5f), _fontMesh->geometry, fontColor);
    font->buildTextGeometry(valueStr, Vector2(x + w - valueLength - SLIDER_HEIGHT * 0.5f, y + SLIDER_HEIGHT * 0.5f + TEXT_HEIGHT * 0.5f), _fontMesh->geometry, fontColor);

    return result || valueChanged;
  }
Exemple #26
0
bool popup::addEntity(entity *tmp) {
   if(tmp->name != "popup" && inRect(tmp->offset.x, tmp->offset.y)) {
      entities.push_back(tmp);
   }
}
Exemple #27
0
//drawing:
void G_segment::draw(QPainter &p, const G_drawstyle &d, bool selected)
{
  QRect r = p.window();

  if(!inRect(r)) return;

  G_point tmp1, tmp2;
  
  if(fabs(p1.getX()) < DRAW_MAX && fabs(p1.getY()) < DRAW_MAX) {
    tmp1 = p1;
  }
  else {
    tmp1 = getNearestPoint(G_point(0, 0));
    tmp1 += (p1 - tmp1) * (DRAW_MAX) / (p1 - tmp1).length();
  }

  if(fabs(p2.getX()) < DRAW_MAX && fabs(p2.getY()) < DRAW_MAX) {
    tmp2 = p2;
  }
  else {
    tmp2 = getNearestPoint(G_point(0, 0));
    tmp2 += (p2 - tmp2) * (DRAW_MAX) / (p2 - tmp2).length();
  }

  //Now Draw!

  if(/*p.device()->isExtDev() ||*/ p.hasViewXForm()) { //draw at higher accuracy to a printer
    tmp1 *= 8.;
    tmp2 *= 8.;
    p.scale(0.125, .125);
    
    int w = d.getPen().width() * 8;
    if(w == 0) w = 2;
    //if(!p.device()->isExtDev()) w = (d.getPen().width() == 0 ? 4 : 4 * d.getPen().width());

    p.setPen(QPen(d.getPen().color(), w, d.getPen().style()));
    p.drawLine(tmp1.toQPoint(), tmp2.toQPoint());

    p.scale(8, 8);

    return;
  }

  if(selected && KSegView::getSelectType() == KSegView::BORDER_SELECT) {
    int width = d.getPen().width() ? d.getPen().width() + 3 : 4;

    p.setPen(QPen(G_drawstyle::getBorderColor(d.getPen().color()), width));

    p.drawLine(tmp1.toQPoint(), tmp2.toQPoint());
    
  }

  p.setPen(d.getPen());
  if(selected && KSegView::getSelectType() == KSegView::BLINKING_SELECT) {
    QColor c(QTime::currentTime().msec() * 17, 255, 255, QColor::Hsv);

    p.setPen(QPen(c, d.getPen().width(), d.getPen().style()));
  }

  p.drawLine(tmp1.toQPoint(), tmp2.toQPoint());

  return;
	     
}
Exemple #28
0
/****************************************
* TitleScreen: Display the title screen *
*****************************************
* display title screen, get input
*/
void TitleScreen(void)
{

  Uint32 frame = 0;
  Uint32 start = 0;

  /* NOTE for 'depth', think pages like a restaurant menu, */
  /* not heirarchical depth - choice of term is misleading */
  int menu_depth; // how deep we are in the menu

  int i, j, tux_frame = 0;
  int done = 0;
  int firstloop = 1;
  int menu_opt = NONE;
  int sub_menu = NONE;
  int update_locs = 1;
  int redraw = 0;
  int key_menu = 1;
  int old_key_menu = 5;


  if (settings.sys_sound)
  {
    settings.menu_sound = 1;
    settings.menu_music = 1;
  }

  start = SDL_GetTicks();


  /*
  * Display the Standby screen.... 
  */
  show_logo();
  snd_welcome = LoadSound("harp.wav");

  if (snd_welcome && settings.menu_sound)
  {
    PlaySound(snd_welcome);
  }

  /* Load media and menu data: */
  if (!load_media())
  {
    fprintf(stderr, "TitleScreen - load_media() failed!");
    return;
  }

  SDL_WM_GrabInput(SDL_GRAB_ON); // User input goes to TuxType, not window manager


  /***************************
  * Tux and Title animations *
  ***************************/

  LOG( "->Now Animating Tux and Title onto the screen\n" );

  Tuxdest.x = 0;
  Tuxdest.y = screen->h;
  Tuxdest.w = Tux->frame[0]->w;
  Tuxdest.h = Tux->frame[0]->h;

  Titledest.x = screen->w;
  Titledest.y = 10;
  Titledest.w = title->w;
  Titledest.h = title->h;

  spkrdest.x = screen->w - speaker->w - 10;
  spkrdest.y = screen->h - speaker->h - 10;
  spkrdest.w = speaker->w;
  spkrdest.h = speaker->h;

  /* --- wait if the first time in the game --- */

  if (settings.show_tux4kids)
  {
    while ((SDL_GetTicks() - start) < 2000)
    {
      SDL_Delay(50);
    }
    settings.show_tux4kids = 0;
  }

  SDL_ShowCursor(1);    
  /* FIXME not sure the next line works in Windows: */
  TransWipe(CurrentBkgd(), RANDOM_WIPE, 10, 20);
  /* Make sure background gets drawn (since TransWipe() doesn't */
  /* seem to work reliably as of yet):                          */
  SDL_BlitSurface(CurrentBkgd(), NULL, screen, NULL);
  SDL_UpdateRect(screen, 0, 0, 0, 0);

  /* --- Pull tux & logo onscreen --- */
  for (i = 0; i <= (PRE_ANIM_FRAMES * PRE_FRAME_MULT); i++)
  {
    start = SDL_GetTicks();
    SDL_BlitSurface(CurrentBkgd(), &Tuxdest, screen, &Tuxdest);
    SDL_BlitSurface(CurrentBkgd(), &Titledest, screen, &Titledest);


    Tuxdest.y -= Tux->frame[0]->h / (PRE_ANIM_FRAMES * PRE_FRAME_MULT);
    Titledest.x -= (screen->w) / (PRE_ANIM_FRAMES * PRE_FRAME_MULT);
    /* Don't go past 0; */
    if (Tuxdest.y < 0)
      Tuxdest.y = 0;
    if (Titledest.x < 0)
      Titledest.x = 0;

    SDL_BlitSurface(Tux->frame[0], NULL, screen, &Tuxdest);
    SDL_BlitSurface(title, NULL, screen, &Titledest);

    SDL_UpdateRect(screen, Tuxdest.x, Tuxdest.y, Tuxdest.w, Tuxdest.h);
    SDL_UpdateRect(screen, Titledest.x, Titledest.y, Titledest.w + 40, Titledest.h);

    while ((SDL_GetTicks() - start) < 33) 
    {
      SDL_Delay(2);
    }
  }

  recalc_rects();

  /* Pick speaker graphic according to whether music is on: */
  if ( settings.menu_music )
    SDL_BlitSurface(speaker, NULL, screen, &spkrdest);
  else
    SDL_BlitSurface(speakeroff, NULL, screen, &spkrdest);

  /* Start playing menu music if desired: */
  if (settings.menu_music)
    MusicLoad( "tuxi.ogg", -1 );

  LOG( "Tux and Title are in place now\n" );

  SDL_WM_GrabInput(SDL_GRAB_OFF);


  /****************************
  * Main Loop Starts Here ... *
  ****************************/


  menu_depth = 1;
  firstloop = 1;
  Tuxdest.y = screen->h - Tux->frame[0]->h;


  while (!done) 
  {

    start = SDL_GetTicks();

    /* ---process input queue --- */

    menu_opt = NONE; // clear the option so we don't change twice!

    old_key_menu = key_menu;

    /* Retrieve any user interface events: */
    while (SDL_PollEvent(&event))
    {
      switch (event.type)
      {
        /* Update "selection" if mouse moves within a menu entry: */
        case SDL_MOUSEMOTION:
        {
          cursor.x = event.motion.x;
          cursor.y = event.motion.y;

	  for (j = 1; j <= TITLE_MENU_ITEMS; j++)
            if (inRect(menu_button[j], cursor.x, cursor.y))
              key_menu = j;
          break;
        }


        /* Handle mouse clicks based on mouse location: */
        case SDL_MOUSEBUTTONDOWN:
        {
          cursor.x = event.motion.x;
          cursor.y = event.motion.y;

          for (j = 1; j <= TITLE_MENU_ITEMS; j++)
          {
            if (inRect(menu_button[j], cursor.x, cursor.y))
            {
              menu_opt = menu_item[j][menu_depth];
              if (settings.menu_sound)
              {
                PlaySound(snd_select);
              }
              DEBUGCODE
              {
                fprintf(stderr, "->>BUTTON CLICK menu_opt = %d\n", menu_opt);
                fprintf(stderr, "->J = %d menu_depth=%d\n", j, menu_depth);
              }
            }
          }

          /* If mouse over speaker, toggle menu music off or on: */
          if (inRect(spkrdest, cursor.x, cursor.y))
          {
            if (settings.menu_music)
            {
              MusicUnload();
              settings.menu_music = 0;
            }
            else
            {
              settings.menu_music = 1;
              MusicLoad("tuxi.ogg", -1);
            }
            redraw = 1;
          }
          break;
        }



        case SDL_QUIT:
        {
          menu_opt = QUIT_GAME;
          break;
        }


        /* Handle key press events based on key value: */
        case SDL_KEYDOWN:
        {
          switch (event.key.keysym.sym)
          {
            case SDLK_ESCAPE:
            {
              /* Go to main menu (if in submenu) or quit: */
              if (menu_depth != 1) 
                menu_opt = MAIN;
              else
                menu_opt = QUIT_GAME;

              if (settings.menu_sound)
                PlaySound(snd_select);
              break;
            }


            /* Toggle screen mode: */
            case SDLK_F10:
            {
              SwitchScreenMode();
              recalc_rects();
              redraw = 1;
              break;
            }


            /* Toggle menu music: */
            case SDLK_F11:
            {
              if (settings.menu_music)
              {
                MusicUnload( );
                settings.menu_music = 0;
              }
              else
              {
                settings.menu_music = 1;
                MusicLoad("tuxi.ogg", -1);
              }
              redraw = 1;
              break;
            }


            /* --- reload translation/graphics/media: for themers/translaters --- */
            case SDLK_F12:
            {
              unload_media();
              LoadLang();
              load_media();
              redraw = 1;
              break;
            }


            case SDLK_UP:
	    case SDLK_k:
            {
              if (settings.menu_sound)
                PlaySound(snd_move);
              key_menu--;
              if (key_menu < 1)
                key_menu = 5;
              break;
            }


            case SDLK_DOWN:
	    case SDLK_j:
            {
              key_menu++;
              if (settings.menu_sound)
                PlaySound(snd_move);
              if (key_menu > 5)
                key_menu = 1;
              break;
            }


            case SDLK_RETURN:
            {
              if (key_menu)
              {
                menu_opt = menu_item[key_menu][menu_depth];
                if (settings.menu_sound)
                  PlaySound(snd_select);
              }
              break;
            }


            default:     /* Some other key pressed - do nothing: */
            {
              break;
            }
          }             /* End of switch(event.key.keysym.sym) statement */
        }               /* End of case: SDL_KEYDOWN: */


        default:        /* Some other type of SDL event - do nothing;    */
        {
          break;
        }
      }                 /* End of switch(event.type) statement           */
    }	              /* End of while (SDL_PollEvent(&event)) loop     */





    /* --- do menu processing --- */


    if (menu_opt == QUIT_GAME)
      done = 1;


    if (menu_opt == LASER)
    {
      menu_depth = LASER_SUBMENU;
      sub_menu = LASER;
      update_locs = 1;
      redraw = 1;
    }


    if (menu_opt == CASCADE)
    {
      menu_depth = CASCADE_SUBMENU;
      sub_menu = CASCADE;
      update_locs = 1;
      redraw=1;
    }


    if (menu_opt == OPTIONS)
    {
      menu_depth = OPTIONS_SUBMENU;
      sub_menu = OPTIONS;
      update_locs = 1;
      redraw = 1;
    }


    if (menu_opt == MAIN)
    {
      menu_depth = ROOTMENU;
      update_locs = 1;
      redraw = 1;
    }


    if (menu_opt == EDIT_WORDLIST)
    {
      ChooseListToEdit();
      redraw = 1;
    }


    if (menu_opt == PROJECT_INFO)
    {
      ProjectInfo();
      redraw = 1;
    }


    if (menu_opt == LESSONS)
    {
//      not_implemented();
      SDL_BlitSurface(CurrentBkgd(), NULL, screen, NULL);
      SDL_Flip(screen);
      unload_media();

      if (settings.menu_music)
        MusicUnload( );

      XMLLesson();

      load_media();

      redraw = 1;

      if (settings.menu_music)
        MusicLoad( "tuxi.ogg", -1 );
    }


    if (menu_opt == SET_LANGUAGE)
    {
      unload_media();
      ChooseTheme();
      LoadLang();
      LoadKeyboard();
      load_media();
      redraw = 1;

      if (settings.menu_music)
        MusicLoad( "tuxi.ogg", -1 );
    }


    if (menu_opt == LEVEL1)
    {  
      if (chooseWordlist()) 
      {
        unload_media();

        switch (sub_menu)
        {
          case CASCADE: PlayCascade( EASY ); break;
          case LASER:   PlayLaserGame(  EASY ); break;
        }
      }

      load_media();

      if (settings.menu_music)
        MusicLoad("tuxi.ogg", -1);

      redraw = 1;
    }


    if (menu_opt == LEVEL2)
    {
      if (chooseWordlist())
      {
        unload_media();

        switch (sub_menu)
        {
          case CASCADE: PlayCascade( MEDIUM ); break;
          case LASER:   PlayLaserGame(  MEDIUM ); break;
        }


        if (settings.menu_music)
          MusicLoad( "tuxi.ogg", -1 );
      }

      load_media();
      redraw = 1;
    }



    if (menu_opt == LEVEL3)
    {
      if (chooseWordlist())
      {
        unload_media();

        switch (sub_menu)
        {
          case CASCADE: PlayCascade( HARD ); break;
          case LASER:   PlayLaserGame(  HARD ); break;
        }


        if (settings.menu_music)
          MusicLoad( "tuxi.ogg", -1 );
      }

      load_media();
      redraw = 1;
    }



    if (menu_opt == LEVEL4)
    {
      if (chooseWordlist())
      {
        unload_media();

        switch (sub_menu)
        {
          case CASCADE: PlayCascade( INSANE ); break;
          case LASER:   PlayLaserGame(  INSANE ); break;
        }

        if (settings.menu_music)
          MusicLoad( "tuxi.ogg", -1 );
      }

      load_media();
      redraw = 1;
    }



    if (menu_opt == INSTRUCT)
    {
//       not_implemented();
       unload_media();

      switch (sub_menu)
      {
        case CASCADE: InstructCascade(); break;
        case LASER:   InstructLaser();   break;
      }

      load_media();

      if (settings.menu_music)
        MusicLoad( "tuxi.ogg", -1 );

      redraw = 1;
    }



    if (menu_opt == PHRASE_TYPING)
    {
//      not_implemented();

      unload_media();

      Phrases(NULL);

      load_media();

      if (settings.menu_music)
        MusicLoad( "tuxi.ogg", -1 );

      redraw = 1;
    }

    /* ------ End menu_opt processing ----------- */



    if (redraw)
    {
      LOG("TitleScreen() - redraw requested\n");
      recalc_rects();

      SDL_BlitSurface(CurrentBkgd(), NULL, screen, NULL); 
      SDL_BlitSurface(title, NULL, screen, &Titledest);

      if ( settings.menu_music )
        SDL_BlitSurface(speaker, NULL, screen, &spkrdest);
      else
        SDL_BlitSurface(speakeroff, NULL, screen, &spkrdest);

      /* Screen will be updated due to update_locs - see ~30 lines down: */
//      SDL_UpdateRect(screen, 0, 0, 0, 0);
      frame = redraw = 0;   // so we redraw tux
      update_locs = 1;      // so we redraw menu
      firstloop = 1;
    }



    /* --- create new menu screen when needed --- */

    if (update_locs)
    {
      LOG("TitleScreen() - update_locs requested\n");

      /* --- erase the last menu --- */
      for (i = 1; i <= TITLE_MENU_ITEMS; i++)
      {
        text_dst[i].x = screen->w/2 - 70;//290;
        text_dst[i].w = reg_text[i][menu_depth]->w;
        text_dst[i].h = reg_text[i][menu_depth]->h;
        SDL_BlitSurface(CurrentBkgd(), &menu_button[i], screen, &menu_button[i]);
        menu_button[i].w = menu_width[menu_depth] + 20;
      }


      update_locs = 0;

      /* --- draw the full menu --- */

      for (j = 1; j <= TITLE_MENU_ITEMS; j++)
      {
        DOUT(j);
        DrawButton(&menu_button[j], 10, REG_RGBA);
        if (reg_text[j][menu_depth] != NULL)
          SDL_BlitSurface(reg_text[j][menu_depth], NULL, screen, &text_dst[j]);
        if (menu_gfx[j][menu_depth] != NULL)
          SDL_BlitSurface(menu_gfx[j][menu_depth]->default_img, NULL, screen, &menu_gfxdest[j]);
      }

      SDL_UpdateRect(screen, 0, 0, 0, 0);

      LOG("TitleScreen() - update_locs completed\n");
    }



    /* --- make tux blink --- */

    switch (frame % TUX6)
    {
      case 0:    tux_frame = 1; break;
      case TUX1: tux_frame = 2; break;
      case TUX2: tux_frame = 3; break;
      case TUX3: tux_frame = 4; break;			
      case TUX4: tux_frame = 3; break;
      case TUX5: tux_frame = 2; break;
      default: tux_frame = 0;
    }

    if (tux_frame)
    {
      SDL_Rect blink_src, blink_dest;
      blink_src.x = 0;
      blink_src.y = 0;
      blink_src.w = Tuxdest.w;
      blink_src.h = Tuxdest.h;
      blink_dest.x = Tuxdest.x + blink_src.x;
      blink_dest.y = Tuxdest.y + blink_src.y;
      blink_dest.w = blink_src.w;
      blink_dest.h = blink_src.h;
//      SDL_BlitSurface(CurrentBkgd(), , screen, &Tuxdest);
      SDL_BlitSurface(Tux->frame[tux_frame - 1], &blink_src, screen, &blink_dest);
    }


    /* --- check if mouse is in a menu option --- */

//    key_menu = 0;
/*
    for (j = 1; j <= TITLE_MENU_ITEMS; j++)
    {
      if ((cursor.x >= menu_button[j].x && cursor.x <= (menu_button[j].x + menu_button[j].w)) &&
          (cursor.y >= menu_button[j].y && cursor.y <= (menu_button[j].y + menu_button[j].h)))
      {
        key_menu = j; // update menu to point
        break;        // Don't need to check rest of menu
      }
    }*/


    /* --- return old selection to unselected state --- */

    if (old_key_menu && (key_menu != old_key_menu))
    {
      SDL_BlitSurface(CurrentBkgd(), &menu_button[old_key_menu], screen, &menu_button[old_key_menu]);
      DrawButton(&menu_button[old_key_menu], 10, REG_RGBA);
      SDL_BlitSurface(reg_text[old_key_menu][menu_depth], NULL, screen, &text_dst[old_key_menu]);
      SDL_BlitSurface(menu_gfx[old_key_menu][menu_depth]->default_img, NULL, screen, &menu_gfxdest[old_key_menu]);
    }


    /* --- draw current selection --- */

    if ((key_menu != 0) &&
       ((old_key_menu != key_menu) || (frame % 5 == 0))) // Redraw every fifth frame?
    {
      if (key_menu != old_key_menu)
      {
        REWIND(menu_gfx[key_menu][menu_depth]);
        PlaySound(snd_move);
      }

      SDL_BlitSurface(CurrentBkgd(), &menu_button[key_menu], screen, &menu_button[key_menu]);
      DrawButton(&menu_button[key_menu], 10, SEL_RGBA);
      SDL_BlitSurface(sel_text[key_menu][menu_depth], NULL, screen, &text_dst[key_menu]);
      SDL_BlitSurface(menu_gfx[key_menu][menu_depth]->frame[menu_gfx[key_menu][menu_depth]->cur], NULL, screen, &menu_gfxdest[key_menu]);

      NEXT_FRAME(menu_gfx[key_menu][menu_depth]);
    }


    // HACK This is still more than we need to update every frame but
    // it cuts cpu on my machine %60 so it seems better...
    if ( settings.menu_music )
      SDL_BlitSurface(speaker, NULL, screen, &spkrdest);
    else
      SDL_BlitSurface(speakeroff, NULL, screen, &spkrdest);

    SDL_UpdateRect(screen, spkrdest.x, spkrdest.y, spkrdest.w, spkrdest.h);

    for (i = 1; i < 6; i++)
    {
      SDL_UpdateRect(screen, menu_button[i].x, menu_button[i].y, menu_button[i].w, menu_button[i].h);
    }

    if (tux_frame)
      SDL_UpdateRect(screen, Tuxdest.x, Tuxdest.y, Tuxdest.w, Tuxdest.h);

    if (firstloop)
      SDL_UpdateRect(screen, Tuxdest.x, Tuxdest.y, Tuxdest.w, Tuxdest.h);

    firstloop = 0;

    /* Wait so we keep frame rate constant: */
    while ((SDL_GetTicks() - start) < 33)
    {
      SDL_Delay(20);
    }

    frame++;
  } /* ----------- End of 'while(!done)' loop ------------  */
Exemple #29
0
bool imguiSlider(const char* text, float* val, float vmin, float vmax, float vinc, bool enabled)
{
	g_state.widgetId++;
	unsigned int id = (g_state.areaId<<16) | g_state.widgetId;
	
	int x = g_state.widgetX;
	int y = g_state.widgetY - BUTTON_HEIGHT;
	int w = g_state.widgetW;
	int h = SLIDER_HEIGHT;
	g_state.widgetY -= SLIDER_HEIGHT + DEFAULT_SPACING;

	addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, 4.0f, imguiRGBA(0,0,0,128));

	const int range = w - SLIDER_MARKER_WIDTH;

	float u = (*val - vmin) / (vmax-vmin);
	if (u < 0) u = 0;
	if (u > 1) u = 1;
	int m = (int)(u * range);

	bool over = enabled && inRect(x+m, y, SLIDER_MARKER_WIDTH, SLIDER_HEIGHT);
	bool res = buttonLogic(id, over);
	bool valChanged = false;

	if (isActive(id))
	{
		if (g_state.wentActive)
		{
			g_state.dragX = g_state.mx;
			g_state.dragOrig = u;
		}
		if (g_state.dragX != g_state.mx)
		{
			u = g_state.dragOrig + (float)(g_state.mx - g_state.dragX) / (float)range;
			if (u < 0) u = 0;
			if (u > 1) u = 1;
			*val = vmin + u*(vmax-vmin);
			*val = floorf(*val/vinc+0.5f)*vinc; // Snap to vinc
			m = (int)(u * range);
			valChanged = true;
		}
	}

	if (isActive(id))
		addGfxCmdRoundedRect((float)(x+m), (float)y, (float)SLIDER_MARKER_WIDTH, (float)SLIDER_HEIGHT, 4.0f, imguiRGBA(255,255,255,255));
	else
		addGfxCmdRoundedRect((float)(x+m), (float)y, (float)SLIDER_MARKER_WIDTH, (float)SLIDER_HEIGHT, 4.0f, isHot(id) ? imguiRGBA(255,196,0,128) : imguiRGBA(255,255,255,64));

	// TODO: fix this, take a look at 'nicenum'.
	int digits = (int)(ceilf(log10f(vinc)));
	char fmt[16];
	snprintf(fmt, 16, "%%.%df", digits >= 0 ? 0 : -digits);
	char msg[128];
	snprintf(msg, 128, fmt, *val);
	
	if (enabled)
	{
		addGfxCmdText(x+SLIDER_HEIGHT/2, y+SLIDER_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, isHot(id) ? imguiRGBA(255,196,0,255) : imguiRGBA(255,255,255,200));
		addGfxCmdText(x+w-SLIDER_HEIGHT/2, y+SLIDER_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_RIGHT, msg, isHot(id) ? imguiRGBA(255,196,0,255) : imguiRGBA(255,255,255,200));
	}
	else
	{
		addGfxCmdText(x+SLIDER_HEIGHT/2, y+SLIDER_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, imguiRGBA(128,128,128,200));
		addGfxCmdText(x+w-SLIDER_HEIGHT/2, y+SLIDER_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_RIGHT, msg, imguiRGBA(128,128,128,200));
	}

	return res || valChanged;
}
Exemple #30
0
void ATOM_CellData::onPaint (ATOM_WidgetDrawClientEvent *event)
{
	ATOM_STACK_TRACE(ATOM_CellData::onPaint);

	ATOM_Rect2Di outRect(ATOM_Point2Di(0, 0), event->canvas->getSize());
	ATOM_Rect2Di inRect(_frameOffset, _frameOffset, outRect.size.w-_frameOffset*2, outRect.size.h-_frameOffset*2);

	bool inCD = (ATOM_INVALID_IMAGEID != _cooldownImageId) && _cooldownMax;

	if (_frameImageId != ATOM_INVALID_IMAGEID)
	{
		ATOM_GUIImage *image = getValidImage (_frameImageId);
		image->draw (event->state, event->canvas, outRect);
	}

	if (_clientImageId != ATOM_INVALID_IMAGEID)
	{
		ATOM_GUIImage *image = getValidImage (_clientImageId);
		if (!image)
		{
			image = ATOM_GUIImageList::getDefaultImageList().getImage (ATOM_IMAGEID_WINDOW_BKGROUND);
			ATOM_ASSERT(image);
		}
		if(_customColor)
		{
			image->draw (event->state, event->canvas, inRect, &_customColor);
		}
		else
		{
			image->draw (event->state, event->canvas, inRect);
		}

	}

	if (!_caption.empty())
	{
		if (_textDirty)
		{
			calcTextLayout ();
			_textDirty = false;
		}

		ATOM_GUICanvas::DrawTextInfo info;
		info.textObject = _text.get();
		info.textString = _text->getString();
		info.font = _text->getFont();
		info.x = _textPosition.x;
		info.y = _textPosition.y;
		info.shadowOffsetX = 0;
		info.shadowOffsetY = 0;
		info.textColor = getFontColor();
		info.outlineColor = _widgetFontOutLineColor;
		info.shadowColor = 0;
		info.underlineColor = _underlineColor;
		info.flags = ATOM_GUICanvas::DRAWTEXT_TEXTOBJECT;
		if(_widgetFontOutLineColor.getByteA())
		{
			info.flags |= ATOM_GUICanvas::DRAWTEXT_OUTLINE;
		}
		if(_underlineColor.getByteA())
		{
			info.flags |= ATOM_GUICanvas::DRAWTEXT_UNDERLINE;
		}
		event->canvas->drawTextEx(&info);
		//event->canvas->drawText (_text.get(), _textPosition.x, _textPosition.y, getFontColor());
	}
	//»æÖÆϱê×ÖÌå
	if (!_subscriptStr.empty())
	{
		if (_subscirptTextDirty)
		{
			calcSubscriptTextLayout();
			_subscirptTextDirty = false;
		}

		ATOM_GUICanvas::DrawTextInfo info;
		info.textObject = _subscriptText.get();
		info.textString = _subscriptText->getString();
		info.font = _subscriptText->getFont();
		info.x = _subscriptTextPosition.x;
		info.y = _subscriptTextPosition.y;
		info.shadowOffsetX = 0;
		info.shadowOffsetY = 0;
		info.textColor = getFontColor();
		info.outlineColor = _widgetFontOutLineColor;
		info.shadowColor = 0;
		info.underlineColor = _underlineColor;
		info.flags = ATOM_GUICanvas::DRAWTEXT_TEXTOBJECT;
		if(_widgetFontOutLineColor.getByteA())
		{
			info.flags |= ATOM_GUICanvas::DRAWTEXT_OUTLINE;
		}
		if(_underlineColor.getByteA())
		{
			info.flags |= ATOM_GUICanvas::DRAWTEXT_UNDERLINE;
		}
		event->canvas->drawTextEx(&info);
		//event->canvas->drawText (_text.get(), _textPosition.x, _textPosition.y, getFontColor());
	}
	//»æÖÆϱêͼƬ
	if(_subscriptImageId != ATOM_INVALID_IMAGEID)
	{
		ATOM_GUIImage *image = getValidImage (_subscriptImageId);
		if(!image)
		{
			image = ATOM_GUIImageList::getDefaultImageList().getImage(ATOM_IMAGEID_WINDOW_BKGROUND);
			ATOM_ASSERT(image);
		}
		image->draw(event->state,event->canvas,ATOM_Rect2Di(inRect.point.x+_subscriptRect.point.x,
			inRect.point.y+_subscriptRect.point.y,_subscriptRect.size.w,_subscriptRect.size.h));
	}

	if (_selectImageId != ATOM_INVALID_IMAGEID)
	{
#if 1
		ATOM_GUIImage *image = getValidImage (_selectImageId);
#else
		const ATOM_GUIImageList *imagelist = getValidImageList ();
		ATOM_GUIImage *image = imagelist->getImage (_selectImageId);
#endif
		if (!image)
		{
			image = ATOM_GUIImageList::getDefaultImageList().getImage (ATOM_IMAGEID_WINDOW_BKGROUND);
			ATOM_ASSERT(image);
		}
		image->draw (event->state, event->canvas, outRect);
	}

	//
	//bool inCD = (ATOM_INVALID_IMAGEID != _cooldownImageId) && _cooldownMax;

	//// »­CELL±³¾°
	//if(cell->_texture.pointer)
	//{
	//	unsigned color = inCD ? 0xFF808080 : 0xFFFFFFFF;
	//	canvas->drawTexturedRectEx(ATOM_Rect2Di(x*(xCellWidth+_xSpace), y*(yCellWidth+_ySpace), xCellWidth, yCellWidth), color, cell->_texture.pointer, cell->_region, false);
	//}
	//else if (_clientImageId != ATOM_INVALID_IMAGEID)
	//{
	//	imageDefault->draw (event->state, event->canvas, ATOM_Rect2Di(x*(xCellWidth+_xSpace), y*(yCellWidth+_ySpace), xCellWidth, yCellWidth));
	//}

	//if(cell->_text.pointer)
	//{
	//	const char* str = cell->_text->getString();
	//	if (strcmp (str, ""))
	//	{
	//		ATOM_FontHandle font = ATOM_GUIFont::getFontHandle (getFont());
	//		int charmargin = ATOM_GUIFont::getFontCharMargin (getFont());
	//		int charset = ATOM_GUIFont::getFontCharSet (getFont());
	//		ATOM_SetCharMargin (charmargin);
	//		int l, t, w, h;
	//		ATOM_CalcStringBounds (font, charset, str, strlen(str), &l, &t, &w, &h);
	//		canvas->drawText (cell->_text.pointer, x*(xCellWidth+_xSpace), y*(yCellWidth+_ySpace)-t, _fontColor);
	//	}
	//}

	// »­CD
	if(inCD)
	{
#if 1
		ATOM_GUIImage *image = getValidImage (_cooldownImageId);
#else
		ATOM_GUIImage* image = getValidImageList()->getImage (_cooldownImageId);
#endif
		if(image)
		{
			ATOM_Texture* texture = image->getTexture(WST_NORMAL);
			if(texture)
			{
				ATOM_CircleDrawer drawer(event->canvas, texture);
				drawer.DrawRemove(inRect, float(_cooldown)/float(_cooldownMax));
			}
		}
#if 0
		char buffer[256];
		sprintf (buffer, "%d", _cooldown);
		event->canvas->drawText (buffer, ATOM_GUIFont::getFontHandle(ATOM_GUIFont::getDefaultFont(10, 0)), 0, 0, 0xFFFFFFFF);
#endif
	}
}