.Developing rainbow FB

git-svn-id: svn://ultimatepp.org/upp/trunk@3701 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-07-22 16:07:57 +00:00
parent 5a4b55c12b
commit a2584eb8dc
6 changed files with 82 additions and 44 deletions

View file

@ -233,20 +233,6 @@ Vector<String> GetFiles(PasteClip& clip)
return f;
}
bool PasteClip::IsAvailable(const char *fmt) const
{
return IsClipboardAvailable(fmt);
}
String PasteClip::Get(const char *fmt) const
{
return ReadClipboard(fmt);
}
void PasteClip::GuiPlatformConstruct()
{
}
END_UPP_NAMESPACE
#endif

View file

@ -47,6 +47,7 @@ private:
friend struct PaintProxy__;
friend class TopWindowFrame;
friend class SystemDraw;
friend struct DnDLoop;
void SetOpen(bool b) { isopen = b; }
@ -74,6 +75,8 @@ public:
void DragRectDraw(const Rect& rect1, const Rect& rect2, const Rect& clip, int n,
Color color, int type, int animation);
static Ctrl *FindMouseTopCtrl();
static bool FullWindowDrag;
enum { DRAWDRAGRECT_SCREEN = 0x8000 };

View file

@ -16,14 +16,17 @@ Ctrl * Ctrl::GetDragAndDropSource()
}
struct DnDLoop : LocalLoop {
Image move, copy, reject;
const VectorMap<String, ClipData> *data;
Ptr<Ctrl> source;
int action;
Vector<String> fmts;
void Sync();
Image move, copy, reject;
Ptr<Ctrl> target;
int action;
byte actions;
void Sync();
String GetData(const String& f);
void Leave();
void DnD(bool paste);
virtual void LeftUp(Point, dword);
virtual bool Key(dword, int);
@ -33,20 +36,67 @@ struct DnDLoop : LocalLoop {
Ptr<DnDLoop> dndloop;
void DnDLoop::Leave()
bool PasteClip::IsAvailable(const char *fmt) const
{
GuiLock __;
DDUMP(fmt);
GuiLock __;
return dnd ? dndloop && FindIndex(dndloop->fmts, fmt) >= 0
: IsClipboardAvailable(fmt);
}
String DnDLoop::GetData(const String& f)
{
GuiLock __;
int i = data->Find(f);
String d;
if(i >= 0)
d = (*data)[i].Render();
else
if(sDnDSource)
d = sDnDSource->GetDropData(f);
return d;
}
String PasteClip::Get(const char *fmt) const
{
return dnd ? dndloop ? dndloop->GetData(fmt) : String() : ReadClipboard(fmt);
}
void PasteClip::GuiPlatformConstruct()
{
dnd = false;
}
void DnDLoop::DnD(bool paste)
{
PasteClip d;
d.paste = paste;
d.accepted = false;
d.allowed = (byte)actions;
d.action = GetCtrl() ? DND_COPY : DND_MOVE;
d.dnd = true;
if(target)
target->DnD(GetMousePos() - target->GetScreenRect().TopLeft(), d);
action = d.IsAccepted() ? d.GetAction() : DND_NONE;
}
void DnDLoop::Sync()
{
GuiLock __;
GuiLock __;
Ptr<Ctrl> t = FindMouseTopCtrl();
if(t != target)
if(target)
target->DnDLeave();
target = t;
DnD(false);
}
void DnDLoop::LeftUp(Point, dword)
{
GuiLock __;
LLOG("DnDLoop::LeftUp");
DnD(true);
/* if(target) {
LLOG("Sending XdndDrop to " << target);
XEvent e = ClientMsg(target, XdndDrop);
@ -95,34 +145,21 @@ Image DnDLoop::CursorImage(Point, dword)
return action == DND_MOVE ? move : action == DND_COPY ? copy : reject;
}
String DnDLoop::GetData(const String& f)
{
GuiLock __;
int i = data->Find(f);
String d;
if(i >= 0)
d = (*data)[i].Render();
else
if(source)
d = source->GetDropData(f);
return d;
}
int Ctrl::DoDragAndDrop(const char *fmts, const Image& sample, dword actions,
const VectorMap<String, ClipData>& data)
{
GuiLock __;
DnDLoop d;
PNGEncoder().SaveFile("U://sample.png", sample); _DBG_
d.actions = actions;
d.reject = actions & DND_EXACTIMAGE ? CtrlCoreImg::DndNone() : MakeDragImage(CtrlCoreImg::DndNone(), sample);
PNGEncoder().SaveFile("U://reject.png", d.reject); _DBG_
if(actions & DND_COPY)
d.copy = actions & DND_EXACTIMAGE ? sample : MakeDragImage(CtrlCoreImg::DndCopy(), sample);
if(actions & DND_MOVE)
d.move = actions & DND_EXACTIMAGE ? sample : MakeDragImage(CtrlCoreImg::DndMoveX11(), sample);
d.SetMaster(*this);
d.data = &data;
d.source = this;
d.action = DND_NONE;
d.fmts = Split(fmts, ';');
dndloop = &d;
sDnDSource = this;
d.Run();

View file

@ -32,6 +32,16 @@ void Ctrl::MouseEventFB(Ptr<Ctrl> t, int event, Point p, int zdelta)
t->PostInput();
}
Ctrl *Ctrl::FindMouseTopCtrl()
{
for(int i = topctrl.GetCount() - 1; i >= 0; i--) {
Ctrl *t = topctrl[i];
if(t->GetRect().Contains(fbmousepos))
return t->IsEnabled() ? t : NULL;
}
return desktop->IsEnabled() ? desktop : NULL;
}
void Ctrl::DoMouseFB(int event, Point p, int zdelta)
{
fbmousepos = p;

View file

@ -95,7 +95,9 @@ class TopWindowFrame;
#define GUIPLATFORM_CTRL_DECLS_INCLUDE <Framebuffer/Ctrl.h>
#define GUIPLATFORM_PASTECLIP_DECLS
#define GUIPLATFORM_PASTECLIP_DECLS \
bool dnd; \
friend struct DnDLoop; \
#define GUIPLATFORM_TOPWINDOW_DECLS_INCLUDE <Framebuffer/Top.h>

View file

@ -4,9 +4,9 @@
NAMESPACE_UPP
#define LLOG(x) //DLOG(x)
#define LDUMP(x) //DDUMP(x)
#define LDUMPC(x) //DDUMPC(x)
#define LLOG(x) DLOG(x)
#define LDUMP(x) DDUMP(x)
#define LDUMPC(x) DDUMPC(x)
ImageBuffer Ctrl::framebuffer;
Vector<Rect> Ctrl::invalid;
@ -419,7 +419,7 @@ void Ctrl::EventLoop0(Ctrl *ctrl)
ASSERT(IsMainThread());
ASSERT(LoopLevel == 0 || ctrl);
LoopLevel++;
LLOG("Entering event loop at level " << LoopLevel << BeginIndent);
LLOG("Entering event loop at level " << LoopLevel << LOG_BEGIN);
Ptr<Ctrl> ploop;
if(ctrl) {
ploop = LoopCtrl;
@ -447,7 +447,7 @@ void Ctrl::EventLoop0(Ctrl *ctrl)
if(ctrl)
LoopCtrl = ploop;
LoopLevel--;
LLOG(EndIndent << "Leaving event loop ");
LLOG(LOG_END << "Leaving event loop ");
}
void Ctrl::GuiSleep0(int ms)