From c21ddc2d5eb81eb700bd60a3ec53df4d047b6c48 Mon Sep 17 00:00:00 2001 From: unodgs Date: Wed, 17 Jul 2013 18:10:20 +0000 Subject: [PATCH] CtrlCore, Draw: LinuxGl adjustments git-svn-id: svn://ultimatepp.org/upp/trunk@6199 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlCore/CtrlCore.h | 2 +- uppsrc/CtrlCore/CtrlDraw.cpp | 15 +++++++++------ uppsrc/CtrlCore/CtrlMouse.cpp | 2 +- uppsrc/Draw/Cham.cpp | 10 +++++++--- uppsrc/Draw/Draw.h | 2 +- uppsrc/Draw/DrawText.cpp | 8 ++++++-- uppsrc/Draw/DrawUtil.cpp | 2 +- uppsrc/Draw/Font.cpp | 2 +- uppsrc/Draw/FontFc.cpp | 16 ++++++++++++++++ 9 files changed, 43 insertions(+), 16 deletions(-) diff --git a/uppsrc/CtrlCore/CtrlCore.h b/uppsrc/CtrlCore/CtrlCore.h index 6febe869f..212ccbd68 100644 --- a/uppsrc/CtrlCore/CtrlCore.h +++ b/uppsrc/CtrlCore/CtrlCore.h @@ -582,7 +582,7 @@ private: Ctrl *FindBestOpaque(const Rect& clip); void UpdateArea0(SystemDraw& draw, const Rect& clip, int backpaint); void UpdateArea(SystemDraw& draw, const Rect& clip); - Ctrl *GetTopRect(Rect& r, bool inframe); + Ctrl *GetTopRect(Rect& r, bool inframe, bool clip = true); void DoSync(Ctrl *q, Rect r, bool inframe); bool HasDHCtrl() const; void SyncDHCtrl(); diff --git a/uppsrc/CtrlCore/CtrlDraw.cpp b/uppsrc/CtrlCore/CtrlDraw.cpp index e4c9956b0..50b27bba0 100644 --- a/uppsrc/CtrlCore/CtrlDraw.cpp +++ b/uppsrc/CtrlCore/CtrlDraw.cpp @@ -261,7 +261,7 @@ struct sDrawLevelCheck { #define LEVELCHECK(w, q) #define DOLEVELCHECK #endif -#ifdef flagWINGL +#if defined(flagWINGL) || defined(flagLINUXGL) void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) { GuiLock __; LEVELCHECK(w, this); @@ -272,7 +272,8 @@ void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) { if(!IsShown() || orect.IsEmpty() || clip.IsEmpty() || !clip.Intersects(orect)) return; - glPushMatrix(); + w.PushContext(); + //glPushMatrix(); ApplyTransform(TS_BEFORE_CTRL_PAINT); Ctrl *q; @@ -338,7 +339,8 @@ void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) { } ApplyTransform(TS_AFTER_CTRL_PAINT); - glPopMatrix(); + //glPopMatrix(); + w.PopContext(); } #else void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) { @@ -639,16 +641,17 @@ void Ctrl::RemoveFullRefresh() q->RemoveFullRefresh(); } -Ctrl *Ctrl::GetTopRect(Rect& r, bool inframe) +Ctrl *Ctrl::GetTopRect(Rect& r, bool inframe, bool clip) { GuiLock __; if(!inframe) { - r &= Rect(GetSize()); + if(clip) + r &= Rect(GetSize()); r.Offset(GetView().TopLeft()); } if(parent) { r.Offset(GetRect().TopLeft()); - return parent->GetTopRect(r, InFrame()); + return parent->GetTopRect(r, InFrame(), clip); } return this; } diff --git a/uppsrc/CtrlCore/CtrlMouse.cpp b/uppsrc/CtrlCore/CtrlMouse.cpp index eca545a03..330e2c87e 100644 --- a/uppsrc/CtrlCore/CtrlMouse.cpp +++ b/uppsrc/CtrlCore/CtrlMouse.cpp @@ -577,7 +577,7 @@ Image Ctrl::DispatchMouse(int e, Point p, int zd) { Image Ctrl::DispatchMouseEvent(int e, Point p, int zd) { GuiLock __; -#ifdef flagWINGL +#if defined(flagWINGL) || defined(flagLINUXGL) if(!IsEnabled() && this != (Ctrl*) &infoPanel) return Image::Arrow(); #else diff --git a/uppsrc/Draw/Cham.cpp b/uppsrc/Draw/Cham.cpp index bc6023f6d..1a44ba62d 100644 --- a/uppsrc/Draw/Cham.cpp +++ b/uppsrc/Draw/Cham.cpp @@ -56,7 +56,7 @@ void ChDraw(Draw& w, int x, int y, int cx, int cy, const Image& img, const Rect { LTIMING("ChDraw"); if(cx > 0 && cy > 0) { - #ifdef flagWINGL + #if defined(flagWINGL) || defined(flagLINUXGL) w.DrawImage(x, y, cx, cy, img, src); #else ChImageMaker m; @@ -253,7 +253,11 @@ Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op) } if(op == LOOK_PAINT || op == LOOK_PAINTEDGE) { LTIMING("ChPaint Image"); + #if defined(flagWINGL) || defined(flagLINUXGL) + w.Offset(r.TopLeft()); + #else w.Clipoff(r); + #endif Rect sr(p, p2); Size sz2(isz.cx - sr.right, isz.cy - sr.bottom); Rect r = RectC(p.x, p.y, sz.cx - sr.left - sz2.cx, sz.cy - sr.top - sz2.cy); @@ -274,7 +278,7 @@ Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op) ChDraw(w, r.right, p.y, sz2.cx, r.Height(), img, RectC(sr.right, p.y, sz2.cx, sr.Height())); if(op == LOOK_PAINT) { - if(IsNull(r) || IsNull(sr)) { + if(IsNull(r) || IsNull(sr)) { w.End(); return 1; } @@ -284,7 +288,7 @@ Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op) Size sz; sz.cx = (tile & 1 ? sr : r).GetWidth(); sz.cy = (tile & 2 ? sr : r).GetHeight(); - #ifdef flagWINGL + #if defined(flagWINGL) || defined(flagLINUXGL) DrawTiles(w, r, img, sz, sr); #else img = Rescale(img, sz, sr); diff --git a/uppsrc/Draw/Draw.h b/uppsrc/Draw/Draw.h index eb0c010a5..410ef7945 100644 --- a/uppsrc/Draw/Draw.h +++ b/uppsrc/Draw/Draw.h @@ -814,7 +814,7 @@ void AddRefreshRect(Vector& invalid, const Rect& _r); void DrawRect(Draw& w, const Rect& rect, const Image& img, bool ralgn = false); //??? TODO void DrawRect(Draw& w, int x, int y, int cx, int cy, const Image& img, bool ra = false); -#ifdef flagWINGL +#if defined(flagWINGL) || defined(flagLINUXGL) void DrawTiles(Draw& w, int x, int y, int cx, int cy, const Image& img, const Size& isz, const Rect& src); void DrawTiles(Draw& w, const Rect& rect, const Image& img, const Size& isz, const Rect& src); #endif diff --git a/uppsrc/Draw/DrawText.cpp b/uppsrc/Draw/DrawText.cpp index 960d648f5..b36a5bbb7 100644 --- a/uppsrc/Draw/DrawText.cpp +++ b/uppsrc/Draw/DrawText.cpp @@ -6,6 +6,10 @@ NAMESPACE_UPP #include #include #endif +#ifdef flagLINUXGL +#include +#include +#endif #define LLOG(x) // LOG(x) #define LTIMING(x) // TIMING(x) @@ -31,7 +35,7 @@ WString TextUnicode(const char *s, int n, byte cs, Font font) void Draw::DrawText(int x, int y, int angle, const wchar *text, Font font, Color ink, int n, const int *dx) { -#ifdef flagWINGL +#if defined(flagWINGL) || defined(flagLINUXGL) if(IsNull(ink)) return; DrawTextOp(x, y, angle, text, font, ink, n, dx); @@ -221,7 +225,7 @@ void Draw::DrawText(int x, int y, const String& text, Font font, Color ink, cons Size GetTextSize(const wchar *text, Font font, int n) { -#ifdef flagWINGL +#if defined(flagWINGL) || defined(flagLINUXGL) return GetTextSize(text, resources.GetFont(font), n); #else FontInfo fi = font.Info(); diff --git a/uppsrc/Draw/DrawUtil.cpp b/uppsrc/Draw/DrawUtil.cpp index 5a3494e7a..971e6dcdc 100644 --- a/uppsrc/Draw/DrawUtil.cpp +++ b/uppsrc/Draw/DrawUtil.cpp @@ -329,7 +329,7 @@ void DrawRect(Draw& w, const Rect& rect, const Image& img, bool ralgn) DrawRect(w, rect.left, rect.top, rect.Width(), rect.Height(), img, ralgn); } -#ifdef flagWINGL +#if defined(flagWINGL) || defined(flagLINUXGL) void DrawTiles(Draw& w, int x, int y, int cx, int cy, const Image& img, const Size& isz, const Rect& src) { w.Clip(x, y, cx, cy); Size sz = isz; diff --git a/uppsrc/Draw/Font.cpp b/uppsrc/Draw/Font.cpp index 84760bbf7..554b2b395 100644 --- a/uppsrc/Draw/Font.cpp +++ b/uppsrc/Draw/Font.cpp @@ -129,7 +129,7 @@ void Font::InitStdFont() int height = 0; GetStdFontSys(name, height); #ifdef PLATFORM_WIN32 -#ifdef flagWINGL +#if defined(flagWINGL) AStdFont = Font(FindFaceNameIndex("Tahoma"), 12); #else int q = FindFaceNameIndex(name); diff --git a/uppsrc/Draw/FontFc.cpp b/uppsrc/Draw/FontFc.cpp index d75498eae..4a29f587d 100644 --- a/uppsrc/Draw/FontFc.cpp +++ b/uppsrc/Draw/FontFc.cpp @@ -179,6 +179,21 @@ CommonFontInfo GetFontInfoSys(Font font) GlyphInfo (*GetGlyphInfoSysXft)(Font font, int chr); +#ifdef flagLINUXGL +#include +#include +GlyphInfo GetGlyphInfoSys(Font font, int chr) +{ + static GlyphInfo gi; + const OpenGLFont& fi = resources.GetFont(font); + gi.width = chr < fi.chars.GetCount() + ? int(fi.chars[chr].xadvance * fi.scale + 0.5f) + : 0; + gi.lspc = 0; + gi.rspc = 0; + return gi; +} +#else GlyphInfo GetGlyphInfoSys(Font font, int chr) { LTIMING("GetGlyphInfoSys"); @@ -207,6 +222,7 @@ GlyphInfo GetGlyphInfoSys(Font font, int chr) } return gi; } +#endif Vector GetAllFacesSys() {