git-svn-id: svn://ultimatepp.org/upp/trunk@6167 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2013-07-06 11:19:06 +00:00
parent ae09998c68
commit 066794e213
8 changed files with 139 additions and 38 deletions

View file

@ -0,0 +1,9 @@
uses
CtrlLib;
file
main.cpp;
mainconfig
"" = "GUI SSE2";

View file

@ -0,0 +1,52 @@
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct App : TopWindow {
Thread work;
void Work();
ArrayCtrl list;
typedef App CLASSNAME;
App();
~App();
};
void App::Work()
{
for(;;) {
Sleep(1);
GuiLock __;
if(IsShutdownThreads())
break;
if(list.GetCount() > 10000) {
if(PromptYesNo("Quit?")) {
Break();
return;
}
list.Clear();
}
list.Add(AsString((int64)Random()) + String('x', 200));
}
}
App::App()
{
list.AddColumn("Test");
Add(list.SizePos());
work.Run(THISBACK(Work));
}
App::~App()
{
ShutdownThreads();
}
GUI_APP_MAIN
{
App app;
app.Run();
}

View file

@ -16,25 +16,35 @@ int main(int argc, char** argv){
SDLWindow win;
win.Create(RectC(100, 100, 1024, 768), "First test");
bool quit = false;
int i = 0;
while(!quit) {
SDLDraw w;
{
SystemDraw w;
w.Set(win);
Size sz = Size(1024, 768);
w.Init(sz);
w.DrawRect(sz, White);
// w.DrawText(10, 10, "Hello world!", Arial(40));
w.DrawText(10, 10, "Hello world!", Arial(40));
}
bool quit = false;
int i = 0;
while(!quit) {
SystemDraw w;
w.Set(win);
Size sz = Size(1024, 768);
w.Init(sz);
w.DrawText(i++, i, "Hello world!", Arial(40));
/*
// w.DrawImage(300, 300, TestImg::pinkie());
RichText txt = ParseQTF(LoadFile(GetDataFile("text.qtf")));
if(1) {
RTIMING("SDLDraw");
RTIMING("SystemDraw");
txt.Paint(Zoom(2, 10), w, 0, 0, sz.cx);
}
*/
win.Present();
SDL_Event e;

View file

@ -7,6 +7,8 @@
using namespace Upp;
NAMESPACE_UPP
struct SDLWindow {
SDL_Window *win;
SDL_Renderer *ren;
@ -23,7 +25,7 @@ struct SDLWindow {
~SDLWindow();
};
struct SDLDraw : SDraw {
struct SystemDraw : SDraw {
SDLWindow *win;
virtual void PutImage(Point p, const Image& m, const Rect& src);
@ -31,8 +33,38 @@ struct SDLDraw : SDraw {
void Set(SDLWindow& win_);
SDLDraw();
~SDLDraw();
SystemDraw();
~SystemDraw();
};
END_UPP_NAMESPACE
/*
class BackDraw : public SDLDraw {
public:
virtual bool IsPaintingOp(const Rect& r) const;
protected:
HBITMAP hbmpold;
HBITMAP hbmp;
Size size;
Draw *painting;
Point painting_offset;
public:
void Put(SystemDraw& w, int x, int y);
void Put(SystemDraw& w, Point p) { Put(w, p.x, p.y); }
void Create(SystemDraw& w, int cx, int cy);
void Create(SystemDraw& w, Size sz) { Create(w, sz.cx, sz.cy); }
void Destroy();
void SetPaintingDraw(Draw& w, Point off) { painting = &w; painting_offset = off; }
BackDraw();
~BackDraw();
};
*/
#endif

View file

@ -2,6 +2,8 @@
#define LLOG(x) // DLOG(x)
NAMESPACE_UPP
struct RectSDL {
SDL_Rect sr;
@ -19,8 +21,6 @@ struct RectSDL {
SDL_Texture *TextureFromImage(SDL_Renderer *renderer, const Image& m)
{
Size isz = m.GetSize();
void *pixels;
int pitch;
SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STATIC, isz.cx, isz.cy);
if(texture) {
@ -60,7 +60,7 @@ struct ImageSysDataMaker : LRUCache<ImageSysData, int64>::Maker {
virtual int Make(ImageSysData& object) const { object.Init(renderer, img); return img.GetLength(); }
};
void SDLDraw::PutImage(Point p, const Image& img, const Rect& src)
void SystemDraw::PutImage(Point p, const Image& img, const Rect& src)
{
if(img.GetLength() == 0 || !win)
return;
@ -73,13 +73,13 @@ void SDLDraw::PutImage(Point p, const Image& img, const Rect& src)
m.wserial = win->serial;
ImageSysData& sd = cache.Get(m);
{
RTIMING("SDL_RenderCopy");
SDL_RenderCopy(win->ren, sd.texture, RectSDL(src), RectSDL(Rect(p, src.GetSize())));
RTIMING("SDL_RenderCopy");
SDL_RenderCopy(win->ren, sd.texture, RectSDL(src), RectSDL(Rect(p, src.GetSize())));
}
cache.Shrink(4 * 1024 * 768, 1000); // Cache shrink must be after Paint because of PaintOnly!
}
void SDLDraw::PutRect(const Rect& r, Color color)
void SystemDraw::PutRect(const Rect& r, Color color)
{
if(win && !IsNull(color)) {
SDL_SetRenderDrawColor(win->ren, color.GetR(), color.GetG(), color.GetB(), 255); // Optimize?
@ -87,16 +87,18 @@ void SDLDraw::PutRect(const Rect& r, Color color)
}
}
void SDLDraw::Set(SDLWindow& win_)
void SystemDraw::Set(SDLWindow& win_)
{
win = win_.ren ? &win_ : NULL;
}
SDLDraw::SDLDraw()
SystemDraw::SystemDraw()
{
win = NULL;
}
SDLDraw::~SDLDraw()
SystemDraw::~SystemDraw()
{
}
END_UPP_NAMESPACE

View file

@ -1,5 +1,7 @@
#include "SDL20.h"
NAMESPACE_UPP
bool SDLWindow::Create(const Rect& rect, const char *title)
{
win = SDL_CreateWindow(title, rect.left, rect.top, rect.GetWidth(), rect.GetHeight(),
@ -48,3 +50,5 @@ SDLWindow::~SDLWindow()
{
Destroy();
}
END_UPP_NAMESPACE

View file

@ -2,8 +2,10 @@
using namespace Upp;
CONSOLE_APP_MAIN
{
CONSOLE_APP_MAIN {
TcpSocket s;
if(!s.Connect("www.idnessdfg.cz", 12314)) {
DDUMP(s.GetErrorDesc());
}
DLOG("OK");
}

View file

@ -39,7 +39,9 @@ void ToolWin::FrameLayout(Rect& r)
return;
}
close.Show();
close.SetFrameRect(r.right - 18, r.top, 16, 16);
int c = GetTitleCy();
int b = GetBorder();
close.SetFrameRect(r.right - c - b + 1, r.top + b, c - 1, c - 1);
Rect m = GetMargins();
r.left += m.left;
r.right -= m.right;
@ -107,12 +109,11 @@ void ToolWin::MouseMove(Point, dword)
if(dragdir.x == 1)
r.right = minmax(r.right + off.x, r.left + minsz.cx, r.left + maxsz.cx);
if(dragdir.y == -1)
r.top = minmax(r.top + off.y, r.bottom - maxsz.cy, r.bottom - maxsz.cy);
r.top = minmax(r.top + off.y, r.bottom - maxsz.cy, r.bottom - minsz.cy);
if(dragdir.y == 1)
r.bottom = minmax(r.bottom + off.y, r.top + minsz.cy, r.top + maxsz.cy);
}
SetRect(r);
DDUMP(HasCapture());
}
void ToolWin::LeftUp(Point, dword)
@ -182,18 +183,6 @@ Point ToolWin::GetDir(Point p) const
return r;
}
/*
Size ToolWin::GetMinSize() const
{
return AddMargins(client ? client->GetMinSize() : Size(0, 0));
}
Size ToolWin::GetMaxSize() const
{
return AddMargins(client ? client->GetMaxSize() : Size(99999, 99999));
}
*/
void ToolWin::SetClientRect(Rect r)
{
Rect m = GetMargins();
@ -241,6 +230,7 @@ ToolWin::ToolWin()
close.Image(CtrlImg::cross());
close <<= THISBACK(DoClose);
AddFrame(*this);
Sizeable();
FrameLess();
}