AutoPtr<IView> NotificationRowLayout::GetChildAtRawPosition(
    /* [in] */ Float touchX,
    /* [in] */ Float touchY)
{
    Int32 x, y;
    GetLocationOnScreen(&x, &y);
    return GetChildAtPosition((Float) (touchX - x), (Float) (touchY - y));
}
ECode ShortcutAndWidgetContainer::OnLayout(
    /* [in] */ Boolean changed,
    /* [in] */ Int32 l,
    /* [in] */ Int32 t,
    /* [in] */ Int32 r,
    /* [in] */ Int32 b)
{
    Int32 count;
    GetChildCount(&count);
    for (Int32 i = 0; i < count; i++) {
        AutoPtr<IView> child;
        ViewGroup::GetChildAt(i, (IView**)&child);
        Int32 visibility;
        child->GetVisibility(&visibility);
        if (visibility != GONE) {
            AutoPtr<IViewGroupLayoutParams> params;
            child->GetLayoutParams((IViewGroupLayoutParams**)&params);
            AutoPtr<CellLayout::LayoutParams> lp =
                    (CellLayout::LayoutParams*)IObject::Probe(params);
            Int32 childLeft = lp->mX;
            Int32 childTop = lp->mY;
            child->Layout(childLeft, childTop, childLeft + lp->mWidth, childTop + lp->mHeight);
            if (lp->mDropped) {
                lp->mDropped = FALSE;

                AutoPtr<ArrayOf<Int32> > cellXY = mTmpCellXY;
                GetLocationOnScreen(cellXY);
                AutoPtr<IBinder> token;
                GetWindowToken((IBinder**)&token);
                mWallpaperManager->SendWallpaperCommand(token,
                        IWallpaperManager::COMMAND_DROP,
                        (*cellXY)[0] + childLeft + lp->mWidth / 2,
                        (*cellXY)[1] + childTop + lp->mHeight / 2, 0, NULL);
            }
        }
    }
    return NOERROR;
}
Esempio n. 3
0
void Slider::MouseReleased(const MouseEvent& lEvent)
{
	if(!m_bDragging && m_bPressedBar)
	{
		int lSliderWidth;
		int lSliderHeight;

		int lBarX;
		int lBarY;
		int lBarWidth;
		int lBarHeight;

		if(m_eSliderDirection == ESliderDirection_Horizontal)
		{
			lBarX = GetLocationOnScreen().m_x + (m_sliderWidth / 2);
			lBarY = GetLocationOnScreen().m_y + (m_dimensions.m_height / 2) - (m_barHeight / 2);
			lBarWidth = m_dimensions.m_width - m_sliderWidth;
			lBarHeight = m_barHeight;

			lSliderWidth = m_sliderWidth;
			lSliderHeight = m_dimensions.m_height;
		}
		else //if(m_eSliderDirection == ESliderDirection_Vertical)
		{
			lBarX = GetLocationOnScreen().m_x + (m_dimensions.m_width / 2) - (m_barHeight / 2);
			lBarY = GetLocationOnScreen().m_y + (m_sliderWidth / 2);
			lBarWidth = m_barHeight;
			lBarHeight = m_dimensions.m_height - m_sliderWidth;

			lSliderWidth = m_dimensions.m_width;
			lSliderHeight = m_sliderWidth;
		}

		int mouseX = lEvent.GetX();
		int mouseY = lEvent.GetY();

		// Store the value before we change it, to see if we have actually changed the value
		float lValueBefore = m_currentValue;

		if((mouseX >= lBarX) && (mouseX < lBarX + lBarWidth) && (mouseY >= lBarY) && (mouseY < lBarY + lBarHeight))
		{
			// Check to see if we have clicked on the bar to 'zoom' to a location

			if(m_eSliderDirection == ESliderDirection_Horizontal)
			{
				int lRelativeX = mouseX - GetLocationOnScreen().m_x;
				float ratio = (float)lRelativeX / (float)lBarWidth;
				m_currentValue = m_minValue + ((m_maxValue - m_minValue) * ratio);
			}
			else //if(m_eSliderDirection == ESliderDirection_Vertical)
			{
				int lRelativeY = mouseY - GetLocationOnScreen().m_y;
				float ratio = (float)lRelativeY / (float)lBarWidth;
				m_currentValue = m_minValue + ((m_maxValue - m_minValue) * ratio);
			}
		}

		if(m_currentValue != lValueBefore)
		{
			ValueChanged();
		}

		m_bPressedBar = false;
	}

	m_bDragging = false;
	m_bPressedBar = false;

	// Allow dragging again now, since we have released the button, we can now check for dragging again on pressing
	m_bAllowDragging = true;

	// Allow releasing on the bar now, we can now check for this again on pressing
	m_bAllowReleasingOnBar = true;

	OnMouseReleased();
}
Esempio n. 4
0
void Slider::MousePressed(const MouseEvent& lEvent)
{
	int lSliderX;
	int lSliderY;
	int lSliderWidth;
	int lSliderHeight;

	int lBarX;
	int lBarY;
	int lBarWidth;
	int lBarHeight;

	if(m_eSliderDirection == ESliderDirection_Horizontal)
	{
		lSliderX = GetLocationOnScreen().m_x + (int)((m_dimensions.m_width - m_sliderWidth) * ((m_currentValue - m_minValue) / (m_maxValue - m_minValue)));
		lSliderY = GetLocationOnScreen().m_y;
		lSliderWidth = m_sliderWidth;
		lSliderHeight = m_dimensions.m_height;

		lBarX = GetLocationOnScreen().m_x + (m_sliderWidth / 2);
		lBarY = GetLocationOnScreen().m_y + (m_dimensions.m_height / 2) - (m_barHeight / 2);
		lBarWidth = m_dimensions.m_width - m_sliderWidth;
		lBarHeight = m_barHeight;
	}
	else //if(m_eSliderDirection == ESliderDirection_Vertical)
	{
		lSliderX = GetLocationOnScreen().m_x;
		lSliderY = GetLocationOnScreen().m_y + (int)((m_dimensions.m_height - m_sliderWidth) * ((m_currentValue - m_minValue) / (m_maxValue - m_minValue)));
		lSliderWidth = m_dimensions.m_width;
		lSliderHeight = m_sliderWidth;

		lBarX = GetLocationOnScreen().m_x + (m_dimensions.m_width / 2) - (m_barHeight / 2);
		lBarY = GetLocationOnScreen().m_y + (m_sliderWidth / 2);
		lBarWidth = m_barHeight;
		lBarHeight = m_dimensions.m_height - m_sliderWidth;
	}

	int mouseX = lEvent.GetX();
	int mouseY = lEvent.GetY();

	// Check to see if we have clicked the slider to start dragging
	if((mouseX >= lSliderX) && (mouseX < lSliderX + lSliderWidth) && (mouseY >= lSliderY) && (mouseY < lSliderY + lSliderHeight))
	{
		if(m_bAllowDragging)
		{
			m_bDragging = true;
			m_bAllowDragginOutside = true;
		}
	}
	else
	{
		// Check to see if we have clicked on the bar to 'zoom' to a location
		if((mouseX >= lBarX) && (mouseX < lBarX + lBarWidth) && (mouseY >= lBarY) && (mouseY < lBarY + lBarHeight))
		{
			if(m_bAllowReleasingOnBar && !m_bDragging)
			{
				m_bPressedBar = true;
			}
		}
		else
		{
			// Don't allow releasing on the bar since we didnt first click on the bar, have to wait for release now
			m_bAllowReleasingOnBar = false;
		}

		// Don't allow dragging, or dragging outside, since our first press wasnt on the slider, have to wait for release now
		if(!m_bDragging)
		{
			m_bAllowDragging = false;
			m_bAllowDragginOutside = false;
		}
	}

	// If our parent is a GUIWindow, then makew this window have focus in the GUI, used to make it's depth the highest
	if(GetParent() != NULL && GetParent()->GetComponentType() == EComponentType_GUIWindow)
	{
		GUIWindow* lpParentWindow = (GUIWindow *)GetParent();
		lpParentWindow->SetFocusWindow();
	}

	OnMousePressed();
}
Esempio n. 5
0
void Slider::MouseMotion(const MouseEvent& lEvent)
{
	int lSliderX;
	int lSliderY;
	int lSliderWidth;
	int lSliderHeight;

	int lBarX;
	int lBarY;
	int lBarWidth;
	int lBarHeight;

	if(m_eSliderDirection == ESliderDirection_Horizontal)
	{
		lSliderX = GetLocationOnScreen().m_x + (int)((m_dimensions.m_width - m_sliderWidth) * ((m_currentValue - m_minValue) / (m_maxValue - m_minValue)));
		lSliderY = GetLocationOnScreen().m_y;
		lSliderWidth = m_sliderWidth;
		lSliderHeight = m_dimensions.m_height;

		lBarX = GetLocationOnScreen().m_x + (m_sliderWidth / 2);
		lBarY = GetLocationOnScreen().m_y + (m_dimensions.m_height / 2) - (m_barHeight / 2);
		lBarWidth = m_dimensions.m_width - m_sliderWidth;
		lBarHeight = m_barHeight;
	}
	else //if(m_eSliderDirection == ESliderDirection_Vertical)
	{
		lSliderX = GetLocationOnScreen().m_x;
		lSliderY = GetLocationOnScreen().m_y + (int)((m_dimensions.m_height - m_sliderWidth) * ((m_currentValue - m_minValue) / (m_maxValue - m_minValue)));
		lSliderWidth = m_dimensions.m_width;
		lSliderHeight = m_sliderWidth;

		lBarX = GetLocationOnScreen().m_x + (m_dimensions.m_width / 2) - (m_barHeight / 2);
		lBarY = GetLocationOnScreen().m_y + (m_sliderWidth / 2);
		lBarWidth = m_barHeight;
		lBarHeight = m_dimensions.m_height - m_sliderWidth;
	}

	int mouseX = lEvent.GetX();
	int mouseY = lEvent.GetY();

	// Check to see if we are over the slider
	if((mouseX > lSliderX) && (mouseX < lSliderX + lSliderWidth) && (mouseY > lSliderY) && (mouseY < lSliderY + lSliderHeight))
	{
		if(!m_bPressedBar)
		{
			m_bHover = true;
		}
	}
	else
	{
		m_bHover = false;
	}

	// Check to see if we are over the bar
	if((mouseX >= lBarX) && (mouseX < lBarX + lBarWidth) && (mouseY >= lBarY) && (mouseY < lBarY + lBarHeight))
	{
		m_bOverBar = true;
	}
	else
	{
		m_bOverBar = false;
	}
}
Esempio n. 6
0
void Slider::MouseDraggedOutside(const MouseEvent& lEvent)
{
	if(!m_bAllowDragginOutside)
	{
		// If we are not allowing dragging outside, just early out
		return;
	}

	if(!m_bFirstOutsideDrag)
	{
		m_lastX = lEvent.GetX();
		m_lastY = lEvent.GetY();
		m_bFirstOutsideDrag = true;
	}

	if(m_bDragginOutside)
	{
		int lNewX = lEvent.GetX();
		int lNewY = lEvent.GetY();

		int lMinX = GetLocationOnScreen().m_x;
		int lMinY = GetLocationOnScreen().m_y;
		int lMaxX = lMinX + m_dimensions.m_width;
		int lMaxY = lMinY + m_dimensions.m_height;

		int l_ChangeX = lNewX - m_lastX;
		int l_ChangeY = lNewY - m_lastY;

		if(l_ChangeX == 0 && l_ChangeY == 0)
			return;

		// Store the value before we change it, to see if we have actually changed the value
		float lValueBefore = m_currentValue;

		float lValueChange;
		if(m_eSliderDirection == ESliderDirection_Horizontal)
		{
			lValueChange = static_cast<float>(l_ChangeX) * ((m_maxValue - m_minValue) / (static_cast<float>(m_dimensions.m_width) - static_cast<float>(m_sliderWidth)));

			if( (lValueChange > 0) && (lNewX > lMinX))
			{
				m_currentValue += lValueChange;
			}
			else if((lValueChange < 0) && (lNewX < lMaxX))
			{
				m_currentValue += lValueChange;
			}
		}
		else //if(m_eSliderDirection == ESliderDirection_Vertical)
		{
			lValueChange = static_cast<float>(l_ChangeY) * ((m_maxValue - m_minValue) / (static_cast<float>(m_dimensions.m_height) - static_cast<float>(m_sliderWidth)));

			if( (lValueChange > 0) && (lNewY > lMinY))
			{
				m_currentValue += lValueChange;
			}
			else if((lValueChange < 0) && (lNewY < lMaxY))
			{
				m_currentValue += lValueChange;
			}
		}


		if(m_currentValue > m_maxValue)
		{
			m_currentValue = m_maxValue;
		}
		if(m_currentValue < m_minValue)
		{
			m_currentValue = m_minValue;
		}

		if(m_currentValue != lValueBefore)
		{
			ValueChanged();
		}

		m_lastX = lNewX;
		m_lastY = lNewY;
	}
}