mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
.Developing TURTLE
git-svn-id: svn://ultimatepp.org/upp/trunk@6713 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
48e58356e6
commit
f8ea64c209
31 changed files with 3328 additions and 3 deletions
98
rainbow/Turtle/DrawDragRect.cpp
Normal file
98
rainbow/Turtle/DrawDragRect.cpp
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
#include "Local.h"
|
||||
|
||||
#ifdef GUI_TURTLE
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
struct DrawDragRectInfo {
|
||||
Rect rect1, rect2, clip;
|
||||
int n;
|
||||
int type;
|
||||
int animation;
|
||||
};
|
||||
|
||||
void DrawDragLine(SystemDraw& w, bool horz, int x, int y, int len, int n, const int *pattern, int animation)
|
||||
{
|
||||
if(len <= 0)
|
||||
return;
|
||||
if(horz)
|
||||
w.Clip(x, y, len, n);
|
||||
else
|
||||
w.Clip(x, y, n, len);
|
||||
|
||||
(horz ? x : y) -= animation;
|
||||
len += animation;
|
||||
bool ch = false;
|
||||
while(len > 0) {
|
||||
int segment = pattern[ch];
|
||||
int d = segment + pattern[2];
|
||||
if(horz) {
|
||||
w.DrawRect(x, y, segment, n, InvertColor());
|
||||
x += d;
|
||||
}
|
||||
else {
|
||||
w.DrawRect(x, y, n, segment, InvertColor());
|
||||
y += d;
|
||||
}
|
||||
len -= d;
|
||||
ch = !ch;
|
||||
}
|
||||
w.End();
|
||||
}
|
||||
|
||||
void DrawDragFrame(SystemDraw& w, const Rect& r, int n, const int *pattern, int animation)
|
||||
{
|
||||
DrawDragLine(w, true, r.left, r.top, r.GetWidth(), n, pattern, animation);
|
||||
DrawDragLine(w, false, r.left, r.top + n, r.GetHeight() - 2 * n, n, pattern, animation);
|
||||
DrawDragLine(w, false, r.right - n, r.top + n, r.GetHeight() - 2 * n, n, pattern, animation);
|
||||
DrawDragLine(w, true, r.left, r.bottom - n, r.GetWidth(), n, pattern, animation);
|
||||
}
|
||||
|
||||
void DrawDragRect(Ctrl& q, const DrawDragRectInfo& f)
|
||||
{
|
||||
_TODO_
|
||||
SystemDraw w;
|
||||
Ctrl::PaintScene(w);
|
||||
w.Clip(f.clip);
|
||||
static int dashes[3][3] = {
|
||||
{ 32, 32, 0 },
|
||||
{ 1, 1, 1 },
|
||||
{ 5, 1, 2 },
|
||||
};
|
||||
const int *dash = dashes[minmax(f.type, 0, 2)];
|
||||
DrawDragFrame(w, f.rect1, f.n, dash, f.animation);
|
||||
DrawDragFrame(w, f.rect2, f.n, dash, f.animation);
|
||||
// w.End();
|
||||
Ctrl::PaintCaretCursor(w);
|
||||
// SDL_GL_SwapWindow(screen.win);
|
||||
}
|
||||
|
||||
void DrawDragRect(Ctrl& q, const Rect& rect1, const Rect& rect2, const Rect& clip, int n,
|
||||
Color color, int type, int animation)
|
||||
{
|
||||
Ctrl *top = q.GetTopCtrl();
|
||||
if(top) {
|
||||
Point off = q.GetScreenView().TopLeft();
|
||||
DrawDragRectInfo f;
|
||||
f.rect1 = rect1.Offseted(off);
|
||||
f.rect2 = rect2.Offseted(off);
|
||||
f.clip = (clip & q.GetSize()).Offseted(off);
|
||||
f.n = n;
|
||||
f.type = type;
|
||||
f.animation = animation;
|
||||
DrawDragRect(*top, f);
|
||||
}
|
||||
}
|
||||
|
||||
void FinishDragRect(Ctrl& q)
|
||||
{
|
||||
SystemDraw w;
|
||||
Ctrl::PaintScene(w);
|
||||
Ctrl::PaintCaretCursor(w);
|
||||
_TODO_
|
||||
//SDL_GL_SwapWindow(screen.win);
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue