Exemplo n.º 1
0
UI_base* W_colorBand::OnLButtonDown(int x, int y)
{

	if (Hittest(x,y))
	{
		colorbandItem* pCurrentColorbandItem;
		for(std::list<colorbandItem*>::iterator iter = listofcolorbandItems.begin(); iter != listofcolorbandItems.end(); iter ++)
			{
				pCurrentColorbandItem = *iter;

				if (y > posy - height+pCurrentColorbandItem->pos*height-4.0f && y < posy - height+pCurrentColorbandItem->pos*height+4.0f)
				{
					if (pActiveColorBandItem != pCurrentColorbandItem)
					{
						pActiveColorBandItem = pCurrentColorbandItem;
					}
					draggingcolorbandItem = true;
                    pInterceptChild = this;
                    return this;
				}
			}


		if (!draggingcolorbandItem)
		{
			float r,g,b,a;
			GetColorAt(&r,&g,&b,&a,(float)(y+height-posy)/(float)(height));
			colorbandItem* tempnode = NewColorbandItem((float)(y+height-posy)/(float)(height),r,g,b,a);

			listofcolorbandItems.push_back( tempnode);
			SortList();
			pActiveColorBandItem = tempnode;

			//if (pParentUI_base) pParentUI_base->Callback(this,2);

			draggingcolorbandItem = true;
            pInterceptChild = this;
            return this;

		}
	}
    pInterceptChild = 0;
    return 0;
}
Exemplo n.º 2
0
UI_base* W_slider::OnLButtonDown(int x, int y)
{
	if (Hittest(x,y))
	{
        float position;
		pInterceptChild = this;

        if (vertical)
            position = 1+((float)(y-posy)/(float)height);
        else
            position = ((float)(x-posx)/(float)width);

        if (barSize)
        {
            if ((position*(to-from)+from)<value)
            {
                tmpValue = max(value - barSize,from);
                pInterceptChild = 0;
            }
            else if ((position*(to-from)+from)>(value + barSize))
            {
                tmpValue = min(value + barSize,to);
                pInterceptChild = 0;
            }
        }
        else
            tmpValue = position*(to-from)+from;

        tmpValue = max(min(tmpValue,to - barSize),from);
        SetValue(tmpValue);

		return pInterceptChild;
	}
	pInterceptChild = 0;
	return 0;
}