| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- /******************************************************************************/
- #include "stdafx.h"
- namespace EE{
- /******************************************************************************/
- GuiPC::GuiPC(Desktop &desktop)
- {
- visible=(Gui.desktop()==&desktop);
- enabled=(Gui.desktop()==&desktop && desktop.enabled());
- offset.zero();
- client_rect=clip=desktop.rect();
- }
- /******************************************************************************/
- void Desktop::zero()
- {
- }
- Desktop::Desktop() {zero(); create();}
- Desktop& Desktop::del()
- {
- _children.del();
- super::del(); zero(); return T;
- }
- Desktop& Desktop::create()
- {
- del();
-
- _type =GO_DESKTOP;
- _visible=true;
- _rect =D.rect();
- return T;
- }
- Desktop& Desktop::create(C Desktop &src)
- {
- if(this!=&src)
- {
- if(!src.is())del();else
- {
- _children.del();
- copyParams(src);
- _type=GO_DESKTOP;
- }
- }
- return T;
- }
- /******************************************************************************/
- void Desktop::addChild(GuiObj &child)
- {
- _children.add(child, T);
- }
- void Desktop::removeChild(GuiObj &child)
- {
- _children.remove(child);
- }
- /******************************************************************************/
- GuiObj* Desktop::test(C Vec2 &pos, GuiObj* &mouse_wheel)
- {
- GuiPC gpc(T);
- mouse_wheel=this;
- // test overlay textline
- Vec2 offset; if(Gui.desktop()==this)if(TextLine *tl=Gui.overlayTextLine(offset))
- {
- GuiPC gpc2=gpc; gpc2.offset=offset; if(GuiObj *go=tl->test(gpc2, pos, mouse_wheel))return go;
- if(Cuts(pos, Rect(-D.w(), tl->rect().min.y+offset.y, D.w(), tl->rect().max.y+offset.y)))return tl;
- }
- // test children
- if(GuiObj *go=_children.test(gpc, pos, mouse_wheel))return go;
- // test self
- if(CutsEps(pos, rect()))return this; // use EPS version to make sure that for example Mouse Position will cut the Desktop despite numerical precision issues
- return null;
- }
- void Desktop::update()
- {
- GuiPC gpc(T); if(gpc.enabled)_children.update(gpc);
- }
- void Desktop::draw()
- {
- if(visible())
- {
- // draw children
- GuiPC gpc(T); _children.draw(gpc);
- // draw overlay textline
- Vec2 offset; if(Gui.desktop()==this)if(TextLine *tl=Gui.overlayTextLine(offset)) // don't use "Gui._overlay_textline" because offset can change during textline's window resize
- {
- D.clip(gpc.clip); Rect(-D.w(), tl->rect().min.y+offset.y, D.w(), tl->rect().max.y+offset.y).extend(0.01f).drawShaded(Color(0, 0, 0, 128), TRANSPARENT, 0.01f);
- GuiPC gpc2=gpc; gpc2.offset=offset; tl->draw(gpc2);
- }
- }
- }
- /******************************************************************************/
- }
- /******************************************************************************/
|