Beispiel #1
0
void CUIButton::DrawTexture()
{
	Frect rect; 
	GetAbsoluteRect		(rect);

	if(m_bAvailableTexture && m_bTextureEnable)
	{
		if(m_eButtonState == BUTTON_UP || m_eButtonState == BUTTON_NORMAL)
			m_UIStaticItem.SetPos(rect.left + m_TextureOffset.x, rect.top + m_TextureOffset.y);
		else
			m_UIStaticItem.SetPos(rect.left + m_PushOffset.x + m_TextureOffset.x, rect.top + m_PushOffset.y + m_TextureOffset.y);

		if(m_bStretchTexture)
			m_UIStaticItem.SetRect(0, 0, rect.width(), rect.height());
		else
		{
			Frect r={0,0,
				m_UIStaticItem.GetOriginalRectScaled().width(),
				m_UIStaticItem.GetOriginalRectScaled().height()};
			m_UIStaticItem.SetRect(r);
		}

		if( Heading() )
			m_UIStaticItem.Render( GetHeading() );
		else
			m_UIStaticItem.Render();		
	}
}
Beispiel #2
0
void CUIWindow::Update()
{
	if (GetUICursor()->IsVisible())
	{
		bool cursor_on_window;

		Fvector2			temp = GetUICursor()->GetCursorPosition();
		Frect				r;
		GetAbsoluteRect		(r);
		cursor_on_window	= !!r.in(temp);
		// RECEIVE and LOST focus
		if(m_bCursorOverWindow != cursor_on_window)
		{
			if(cursor_on_window)
				OnFocusReceive();			
			else
				OnFocusLost();			
		}
	}
	
	for(WINDOW_LIST_it it = m_ChildWndList.begin(); m_ChildWndList.end()!=it; ++it){
		if(!(*it)->IsShown()) continue;
			(*it)->Update();
	}
}
Beispiel #3
0
void ui_core::PushScissor(const Frect& r_tgt, bool overlapped)
{
//.	return;
	Frect r_top			= ScreenRect();
	Frect result		= r_tgt;
	if (!m_Scissors.empty()&&!overlapped){
		r_top			= m_Scissors.top();
	}
	if (!result.intersection(r_top,r_tgt))
			result.set	(0.0f,0.0f,0.0f,0.0f);

	if (!(result.x1>=0&&result.y1>=0&&result.x2<=UI_BASE_WIDTH&&result.y2<=UI_BASE_HEIGHT) )
	{
		Msg("! r_tgt [%.3f][%.3f][%.3f][%.3f]", r_tgt.x1, r_tgt.y1, r_tgt.x2, r_tgt.y2);
		Msg("! result [%.3f][%.3f][%.3f][%.3f]", result.x1, result.y1, result.x2, result.y2);
		VERIFY(result.x1>=0&&result.y1>=0&&result.x2<=UI_BASE_WIDTH&&result.y2<=UI_BASE_HEIGHT);
	}
	m_Scissors.push		(result);

	result.lt.x 		= ClientToScreenScaledX(result.lt.x);
	result.lt.y 		= ClientToScreenScaledY(result.lt.y);
	result.rb.x 		= ClientToScreenScaledX(result.rb.x);
	result.rb.y 		= ClientToScreenScaledY(result.rb.y);

	Irect				r;
	r.x1 				= iFloor(result.x1);
	r.x2 				= iFloor(result.x2+0.5f);
	r.y1 				= iFloor(result.y1);
	r.y2 				= iFloor(result.y2+0.5f);
	RCache.set_Scissor	(&r);
}
Beispiel #4
0
void CUICellItem::Update()
{
	if (m_pParentList)
		EnableHeading(m_pParentList->GetVerticalPlacement());

	if(Heading())
	{
		SetHeading			( 90.0f * (PI/180.0f) );
		SetHeadingPivot		(Fvector2().set(0.0f,0.0f), Fvector2().set(0.0f,GetWndSize().y), true);
	}else
		ResetHeadingPivot	();

	inherited::Update();
	
	if ( CursorOverWindow() )
	{
		Frect clientArea;
		m_pParentList->GetClientArea(clientArea);
		Fvector2 cp			= GetUICursor()->GetCursorPosition();
		if(clientArea.in(cp))
			GetMessageTarget()->SendMessage(this, DRAG_DROP_ITEM_FOCUSED_UPDATE, NULL);
	}
	
	m_b_already_drawn=false;
 
}
Beispiel #5
0
CUIDragItem* CUICellItem::CreateDragItem()
{
	CUIDragItem* tmp;
	tmp = xr_new<CUIDragItem>(this);
	Frect r;
	GetAbsoluteRect(r);
	if( m_UIStaticItem.GetFixedLTWhileHeading() )
	{
		float w, h;
		w				= r.width();
		h				= r.height();
		if (Heading())
		{   // исправление пропорций
			w = w / m_cell_size.x * m_cell_size.y;
			h = h / m_cell_size.y * m_cell_size.x;
		}

		Fvector2 cp = GetUICursor()->GetCursorPosition();
		// поворот на 90 градусов, и центрирование по курсору мыша						
		r.x1			= (cp.x - h / 2.0f);
		r.y1			= (cp.y - w / 2.0f);
		r.x2			= r.x1 + h;
		r.y2			= r.y1 + w;
	} 
	tmp->Init(GetShader(),r,GetUIStaticItem().GetOriginalRect());
	return tmp;
}
Beispiel #6
0
float CUIPdaKillMessage::InitIcon(CUIStatic& refStatic, float x, IconInfo& info){
	if ( 0 == info.m_rect.width())
		return 0;

	if (info.m_shader == NULL)
		return 0;

	float		y = 0;
	float		selfHeight = GetHeight();
	float		scale = 0;
	Frect		rect = info.m_rect;

	float width = rect.width();
	float height = rect.height();
	
	scale = selfHeight/height;
	if (scale > 1)
		scale = 1;
	width  = width*scale;
	height = height*scale;
	y = (selfHeight - height) /2;
	refStatic.Init(x, y, width, height);
	refStatic.SetOriginalRect(info.m_rect);
	refStatic.SetShader(info.m_shader);
	refStatic.SetStretchTexture(true);

	return width;
}
Beispiel #7
0
bool CUIFrameWindow::get_points(Frect const& r, int i, Fvector2& LTp, Fvector2& RBp, Fvector2& LTt, Fvector2& RBt)
{
	LTt				= m_tex_rect[i].lt;
	RBt				= m_tex_rect[i].rb;

	LTp				= r.lt; 
	RBp				= r.lt; 
	RBp.x			+= m_tex_rect[i].width();
	RBp.y			+= m_tex_rect[i].height();

	float rem_x		= r.width()-m_tex_rect[i].width();
	float rem_y		= r.height()-m_tex_rect[i].height();
	if(rem_x<0.0f)
	{
		RBt.x		+= rem_x;
		RBp.x		+= rem_x;
	}
	if(rem_y<0.0f)
	{
		RBt.y		+= rem_y;
		RBp.y		+= rem_y;
	}

	return true;
}
Beispiel #8
0
void CUICustomMap::OptimalFit(const Frect& r)
{
	if ((m_BoundRect.height()/r.height())<(m_BoundRect.width()/r.width()))
		FitToHeight	(r.height());
	else
		FitToWidth	(r.width());

}
Beispiel #9
0
Frect CUICustomItem::GetOriginalRectScaled()
{
	Frect rect = iOriginalRect;

	rect.x2		= rect.x1 + rect.width();
	rect.y2		= rect.y1 + rect.height();

	return rect;
}
Beispiel #10
0
void CUIGlobalMap::ClipByVisRect()
{
	Frect r					= GetWndRect();
	Frect clip				= GetClipperRect();
	if (r.x2<clip.width())	r.x1 += clip.width()-r.x2;
	if (r.y2<clip.height())	r.y1 += clip.height()-r.y2;
	if (r.x1>0.0f)			r.x1 = 0.0f;
	if (r.y1>0.0f)			r.y1 = 0.0f;
	SetWndPos				(r.x1,r.y1);
}
Beispiel #11
0
void CUIRadioButton::Init(float x, float y, float width, float height){
	if (!m_pLines)
		m_pLines = xr_new<CUILines>();
	m_pLines->SetTextAlignment(CGameFont::alLeft);
    CUI3tButton::InitTexture("ui_radio");
	Frect r = m_background.GetE()->GetStaticItem()->GetRect(); 
	CUI3tButton::SetTextX(r.width());
    CUI3tButton::Init(x,y, width, r.height() - 5);
	m_pLines->Init(x,y,width,m_background.GetE()->GetStaticItem()->GetRect().height());
}
Beispiel #12
0
Frect CUILevelMap::CalcWndRectOnGlobal	()
{
	Frect res;
	CUIGlobalMap* globalMap			= MapWnd()->GlobalMap();

	res.lt							= globalMap->ConvertRealToLocal(GlobalRect().lt);
	res.rb							= globalMap->ConvertRealToLocal(GlobalRect().rb);
	res.add							(globalMap->GetWndPos().x, globalMap->GetWndPos().y);

	return res;
}
Beispiel #13
0
bool CUIMMShniaga::OnMouse(float x, float y, EUIMessages mouse_action){
	
	Fvector2 pos = UI()->GetUICursor()->GetCursorPosition();
    Frect r;
	m_magnifier->GetAbsoluteRect(r);
	if (WINDOW_LBUTTON_DOWN == mouse_action && r.in(pos.x, pos.y))
	{
		OnBtnClick();
	}

	return CUIWindow::OnMouse(x,y,mouse_action);
}
Beispiel #14
0
void CUIArtefactDetectorElite::Draw()
{
	Fmatrix						LM;
	GetUILocatorMatrix			(LM);

	IUIRender::ePointType bk	= UI()->m_currentPointType;

	UI()->m_currentPointType	= IUIRender::pttLIT;

	UIRender->CacheSetXformWorld(LM);
	UIRender->CacheSetCullMode	(IUIRender::cmNONE);

	CUIWindow::Draw				();

	Frect r						= m_wrk_area->GetWndRect();
	Fvector2					rp; 
	m_wrk_area->GetAbsolutePos	(rp);

	Fmatrix						M, Mc;
	float h,p;
	Device.vCameraDirection.getHP(h,p);
	Mc.setHPB					(h,0,0);
	Mc.c.set					(Device.vCameraPosition);
	M.invert					(Mc);

	xr_vector<Fvector>::const_iterator it	 = m_af_to_draw.begin();
	xr_vector<Fvector>::const_iterator it_e  = m_af_to_draw.end();
	for(;it!=it_e;++it)
	{
		Fvector					p = (*it);
		Fvector					pt3d;
		M.transform_tiny		(pt3d,p);
//		float kx				= m_wrk_area->GetWndSize().x / m_parent->m_fAfDetectRadius;
		float kz				= m_wrk_area->GetWndSize().y / m_parent->m_fAfDetectRadius;
		pt3d.x					*= kz;
		pt3d.z					*= kz;

		pt3d.x					+= m_wrk_area->GetWndSize().x/2.0f;	
		pt3d.z					-= m_wrk_area->GetWndSize().y;

		Fvector2				pos;
		pos.set					(pt3d.x, -pt3d.z);
		pos.sub					(rp);
		if( r.in(pos) )
		{
			m_af_sign->SetWndPos	(pos);
			m_af_sign->Draw			();
		}
	}

	UI()->m_currentPointType		= bk;
}
Beispiel #15
0
void CUICursor::InitInternal()
{
	m_static					= xr_new<CUIStatic>();
	m_static->InitTextureEx		("ui\\ui_ani_cursor", "hud\\cursor");
	Frect						rect;
	rect.set					(0.0f,0.0f,40.0f,40.0f);
	m_static->SetOriginalRect	(rect);
	Fvector2					sz;
	sz.set						(rect.rb);
	if(UI()->is_16_9_mode())
		sz.x					/= 1.2f;

	m_static->SetWndSize		(sz);
	m_static->SetStretchTexture	(true);
}
Beispiel #16
0
bool CUIWindow::HasChildMouseHandler(){
	WINDOW_LIST::reverse_iterator it = m_ChildWndList.rbegin();

	for( ; it!=m_ChildWndList.rend(); ++it)
	{
		if ((*it)->m_bClickable)
		{
			Frect wndRect = (*it)->GetWndRect();
			if (wndRect.in(cursor_pos) )
				return true;
		}
	}

	return false;
}
Beispiel #17
0
void CUIFrameLineWnd::DrawElements()
{
	UIRender->SetShader			(*m_shader);

	Fvector2					ts;
	UIRender->GetActiveTextureResolution(ts);

	Frect						rect;
	GetAbsoluteRect				(rect);
	UI().ClientToScreenScaled	(rect.lt);
	UI().ClientToScreenScaled	(rect.rb);
	
	float back_len				= 0.0f;
	u32 prim_count				= 6*2; //first&second 
	if(bHorizontal)
	{
		back_len				= rect.width()-m_tex_rect[flFirst].width()-m_tex_rect[flSecond].width();
		if(back_len<0.0f)
			rect.x2				-= back_len;

		if(back_len>0.0f)
			prim_count				+= 6* iCeil(back_len / m_tex_rect[flBack].width());
	}else
	{
		back_len				= rect.height()-m_tex_rect[flFirst].height()-m_tex_rect[flSecond].height();
		if(back_len<0)
			rect.y2				-= back_len;

		if(back_len>0.0f)
			prim_count				+= 6* iCeil(back_len / m_tex_rect[flBack].height());
	}

	UIRender->StartPrimitive	(prim_count, IUIRender::ptTriList, UI().m_currentPointType);

	for(int i=0; i<flMax; ++i)
	{
		Fvector2 LTt, RBt;
		Fvector2 LTp, RBp;
		int counter				= 0;

		while(inc_pos(rect, counter, i, LTp, RBp, LTt, RBt))
		{
			draw_rect				(LTp, RBp, LTt, RBt, m_texture_color, ts);
			++counter;
		};
	}
	UIRender->FlushPrimitive		();
}
bool CEvaluatorTargetMapShown::evaluate()
{
	if(m_storage->property(1)) return true;
	if(m_storage->property(2)) return true;
	Fvector2 pt					= m_object->m_tgtCenter; 
	pt.mul						(m_object->GlobalMap()->GetCurrentZoom());
	Fvector2 _p;
	m_object->GlobalMap()->GetAbsolutePos(_p);
	pt.add						(_p);
	Frect	rect	=	m_object->ActiveMapRect();
			rect.grow	(rect.width(),rect.height());
	if (rect.in(pt))	{
		m_storage->set_property	(2,true);
		return true;
	}
	return false;
}
Beispiel #19
0
bool CUICustomMap::IsRectVisible(Frect r)
{
	Frect map_visible_rect = GetClipperRect();
	Fvector2 pos;
	GetAbsolutePos(pos);
	r.add(pos.x,pos.y);

	return !!map_visible_rect.intersected(r);
}
Beispiel #20
0
bool CUICustomMap::NeedShowPointer(Frect r)
{
	Frect map_visible_rect = GetClipperRect();
	map_visible_rect.shrink(5,5);
	Fvector2 pos;
	GetAbsolutePos(pos);
	r.add(pos.x,pos.y);

	return !map_visible_rect.intersected(r);
}
Beispiel #21
0
float CUIGlobalMap::CalcOpenRect(const Fvector2& center_point, Frect& map_desired_rect, float tgt_zoom)
{
    Fvector2                    new_center_pt;
	// calculate desired rect in new zoom
    map_desired_rect.set		(0.0f,0.0f, BoundRect().width()*tgt_zoom,BoundRect().height()*tgt_zoom);
	// calculate center point in new zoom (center_point is in identity global map space)
    new_center_pt.set           (center_point.x*tgt_zoom,center_point.y*tgt_zoom);
	// get vis width & height
	Frect vis_abs_rect			= m_mapWnd->ActiveMapRect();
	float vis_w					= vis_abs_rect.width();
	float vis_h					= vis_abs_rect.height();
	// calculate center delta from vis rect
	Fvector2 delta_pos;
	delta_pos.set				(new_center_pt.x-vis_w*0.5f,new_center_pt.y-vis_h*0.5f);
	// correct desired rect
	map_desired_rect.sub		(delta_pos.x,delta_pos.y);
	// clamp pos by vis rect
	const Frect& r				= map_desired_rect;
	Fvector2 np					= r.lt;
	if (r.x2<vis_w)	np.x		+= vis_w-r.x2;
	if (r.y2<vis_h)	np.y		+= vis_h-r.y2;
	if (r.x1>0.0f)	np.x		= 0.0f;
	if (r.y1>0.0f)	np.y		= 0.0f;
	np.sub						(r.lt);
	map_desired_rect.add		(np.x,np.y);
	// calculate max way dist
	float dist					= 0.f;

	Frect s_rect,t_rect;
	s_rect.div					(GetWndRect(),GetCurrentZoom(),GetCurrentZoom());
	t_rect.div					(map_desired_rect,tgt_zoom,tgt_zoom);

	Fvector2 cpS,cpT;
	s_rect.getcenter			(cpS);
	t_rect.getcenter			(cpT);

	dist						= cpS.distance_to(cpT);

	return dist;
}
Beispiel #22
0
void CUICellItem::Update()
{
	EnableHeading(m_pParentList->GetVerticalPlacement());
	if(Heading())
	{
		SetHeading			( 90.0f * (PI/180.0f) );
		SetHeadingPivot		(Fvector2().set(0.0f,0.0f), Fvector2().set(0.0f,GetWndSize().y), true);
	}else
		ResetHeadingPivot	();

	inherited::Update();
	
	if ( CursorOverWindow() )
	{
		Frect clientArea;
		m_pParentList->GetClientArea(clientArea);
		Fvector2 cp			= GetUICursor().GetCursorPosition();
		if(clientArea.in(cp))
			GetMessageTarget()->SendMessage(this, DRAG_DROP_ITEM_FOCUSED_UPDATE, NULL);
	}
	
	PIItem item = (PIItem)m_pData;
	if ( item )
	{
		m_has_upgrade = item->has_any_upgrades();

//		Fvector2 size      = GetWndSize();
//		Fvector2 up_size = m_upgrade->GetWndSize();
//		pos.x = size.x - up_size.x - 4.0f;
		Fvector2 pos;
		pos.set( m_upgrade_pos );
		if ( ChildsCount() )
		{
			pos.x += m_text->GetWndSize().x + 2.0f;
		}
		m_upgrade->SetWndPos( pos );
	}
	m_upgrade->Show( m_has_upgrade );
}
Beispiel #23
0
// try to positioning clipRect center to vNewPoint
void CUICustomMap::SetActivePoint(const Fvector &vNewPoint)
{
	Fvector2 pos;
	pos.set(vNewPoint.x,vNewPoint.z);
	Frect bound = BoundRect();
	if( FALSE==bound.in(pos) )return;

	Fvector2	pos_on_map		= ConvertRealToLocalNoTransform(pos);
	Frect		map_abs_rect;
	GetAbsoluteRect(map_abs_rect);
	Fvector2	pos_abs;

	pos_abs.set(map_abs_rect.lt);
	pos_abs.add(pos_on_map);

	Frect		clip_abs_rect	= GetClipperRect();
	Fvector2	clip_center;
	clip_abs_rect.getcenter(clip_center);
	clip_center.sub(pos_abs);
	MoveWndDelta				(clip_center);
	SetHeadingPivot				(pos_on_map, Fvector2().set(0,0), false); 
}
Beispiel #24
0
CUIDragItem* CUICellItem::CreateDragItem()
{
	CUIDragItem* tmp;
	tmp = xr_new<CUIDragItem>(this);
	Frect r;
	GetAbsoluteRect(r);

	if( m_UIStaticItem.GetFixedLTWhileHeading() )
	{
		float t1,t2;
		t1				= r.width();
		t2				= r.height()*UI().get_current_kx();

		Fvector2 cp = GetUICursor().GetCursorPosition();

		r.x1			= (cp.x-t2/2.0f);
		r.y1			= (cp.y-t1/2.0f);
		r.x2			= r.x1 + t2;
		r.y2			= r.y1 + t1;
	}
	tmp->Init(GetShader(), r, GetUIStaticItem().GetTextureRect());
	return tmp;
}
Beispiel #25
0
CUIWindow* CUIWindow::GetChildMouseHandler(){
	CUIWindow* pWndResult;
	WINDOW_LIST::reverse_iterator it = m_ChildWndList.rbegin();

	for(; it!=m_ChildWndList.rend(); ++it)
	{
		Frect wndRect = (*it)->GetWndRect();
		// very strange code.... i can't understand difference between
		// first and second condition. I Got It from OnMouse() method;
		if (wndRect.in(cursor_pos) )
		{
			if((*it)->IsEnabled())
			{
				return pWndResult = (*it)->GetChildMouseHandler();				
			}
		}
		else if ((*it)->IsEnabled() && (*it)->CursorOverWindow())
		{
			return pWndResult = (*it)->GetChildMouseHandler();
		}
	}

    return this;
}
Beispiel #26
0
//position and heading for drawing pointer to src pos
bool CUICustomMap::GetPointerTo(const Fvector2& src, float item_radius, Fvector2& pos, float& heading)
{
	Frect		clip_rect_abs			= GetClipperRect(); //absolute rect coords
	Frect		map_rect_abs;
	GetAbsoluteRect(map_rect_abs);

	Frect		rect;
	BOOL res = rect.intersection(clip_rect_abs, map_rect_abs);
	if(!res) return false;
	
	rect = clip_rect_abs;
	rect.sub(map_rect_abs.lt.x,map_rect_abs.lt.y);

	Fbox2 f_clip_rect_local;
	f_clip_rect_local.set(rect.x1, rect.y1, rect.x2, rect.y2 );

	Fvector2 f_center;
	f_clip_rect_local.getcenter(f_center);

	Fvector2 f_dir, f_src;

	f_src.set(src.x, src.y );
	f_dir.sub(f_center, f_src );
	f_dir.normalize_safe();
	Fvector2 f_intersect_point;
	res = f_clip_rect_local.Pick2(f_src,f_dir,f_intersect_point);
	VERIFY(res);


	heading = -f_dir.getH();

	f_intersect_point.mad(f_intersect_point,f_dir,item_radius );

	pos.set( iFloor(f_intersect_point.x), iFloor(f_intersect_point.y) );
	return true;
}
Beispiel #27
0
bool CUITradeWnd::OnItemFocusedUpdate(CUICellItem* itm)
{
	if ( itm )
	{
		#ifdef INV_FLOAT_ITEM_INFO
		Fvector2 c_pos			= GetUICursor()->GetCursorPosition();
		Frect vis_rect;
		vis_rect.set			(0,0,UI_BASE_WIDTH, UI_BASE_HEIGHT);

		Frect r;
		r.set					(0.0f, 0.0f, m_uidata->UIItemInfo.GetWidth(), m_uidata->UIItemInfo.GetHeight());
		r.add					(c_pos.x, c_pos.y);

		r.sub					(0.0f,r.height());
		if (false==((vis_rect.x1<r.x1)&&(vis_rect.x2>r.x2)&&(vis_rect.y1<r.y1)&&(vis_rect.y2>r.y2)))
			r.sub				(r.width(),0.0f);
		if (false==((vis_rect.x1<r.x1)&&(vis_rect.x2>r.x2)&&(vis_rect.y1<r.y1)&&(vis_rect.y2>r.y2)))
			r.add				(0.0f,r.height());
		if (false==((vis_rect.x1<r.x1)&&(vis_rect.x2>r.x2)&&(vis_rect.y1<r.y1)&&(vis_rect.y2>r.y2)))
			r.add				(r.width(), 45.0f);

		m_uidata->UIItemInfo.SetWndPos(r.lt);
		SetCurrentItem	(itm);
		#endif
	}
	return true;
}
Beispiel #28
0
bool CUIWindow::AlignHintWndPos( Frect const& vis_rect, float border, float dx16pos ) //this = hint wnd
{
	float const cursor_height = 43.0f;
	Fvector2 cursor_pos	= GetUICursor()->GetCursorPosition();
	if ( UI()->is_16_9_mode() )
	{
		cursor_pos.x -= dx16pos;
	}

	if ( !vis_rect.in(cursor_pos) )
	{
		return false;
	}

	Frect	rect;
	rect.set( -border, -border, GetWidth() - 2.0f*border, GetHeight() - 2.0f*border );
	rect.add( cursor_pos.x, cursor_pos.y );

	rect.sub( 0.0f, rect.height() - border );
	if ( !is_in( vis_rect, rect ) ) {	rect.sub( rect.width() - border, 0.0f                   );	}
	if ( !is_in( vis_rect, rect ) ) {	rect.add( 0.0f                 , rect.height() - border );	}
	if ( !is_in( vis_rect, rect ) ) {	rect.add( rect.width() - border, cursor_height          );	}

	float yn = rect.top - vis_rect.height() + rect.height( ) - border + cursor_height;
	if ( !is_in( vis_rect, rect ) ) {	rect.sub( 0.0f                 , yn                     );	}
	if ( !is_in( vis_rect, rect ) ) {	rect.sub( rect.width() - border, 0.0f                   );	}

	SetWndPos( rect.lt );
	return true;
}
Beispiel #29
0
bool CUIWindow::OnMouse(float x, float y, EUIMessages mouse_action)
{	
	Frect	wndRect = GetWndRect();

	cursor_pos.x = x;
	cursor_pos.y = y;


	if( WINDOW_LBUTTON_DOWN == mouse_action )
	{
		static u32 _last_db_click_frame		= 0;
		u32 dwCurTime						= Device.dwTimeContinual;

		if( (_last_db_click_frame!=Device.dwFrame) && (dwCurTime-m_dwLastClickTime < DOUBLE_CLICK_TIME) )
		{
            mouse_action			= WINDOW_LBUTTON_DB_CLICK;
			_last_db_click_frame	= Device.dwFrame;
		}

		m_dwLastClickTime = dwCurTime;
	}

	if(GetParent()== NULL)
	{
		if(!wndRect.in(cursor_pos))
            return false;
		//получить координаты относительно окна
		cursor_pos.x -= wndRect.left;
		cursor_pos.y -= wndRect.top;
	}


	//если есть дочернее окно,захватившее мышь, то
	//сообщение направляем ему сразу
	if(m_pMouseCapturer)
	{
		m_pMouseCapturer->OnMouse(cursor_pos.x - m_pMouseCapturer->GetWndRect().left, 
								  cursor_pos.y - m_pMouseCapturer->GetWndRect().top, 
								  mouse_action);
		return true;
	}

	// handle any action
	switch (mouse_action){
		case WINDOW_MOUSE_MOVE:
			OnMouseMove();							break;
		case WINDOW_MOUSE_WHEEL_DOWN:
			OnMouseScroll(WINDOW_MOUSE_WHEEL_DOWN); break;
		case WINDOW_MOUSE_WHEEL_UP:
			OnMouseScroll(WINDOW_MOUSE_WHEEL_UP);	break;
		case WINDOW_LBUTTON_DOWN:
			if(OnMouseDown(MOUSE_1))				return true;	break;
		case WINDOW_RBUTTON_DOWN:
			if(OnMouseDown(MOUSE_2))				return true;	break;
		case WINDOW_CBUTTON_DOWN:
			if(OnMouseDown(MOUSE_3))				return true;	break;
		case WINDOW_LBUTTON_DB_CLICK:
			if (OnDbClick())						return true;	break;
		default:
            break;
	}

	//Проверка на попадание мыши в окно,
	//происходит в обратном порядке, чем рисование окон
	//(последние в списке имеют высший приоритет)
	WINDOW_LIST::reverse_iterator it = m_ChildWndList.rbegin();

	for(; it!=m_ChildWndList.rend(); ++it)
	{
		CUIWindow* w	= (*it);
		Frect wndRect	= w->GetWndRect();
		if (wndRect.in(cursor_pos) )
		{
			if(w->IsEnabled())
			{
				if( w->OnMouse(cursor_pos.x -w->GetWndRect().left, 
							   cursor_pos.y -w->GetWndRect().top, mouse_action))return true;
			}
		}
		else if (w->IsEnabled() && w->CursorOverWindow())
		{
			if( w->OnMouse(cursor_pos.x -w->GetWndRect().left, 
						   cursor_pos.y -w->GetWndRect().top, mouse_action))return true;
		}
	}


	return false;
}
Beispiel #30
0
void  CUIButton::Update()
{
	CUIStatic::Update();

	if(CursorOverWindow() && m_hint_text.size() && !g_btnHint->Owner() && Device.dwTimeGlobal>m_dwFocusReceiveTime+500)
	{
		g_btnHint->SetHintText	(this,*m_hint_text);

		Fvector2 c_pos			= GetUICursor()->GetCursorPosition();
		Frect vis_rect;
		vis_rect.set			(0,0,UI_BASE_WIDTH, UI_BASE_HEIGHT);

		//select appropriate position
		Frect r;
		r.set					(0.0f, 0.0f, g_btnHint->GetWidth(), g_btnHint->GetHeight());
		r.add					(c_pos.x, c_pos.y);

		r.sub					(0.0f,r.height());
		if (false==is_in2(vis_rect,r))
			r.sub				(r.width(),0.0f);
		if (false==is_in2(vis_rect,r))
			r.add				(0.0f,r.height());

		if (false==is_in2(vis_rect,r))
			r.add				(r.width(), 45.0f);

		g_btnHint->SetWndPos(r.lt);
	}
}