From cde2305fc9422683bddb0123268af62b69e0e0ed Mon Sep 17 00:00:00 2001 From: unodgs Date: Tue, 19 Jul 2011 18:12:50 +0000 Subject: [PATCH] Rainbow: WinGL.. git-svn-id: svn://ultimatepp.org/upp/trunk@3677 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- rainbow/WinGl/ControlPanel.cpp | 8 ++++---- rainbow/WinGl/Ctrl.h | 5 +++-- rainbow/WinGl/DrawText.cpp | 2 +- rainbow/WinGl/Event.cpp | 8 ++++---- rainbow/WinGl/FontGl.h | 2 +- rainbow/WinGl/Top.cpp | 1 - rainbow/WinGl/TopFrame.cpp | 3 --- rainbow/WinGl/Wnd.cpp | 31 ++++++++++++++++++------------- uppsrc/CtrlCore/CtrlCore.h | 2 +- uppsrc/CtrlCore/CtrlDraw.cpp | 33 +++++++-------------------------- 10 files changed, 39 insertions(+), 56 deletions(-) diff --git a/rainbow/WinGl/ControlPanel.cpp b/rainbow/WinGl/ControlPanel.cpp index 78b639fb2..f077466bb 100644 --- a/rainbow/WinGl/ControlPanel.cpp +++ b/rainbow/WinGl/ControlPanel.cpp @@ -107,7 +107,7 @@ void InfoPanel::Paint(Draw& w) Size sz = GetSize(); Size wsz = screenRect.GetSize(); Color frameColor = Color(183, 183, 183); - Color bgColor = Color(102, 102, 102);// Color(74, 125, 153); + Color bgColor = Color(102, 102, 102); w.DrawRect(sz, bgColor); w.DrawRect(0, 0, 1, sz.cy, frameColor); w.DrawRect(0, 0, sz.cx, 1, frameColor); @@ -118,7 +118,6 @@ void InfoPanel::Paint(Draw& w) void InfoPanel::Init(Ctrl& parent, float angle, float scale, float alpha) { - int screenWidth = screenRect.Width(); int width = 585; int distance = (screenWidth - width) / 2; @@ -128,10 +127,11 @@ void InfoPanel::Init(Ctrl& parent, float angle, float scale, float alpha) return; init = false; - parent.Add(*this); + //parent.Add(*this); + PopUp(&parent, true, false); alphaSlider.SetPos(alpha, 0.f, 255.f); angleSlider.SetPos(angle, 0.f, 360.f); - scaleSlider.SetPos(scale, 1.f, 10.f); + scaleSlider.SetPos(scale, 1.f, 5.f); } float InfoPanel::GetAlpha() diff --git a/rainbow/WinGl/Ctrl.h b/rainbow/WinGl/Ctrl.h index ca3504c69..5836fb70a 100644 --- a/rainbow/WinGl/Ctrl.h +++ b/rainbow/WinGl/Ctrl.h @@ -30,7 +30,7 @@ friend class TopWindowFrame; friend class SystemDraw; - void SetOpen(bool b) { isopen = b; } + void SetOpen(bool b) { isopen = b; } public: static Rect screenRect; @@ -41,9 +41,10 @@ public: static void DoMouseGl(int event, Point p, int zdelta = 0); static bool DoKeyGl(dword key, int cnt); static void CursorSync(Draw& w); + static void MouseSync(Draw& w); static void SetDesktop(Ctrl& q); - static Ctrl *GetDesktop() { return desktop; } + static Ctrl *GetDesktop() { return desktop; } static void SetWindowSize(Size sz); static void DrawScreen(); diff --git a/rainbow/WinGl/DrawText.cpp b/rainbow/WinGl/DrawText.cpp index e04d60c4a..bdb087ae5 100644 --- a/rainbow/WinGl/DrawText.cpp +++ b/rainbow/WinGl/DrawText.cpp @@ -7,7 +7,7 @@ NAMESPACE_UPP void OpenGLFont::LoadBrc(const byte* xml, const byte* image) { Parse((const char*) xml, false); - compiledFiles.Add(image); + compiledFiles.Add((byte*) image); pages.Add(); } diff --git a/rainbow/WinGl/Event.cpp b/rainbow/WinGl/Event.cpp index 625df269a..b98b3b4c8 100644 --- a/rainbow/WinGl/Event.cpp +++ b/rainbow/WinGl/Event.cpp @@ -1,4 +1,3 @@ -//#include #include "TopFrame.h" #ifdef GUI_WINGL @@ -99,12 +98,13 @@ void Ctrl::CursorSync(Draw& w) glCaretRect = cr; if(!cr.IsEmpty()) w.DrawRect(cr, Black); +} + +void Ctrl::MouseSync(Draw& w) +{ glCursorPos = GetMousePos() - glCursorImage.GetHotSpot(); Size sz = glCursorImage.GetSize(); - glPushMatrix(); - glLoadIdentity(); w.DrawImage(glCursorPos.x, glCursorPos.y, sz.cx, sz.cy, glCursorImage); - glPopMatrix(); } void Ctrl::SetMouseCursor(const Image& image) diff --git a/rainbow/WinGl/FontGl.h b/rainbow/WinGl/FontGl.h index 5059e1f39..caf6bd3ab 100644 --- a/rainbow/WinGl/FontGl.h +++ b/rainbow/WinGl/FontGl.h @@ -29,7 +29,7 @@ struct OpenGLFont : Moveable Vector chars; VectorMap > kerns; Vector files; - Array compiledFiles; + Array compiledFiles; Vector pages; OpenGLFont() : texturesUpdated(false) diff --git a/rainbow/WinGl/Top.cpp b/rainbow/WinGl/Top.cpp index 13fec5c62..409be7f88 100644 --- a/rainbow/WinGl/Top.cpp +++ b/rainbow/WinGl/Top.cpp @@ -64,7 +64,6 @@ void TopWindow::SyncRect() void TopWindow::Open(Ctrl *owner) { GuiLock __; - DLOG("Open " << Upp::Name(owner)); Rect r = GetRect(); if(r.IsEmpty()) SetRect(GetDefaultWindowRect()); diff --git a/rainbow/WinGl/TopFrame.cpp b/rainbow/WinGl/TopFrame.cpp index 40609b1dc..9ad36fa6b 100644 --- a/rainbow/WinGl/TopFrame.cpp +++ b/rainbow/WinGl/TopFrame.cpp @@ -140,7 +140,6 @@ void TopWindowFrame::StartDrag() SetCapture(); startrect = GetRect(); startpos = GetMousePos(); - DLOG("START DRAG ---------------"); } void TopWindowFrame::GripResize() @@ -163,8 +162,6 @@ void TopWindowFrame::LeftDouble(Point p, dword keyflags) void TopWindowFrame::MouseMove(Point, dword) { - //DDUMP(HasWndCapture()); - DDUMP(HasCapture()); if(!HasCapture()) return; Size msz = ComputeClient(minsize).GetSize(); diff --git a/rainbow/WinGl/Wnd.cpp b/rainbow/WinGl/Wnd.cpp index b04db6b59..d927842c8 100644 --- a/rainbow/WinGl/Wnd.cpp +++ b/rainbow/WinGl/Wnd.cpp @@ -47,10 +47,8 @@ void Ctrl::InitGl() void Ctrl::EndSession() { GuiLock __; - DLOG("Ctrl::EndSession"); glEndSession = true; glEndSessionLoop = glEventLoop; - DDUMP(glEndSessionLoop); } void Ctrl::ExitGl() { @@ -96,7 +94,6 @@ Ctrl *Ctrl::GetOwner() int q = FindTopCtrl(); if(q > 0 && topctrl[q]->top) { Ctrl *x = topctrl[q]->top->owner_window; - DDUMP(Upp::Name(x)); return dynamic_cast(x) ? x->GetOwner() : x; } return NULL; @@ -105,6 +102,8 @@ Ctrl *Ctrl::GetOwner() Ctrl *Ctrl::GetActiveCtrl() { GuiLock __; + if(focusCtrl == &infoPanel) + return desktop; return focusCtrl ? focusCtrl->GetTopCtrl() : NULL; } @@ -156,7 +155,6 @@ void Ctrl::SyncTopWindows() bool Ctrl::ProcessEvent(bool *quit) { - DLOG("@ ProcessEvent"); ASSERT(IsMainThread()); if(DoCall()) { SyncTopWindows(); @@ -165,7 +163,6 @@ bool Ctrl::ProcessEvent(bool *quit) if(!GetMouseLeft() && !GetMouseRight() && !GetMouseMiddle()) ReleaseCtrlCapture(); if(GlProcessEvent(quit)) { - DLOG("GlProcesEvent returned true"); SyncTopWindows(); DefferedFocusSync(); SyncCaret(); @@ -188,16 +185,29 @@ void Ctrl::DrawScreen() draw.FlatView(); draw.Clear(); desktop->ApplyTransform(TS_BEFORE_PAINT); - desktop->CtrlPaint(draw, clip, &infoPanel); - //desktop->UpdateArea(draw, clip); + desktop->CtrlPaint(draw, clip); for(int i = 0; i < topctrl.GetCount(); i++) { + if(topctrl[i] == &infoPanel) + continue; Rect r = topctrl[i]->GetRect(); draw.Clipoff(r); topctrl[i]->CtrlPaint(draw, clip); draw.End(); } CursorSync(draw); - desktop->ApplyTransform(TS_AFTER_PAINT); + desktop->ApplyTransform(TS_AFTER_PAINT); + glLoadIdentity(); + #if CLIP_MODE == 2 + glDisable(GL_STENCIL_TEST); + #endif + draw.alpha = 255.f; + draw.Offset(infoPanel.GetRect().TopLeft()); + infoPanel.CtrlPaint(draw, clip, NULL); + draw.End(); + #if CLIP_MODE == 2 + glEnable(GL_STENCIL_TEST); + #endif + MouseSync(draw); SwapBuffers(hDC); painting = false; LOGF("Fps %.2f\n", GetFps()); @@ -272,8 +282,6 @@ void Ctrl::EventLoop0(Ctrl *ctrl) bool quit = false; ProcessEvents(&quit); int64 loopno = ++glEventLoop; - DDUMP(loopno); - DDUMP(glEndSessionLoop); while(loopno > glEndSessionLoop && !quit && (ctrl ? ctrl->IsOpen() && ctrl->InLoop() : GetTopCtrls().GetCount())) { // LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / GuiSleep"); @@ -282,8 +290,6 @@ void Ctrl::EventLoop0(Ctrl *ctrl) // LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / ProcessEvents"); ProcessEvents(&quit); // LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / after ProcessEvents"); - DDUMP(loopno); - DDUMP(glEndSessionLoop); } if(ctrl) @@ -491,7 +497,6 @@ void Ctrl::WndSetPos0(const Rect& rect) void Ctrl::WndScrollView0(const Rect& r, int dx, int dy) { GuiLock __; - //Refresh(r); } void Ctrl::PopUp(Ctrl *owner, bool savebits, bool activate, bool dropshadow, bool topmost) diff --git a/uppsrc/CtrlCore/CtrlCore.h b/uppsrc/CtrlCore/CtrlCore.h index dc7785f20..93bb89fbd 100644 --- a/uppsrc/CtrlCore/CtrlCore.h +++ b/uppsrc/CtrlCore/CtrlCore.h @@ -562,7 +562,7 @@ private: void SyncScroll(); void PaintCaret(SystemDraw& w); #ifdef flagWINGL - void CtrlPaint(SystemDraw& w, const Rect& clip, Ctrl* debugctrl = NULL, int depth = 0); + void CtrlPaint(SystemDraw& w, const Rect& clip, int depth = 0); #else void CtrlPaint(SystemDraw& w, const Rect& clip); #endif diff --git a/uppsrc/CtrlCore/CtrlDraw.cpp b/uppsrc/CtrlCore/CtrlDraw.cpp index b6cc72459..18e2b3dc3 100644 --- a/uppsrc/CtrlCore/CtrlDraw.cpp +++ b/uppsrc/CtrlCore/CtrlDraw.cpp @@ -241,7 +241,7 @@ struct sDrawLevelCheck { #define DOLEVELCHECK #endif #ifdef flagWINGL -void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip, Ctrl* debugctrl, int depth) { +void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip, int depth) { GuiLock __; LEVELCHECK(w, this); LTIMING("CtrlPaint"); @@ -251,18 +251,8 @@ void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip, Ctrl* debugctrl, int depth if(!IsShown() || orect.IsEmpty() || clip.IsEmpty() || !clip.Intersects(orect)) return; - if(debugctrl == this) - { - #if CLIP_MODE == 2 - glDisable(GL_STENCIL_TEST); - #endif - w.FlatView(false); - } - else - { - glPushMatrix(); - ApplyTransform(TS_BEFORE_CTRL_PAINT); - } + glPushMatrix(); + ApplyTransform(TS_BEFORE_CTRL_PAINT); Ctrl *q; Rect view = rect; @@ -286,7 +276,7 @@ void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip, Ctrl* debugctrl, int depth LEVELCHECK(w, q); Point off = q->GetRect().TopLeft(); w.Offset(off); - q->CtrlPaint(w, clip - off, debugctrl, depth + 1); + q->CtrlPaint(w, clip - off, depth + 1); w.End(); } else @@ -333,7 +323,7 @@ void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip, Ctrl* debugctrl, int depth Rect ocl = cl - off; if(ocl.Intersects(Rect(qr.GetSize()).Inflated(overpaint))) { w.Offset(off); - q->CtrlPaint(w, rr - off, debugctrl, depth + 1); + q->CtrlPaint(w, rr - off, depth + 1); w.End(); } //if(q->cliptobounds) @@ -341,17 +331,8 @@ void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip, Ctrl* debugctrl, int depth } } - if(debugctrl != this) - { - ApplyTransform(TS_AFTER_CTRL_PAINT); - glPopMatrix(); - } - else - { - #if CLIP_MODE == 2 - glEnable(GL_STENCIL_TEST); - #endif - } + ApplyTransform(TS_AFTER_CTRL_PAINT); + glPopMatrix(); } #else void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) {