void CControlLineStyleSelector::Draw(CDC* pDC) { CRect rc(m_rcControl); int nCount = sizeof(lineStyles) / sizeof(lineStyles[0]); for (int i = 0; i < nCount; i++) { CRect rcButton = GetRect(i); if (i == m_nSelected || lineStyles[i].iLineStyle == m_iLineStyle) { BOOL bPressed = GetPressed() && i == m_nSelected; //GetPaintManager()->DrawControlEntry(pDC, &rcButton, m_bEnabled, 1, bPressed, lineStyles[i].iLineStyle == m_iLineStyle, FALSE, GetParent()->GetPosition()); GetPaintManager()->DrawRectangle(pDC, &rcButton, i == m_nSelected, bPressed, m_bEnabled, lineStyles[i].iLineStyle == m_iLineStyle, FALSE,GetParent()->GetType(), GetParent()->GetPosition()); } Gdiplus::Graphics gdipGraphics(pDC->m_hDC); Gdiplus::Pen pen(Gdiplus::Color(255, 0, 0, 0), 3); pen.SetDashCap(Gdiplus::DashCapFlat); pen.SetDashPattern(lineStyles[i].dashValues, lineStyles[i].iDashValueCount); pen.SetDashStyle(Gdiplus::DashStyleCustom); int yPos = rcButton.top + XTP_LS_SELECTOR_HEIGHT / 2; if (!m_bEnabled) { pen.SetColor(Gdiplus::Color(255, 128, 128, 128)); } gdipGraphics.DrawLine(&pen, Gdiplus::Point(rcButton.left, yPos), Gdiplus::Point(rcButton.right, yPos)); } }
bool PG_ScrollBar::ScrollButton::eventMouseMotion(const SDL_MouseMotionEvent* motion) { PG_Point p; if(GetPressed()) { //SDL_GetMouseState(&x, &y); p = GetParent()->ScreenToClient(motion->x, motion->y); if(GetParent()->sb_direction == VERTICAL) { p.y -= offset.y; if(p.y < GetParent()->position[2].y) { p.y = GetParent()->position[2].y; } int maxy; if(!my_tickMode) { maxy = GetParent()->position[2].y + (GetParent()->position[2].h) - my_height; } else { maxy = GetParent()->my_height - my_height; } if(p.y > maxy) { p.y = maxy; } MoveWidget(GetParent()->position[2].x, p.y); } else { p.x -= offset.x; if(p.x < GetParent()->position[2].x) { p.x = GetParent()->position[2].x; } int maxx; if(!my_tickMode) { maxx = GetParent()->position[2].x + (GetParent()->position[2].w) - (my_width); } else { maxx = GetParent()->my_width - my_width; } if(p.x > maxx) { p.x = maxx; } MoveWidget(p.x, GetParent()->position[2].y); } int pos = GetPosFromPoint(p); if(GetParent()->scroll_current != pos || my_tickMode) { GetParent()->scroll_current = pos; GetParent()->sigScrollTrack(GetParent(), pos); } } return true; }
void StateRenderTest::Update(beStateMachine* stateMachine, float dt) { auto gamepad = m_appData->gamepad; auto keyboard = m_appData->keyboard; auto mouse = m_appData->mouse; auto renderInterface = m_appData->renderInterface; if (gamepad->GetPressed(beGamepad::A) || keyboard->IsPressed(beKeyboard::Button::W)) { renderInterface->ToggleWireframe(); } if (keyboard->IsPressed(beKeyboard::Button::G)) { m_renderGrid = !m_renderGrid; } if (keyboard->IsPressed(beKeyboard::Button::F)) { m_showGroundFilled = !m_showGroundFilled; m_gridModel.SetMeshVisibility("GroundFilled", m_showGroundFilled); } if (gamepad->GetPressed(beGamepad::B) || keyboard->IsPressed(beKeyboard::Button::Escape)) { stateMachine->ChangeState(nullptr); return; } if (gamepad->GetPressed(beGamepad::Y)) { const int shader = ((int)m_shaderToUse + 1) % (int)beRendering::ShaderType::Count; m_shaderToUse = (beRendering::ShaderType)shader; } if (gamepad->GetPressed(beGamepad::X) || mouse->IsPressed(beMouse::Button::MiddleButton)) { m_modelToUse++; m_modelToUse %= m_models.Count() + 1; } if (gamepad->GetPressed(beGamepad::Select)) { m_renderAxes = !m_renderAxes; } if (gamepad->GetPressed(beGamepad::Up)) { m_bitmapTexQuadNorm.SetPosition(m_bitmapTexQuadNorm.GetPosition() + Vec2(0.f, 0.1f)); m_bitmapTexQuadPixelCoord.SetPosition(m_bitmapTexQuadPixelCoord.GetPosition() + Vec2(0.f, 20.f)); } if (gamepad->GetPressed(beGamepad::Down)) { m_bitmapTexQuadNorm.SetPosition(m_bitmapTexQuadNorm.GetPosition() - Vec2(0.f, 0.1f)); m_bitmapTexQuadPixelCoord.SetPosition(m_bitmapTexQuadPixelCoord.GetPosition() - Vec2(0.f, 20.f)); } if (gamepad->GetPressed(beGamepad::Left)) { m_bitmapTexQuadNorm.SetPosition(m_bitmapTexQuadNorm.GetPosition() - Vec2(0.1f, 0.f)); m_bitmapTexQuadPixelCoord.SetPosition(m_bitmapTexQuadPixelCoord.GetPosition() - Vec2(20.f, 0.f)); } if (gamepad->GetPressed(beGamepad::Right)) { m_bitmapTexQuadNorm.SetPosition(m_bitmapTexQuadNorm.GetPosition() + Vec2(0.1f, 0.f)); m_bitmapTexQuadPixelCoord.SetPosition(m_bitmapTexQuadPixelCoord.GetPosition() + Vec2(20.f, 0.f)); } if (mouse->IsPressed(beMouse::LeftButton)) { //auto window = m_appData->window; const float screenX = (float)mouse->GetX();// -window->GetX(); const float screenY = (float)mouse->GetY();// - window->GetY(); Vec3 worldPos, worldDir; const bool isInBounds = beCameraUtils::GetScreeenToWorldRay(*renderInterface, m_camera.GetViewMatrix(), screenX, screenY, &worldPos, &worldDir); if (isInBounds) { //LOG("MOUSE CLICK: (%.2f, %.2f) POS:{%3.3f, %3.3f, %3.3f} dir:{%3.3f, %3.3f, %3.3f}\r\n", screenX, screenY, worldPos.x, worldPos.y, worldPos.z, worldDir.x, worldDir.y, worldDir.z); //LOG("MOUSE Deets:"); PositionFromMatrix(m_camera.GetViewMatrix()); } //if (auto realWorldPos = beCameraUtils::WorldPosFromScreenPos(*renderInterface, m_camera.GetViewMatrix(), m_camera.GetPosition(), screenX, screenY)) //{ // LOG("Collision! mouse pos:{%.3f, %.3f, %.3f} World collision at:{%3.3f, %3.3f, %3.3f}\r\n", m_camera.GetPosition().x, m_camera.GetPosition().y, m_camera.GetPosition().z, realWorldPos->x, realWorldPos->y, realWorldPos->z); //} } m_camera.Update(dt); }
void CControlArrowStyleSelector::Draw(CDC* pDC) { CRect rc(m_rcControl); int nCount = sizeof(arrowStyles) / sizeof(arrowStyles[0]); for (int i = 0; i < nCount; i++) { CRect rcButton = GetRect(i); if (i == m_nSelected || arrowStyles[i].iArrowStyle == m_iArrowStyle) { BOOL bPressed = GetPressed() && i == m_nSelected; //GetPaintManager()->DrawControlEntry(pDC, &rcButton, m_bEnabled, i == m_nSelected, bPressed, arrowStyles[i].iArrowStyle == m_iArrowStyle, FALSE, GetParent()->GetPosition()); GetPaintManager()->DrawRectangle(pDC, &rcButton, i == m_nSelected, bPressed, m_bEnabled, arrowStyles[i].iArrowStyle == m_iArrowStyle, FALSE, GetParent()->GetType(), GetParent()->GetPosition()); } Gdiplus::Graphics gdipGraphics(pDC->m_hDC); Gdiplus::Pen pen(Gdiplus::Color(255, 0, 0, 0), 1); Gdiplus::SolidBrush brush(Gdiplus::Color(255, 0, 0, 0)); /* if (arrowStyles[i].iArrowStyle == msoLineRoundDot) pen.SetDashCap(Gdiplus::DashCapTriangle); else pen.SetDashCap(Gdiplus::DashCapFlat); pen.SetDashPattern(arrowStyles[i].dashValues, arrowStyles[i].iDashValueCount); pen.SetDashStyle(Gdiplus::DashStyleCustom);*/ // Gdiplus::Point points[3] = {Gdiplus::Point(0, 0), Gdiplus::Point(0, 0), Gdiplus::Point(0, 0)}; Gdiplus::GraphicsPath startCapPath; Gdiplus::GraphicsPath endCapPath; // Create a CustomLineCap object with capPath as the stroke path. int yPos = rcButton.top + XTP_AS_SELECTOR_HEIGHT / 2; switch(arrowStyles[i].startCap) { case Gdiplus::LineCapArrowAnchor: { Gdiplus::AdjustableArrowCap capStart(9, 9, false); pen.SetCustomStartCap(&capStart); break; } case Gdiplus::LineCapTriangle: { Gdiplus::AdjustableArrowCap capStart(6, 5, true); pen.SetCustomStartCap(&capStart); break; } case Gdiplus::LineCapDiamondAnchor: { Gdiplus::Point points[4] = {Gdiplus::Point(rcButton.left , yPos ), Gdiplus::Point(rcButton.left + 5, yPos + 5), Gdiplus::Point(rcButton.left + 10, yPos), Gdiplus::Point(rcButton.left + 5, yPos - 5)}; startCapPath.AddPolygon(points, 4); break; } case Gdiplus::LineCapRoundAnchor: { Gdiplus::Rect rect(rcButton.left, yPos - 5, 10, 10); startCapPath.AddEllipse(rect); break; } default: break; } switch(arrowStyles[i].endCap) { case Gdiplus::LineCapArrowAnchor: { Gdiplus::AdjustableArrowCap capEnd(9, 9, false); pen.SetCustomEndCap(&capEnd); break; } case Gdiplus::LineCapTriangle: { Gdiplus::AdjustableArrowCap capEnd(6, 5, true); pen.SetCustomEndCap(&capEnd); break; } case Gdiplus::LineCapDiamondAnchor: { Gdiplus::Point points[4] = {Gdiplus::Point(rcButton.right - 10 , yPos ), Gdiplus::Point(rcButton.right - 5, yPos + 5), Gdiplus::Point(rcButton.right, yPos), Gdiplus::Point(rcButton.right - 5, yPos - 5)}; endCapPath.AddPolygon(points, 4); break; } case Gdiplus::LineCapRoundAnchor: { Gdiplus::Rect rect(rcButton.right - 10, yPos - 5, 10, 10); endCapPath.AddEllipse(rect); break; } default: break; } if (!m_bEnabled) { pen.SetColor(Gdiplus::Color(255, 128, 128, 128)); brush.SetColor(Gdiplus::Color(255, 128, 128, 128)); } gdipGraphics.DrawLine(&pen, Gdiplus::Point(rcButton.left + 2, yPos), Gdiplus::Point(rcButton.right-2, yPos)); gdipGraphics.FillPath(&brush,&startCapPath); gdipGraphics.FillPath(&brush,&endCapPath); } }