.developing rainbow

git-svn-id: svn://ultimatepp.org/upp/trunk@3605 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-07-04 12:06:56 +00:00
parent 99a828c877
commit afda083cf6
8 changed files with 195 additions and 36 deletions

View file

@ -27,6 +27,7 @@ private:
int FindTopCtrl() const;
static Rect GetClipBound(const Vector<Rect>& inv, const Rect& r);
static void DoPaint(const Vector<Rect>& invalid);
static void SyncTopWindows();
void NewTop() { top = new Top; top->owner_window = NULL; }
void PutForeground();

View file

@ -14,27 +14,32 @@ IMAGE_ID(sizetopright)
IMAGE_ID(sizebottomleft)
IMAGE_ID(sizebottom)
IMAGE_ID(sizebottomright)
IMAGE_ID(closebutton)
IMAGE_ID(title)
IMAGE_ID(border)
IMAGE_BEGIN_DATA
IMAGE_DATA(120,156,237,87,189,75,28,65,20,159,4,46,6,34,72,10,187,20,105,242,79,164,73,155,210,194,46,165,69,42,59,83)
IMAGE_DATA(4,99,180,8,33,16,228,20,98,144,96,226,233,69,208,132,164,216,70,68,197,179,240,3,193,15,252,0,17,69,16,65)
IMAGE_DATA(68,4,173,180,251,57,222,158,27,179,59,243,246,189,89,93,21,246,55,12,183,55,247,251,189,55,243,62,230,238,84,181)
IMAGE_DATA(170,85,231,120,160,238,157,191,64,201,0,161,6,128,72,131,211,211,167,56,57,121,198,213,224,248,248,57,142,142,94,224)
IMAGE_DATA(240,240,37,71,131,131,131,58,236,239,215,99,111,239,21,118,118,26,226,52,216,221,109,208,188,215,216,222,110,196,214,86)
IMAGE_DATA(19,214,215,155,41,13,54,55,223,96,99,227,173,230,181,98,117,245,35,150,151,219,177,184,216,97,211,96,109,237,3,86)
IMAGE_DATA(86,62,97,105,41,143,133,133,110,204,205,21,49,59,251,19,51,51,189,38,141,230,116,96,126,254,139,230,245,96,122,122)
IMAGE_DATA(8,165,82,169,50,255,96,98,162,24,214,104,91,221,154,215,131,169,169,34,38,39,255,6,124,245,47,151,151,53,154,243)
IMAGE_DATA(93,207,2,198,199,7,48,54,246,27,35,35,30,121,222,209,209,94,12,15,247,5,118,60,111,136,228,123,222,143,200,30)
IMAGE_DATA(7,7,251,173,241,49,197,160,80,248,70,241,141,126,187,186,58,69,117,152,207,127,22,215,122,91,219,123,145,143,150,150)
IMAGE_DATA(119,98,31,2,110,20,57,85,163,238,171,170,242,84,161,196,171,114,179,250,8,61,7,206,67,239,239,252,154,229,188,145)
IMAGE_DATA(184,168,106,29,184,156,14,90,238,255,192,113,103,89,243,228,215,87,114,94,226,166,193,39,53,6,174,85,67,112,35,26)
IMAGE_DATA(6,55,208,72,184,46,123,113,57,171,75,44,111,32,191,178,250,124,172,199,195,202,160,2,103,152,92,112,155,132,163,79)
IMAGE_DATA(242,185,100,159,73,245,145,4,50,108,152,111,31,119,189,109,95,82,61,215,134,228,243,56,31,156,61,82,231,164,16,23)
IMAGE_DATA(99,137,222,180,39,73,173,152,214,92,245,92,59,46,125,231,210,183,113,182,204,168,209,163,170,50,24,70,93,224,114,128)
IMAGE_DATA(176,206,69,127,97,195,21,92,173,173,185,226,214,168,198,52,173,153,26,71,58,147,248,141,227,113,214,76,72,35,71,97)
IMAGE_DATA(77,146,186,74,82,143,23,122,59,252,31,191,254,63,7,182,200,206,147,108,52,141,34,139,243,107,59,7,165,245,145,5)
IMAGE_DATA(206,120,14,74,235,35,11,156,241,28,148,214,71,232,47,190,205,144,109,163,166,123,36,201,221,154,246,90,92,34,236,1)
IMAGE_DATA(126,164,71,174,50,44,70,108,144,92,190,82,174,233,153,131,219,204,191,142,56,73,243,132,172,83,174,168,83,40,72,186)
IMAGE_DATA(136,114,158,132,203,173,60,215,239,22,23,158,164,27,210,136,31,205,207,18,158,152,119,183,18,158,93,141,87,115,53,74)
IMAGE_DATA(186,225,58,179,110,122,230,224,54,243,111,242,118,9,230,25,68,109,209,184,0,0,0,0,0,0,0,0,0,0,0,0)
IMAGE_END_DATA(672, 15)
IMAGE_DATA(120,156,237,90,191,75,28,65,20,158,252,56,77,200,17,9,33,157,69,26,155,252,9,105,210,166,76,145,84,41,45,82)
IMAGE_DATA(165,51,69,72,140,91,132,16,8,225,12,196,32,193,196,75,46,1,53,36,197,53,34,42,158,133,63,16,252,129,122,32)
IMAGE_DATA(162,8,34,136,136,160,149,118,95,102,111,239,206,203,238,204,236,123,179,222,170,97,191,225,113,187,115,223,247,102,230,189)
IMAGE_DATA(121,179,119,220,137,180,184,37,92,52,136,11,238,11,4,15,96,106,0,176,52,56,58,186,141,195,195,22,170,6,7,7)
IMAGE_DATA(119,177,191,127,15,123,123,247,41,26,236,238,62,192,206,206,67,108,111,63,198,230,102,107,152,6,91,91,173,146,247,4)
IMAGE_DATA(27,27,79,177,190,222,134,149,149,23,38,13,214,214,158,97,117,245,185,228,117,96,121,249,13,22,23,223,99,126,190,83)
IMAGE_DATA(167,65,177,248,26,75,75,111,177,176,144,193,220,92,55,102,102,114,152,158,254,129,169,169,94,149,70,114,58,49,59,251)
IMAGE_DATA(81,242,122,48,57,217,143,66,161,80,182,223,24,27,203,249,53,210,87,183,228,245,96,98,34,135,241,241,63,85,190,56)
IMAGE_DATA(206,101,173,70,114,190,72,203,98,116,244,39,70,70,126,97,104,40,111,92,239,240,112,47,6,7,191,85,253,228,243,253)
IMAGE_DATA(70,126,62,255,53,48,199,190,190,239,218,248,168,98,144,205,126,54,241,149,227,118,117,125,96,237,195,76,230,29,123,175)
IMAGE_DATA(59,206,43,214,24,237,237,47,217,99,48,184,65,164,68,147,184,40,26,75,38,124,137,23,165,98,245,224,187,174,14,238)
IMAGE_DATA(187,63,247,125,154,245,6,226,34,210,50,112,41,25,180,212,191,129,163,90,73,211,60,240,201,104,53,220,56,248,70,141)
IMAGE_DATA(130,171,213,24,184,1,13,129,91,213,112,184,54,115,177,89,171,77,44,79,33,191,188,253,121,67,182,43,229,102,10,156)
IMAGE_DATA(194,168,160,22,9,69,31,229,125,206,60,163,234,3,9,36,248,80,159,62,246,122,221,188,184,122,170,15,206,251,97,99)
IMAGE_DATA(80,230,104,90,167,9,97,49,230,232,85,115,226,236,21,85,159,173,158,234,199,166,238,108,234,54,204,151,26,77,178,53)
IMAGE_DATA(150,27,193,169,13,108,22,224,215,217,232,43,62,108,65,213,234,138,43,172,207,84,152,170,62,85,225,112,45,202,184,97)
IMAGE_DATA(60,74,159,10,113,228,200,175,137,178,175,162,236,199,138,94,15,239,195,175,247,205,129,44,210,243,56,19,141,99,147,133)
IMAGE_DATA(141,171,91,135,73,235,33,9,156,114,29,38,173,135,36,112,202,117,152,180,30,124,95,241,117,142,116,19,85,157,35,81)
IMAGE_DATA(206,214,184,251,194,18,161,15,240,53,217,82,229,166,113,162,3,231,240,229,114,85,215,20,156,101,126,61,226,196,205,19)
IMAGE_DATA(146,74,57,161,74,49,129,83,69,166,193,163,112,169,59,207,246,217,98,195,227,84,67,28,241,51,243,147,132,71,230,157)
IMAGE_DATA(175,132,39,71,227,201,28,141,156,106,168,103,214,85,215,20,156,101,254,105,158,46,199,230,254,156,222,34,174,19,252,39)
IMAGE_DATA(72,144,224,191,194,101,217,92,92,146,77,8,7,87,239,12,224,230,163,34,154,59,220,159,145,153,247,105,217,220,199,70)
IMAGE_DATA(131,108,66,253,12,50,26,5,181,127,252,168,220,155,204,113,156,132,95,39,126,229,62,204,108,246,194,95,138,97,99,99)
IMAGE_END_DATA(736, 18)

View file

@ -4,6 +4,10 @@
NAMESPACE_UPP
#define IMAGECLASS FBImg
#define IMAGEFILE <Framebuffer/FB.iml>
#include <Draw/iml_header.h>
class SystemDraw : public BufferPainter {
public:
virtual void BeginOp();

View file

@ -97,9 +97,6 @@ ImageDraw::ImageDraw(int cx, int cy)
has_alpha = false;
}
#define IMAGECLASS FBImg
#define IMAGEFILE <Framebuffer/FB.iml>
#include <Draw/iml_header.h>
#define IMAGECLASS FBImg
#define IMAGEFILE <Framebuffer/FB.iml>
#include <Draw/iml_source.h>

View file

@ -6,29 +6,131 @@ NAMESPACE_UPP
#define LLOG(x) // LOG(x)
void TopWindow::SyncSizeHints() {}
void TopWindow::TopWindowFrame::Paint(Draw& w)
{
Size sz = GetSize();
Rect m = ChMargins(FBImg::border());
ChPaintEdge(w, sz, FBImg::border());
ChPaint(w, m.left, m.top, sz.cx - m.left - m.right, GetStdFontCy() + 4, FBImg::title());
w.DrawText(m.left + 2, m.top + 2, title, StdFont(), White());
}
Rect TopWindow::TopWindowFrame::GetClient() const
{
Rect r = GetRect();
Rect m = ChMargins(FBImg::border());
DDUMP(r);
DDUMP(m);
r.left += m.left;
r.right -= m.right;
r.top += m.top;
r.bottom -= m.bottom;
r.top += GetStdFontCy() + 4;
return r;
}
void TopWindow::TopWindowFrame::SetClient(Rect r)
{
Rect m = ChMargins(FBImg::border());
r.left -= m.left;
r.right += m.right;
r.top -= m.top;
r.bottom += m.bottom;
r.top -= GetStdFontCy() + 4;
SetRect(r);
}
Point TopWindow::TopWindowFrame::GetDragMode(Point p)
{
Size sz = GetSize();
Rect m = ChMargins(FBImg::border());
Point dir;
dir.y = p.y < m.top ? -1 : p.y > sz.cy - m.top ? 1 : 0;
dir.x = p.x < m.left ? -1 : p.x > sz.cx - m.right ? 1 : 0;
return dir;
}
void TopWindow::TopWindowFrame::LeftDown(Point p, dword keyflags)
{
SetCapture();
dir = GetDragMode(p);
startrect = GetRect();
startpos = GetMousePos();
}
void TopWindow::TopWindowFrame::MouseMove(Point, dword)
{
if(!HasCapture())
return;
Point p = GetMousePos() - startpos;
Rect r = startrect;
if(dir.x == -1)
r.left += p.x;
if(dir.x == 1)
r.right += p.x;
if(dir.y == -1)
r.top += p.y;
if(dir.y == 1)
r.bottom += p.y;
if(dir.y == 0 && dir.x == 0)
r.Offset(p);
SetRect(r);
WhenLayout();
}
void TopWindow::TopWindowFrame::Layout()
{
WhenLayout();
}
Image TopWindow::TopWindowFrame::CursorImage(Point p, dword)
{
p = GetDragMode(p);
static Image (*im[9])() = {
Image::SizeTopLeft, Image::SizeLeft, Image::SizeBottomLeft,
Image::SizeTop, Image::Arrow, Image::SizeBottom,
Image::SizeTopRight, Image::SizeRight, Image::SizeBottomRight,
};
return (*im[(p.x + 1) * 3 + (p.y + 1)])();
}
void TopWindow::SyncSizeHints() {}
void TopWindow::SyncTitle0()
{
GuiLock __;
SyncCaption0();
}
void TopWindow::SyncCaption0()
{
GuiLock __;
frame.SetTitle(title.ToString());
}
void TopWindow::SyncRect()
{
Rect r = frame.GetClient();
DLOG("SyncRect to " << r);
if(r != GetRect())
SetRect(r);
}
void TopWindow::Open(Ctrl *owner)
{
GuiLock __;
frame.PopUp(owner, false, true);
PopUp(&frame, false, true);
SetRect(frame.GetClient());
}
void TopWindow::Open()
{
Open(GetActiveCtrl());
}
void TopWindow::OpenMain()
{
Open(NULL);
}
void TopWindow::Minimize(bool effect)

View file

@ -1,3 +1,35 @@
//$ class TopWindow {
private:
class TopWindowFrame : public Ctrl {
public:
virtual void Layout();
virtual void Paint(Draw& w);
virtual Image CursorImage(Point p, dword keyflags);
virtual void LeftDown(Point p, dword keyflags);
virtual void MouseMove(Point p, dword keyflags);
private:
String title;
Point dir;
Point startpos;
Rect startrect;
Point GetDragMode(Point p);
public:
void SetTitle(const String& s) { title = s; Refresh(); }
Rect GetClient() const;
void SetClient(Rect r);
Callback WhenLayout;
};
//$ };
TopWindowFrame frame;
void SyncRect();
void SyncFrameRect(const Rect& r) { frame.SetClient(r); }
void DestroyFrame() { if(frame.IsOpen()) frame.Close(); }
friend class Ctrl;
//$ };

View file

@ -136,11 +136,22 @@ void Ctrl::AddInvalid(const Rect& rect)
AddRefreshRect(invalid, rect);
}
void Ctrl::SyncTopWindows()
{
for(int i = 0; i < topctrl.GetCount(); i++) {
TopWindow *w = dynamic_cast<TopWindow *>(topctrl[i]);
if(w)
w->SyncRect();
}
}
bool Ctrl::ProcessEvent(bool *quit)
{
ASSERT(IsMainThread());
if(DoCall())
if(DoCall()) {
SyncTopWindows();
return false;
}
if(FBEndSession()) {
if(quit) *quit = true;
return false;
@ -148,6 +159,7 @@ bool Ctrl::ProcessEvent(bool *quit)
if(!GetMouseLeft() && !GetMouseRight() && !GetMouseMiddle())
ReleaseCtrlCapture();
if(FBProcessEvent(quit)) {
SyncTopWindows();
DefferedFocusSync();
SyncCaret();
return true;
@ -349,6 +361,9 @@ void Ctrl::WndDestroy0()
top = NULL;
}
isopen = false;
TopWindow *win = dynamic_cast<TopWindow *>(this);
if(win)
win->DestroyFrame();
}
void Ctrl::PutForeground()
@ -433,6 +448,9 @@ void Ctrl::WndInvalidateRect0(const Rect& r)
void Ctrl::WndSetPos0(const Rect& rect)
{
GuiLock __;
TopWindow *w = dynamic_cast<TopWindow *>(this);
if(w)
w->SyncFrameRect(rect);
invalid.Add(GetRect());
SetWndRect(rect);
invalid.Add(rect);
@ -468,7 +486,7 @@ void Ctrl::PopUp(Ctrl *owner, bool savebits, bool activate, bool dropshadow, boo
topctrl.Add(this);
popup = isopen = true;
RefreshLayoutDeep();
if(activate) SetFocus();
if(activate) SetFocusWnd();
AddInvalid(GetRect());
}

View file

@ -9,7 +9,8 @@ struct App : public Ctrl {
DropList dl;
StaticRect popup;
StaticRect popup2, popup3;
StaticRect popup2;
TopWindow win;
void Paint(Draw& w)
{
@ -38,8 +39,8 @@ struct App : public Ctrl {
void RightDown(Point p, dword)
{
popup3.SetRect(p.x, p.y, 100, 100);
popup3.SetForeground();
win.SetRect(p.x, p.y, 300, 100);
win.SetForeground();
}
void InitArray(ArrayCtrl& a)
@ -68,8 +69,7 @@ struct App : public Ctrl {
popup2.SetFrame(BlackFrame());
popup2.Color(Magenta());
popup3.SetFrame(OutsetFrame());
popup3.Color(Cyan());
win.Title("Title of the window !");
// Add(popup);
@ -94,7 +94,7 @@ GUI_APP_MAIN
#if !EDITOR
app.popup.PopUp();
app.popup2.PopUp(&app.popup);
app.popup3.PopUp();
app.win.Open();
#endif
// Ctrl::SetRenderingMode(MODE_NOAA);
// Ctrl::SetRenderingMode(MODE_SUBPIXEL);