Exemplo n.º 1
0
LRESULT CALLBACK Win32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    PAINTSTRUCT ps;
    HDC hdc;

    switch(uMsg)
    {
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);
        draw_update(hdc);
        EndPaint(hWnd, &ps);
        break;
    case WM_ERASEBKGND:
        break;

    case WM_TIMER:
        timerFunc();
        break;

    case WM_KEYDOWN:
        keyboardPressed((char)wParam);
        break;
    case WM_LBUTTONDBLCLK: 
    case WM_LBUTTONDOWN:
        mousePressed(0, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); 
        break;
    
    case WM_RBUTTONDBLCLK: 
    case WM_RBUTTONDOWN:
        mousePressed(1, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); 
        break;

    case WM_COMMAND:
        for(std::vector<Button*>::iterator it = m_buttons.begin(); it != m_buttons.end(); ++it)
        {
            Button *p = *it;
            if(LOWORD(wParam) ==p->m_id)
            {
                if(HIWORD(wParam) == BN_CLICKED)
                    if(p->m_click)
                        p->m_click();
                break;
            }
        }

            break;
    case WM_CREATE:
        break;
    case WM_CLOSE:
        DeleteObject(hDoubleBufferBM);
        DeleteDC    (hDoubleBufferDC);
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, uMsg, wParam, lParam);
    }

    return 0;
}
	void UIElement::BlendTo(float f_Length, glm::vec4 v4_FinalColour){
		if (f_Length == 0.0f) {return;}
		AnimationStart(FuncTimer(timerFunc(f_Length,f_Length),&BlendFunc));
		v4ColourA = v4_FinalColour;
		v4ColourO = v4Colour;
	}
	void UIElement::ScaleTo(float f_Length, glm::vec2 v2_FinalScale){
		if (f_Length == 0.0f) {return;}
		AnimationStart(FuncTimer(timerFunc(f_Length,f_Length),&ScaleFunc));
		v2ScaleA = v2_FinalScale;
		v2ScaleO = v2Scale;
	}
	void UIElement::RotateTo(float f_Length, float f_FinalRotation){
		if (f_Length == 0.0f) {return;}
		AnimationStart(FuncTimer(timerFunc(f_Length,f_Length),&RotateFunc));
		fRotationA = f_FinalRotation;
		fRotationO = fRotation;
	}
	// Animations
	void UIElement::TranslateTo(float f_Length, glm::vec3 v3_FinalTranslation){
		if (f_Length == 0.0f) {return;}
		AnimationStart(FuncTimer(timerFunc(f_Length,f_Length),&TranslateFunc));
		v4TranslateA = glm::vec4(v3_FinalTranslation,1);
		v4TranslateO = v4Translate;
	}