From f49793113a2ce603d8b060906e7054948b792abe Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Thu, 2 Mar 2017 12:19:13 +0800 Subject: [PATCH] Create MiniEngine_Widget.cpp --- MiniEngine_Widget.cpp | 134 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 MiniEngine_Widget.cpp diff --git a/MiniEngine_Widget.cpp b/MiniEngine_Widget.cpp new file mode 100644 index 0000000..52879e6 --- /dev/null +++ b/MiniEngine_Widget.cpp @@ -0,0 +1,134 @@ +#include "MiniEngine_Widget.h" +using namespace MiniEngine; + +void Brush::setArea(Rect Area) +{ + area=Area; +} + +int Brush::copy(Texture t,Rect src,Rect dst) +{ + dst.x+=area.x; + dst.y+=area.y; + if(stretching) + { + if(dst.w>area.w) + { + dst.w=area.w; + } + if(dst.h>area.h) + { + dst.h=area.h; + } + } + else + { + if(dst.w>area.w) + { + dst.w=src.w=area.w; + } + if(dst.h>area.h) + { + src.w=src.h=area.h; + } + } + return Renderer::copy(t,src,dst); +} + +int Brush::copyTo(Texture t,Rect dst) +{ + dst.x+=area.x; + dst.y+=area.y; + + if(streching) + { + if(dst.w>area.w) + { + dst.w=area.w; + } + if(dst.h>area.h) + { + dst.h=area.h; + } + + return Renderer::copyTo(t,dst); + } + else + { + Rect src=t.getSize(); + src.x=src.y=0; + if(dst.w>area.w) + { + src.w=dst.w=area.w; + } + if(dst.h>area.h) + { + src.h=dst.h=area.h; + } + + return Renderer::copy(t,src,dst); + } +} + +int Brush::copyTo(Texture t,Point lupoint) +{ + return copyTo(t,Rect(lupoint.x,lupoint.y,t.getw(),t.geth())); +} + +int Brush::copyFill(Texture t,Rect src) +{ + Rect dst=area; + return Renderer::copy(t,src,dst); +} + +int Brush::copyFullFill(Texture t ) +{ + Rect dst=area; + return Renderer::copyTo(t,dst); +} + +Board::Board(Window wnd,Rect Area) +{ + area=Area; + fullwnd=wnd.getSize(); +} + +Brush Board::getBrush() +{ + Brush b; + return b; +} + +ButtonBase::ButtonBase() +{ + status=0; +} + +void ButtonBase::setTextureClicked(Texture Clicked) +{ + t3=Clicked; +} + +void ButtonBase::setTextureMouseover(Texture Mouseover) +{ + t2=Mouseover; +} + +void ButtonBase::setTextureNormal(Texture Normal) +{ + t1=Normal; +} + +void ButtonBase::setRect(Rect SensorArea) +{ + rect=SensorArea; +} + +virtual void ButtonBase::draw(Brush& brush) +{ + switch(status) + { + case 0: + brush.copyTo( ) + } +}