Ejemplo n.º 1
0
	void UIBase::_InternalDraw(Render& drawer) {
		if (!this->ShouldRender) return;

		Vector2 oldoffset = drawer.GetDrawingOffset();
		Vector2 pos = this->GetAbsoluteLocation();

		drawer.SetDrawingOffset((int)pos.X, (int)pos.Y);
		drawer.EnableClipping((int)pos.X, (int)pos.Y, this->W, this->H);

		bool recorderstarted = false;
		if (this->ShouldRedraw) {
			drawer.RecorderStart();
			recorderstarted = true;
		}
		
		if (!this->Frozen && (this->ShouldRedraw || this->AlwaysRedraw)) {
			this->OnDraw(drawer);
		} else if(this->Buffer != nullptr) {
			drawer.Buffer(this->Buffer);
		}

		if (recorderstarted) {
			if (this->Buffer != nullptr) delete this->Buffer;
			this->Buffer = drawer.RecorderStop();
			this->ShouldRedraw = false;
		}

		for (unsigned int i = 0; i < this->Children.size(); i++) {
			UIBase* p = this->Children[i];
			Vector2 pos2 = p->GetAbsoluteLocation();
			if (pos2.X + p->W < drawer._ClippingPos.X) continue;
			if (pos2.Y + p->H < drawer._ClippingPos.Y) continue;

			if (pos2.X > drawer._ClippingPos.X + drawer._ClippingSize.X) continue;
			if (pos2.Y > drawer._ClippingPos.Y + drawer._ClippingSize.Y) continue;

			p->_InternalDraw(drawer);
		}

		drawer.SetDrawingOffset((int)oldoffset.X, (int)oldoffset.Y);
		drawer.DisableClipping();
	}