示例#1
2
bool RadioButton::OnLButtonUp(int mouse_x, int mouse_y) {
	if (IsOver(mouse_x, mouse_y) == true) {
		Component* parent = GetParent();
		Layout* layout = parent->GetLayout();

		// Update all the other radio buttons.
		Component* child = layout->GetFirst();
		while (child != 0) {
			if (child != this && child->GetType() == Component::kRadiobutton) {
				RadioButton* button = (RadioButton*)child;
				button->SetPressed(false);
			}

			child = layout->GetNext();
		}

		SetPressed(true);
		Click(true);
	} else {
		// Go back to previous state.
		switch(GetState()) {
		case kReleasing:
			SetState(kPressed);
			break;
		case kPressing:
			SetState(kReleased);
			break;
		default:
			break;
		}
	}

	ReleaseMouseFocus();
	return true;
}
示例#2
0
bool nuiToggleButton::MouseUnclicked  (nuiSize X, nuiSize Y, nglMouseInfo::Flags Button)
{
  if ( (Button & nglMouseInfo::ButtonLeft) && mClicked)
  {
    mClicked = false;
    Ungrab();

    if (IsInsideFromSelf(X,Y, GetActivationOffset()))
    {
      SetPressed(!mWasPressed);
      if (IsPressed())
				Activated();
			else
				Deactivated();
    }
    else
    {
      SetPressed(mWasPressed);
    }

    Invalidate();
    return true;
  }
  return false;
}
示例#3
0
void CUIEditBox::OnLButtonUp(POINT point)
{
    if(IsPressed())
    {
        SetPressed(false);
    }
}
示例#4
0
bool nuiButton::MouseUnclicked(nuiSize X, nuiSize Y, nglMouseInfo::Flags Button)
{
//  printf("unclicked\n");
  if ( (Button & nglMouseInfo::ButtonLeft) && mClicked)
  {
//    printf("was clicked\n");
    mClicked = false;
    SetPressed(false);
    Invalidate();
    if (!mAutoRepeat)
    {
      if (IsInsideFromSelf(X,Y, GetActivationOffset()))
      {
        //      printf("activated\n");
        Activated();
      }
      else
      {
        //      printf("unclicked inactive\n");
        ButtonDePressedInactive();
      }
      
    }
    return true;
  }
  return false;
}
示例#5
0
void CUIListBox::OnLButtonUp(POINT point)
{
	if (m_ScrollBar.ContainsPoint(point))
	{
		m_ScrollBar.OnLButtonUp(point);
		return;
	}
	SetPressed(false);

	if(m_nSelected != -1)
	{
		// Set all items between m_nSelStart and m_nSelected to
		// the same state as m_nSelStart
		int nEnd = __max(m_nSelStart, m_nSelected);
		int nBegin = __min(m_nSelStart, m_nSelected);

		for(int n = nBegin + 1; n < nEnd; ++n)
			m_Items[n]->bSelected = m_Items[m_nSelStart]->bSelected;
		m_Items[m_nSelected]->bSelected = m_Items[m_nSelStart]->bSelected;

		// If m_nSelStart and m_nSelected are not the same,
		// the user has dragged the mouse to make a selection.
		// Notify the application of this.
		if(m_nSelStart != m_nSelected)
			sendEvent(EVENT_LISTBOX_SELECTION);

		sendEvent(EVENT_LISTBOX_SELECTION_END);
	}
}
示例#6
0
// Received Mouse events:
bool nuiButton::MouseClicked(nuiSize X, nuiSize Y, nglMouseInfo::Flags Button)
{
  if (IsDisabled())
    return false;
  if (Button & nglMouseInfo::ButtonLeft)
  {
//    printf("clicked\n");
    mClicked = true;
    SetPressed(true);
    Invalidate();
    
    if (mAutoRepeat)
    {
      Activated();

      mLastTime = nglTime();
      mCurrentRepeatDelay = mRepeatDelay;
      mUntilRepeat = mCurrentRepeatDelay;

      if (!mpAutoRepeatTimer)
      {
        mpAutoRepeatTimer = nuiAnimation::AcquireTimer();
        mEventSink.Connect(mpAutoRepeatTimer->Tick, &nuiButton::OnAutoRepeat);
      }
    }
    return true;
  }
  return false;
}            
示例#7
0
//When an event (e.g Click) occurs this method calls functions, via function pointers, that are assigned
//as event handlers
void Control::Update() 
{
	bool oldMouseIn = this->mouseIn;
	bool oldMouseUp = this->mouseUp;
	bool oldPressed = this->pressed;
	SetMouseIn();
	SetMouseUp();
	SetPressed(oldMouseUp);
	SetClicked(oldPressed);
	
	//check for mouse enetering/leaving
	if(oldMouseIn !=this->mouseIn && !this->clicked)
	{
		if(this->mouseIn && MouseEnter)
		{
			MouseEnter();
		}
		else
		{
			if(MouseLeave)
			{
				MouseLeave();
			}
		}
	}
	//check for pressed
	if(this->pressed && Pressed)
	{
		inPress = true;
		Pressed();
	}
	//check for click
	if(this->clicked && Clicked)
	{
		Clicked();
	}
	if(this->mouseUp)
	{
		if(oldMouseUp != this->mouseUp)
		{
			if(MouseUp)
			{
				MouseUp();
			}
			if(inPress && OutOfPress)
			{
				OutOfPress();
				inPress=false;
			}
		}
	}
	
	//loop through all child controls and update
	list<Control*>::iterator i;
	for(i = this->controls.begin(); i != this->controls.end(); i++) 
	{
		(*i)->Update();
	}
}
示例#8
0
void CUISlider::OnLButtonUp(POINT point)
{
	if(IsPressed())
	{
		SetPressed(false);
		sendEvent(EVENT_SLIDER_VALUE_CHANGED);
	}
}
示例#9
0
void
CheckBoxControl::OnCancelMode()
{
  dragging = false;
  SetPressed(false);

  PaintWindow::OnCancelMode();
}
示例#10
0
void CPianoCtrl::OnLButtonUp(UINT nFlags, CPoint point) 
{
	if (m_CurKey >= 0) {
		SetPressed(m_CurKey, FALSE);
		ReleaseCapture();	// release mouse input
		m_CurKey = -1;	// reset current key
	}
	CWnd::OnLButtonUp(nFlags, point);
}
示例#11
0
文件: gui.cpp 项目: darwin/pacwars2
GUI_CheckBox::GUI_CheckBox(PG_Widget* parent, const PG_Rect& r, char* text, bool ipressed, SDL_Color bg) : PG_CheckButton(parent,99, r, text) {
	if (ipressed) {
		SetPressed();
	}

	LoadThemeStyle("GUI_CheckButton");
	my_widgetButton->LoadThemeStyle("GUI_CheckButton", "CheckWidget");
	//SetTransparency(0);
}
示例#12
0
bool
CheckBoxControl::OnMouseMove(PixelPoint p, unsigned keys)
{
  if (dragging) {
    SetPressed(IsInside(p));
    return true;
  } else
    return PaintWindow::OnMouseMove(p, keys);
}
示例#13
0
void CPianoCtrl::OnKeyChange(UINT nKeyFlags, bool IsDown)
{
	if (GetStyle() & PS_USE_SHORTCUTS) {	// if using shortcuts
		int ScanCode = nKeyFlags & 0xff;
		int	iKey = m_ScanCodeToKey[ScanCode];
		if (iKey >= 0 && iKey < _countof(m_ScanCodeToKey))
			SetPressed(iKey, IsDown);
	}
}
示例#14
0
void CUIDisplayWorld::OnMButtonDown(POINT point)
{
	if(ContainsPoint(point) == true)
	{
		SetPressed(true);
		// ----
		m_ptLastMousePosition	=	point;
	}
}
示例#15
0
uint16_t TFTSlider::processTouch(uint16_t x, uint16_t y) {

	if (!((x >= _x) && (x <= (_x+_w)) && (y >= _y) && (y <= (_y+_h))))
		return 0x0;        // Special value that says Not within the object...

	SetPressed(true);
	draw();    // Show it as depressed.

	// Now lets wait for the touch to release...
    while (ts.touched()) {
      GetTouchPoint(&x, &y);
      if (_fVert) {
    	  if ((y >= _y) && (y <= (_y+_h))) {
    		  _wDispVal = y;
    		  draw();    // try to redraw....
    	  }
      }
      else {
    	  if ((x >= _x) && (x <= (_x+_w))) {
    		  _wDispVal = x;
    		  draw();    // try to redraw....
    	  }
      }
	}
    while (!ts.bufferEmpty()) {
		GetTouchPoint(&x, &y);
	}

	SetPressed(false);

	// And see if we were still inside the button
	if ((x >= _x) && (x < (_x+_w)) && (y >= _y) && (y < (_y+_h))) {
		if (_fVert)
			SetValue(mapDisplayValueToValue(y));
		else
			SetValue(mapDisplayValueToValue(x));
		return 1;
	}

	// Otherwise make sure we are mapped back to the correct value...
	mapValueToDisplayValue();
	draw();
	return 0xffff;    // not on the button any more...
}
示例#16
0
bool PG_CheckButton::eventMouseButtonUp(const SDL_MouseButtonEvent* my_widgetButton) {

	if(my_isPressed) {
		SetUnpressed();
	} else {
		SetPressed();
	}

	return true;
}
示例#17
0
void Button::OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, MouseButton button, int buttons, int qualifiers, Cursor* cursor)
{
    if (button == MOUSEB_LEFT)
    {
        SetPressed(true);
        repeatTimer_ = repeatDelay_;
        hovering_ = true;
        pressed(this);
    }
}
示例#18
0
bool
GaugeThermalAssistantWindow::OnMouseMove(PixelPoint p, unsigned keys)
{
  if (dragging) {
    SetPressed(IsInside(p));
    return true;
  }

  return false;
}
示例#19
0
bool
SmallTrafficWindow::OnMouseMove(PixelScalar x, PixelScalar y, unsigned keys)
{
  if (dragging) {
    SetPressed(IsInside(x, y));
    return true;
  }

  return false;
}
示例#20
0
bool nuiToggleButton::MouseUngrabbed()
{
  nuiWidget::MouseUngrabbed();
  if (mClicked)
  {
    mClicked = false;
    SetPressed(mWasPressed);
  }
  return false;
}
示例#21
0
bool nuiToggleButton::MouseMoved(nuiSize X, nuiSize Y)
{
  if (IsDisabled())
    return false;
  
  if (mClicked)
  {
    if (IsInsideFromSelf(X,Y, GetActivationOffset()))
    {
      SetPressed(!mWasPressed);
    }
    else
    {
      SetPressed(mWasPressed);
    }
    return true;
  }
  return false;
}
示例#22
0
void Button::OnClickEnd(const IntVector2& position, const IntVector2& screenPosition, MouseButton button, int buttons, int qualifiers, Cursor* cursor, UIElement* beginElement)
{
    if (pressed_ && button == MOUSEB_LEFT)
    {
        SetPressed(false);
        // If mouse was released on top of the element, consider it hovering on this frame yet (see issue #1453)
        if (IsInside(screenPosition, true))
            hovering_ = true;
        released(this);
    }
}
示例#23
0
bool
CheckBoxControl::OnMouseDown(PixelPoint p)
{
  if (IsTabStop())
    SetFocus();

  SetPressed(true);
  SetCapture();
  dragging = true;
  return true;
}
示例#24
0
void CPianoCtrl::ReleaseKeys(UINT KeySourceMask)
{
	int	nKeys = GetKeyCount();
	for (int iKey = 0; iKey < nKeys; iKey++) {	// for each key
		const CKey&	key = m_Key[iKey];
		UINT	KeyBit = key.m_IsExternal ? KS_EXTERNAL : KS_INTERNAL;
		// if key pressed and its source matches caller's mask
		if (key.m_IsPressed && (KeyBit & KeySourceMask))
			SetPressed(iKey, FALSE);	// reset key to avoid stuck notes
	}
}
示例#25
0
bool
GaugeThermalAssistantWindow::OnMouseMove(PixelScalar x, PixelScalar y,
                                         unsigned keys)
{
  if (dragging) {
    SetPressed(IsInside(x, y));
    return true;
  }

  return false;
}
示例#26
0
void CPianoCtrl::OnLButtonDown(UINT nFlags, CPoint point) 
{
	int	iKey = FindKey(point);	// find key containing cursor position
	if (iKey >= 0) {	// if key found
		ASSERT(m_CurKey < 0);	// shouldn't be a current key, else logic error
		SetPressed(iKey, TRUE);
		SetCapture();	// capture mouse input
		m_CurKey = iKey;	// set current key
	}
	CWnd::OnLButtonDown(nFlags, point);
}
示例#27
0
bool
InfoBoxWindow::OnMouseMove(PixelPoint p, unsigned keys)
{
  if (dragging) {
    SetPressed(IsInside(p));
    if (!pressed)
      dialog_timer.Cancel();
    return true;
  }

  return false;
}
示例#28
0
	//! called during the update of the entity
	void Button::Update()
	{
		if(!GetRootContext()->IsTopContext() || !m_bVisible)
		{
			return;
		}

		if(InputManager::Instance()->IsTouchJustPressed())
		{
			if(IsTouched())
			{
				SetPressed(true);
			}
		}
		else if(InputManager::Instance()->IsTouchPressed())
		{
			if(m_bPressed && !IsTouched())
			{
				SetPressed(false);
			}
		}
		else if(InputManager::Instance()->IsTouchJustReleased())
		{
			if(m_bPressed)
			{
				if(m_bCheckBox)
				{
					SetChecked(!m_bChecked);
				}

				SendUIEvent();

				SetPressed(false);

				// somewhat of a hack, ensures no more elements can catch a touch released in the current frame
				InputManager::Instance()->Update();
			}
		}
	}
示例#29
0
// Assumes that we got a button down event, we pass in the X, Y from this event and it will check to see if the coordinates
// are within the object and process it. If the up happens in the same object then we will return the object ID, else we will
//
uint16_t TFTButton::processTouch(uint16_t x, uint16_t y) {


    if (!((x >= _x) && (x <= (_x+_w)) && (y >= _y) && (y <= (_y+_h))))
        return 0xffff;        // Special value that says Not within the object...

    SetPressed(true);
    draw();    // Show it as depressed.

    // Now lets wait for the touch to release...
    while (ts.touched()) {
        GetTouchPoint(&x, &y);
    }

    SetPressed(false);
    draw();

    // And see if we were still inside the button
    if ((x >= _x) && (x <= (_x+_w)) && (y >= _y) && (y <= (_y+_h)))
        return _wVal;

    return 0xfffe;    // not on the button any more...
}
示例#30
0
// Activate:
void nuiButton::Activate()
{
  SetPressed(true);
  Activated();
  if (mpTask)
  {
    mpTask->Cancel();
    mpTask->Release();
    mpTask = NULL;
  }
  mpTask = nuiMakeTask(this, &nuiButton::SetPressed, false);
  mpTask->Acquire();
  nuiAnimation::RunOnAnimationTick(mpTask, 4);
}