Exemple #1
0
bool Ctrl::PaintOpaqueAreas(SystemDraw& w, const Rect& r, const Rect& clip, bool nochild)
{
	GuiLock __;
	LTIMING("PaintOpaqueAreas");
	if(!IsShown() || r.IsEmpty() || !r.Intersects(clip) || !w.IsPainting(r))
		return true;
	Point off = r.TopLeft();
	Point viewpos = off + GetView().TopLeft();
	if(backpaint == EXCLUDEPAINT)
		return w.ExcludeClip(r);
	Rect cview = clip & (GetView() + off);
	for(Ctrl *q = lastchild; q; q = q->prev)
		if(!q->PaintOpaqueAreas(w, q->GetRect() + (q->InView() ? viewpos : off),
		                        q->InView() ? cview : clip))
			return false;
	if(nochild && (lastchild || GetNext()))
		return true;
	Rect opaque = (GetOpaqueRect() + viewpos) & clip;
	if(opaque.IsEmpty())
		return true;
#ifdef SYSTEMDRAW
	if(backpaint == FULLBACKPAINT && !dynamic_cast<BackDraw *>(&w))
#else
	if(backpaint == FULLBACKPAINT && !w.IsBack())
#endif
	{
		ShowRepaintRect(w, opaque, LtRed());
		BackDraw bw;
		bw.Create(w, opaque.GetSize());
		bw.Offset(viewpos - opaque.TopLeft());
		bw.SetPaintingDraw(w, opaque.TopLeft());
		{
			LEVELCHECK(bw, this);
			Paint(bw);
			PaintCaret(bw);
		}
		bw.Put(w, opaque.TopLeft());
	}
	else {
		w.Clip(opaque);
		ShowRepaintRect(w, opaque, Green());
		w.Offset(viewpos);
		{
			LEVELCHECK(w, this);
			Paint(w);
			PaintCaret(w);
		}
		w.End();
		w.End();
	}
	LLOG("Exclude " << opaque);
	return w.ExcludeClip(opaque);
}
Exemple #2
0
void Ctrl::UpdateArea0(SystemDraw& draw, const Rect& clip, int backpaint)
{
	GuiLock __;
	LTIMING("UpdateArea");
	LLOG("========== UPDATE AREA " << UPP::Name(this) << " ==========");
	if(globalbackbuffer) {
		CtrlPaint(draw, clip);
		LLOG("========== END (TARGET IS BACKBUFFER)");
		return;
	}
	if(backpaint == FULLBACKPAINT || globalbackpaint && !hasdhctrl && !dynamic_cast<DHCtrl *>(this)) {
		ShowRepaintRect(draw, clip, LtRed());
		BackDraw bw;
		bw.Create(draw, clip.GetSize());
		bw.Offset(-clip.TopLeft());
		bw.SetPaintingDraw(draw, clip.TopLeft());
		CtrlPaint(bw, clip);
		bw.Put(draw, clip.TopLeft());
		LLOG("========== END (FULLBACKPAINT)");
		return;
	}
	if(backpaint == TRANSPARENTBACKPAINT) {
		LLOG("TransparentBackpaint");
		Vector<Rect> area;
		GatherTransparentAreas(area, draw, GetRect().GetSize(), clip);
		for(int i = 0; i < area.GetCount(); i++) {
			Rect ar = area[i];
			LLOG("Painting area: " << ar);
			ShowRepaintRect(draw, ar, LtBlue());
			BackDraw bw;
			bw.Create(draw, ar.GetSize());
			bw.Offset(-ar.TopLeft());
			bw.SetPaintingDraw(draw, ar.TopLeft());
			CtrlPaint(bw, ar);
			bw.Put(draw, ar.TopLeft());
			if(!draw.ExcludeClip(ar)) {
				LLOG("========== END");
				return;
			}
		}
		PaintOpaqueAreas(draw, GetRect().GetSize(), clip);
		LLOG("========== END");
		return;
	}
	CtrlPaint(draw, clip);
	LLOG("========== END");
}
Exemple #3
0
void Ctrl::DoPaint()
{
	LLOG("@ DoPaint");
	if(!PaintLock) {
		bool scroll = false;
		if(desktop)
			desktop->SyncScroll();
		for(int i = 0; i < topctrl.GetCount(); i++)
			topctrl[i]->SyncScroll();
		if((invalid.GetCount() || scroll) && desktop) {
			RemoveCursor();
			RemoveCaret();
			for(int phase = 0; phase < 2; phase++) {
				LLOG("DoPaint invalid phase " << phase);
				LDUMPC(invalid);
				SystemDraw painter;
				painter.Begin();
				for(int i = 0; i < invalid.GetCount(); i++) {
					painter.RectPath(invalid[i]);
					AddUpdate(invalid[i]);
				}
				painter.Painter::Clip();
				for(int i = topctrl.GetCount() - 1; i >= 0; i--) {
					Rect r = topctrl[i]->GetRect();
					Rect ri = GetClipBound(invalid, r);
					if(!IsNull(ri)) {
						painter.Clipoff(r);
						topctrl[i]->UpdateArea(painter, ri - r.TopLeft());
						painter.End();
						Subtract(invalid, r);
						painter.ExcludeClip(r);
					}
				}
				Rect ri = GetClipBound(invalid, framebuffer.GetSize());
				if(!IsNull(ri))
					desktop->UpdateArea(painter, ri);
			}
		}
	}
	DoUpdate();
}
Exemple #4
0
void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) {
	GuiLock __;
	LEVELCHECK(w, this);
	LTIMING("CtrlPaint");
	Rect rect = GetRect().GetSize();
	Rect orect = rect.Inflated(overpaint);
	if(!IsShown() || orect.IsEmpty() || clip.IsEmpty() || !clip.Intersects(orect))
		return;
	Ctrl *q;
	Rect view = rect;
	for(int i = 0; i < frame.GetCount(); i++) {
		LEVELCHECK(w, NULL);
		frame[i].frame->FramePaint(w, view);
		view = frame[i].view;
	}
	Rect oview = view.Inflated(overpaint);
	bool hasviewctrls = false;
	bool viewexcluded = false;
	for(q = firstchild; q; q = q->next)
		if(q->IsShown())
			if(q->InFrame()) {
				if(!viewexcluded && IsTransparent() && q->GetRect().Intersects(view)) {
					w.Begin();
					w.ExcludeClip(view);
					viewexcluded = true;
				}
				LEVELCHECK(w, q);
				Point off = q->GetRect().TopLeft();
				w.Offset(off);
				q->CtrlPaint(w, clip - off);
				w.End();
			}
			else
				hasviewctrls = true;
	if(viewexcluded)
		w.End();
	DOLEVELCHECK;
	if(!oview.IsEmpty()) {
		if(oview.Intersects(clip) && w.IsPainting(oview)) {
			LEVELCHECK(w, this);
			if(overpaint) {
				w.Clip(oview);
				w.Offset(view.left, view.top);
				Paint(w);
				PaintCaret(w);
				w.End();
				w.End();
			}
			else {
				w.Clipoff(view);
				Paint(w);
				PaintCaret(w);
				w.End();
			}
		}
	}
	if(hasviewctrls && !view.IsEmpty()) {
		Rect cl = clip & view;
		w.Clip(cl);
		for(q = firstchild; q; q = q->next)
			if(q->IsShown() && q->InView()) {
				LEVELCHECK(w, q);
				Rect qr = q->GetRect();
				Point off = qr.TopLeft() + view.TopLeft();
				Rect ocl = cl - off;
				if(ocl.Intersects(Rect(qr.GetSize()).Inflated(overpaint))) {
					w.Offset(off);
					q->CtrlPaint(w, cl - off);
					w.End();
				}
			}
		w.End();
	}
}
Exemple #5
0
void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) {
	GuiLock __;
	LEVELCHECK(w, this);
	LTIMING("CtrlPaint");
	
	Rect rect = GetRect().GetSize();
	Rect orect = rect.Inflated(overpaint);
	if(!IsShown() || orect.IsEmpty() || clip.IsEmpty() || !clip.Intersects(orect))
		return;
	
	w.PushContext();
	//glPushMatrix();
	ApplyTransform(TS_BEFORE_CTRL_PAINT);
		
	Ctrl *q;
	Rect view = rect;
	for(int i = 0; i < frame.GetCount(); i++) {
		LEVELCHECK(w, NULL);
		frame[i].frame->FramePaint(w, view);
		view = frame[i].view;
	}
	Rect oview = view.Inflated(overpaint);
	bool hasviewctrls = false;
	bool viewexcluded = false;
	
	for(q = firstchild; q; q = q->next)
		if(q->IsShown())
			if(q->InFrame()) {
				if(!viewexcluded && IsTransparent() && q->GetRect().Intersects(view)) {
					w.Begin();
					w.ExcludeClip(view);
					viewexcluded = true;
				}
				LEVELCHECK(w, q);
				Point off = q->GetRect().TopLeft();
				w.Offset(off);
				q->CtrlPaint(w, clip - off);
				w.End();
			}
			else
				hasviewctrls = true;

	if(viewexcluded)
		w.End();
	//DOLEVELCHECK;

	if(!oview.IsEmpty() && oview.Intersects(clip)) {
		LEVELCHECK(w, this);
		if(cliptobounds)
			w.Clip(overpaint ? oview : view);
		w.Offset(view.left, view.top);
		Paint(w);
		PaintCaret(w);		
		w.End();
		
		if(hasviewctrls && !view.IsEmpty()) {
			Rect cl = clip & view;
			for(q = firstchild; q; q = q->next)
				if(q->IsShown() && q->InView()) {
					Rect rr(q->popup ? clip : cl);
					LEVELCHECK(w, q);
					Rect qr = q->GetRect();
					Point off = qr.TopLeft() + view.TopLeft();
					Rect ocl = cl - off;
					if(ocl.Intersects(Rect(qr.GetSize()).Inflated(overpaint))) {
						w.Offset(off);
						q->CtrlPaint(w, rr - off);
						w.End();
					}
				}
		}

		if(cliptobounds)
			w.End();
	}
	
	ApplyTransform(TS_AFTER_CTRL_PAINT);
	//glPopMatrix();
	w.PopContext();
}