void Button::SetDown() { // already down? if (fDown) return; // play sound GUISound("UI::Tick"); // set down fDown = true; }
void Button::SetUp(bool fPress) { // already up? if (!fDown) return; // play sound GUISound(fPress ? "UI::Click" : "UI::Tick"); // set up fDown = false; }
void CheckBox::ToggleCheck(bool fByUser) { // user can't toggle if disabled if (fByUser && !fEnabled) return; // sound if (fByUser) GUISound("ArrowHit"); // toggle state fChecked = !fChecked; // callback (last call; may destroy element) if (pCBHandler) pCBHandler->DoCall(this); }
void ScrollBar::MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam) { // inherited Element::MouseInput(rMouse, iButton, iX, iY, dwKeyParam); // not if scrolling is disabled if (!fScrolling) return; // reset arrow states bool fPrevDown = fTopDown || fBottomDown; fTopDown = fBottomDown = false; // not if dragging if (rMouse.pDragElement) return; // left mouse button down? if (rMouse.IsLDown()) // non-scroll-direction area check if (fHorizontal ? Inside<int32_t>(iY, 0, C4GUI_ScrollBarHgt) : Inside<int32_t>(iX, 0, C4GUI_ScrollBarWdt)) { // scroll-direction area check: up/left arrow if (fHorizontal ? Inside<int32_t>(iX, 0, C4GUI_ScrollArrowWdt-1) : Inside<int32_t>(iY, 0, C4GUI_ScrollArrowHgt-1)) fTopDown = true; // check down arrow else if (fHorizontal ? Inside<int32_t>(iX, GetBounds().Wdt-C4GUI_ScrollArrowWdt, GetBounds().Wdt-1) : Inside<int32_t>(iY, GetBounds().Hgt-C4GUI_ScrollArrowHgt, GetBounds().Hgt-1)) fBottomDown = true; else if (HasPin() && (fHorizontal ? Inside<int32_t>(iX, C4GUI_ScrollArrowWdt, GetBounds().Wdt-C4GUI_ScrollArrowWdt-1) : Inside<int32_t>(iY, C4GUI_ScrollArrowHgt, GetBounds().Hgt-C4GUI_ScrollArrowHgt-1))) { // move thumb here iScrollPos = GetScrollByPos(iX, iY); // reflect movement in associated window or do CB OnPosChanged(); // start dragging rMouse.pDragElement = this; GUISound("UI::Select"); } } // sound effekt when buttons are pressed if ((fTopDown || fBottomDown) != fPrevDown) GUISound("UI::Tick"); }