mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
.developing rainbow
git-svn-id: svn://ultimatepp.org/upp/trunk@3628 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
7014a272f3
commit
931bf5b92f
16 changed files with 317 additions and 81 deletions
11
rainbow/DrawDragRect/DrawDragRect.upp
Normal file
11
rainbow/DrawDragRect/DrawDragRect.upp
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
uses
|
||||||
|
CtrlLib,
|
||||||
|
Framebuffer,
|
||||||
|
WinFb;
|
||||||
|
|
||||||
|
file
|
||||||
|
main.cpp;
|
||||||
|
|
||||||
|
mainconfig
|
||||||
|
"" = "GUI SSE2 WINFB";
|
||||||
|
|
||||||
6
rainbow/DrawDragRect/init
Normal file
6
rainbow/DrawDragRect/init
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef _DrawDragRect_icpp_init_stub
|
||||||
|
#define _DrawDragRect_icpp_init_stub
|
||||||
|
#include "CtrlLib/init"
|
||||||
|
#include "Framebuffer/init"
|
||||||
|
#include "WinFb/init"
|
||||||
|
#endif
|
||||||
70
rainbow/DrawDragRect/main.cpp
Normal file
70
rainbow/DrawDragRect/main.cpp
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
#include <CtrlLib/CtrlLib.h>
|
||||||
|
#include <RichEdit/RichEdit.h>
|
||||||
|
|
||||||
|
using namespace Upp;
|
||||||
|
|
||||||
|
struct App : public Ctrl {
|
||||||
|
uint64 pattern;
|
||||||
|
int pos;
|
||||||
|
int a;
|
||||||
|
int dir;
|
||||||
|
|
||||||
|
void Paint(Draw& w)
|
||||||
|
{
|
||||||
|
DDUMP(pattern);
|
||||||
|
Size sz = GetSize();
|
||||||
|
w.DrawRect(sz, White());
|
||||||
|
DrawDragRect((SystemDraw&)w,
|
||||||
|
Rect(0, 0, 0, 0),
|
||||||
|
RectC(10, 10, a, a / 3),
|
||||||
|
Size(800, 600),
|
||||||
|
1,
|
||||||
|
Black(),
|
||||||
|
pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Animate() {
|
||||||
|
pattern = I64(0xf0f0) >> (pos++ & 7);
|
||||||
|
if(Random() % 100 == 0)
|
||||||
|
dir = (int)Random() % 3 - 1;
|
||||||
|
a += dir;
|
||||||
|
if(a < 0) {
|
||||||
|
a = 0;
|
||||||
|
dir = -dir;
|
||||||
|
}
|
||||||
|
if(a > 1000) {
|
||||||
|
a = 1000;
|
||||||
|
dir = -dir;
|
||||||
|
}
|
||||||
|
// if(++a > 900)
|
||||||
|
// a = 0;
|
||||||
|
DrawDragRect(*this,
|
||||||
|
Rect(0, 0, 0, 0),
|
||||||
|
RectC(10, 10, a, a / 3),
|
||||||
|
Size(800, 600),
|
||||||
|
1,
|
||||||
|
Black(),
|
||||||
|
pattern);
|
||||||
|
PostCallback(THISBACK(Animate));
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef App CLASSNAME;
|
||||||
|
|
||||||
|
App()
|
||||||
|
{
|
||||||
|
pattern = I64(9732030564846854595);
|
||||||
|
pos = 0;
|
||||||
|
a = 200;
|
||||||
|
dir = 1;
|
||||||
|
PostCallback(THISBACK(Animate));
|
||||||
|
SetCaret(0, 0, 20, 20);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GUI_APP_MAIN
|
||||||
|
{
|
||||||
|
App app;
|
||||||
|
Ctrl::SetDesktop(app);
|
||||||
|
app.SetFocus();
|
||||||
|
Ctrl::EventLoop();
|
||||||
|
}
|
||||||
|
|
@ -1,13 +1,17 @@
|
||||||
class ViewDraw : public SystemDraw {
|
class ViewDraw : public SystemDraw {
|
||||||
ImageBuffer ib;
|
|
||||||
|
|
||||||
Vector<Rect> dummy_invalid;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ViewDraw(Ctrl *ctrl) : SystemDraw(ib, dummy_invalid) { _DBG_ }
|
ViewDraw(Ctrl *ctrl);
|
||||||
~ViewDraw() {}
|
~ViewDraw();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
class ViewDraw : public SystemDraw {
|
||||||
|
Vector<Rect> dummy;
|
||||||
|
public:
|
||||||
|
ViewDraw(Ctrl *) : SystemDraw(Ctrl::framebuffer, dummy) { dummy.Add(Rect(10, 10, 100, 100)); }
|
||||||
|
};
|
||||||
|
*/
|
||||||
class DHCtrl : Ctrl {};
|
class DHCtrl : Ctrl {};
|
||||||
|
|
||||||
#include FRAMEBUFFER_INCLUDE
|
#include FRAMEBUFFER_INCLUDE
|
||||||
|
|
|
||||||
|
|
@ -6,36 +6,44 @@ NAMESPACE_UPP
|
||||||
|
|
||||||
#define LLOG(x) // LOG(x)
|
#define LLOG(x) // LOG(x)
|
||||||
|
|
||||||
|
static VectorMap<String, ClipData> fbClipboard;
|
||||||
|
|
||||||
void ClearClipboard()
|
void ClearClipboard()
|
||||||
{
|
{
|
||||||
GuiLock __;
|
GuiLock __;
|
||||||
}
|
fbClipboard.Clear();
|
||||||
|
|
||||||
void AppendClipboard(int format, const byte *data, int length)
|
|
||||||
{
|
|
||||||
GuiLock __;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppendClipboard(const char *format, const byte *data, int length)
|
|
||||||
{
|
|
||||||
GuiLock __;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppendClipboard(const char *format, const String& data)
|
|
||||||
{
|
|
||||||
GuiLock __;
|
|
||||||
AppendClipboard(format, data, data.GetLength());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppendClipboard(const char *format, const Value& data, String (*render)(const Value&))
|
void AppendClipboard(const char *format, const Value& data, String (*render)(const Value&))
|
||||||
{
|
{
|
||||||
GuiLock __;
|
GuiLock __;
|
||||||
|
ClipData& cd = fbClipboard.GetAdd(format);
|
||||||
|
cd.data = data;
|
||||||
|
cd.render = render;
|
||||||
|
}
|
||||||
|
|
||||||
|
static String sRawRender(const Value& v)
|
||||||
|
{
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppendClipboard(const char *format, const String& data)
|
||||||
|
{
|
||||||
|
GuiLock __;
|
||||||
|
AppendClipboard(format, data, sRawRender);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppendClipboard(const char *format, const byte *data, int length)
|
||||||
|
{
|
||||||
|
GuiLock __;
|
||||||
|
AppendClipboard(format, String(data, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
String ReadClipboard(const char *format)
|
String ReadClipboard(const char *format)
|
||||||
{
|
{
|
||||||
GuiLock __;
|
GuiLock __;
|
||||||
return Null;
|
int q = fbClipboard.Find(format);
|
||||||
|
return q >= 0 ? (*fbClipboard[q].render)(fbClipboard[q].data) : String();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppendClipboardText(const String& s)
|
void AppendClipboardText(const String& s)
|
||||||
|
|
@ -125,22 +133,26 @@ String GetTextClip(const String& text, const String& fmt)
|
||||||
|
|
||||||
String ReadClipboardText()
|
String ReadClipboardText()
|
||||||
{
|
{
|
||||||
return ReadClipboardUnicodeText().ToString();
|
String w = ReadClipboard("text");
|
||||||
|
return w.GetCount() ? w : ReadClipboardUnicodeText().ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
WString ReadClipboardUnicodeText()
|
WString ReadClipboardUnicodeText()
|
||||||
{
|
{
|
||||||
return Null;
|
String w = ReadClipboard("wtext");
|
||||||
|
if(w.GetCount())
|
||||||
|
return WString(~w, w.GetLength() / 2);
|
||||||
|
return ReadClipboard("text").ToWString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsClipboardAvailable(const char *id)
|
bool IsClipboardAvailable(const char *id)
|
||||||
{
|
{
|
||||||
return false;
|
return fbClipboard.Find(id) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsClipboardAvailableText()
|
bool IsClipboardAvailableText()
|
||||||
{
|
{
|
||||||
return false;
|
return IsClipboardAvailable("text") || IsClipboardAvailable("wtext");
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ClipFmtsImage()
|
const char *ClipFmtsImage()
|
||||||
|
|
@ -223,12 +235,12 @@ Vector<String> GetFiles(PasteClip& clip)
|
||||||
|
|
||||||
bool PasteClip::IsAvailable(const char *fmt) const
|
bool PasteClip::IsAvailable(const char *fmt) const
|
||||||
{
|
{
|
||||||
return false;
|
return IsClipboardAvailable(fmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
String PasteClip::Get(const char *fmt) const
|
String PasteClip::Get(const char *fmt) const
|
||||||
{
|
{
|
||||||
return Null;
|
return ReadClipboard(fmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PasteClip::GuiPlatformConstruct()
|
void PasteClip::GuiPlatformConstruct()
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
//$ class Ctrl {
|
//$ class Ctrl {
|
||||||
private:
|
private:
|
||||||
static void AddInvalid(const Rect& rect);
|
|
||||||
|
|
||||||
static Ptr<Ctrl> desktop;
|
static Ptr<Ctrl> desktop;
|
||||||
static Vector<Ctrl *> topctrl;
|
static Vector<Ctrl *> topctrl;
|
||||||
static ImageBuffer framebuffer;
|
static ImageBuffer framebuffer;
|
||||||
static Vector<Rect> invalid;
|
static Vector<Rect> invalid, update;
|
||||||
|
|
||||||
static Point fbCursorPos;
|
static Point fbCursorPos;
|
||||||
static Image fbCursorImage;
|
static Image fbCursorImage;
|
||||||
|
|
@ -28,15 +26,19 @@ private:
|
||||||
|
|
||||||
int FindTopCtrl() const;
|
int FindTopCtrl() const;
|
||||||
static Rect GetClipBound(const Vector<Rect>& inv, const Rect& r);
|
static Rect GetClipBound(const Vector<Rect>& inv, const Rect& r);
|
||||||
static void DoPaint(const Vector<Rect>& invalid);
|
static void DoPaint();
|
||||||
|
static void DoUpdate();
|
||||||
static void SyncTopWindows();
|
static void SyncTopWindows();
|
||||||
|
|
||||||
|
static void AddInvalid(const Rect& rect);
|
||||||
|
|
||||||
void NewTop() { top = new Top; top->owner_window = NULL; }
|
void NewTop() { top = new Top; top->owner_window = NULL; }
|
||||||
void PutForeground();
|
void PutForeground();
|
||||||
static void MouseEventFB(Ptr<Ctrl> t, int event, Point p, int zdelta);
|
static void MouseEventFB(Ptr<Ctrl> t, int event, Point p, int zdelta);
|
||||||
|
|
||||||
friend struct PaintProxy__;
|
friend struct PaintProxy__;
|
||||||
friend class TopWindowFrame;
|
friend class TopWindowFrame;
|
||||||
|
friend class SystemDraw;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void DoMouseFB(int event, Point p, int zdelta = 0);
|
static void DoMouseFB(int event, Point p, int zdelta = 0);
|
||||||
|
|
@ -56,4 +58,6 @@ public:
|
||||||
|
|
||||||
static void SetRenderingMode(int mode);
|
static void SetRenderingMode(int mode);
|
||||||
|
|
||||||
|
static void AddUpdate(const Rect& rect);
|
||||||
|
|
||||||
//$ };
|
//$ };
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,16 @@ NAMESPACE_UPP
|
||||||
#define LLOG(x) // LOG(x)
|
#define LLOG(x) // LOG(x)
|
||||||
#define LTIMING(x) // RTIMING(x)
|
#define LTIMING(x) // RTIMING(x)
|
||||||
|
|
||||||
|
SystemDraw::SystemDraw()
|
||||||
|
: BufferPainter(Ctrl::framebuffer, Ctrl::renderingMode)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemDraw::~SystemDraw()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SystemDraw::Push()
|
void SystemDraw::Push()
|
||||||
{
|
{
|
||||||
Point p = GetOffset();
|
Point p = GetOffset();
|
||||||
|
|
@ -64,8 +74,8 @@ bool SystemDraw::ClipoffOp(const Rect& r)
|
||||||
bool SystemDraw::IsPaintingOp(const Rect& r) const
|
bool SystemDraw::IsPaintingOp(const Rect& r) const
|
||||||
{
|
{
|
||||||
Rect rr = r + GetOffset();
|
Rect rr = r + GetOffset();
|
||||||
for(int i = 0; i < invalid.GetCount(); i++)
|
for(int i = 0; i < Ctrl::invalid.GetCount(); i++)
|
||||||
if(invalid[i].Intersects(rr))
|
if(Ctrl::invalid[i].Intersects(rr))
|
||||||
return true;
|
return true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ void Ctrl::DoMouseFB(int event, Point p, int zdelta)
|
||||||
else
|
else
|
||||||
if(a == Ctrl::DOWN && ignoreclick)
|
if(a == Ctrl::DOWN && ignoreclick)
|
||||||
return;
|
return;
|
||||||
LLOG("Mouse event: " << event << " position " << p << " zdelta " << zdelta << ", capture " << Upp::Name(captureCtrl));
|
LLOG("### Mouse event: " << event << " position " << p << " zdelta " << zdelta << ", capture " << Upp::Name(captureCtrl));
|
||||||
if(captureCtrl)
|
if(captureCtrl)
|
||||||
MouseEventFB(captureCtrl->GetTopCtrl(), event, p, zdelta);
|
MouseEventFB(captureCtrl->GetTopCtrl(), event, p, zdelta);
|
||||||
else
|
else
|
||||||
|
|
@ -80,7 +80,7 @@ void Ctrl::RemoveCursor()
|
||||||
{
|
{
|
||||||
if(!IsNull(fbCursorBakPos)) {
|
if(!IsNull(fbCursorBakPos)) {
|
||||||
Copy(framebuffer, fbCursorBakPos, fbCursorBak, fbCursorBak.GetSize());
|
Copy(framebuffer, fbCursorBakPos, fbCursorBak, fbCursorBak.GetSize());
|
||||||
AddInvalid(Rect(fbCursorBakPos, fbCursorBak.GetSize()));
|
AddUpdate(Rect(fbCursorBakPos, fbCursorBak.GetSize()));
|
||||||
}
|
}
|
||||||
fbCursorPos = fbCursorBakPos = Null;
|
fbCursorPos = fbCursorBakPos = Null;
|
||||||
fbCursorBak = Null;
|
fbCursorBak = Null;
|
||||||
|
|
@ -90,7 +90,7 @@ void Ctrl::RemoveCaret()
|
||||||
{
|
{
|
||||||
if(!IsNull(fbCaretRect)) {
|
if(!IsNull(fbCaretRect)) {
|
||||||
Copy(framebuffer, fbCaretRect.TopLeft(), fbCaretBak, fbCaretBak.GetSize());
|
Copy(framebuffer, fbCaretRect.TopLeft(), fbCaretBak, fbCaretBak.GetSize());
|
||||||
AddInvalid(fbCaretRect);
|
AddUpdate(fbCaretRect);
|
||||||
}
|
}
|
||||||
fbCaretRect = Null;
|
fbCaretRect = Null;
|
||||||
fbCaretBak = Null;
|
fbCaretBak = Null;
|
||||||
|
|
@ -113,12 +113,15 @@ void Ctrl::SyncCaret() {
|
||||||
|
|
||||||
void Ctrl::CursorSync()
|
void Ctrl::CursorSync()
|
||||||
{
|
{
|
||||||
|
DLOG("@ CursorSync");
|
||||||
Point p = GetMousePos() - fbCursorImage.GetHotSpot();
|
Point p = GetMousePos() - fbCursorImage.GetHotSpot();
|
||||||
Rect cr = Null;
|
Rect cr = Null;
|
||||||
if(focusCtrl && (((GetTickCount() - fbCaretTm) / 500) & 1) == 0)
|
if(focusCtrl && (((GetTickCount() - fbCaretTm) / 500) & 1) == 0)
|
||||||
cr = (RectC(focusCtrl->caretx, focusCtrl->carety, focusCtrl->caretcx, focusCtrl->caretcy)
|
cr = (RectC(focusCtrl->caretx, focusCtrl->carety, focusCtrl->caretcx, focusCtrl->caretcy)
|
||||||
+ focusCtrl->GetScreenView().TopLeft()) & focusCtrl->GetScreenView();
|
+ focusCtrl->GetScreenView().TopLeft()) & focusCtrl->GetScreenView();
|
||||||
|
DDUMP(GetTickCount());
|
||||||
if(fbCursorPos != p || cr != fbCaretRect) {
|
if(fbCursorPos != p || cr != fbCaretRect) {
|
||||||
|
DDUMP(fbCaretRect);
|
||||||
RemoveCursor();
|
RemoveCursor();
|
||||||
RemoveCaret();
|
RemoveCaret();
|
||||||
|
|
||||||
|
|
@ -128,9 +131,9 @@ void Ctrl::CursorSync()
|
||||||
fbCursorBak = GetBak(tr);
|
fbCursorBak = GetBak(tr);
|
||||||
fbCursorBakPos = tr.TopLeft();
|
fbCursorBakPos = tr.TopLeft();
|
||||||
|
|
||||||
|
fbCaretRect = cr;
|
||||||
if(!cr.IsEmpty()) {
|
if(!cr.IsEmpty()) {
|
||||||
fbCaretBak = GetBak(cr);
|
fbCaretBak = GetBak(cr);
|
||||||
fbCaretRect = cr;
|
|
||||||
for(int y = cr.top; y < cr.bottom; y++) {
|
for(int y = cr.top; y < cr.bottom; y++) {
|
||||||
RGBA *s = framebuffer[y] + cr.left;
|
RGBA *s = framebuffer[y] + cr.left;
|
||||||
const RGBA *e = framebuffer[y] + cr.right;
|
const RGBA *e = framebuffer[y] + cr.right;
|
||||||
|
|
@ -141,11 +144,12 @@ void Ctrl::CursorSync()
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AddInvalid(fbCaretRect);
|
AddUpdate(fbCaretRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
Over(framebuffer, p, fbCursorImage, sz);
|
Over(framebuffer, p, fbCursorImage, sz);
|
||||||
AddInvalid(tr);
|
DLOG("Cursor: " << p << ", rect " << tr);
|
||||||
|
AddUpdate(tr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<Point> offset;
|
Vector<Point> offset;
|
||||||
const Vector<Rect>& invalid;
|
|
||||||
|
|
||||||
void Push();
|
void Push();
|
||||||
void Pop();
|
void Pop();
|
||||||
|
|
@ -29,18 +28,15 @@ public:
|
||||||
bool CanSetSurface() { return false; }
|
bool CanSetSurface() { return false; }
|
||||||
bool Clip(const Rect& r) { return Draw::Clip(r); }
|
bool Clip(const Rect& r) { return Draw::Clip(r); }
|
||||||
bool Clip(int x, int y, int cx, int cy) { return Draw::Clip(x, y, cx, cy); }
|
bool Clip(int x, int y, int cx, int cy) { return Draw::Clip(x, y, cx, cy); }
|
||||||
|
|
||||||
static void Flush() {}
|
static void Flush() {}
|
||||||
|
|
||||||
SystemDraw(ImageBuffer& ib, const Vector<Rect>& invalid, int mode = MODE_ANTIALIASED)
|
SystemDraw();
|
||||||
: BufferPainter(ib, mode), invalid(invalid) {}
|
~SystemDraw();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BackDraw__ : public SystemDraw {
|
struct BackDraw__ : public SystemDraw {
|
||||||
ImageBuffer h;
|
BackDraw__() : SystemDraw() {}
|
||||||
Vector<Rect> dummy_invalid;
|
|
||||||
|
|
||||||
BackDraw__() : SystemDraw(h, dummy_invalid) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class BackDraw : public BackDraw__ { // Dummy only, as we are running in GlobalBackBuffer mode
|
class BackDraw : public BackDraw__ { // Dummy only, as we are running in GlobalBackBuffer mode
|
||||||
|
|
@ -110,6 +106,7 @@ bool FBProcessEvent(bool *quit);
|
||||||
void FBSleep(int ms);
|
void FBSleep(int ms);
|
||||||
bool FBEndSession();
|
bool FBEndSession();
|
||||||
void FBUpdate(const Rect& area);
|
void FBUpdate(const Rect& area);
|
||||||
|
void FBFlush();
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,36 @@
|
||||||
|
|
||||||
NAMESPACE_UPP
|
NAMESPACE_UPP
|
||||||
|
|
||||||
void DrawDragRect(SystemDraw& w, const Rect& rect1, const Rect& rect2, const Rect& clip, int n, Color color, uint64 pattern)
|
static void sRenderLine(SystemDraw& w, int x, int y, int dx, int dy, int cx, int cy, int len, byte pattern)
|
||||||
{
|
{
|
||||||
|
DLOG(len);
|
||||||
|
for(int i = 0; i < len; i++)
|
||||||
|
if((128 >> (i & 7)) & pattern)
|
||||||
|
w.DrawRect(x + dx * i, y + dy * i, cx, cy, Black);
|
||||||
|
DDUMP("~sRenderLine");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sRenderRect(SystemDraw& w, const Rect& r, int n, byte pattern)
|
||||||
|
{
|
||||||
|
sRenderLine(w, r.left, r.top, 1, 0, 1, n, r.GetWidth(), pattern);
|
||||||
|
sRenderLine(w, r.left, r.bottom - 1, 1, 0, 1, n, r.GetWidth(), pattern);
|
||||||
|
sRenderLine(w, r.left, r.top, 0, 1, n, 1, r.GetHeight(), pattern);
|
||||||
|
sRenderLine(w, r.right - 1, r.top, 0, 1, n, 1, r.GetHeight(), pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawDragRect(SystemDraw& w, const Rect& rect1, const Rect& rect2,
|
||||||
|
const Rect& clip, int n, Color color, uint64 pattern)
|
||||||
|
{
|
||||||
|
DLOG("@ DrawDragRect " << rect1 << " " << rect2 << ", clip: " << clip << ", pattern: " << pattern);
|
||||||
|
TIMING("DrawDrawRect");
|
||||||
|
w.Clip(clip);
|
||||||
|
w.Invert();
|
||||||
|
sRenderRect(w, rect1, n, (byte)pattern);
|
||||||
|
sRenderRect(w, rect2, n, (byte)pattern);
|
||||||
|
Ctrl::AddUpdate((rect1 | rect2).Offseted(w.GetOffset()));
|
||||||
|
// MemoryProfile mem;
|
||||||
|
// DDUMP(mem);
|
||||||
|
w.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ NAMESPACE_UPP
|
||||||
|
|
||||||
ImageBuffer Ctrl::framebuffer;
|
ImageBuffer Ctrl::framebuffer;
|
||||||
Vector<Rect> Ctrl::invalid;
|
Vector<Rect> Ctrl::invalid;
|
||||||
|
Vector<Rect> Ctrl::update;
|
||||||
|
|
||||||
Ptr<Ctrl> Ctrl::desktop;
|
Ptr<Ctrl> Ctrl::desktop;
|
||||||
Vector<Ctrl *> Ctrl::topctrl;
|
Vector<Ctrl *> Ctrl::topctrl;
|
||||||
|
|
@ -151,8 +152,15 @@ bool Ctrl::IsWaitingEvent()
|
||||||
return FBIsWaitingEvent();
|
return FBIsWaitingEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ctrl::AddUpdate(const Rect& rect)
|
||||||
|
{
|
||||||
|
DLOG("@AddUpdate " << rect);
|
||||||
|
AddRefreshRect(update, rect);
|
||||||
|
}
|
||||||
|
|
||||||
void Ctrl::AddInvalid(const Rect& rect)
|
void Ctrl::AddInvalid(const Rect& rect)
|
||||||
{
|
{
|
||||||
|
DLOG("@AddInvalid " << rect);
|
||||||
AddRefreshRect(invalid, rect);
|
AddRefreshRect(invalid, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,6 +175,7 @@ void Ctrl::SyncTopWindows()
|
||||||
|
|
||||||
bool Ctrl::ProcessEvent(bool *quit)
|
bool Ctrl::ProcessEvent(bool *quit)
|
||||||
{
|
{
|
||||||
|
DLOG("@ ProcessEvent");
|
||||||
ASSERT(IsMainThread());
|
ASSERT(IsMainThread());
|
||||||
if(DoCall()) {
|
if(DoCall()) {
|
||||||
SyncTopWindows();
|
SyncTopWindows();
|
||||||
|
|
@ -174,11 +183,12 @@ bool Ctrl::ProcessEvent(bool *quit)
|
||||||
}
|
}
|
||||||
if(FBEndSession()) {
|
if(FBEndSession()) {
|
||||||
if(quit) *quit = true;
|
if(quit) *quit = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!GetMouseLeft() && !GetMouseRight() && !GetMouseMiddle())
|
if(!GetMouseLeft() && !GetMouseRight() && !GetMouseMiddle())
|
||||||
ReleaseCtrlCapture();
|
ReleaseCtrlCapture();
|
||||||
if(FBProcessEvent(quit)) {
|
if(FBProcessEvent(quit)) {
|
||||||
|
DLOG("FBProcesEvent returned true");
|
||||||
SyncTopWindows();
|
SyncTopWindows();
|
||||||
DefferedFocusSync();
|
DefferedFocusSync();
|
||||||
SyncCaret();
|
SyncCaret();
|
||||||
|
|
@ -198,47 +208,107 @@ Rect Ctrl::GetClipBound(const Vector<Rect>& inv, const Rect& r)
|
||||||
return ri;
|
return ri;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ctrl::DoPaint(const Vector<Rect>& invalid)
|
|
||||||
|
ViewDraw::ViewDraw(Ctrl *ctrl)
|
||||||
{
|
{
|
||||||
|
if(Ctrl::invalid.GetCount())
|
||||||
|
Ctrl::DoPaint();
|
||||||
|
Ctrl::invalid.Clear();
|
||||||
|
Ctrl::RemoveCursor();
|
||||||
|
Ctrl::RemoveCaret();
|
||||||
|
Rect r = ctrl->GetScreenView();
|
||||||
|
Ctrl::invalid.Add(r);
|
||||||
|
Ctrl::AddUpdate(r);
|
||||||
|
for(int i = max(ctrl->GetTopCtrl()->FindTopCtrl() + 1, 0); i < Ctrl::topctrl.GetCount(); i++) {
|
||||||
|
Rect rr = Ctrl::topctrl[i]->GetScreenRect();
|
||||||
|
ExcludeClip(rr);
|
||||||
|
Subtract(Ctrl::invalid, rr);
|
||||||
|
}
|
||||||
|
Offset(r.TopLeft());
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewDraw::~ViewDraw()
|
||||||
|
{
|
||||||
|
Ctrl::invalid.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ctrl::DoUpdate()
|
||||||
|
{
|
||||||
|
DLOG("DoUpdate");
|
||||||
|
invalid.Clear();
|
||||||
|
CursorSync();
|
||||||
|
DDUMPC(update);
|
||||||
|
#if 0
|
||||||
|
FBUpdate(framebuffer.GetSize());
|
||||||
|
#else
|
||||||
|
for(int i = 0; i < update.GetCount(); i++) {
|
||||||
|
DDUMP(update[i]);
|
||||||
|
FBUpdate(update[i]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
update.Clear();
|
||||||
|
FBFlush();
|
||||||
|
// Sleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ctrl::DoPaint()
|
||||||
|
{
|
||||||
|
DLOG("@ DoPaint");
|
||||||
if(invalid.GetCount() && desktop) {
|
if(invalid.GetCount() && desktop) {
|
||||||
|
DLOG("DoPaint invalid");
|
||||||
|
DDUMPC(invalid);
|
||||||
RemoveCursor();
|
RemoveCursor();
|
||||||
RemoveCaret();
|
RemoveCaret();
|
||||||
SystemDraw painter(framebuffer, invalid, renderingMode);
|
SystemDraw painter;
|
||||||
painter.Begin();
|
painter.Begin();
|
||||||
for(int i = 0; i < invalid.GetCount(); i++)
|
for(int i = 0; i < invalid.GetCount(); i++) {
|
||||||
painter.RectPath(invalid[i]);
|
painter.RectPath(invalid[i]);
|
||||||
|
AddUpdate(invalid[i]);
|
||||||
|
}
|
||||||
painter.Painter::Clip();
|
painter.Painter::Clip();
|
||||||
Vector<Rect> inv;
|
|
||||||
inv <<= invalid;
|
|
||||||
for(int i = topctrl.GetCount() - 1; i >= 0; i--) {
|
for(int i = topctrl.GetCount() - 1; i >= 0; i--) {
|
||||||
Rect r = topctrl[i]->GetRect();
|
Rect r = topctrl[i]->GetRect();
|
||||||
Rect ri = GetClipBound(inv, r);
|
Rect ri = GetClipBound(invalid, r);
|
||||||
if(!IsNull(ri)) {
|
if(!IsNull(ri)) {
|
||||||
painter.Offset(r.TopLeft());
|
painter.Clipoff(r);
|
||||||
topctrl[i]->UpdateArea(painter, ri - r.TopLeft());
|
topctrl[i]->UpdateArea(painter, ri - r.TopLeft());
|
||||||
painter.End();
|
painter.End();
|
||||||
Subtract(inv, r);
|
Subtract(invalid, r);
|
||||||
painter.ExcludeClip(r);
|
painter.ExcludeClip(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Rect ri = GetClipBound(inv, framebuffer.GetSize());
|
Rect ri = GetClipBound(invalid, framebuffer.GetSize());
|
||||||
if(!IsNull(ri))
|
if(!IsNull(ri))
|
||||||
desktop->UpdateArea(painter, ri);
|
desktop->UpdateArea(painter, ri);
|
||||||
}
|
}
|
||||||
CursorSync();
|
DoUpdate();
|
||||||
for(int i = 0; i < invalid.GetCount(); i++)
|
}
|
||||||
FBUpdate(invalid[i]);
|
|
||||||
|
void Ctrl::WndUpdate0r(const Rect& r)
|
||||||
|
{
|
||||||
|
GuiLock __;
|
||||||
|
Rect rr = r + GetRect().TopLeft();
|
||||||
|
bool dummy;
|
||||||
|
Vector<Rect> h;
|
||||||
|
h <<= invalid;
|
||||||
|
invalid = Intersect(invalid, rr, dummy);
|
||||||
|
DoPaint();
|
||||||
|
invalid <<= h;
|
||||||
|
Subtract(invalid, rr);
|
||||||
|
FBFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Ctrl::ProcessEvents(bool *quit)
|
bool Ctrl::ProcessEvents(bool *quit)
|
||||||
{
|
{
|
||||||
|
DLOG("ProcessEvents " << LOG_BEGIN);
|
||||||
if(!ProcessEvent(quit))
|
if(!ProcessEvent(quit))
|
||||||
return false;
|
return false;
|
||||||
while(ProcessEvent(quit) && (!LoopCtrl || LoopCtrl->InLoop()) && !FBEndSession());
|
while(ProcessEvent(quit) && (!LoopCtrl || LoopCtrl->InLoop()) && !FBEndSession());
|
||||||
TimerProc(GetTickCount());
|
TimerProc(GetTickCount());
|
||||||
SweepMkImageCache();
|
SweepMkImageCache();
|
||||||
DoPaint(invalid);
|
DoPaint();
|
||||||
invalid.Clear();
|
FBFlush();
|
||||||
|
DLOG(LOG_END);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -476,15 +546,6 @@ void Ctrl::WndSetPos0(const Rect& rect)
|
||||||
invalid.Add(rect);
|
invalid.Add(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ctrl::WndUpdate0r(const Rect& r)
|
|
||||||
{
|
|
||||||
GuiLock __;
|
|
||||||
Rect rr = r + GetRect().TopLeft();
|
|
||||||
bool dummy;
|
|
||||||
DoPaint(Intersect(invalid, rr, dummy));
|
|
||||||
invalid = Subtract(invalid, rr, dummy);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Ctrl::WndScrollView0(const Rect& r, int dx, int dy)
|
void Ctrl::WndScrollView0(const Rect& r, int dx, int dy)
|
||||||
{
|
{
|
||||||
GuiLock __;
|
GuiLock __;
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,14 @@ struct App : public Ctrl {
|
||||||
w.Clipoff(200, 50, 95, 100);
|
w.Clipoff(200, 50, 95, 100);
|
||||||
w.DrawText(0, 80, "CLIPPED", Roman(25));
|
w.DrawText(0, 80, "CLIPPED", Roman(25));
|
||||||
w.End();
|
w.End();
|
||||||
|
|
||||||
|
DrawDragRect((SystemDraw&)w,
|
||||||
|
Rect(0, 0, 0, 0),
|
||||||
|
Rect(23, 165, 672, 301),
|
||||||
|
Size(1163, 513),
|
||||||
|
1,
|
||||||
|
Black(),
|
||||||
|
MAKEQWORD(Random(), Random()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LeftDown(Point p, dword)
|
void LeftDown(Point p, dword)
|
||||||
|
|
@ -85,6 +93,7 @@ GUI_APP_MAIN
|
||||||
{
|
{
|
||||||
#if EDITOR
|
#if EDITOR
|
||||||
RichEditWithToolBar app;
|
RichEditWithToolBar app;
|
||||||
|
app.SetQTF(LoadFile(ConfigFile("test.qtf")));
|
||||||
#else
|
#else
|
||||||
App app;
|
App app;
|
||||||
app.popup.PopUp();
|
app.popup.PopUp();
|
||||||
|
|
@ -107,4 +116,7 @@ GUI_APP_MAIN
|
||||||
top.Open();
|
top.Open();
|
||||||
#endif
|
#endif
|
||||||
Ctrl::EventLoop();
|
Ctrl::EventLoop();
|
||||||
|
#if EDITOR
|
||||||
|
SaveFile(ConfigFile("test.qtf"), app.GetQTF());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,8 @@ uses(SDLFB) SDLFb;
|
||||||
uses(WINGL) WinGl;
|
uses(WINGL) WinGl;
|
||||||
|
|
||||||
file
|
file
|
||||||
Draw.cpp;
|
Draw.cpp,
|
||||||
|
U:\h.txt;
|
||||||
|
|
||||||
mainconfig
|
mainconfig
|
||||||
"" = "GUI WINFB",
|
"" = "GUI WINFB",
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
NAMESPACE_UPP
|
NAMESPACE_UPP
|
||||||
|
|
||||||
#define LLOG(x) // LOG(x)
|
#define LLOG(x) LOG(x)
|
||||||
|
|
||||||
bool GetShift() { return !!(GetKeyState(VK_SHIFT) & 0x8000); }
|
bool GetShift() { return !!(GetKeyState(VK_SHIFT) & 0x8000); }
|
||||||
bool GetCtrl() { return !!(GetKeyState(VK_CONTROL) & 0x8000); }
|
bool GetCtrl() { return !!(GetKeyState(VK_CONTROL) & 0x8000); }
|
||||||
|
|
@ -58,6 +58,12 @@ LRESULT CALLBACK fbWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
HDC dc = BeginPaint(hwnd, &ps);
|
HDC dc = BeginPaint(hwnd, &ps);
|
||||||
fbUpdate(dc, ps.rcPaint);
|
fbUpdate(dc, ps.rcPaint);
|
||||||
|
#if 0
|
||||||
|
Rect r = ps.rcPaint;
|
||||||
|
::PatBlt(dc, r.left, r.top, r.GetWidth(), r.GetHeight(), DSTINVERT);
|
||||||
|
Sleep(40);
|
||||||
|
::PatBlt(dc, r.left, r.top, r.GetWidth(), r.GetHeight(), DSTINVERT);
|
||||||
|
#endif
|
||||||
EndPaint(hwnd, &ps);
|
EndPaint(hwnd, &ps);
|
||||||
}
|
}
|
||||||
return 0L;
|
return 0L;
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,9 @@ bool FBProcessEvent(bool *quit)
|
||||||
|
|
||||||
void FBSleep(int ms)
|
void FBSleep(int ms)
|
||||||
{
|
{
|
||||||
|
TimeStop tm;
|
||||||
MsgWaitForMultipleObjects(0, NULL, FALSE, ms, QS_ALLINPUT);
|
MsgWaitForMultipleObjects(0, NULL, FALSE, ms, QS_ALLINPUT);
|
||||||
|
DLOG("@ FBSleep " << tm.Elapsed());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FBInit(HINSTANCE hInstance)
|
void FBInit(HINSTANCE hInstance)
|
||||||
|
|
@ -60,10 +62,13 @@ void FBInit(HINSTANCE hInstance)
|
||||||
// Csizeinit();
|
// Csizeinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void fbUpdate(HDC hdc, const Rect& r)
|
void fbUpdate(HDC hdc, const Rect& r_)
|
||||||
{
|
{
|
||||||
const ImageBuffer& framebuffer = Ctrl::GetFrameBuffer();
|
const ImageBuffer& framebuffer = Ctrl::GetFrameBuffer();
|
||||||
Size sz = framebuffer.GetSize();
|
Size sz = framebuffer.GetSize();
|
||||||
|
Rect r = sz;
|
||||||
|
// Rect r = r_;
|
||||||
|
DLOG("fbUpdate " << r);
|
||||||
Buffer<byte> data;
|
Buffer<byte> data;
|
||||||
data.Alloc(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256);
|
data.Alloc(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256);
|
||||||
BITMAPINFOHEADER *hi = (BITMAPINFOHEADER *) ~data;;
|
BITMAPINFOHEADER *hi = (BITMAPINFOHEADER *) ~data;;
|
||||||
|
|
@ -84,7 +89,7 @@ void fbUpdate(HDC hdc, const Rect& r)
|
||||||
|
|
||||||
void FBUpdate(const Rect& r)
|
void FBUpdate(const Rect& r)
|
||||||
{
|
{
|
||||||
LLOG("FBUpdate " << r);
|
DLOG("FBUpdate " << r);
|
||||||
if(fbHWND) {
|
if(fbHWND) {
|
||||||
HDC hdc = GetDC(fbHWND);
|
HDC hdc = GetDC(fbHWND);
|
||||||
fbUpdate(hdc, r);
|
fbUpdate(hdc, r);
|
||||||
|
|
@ -95,6 +100,13 @@ void FBUpdate(const Rect& r)
|
||||||
#endif
|
#endif
|
||||||
ReleaseDC(fbHWND, hdc);
|
ReleaseDC(fbHWND, hdc);
|
||||||
}
|
}
|
||||||
|
// ::InvalidateRect(fbHWND, NULL, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FBFlush()
|
||||||
|
{
|
||||||
|
::UpdateWindow(fbHWND);
|
||||||
|
GdiFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
END_UPP_NAMESPACE
|
END_UPP_NAMESPACE
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
#define _WinGl_After_h_
|
#define _WinGl_After_h_
|
||||||
|
|
||||||
class ViewDraw : public SystemDraw {
|
class ViewDraw : public SystemDraw {
|
||||||
ImageBuffer ib;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ViewDraw(Ctrl *ctrl) {}
|
ViewDraw(Ctrl *ctrl) {}
|
||||||
~ViewDraw() {}
|
~ViewDraw() {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue