mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
.developing rainbow gtk
git-svn-id: svn://ultimatepp.org/upp/trunk@5652 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
e7e67654e2
commit
e9aec6c6d5
6 changed files with 61 additions and 30 deletions
|
|
@ -53,7 +53,7 @@ void SystemDraw::OffsetOp(Point p)
|
|||
|
||||
void SystemDraw::RectPath(const Rect& r)
|
||||
{
|
||||
cairo_rectangle(cr, r.left, r.top, r.GetWidth(), r.GetHeight());
|
||||
cairo_rectangle(cr, r.left, r.top, r.GetWidth() - 1, r.GetHeight() - 1);
|
||||
}
|
||||
|
||||
bool SystemDraw::ClipOp(const Rect& r)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ class SystemDraw : public Draw {
|
|||
|
||||
|
||||
private:
|
||||
void SetColor(Color c);
|
||||
void RectPath(const Rect& r);
|
||||
void Push();
|
||||
void Pop();
|
||||
|
|
@ -52,6 +51,7 @@ private:
|
|||
friend class ViewDraw;
|
||||
|
||||
public:
|
||||
void SetColor(Color c);
|
||||
operator cairo_t*() { return cr; }
|
||||
|
||||
Point GetOffset() const;
|
||||
|
|
|
|||
|
|
@ -129,18 +129,17 @@ bool Ctrl::Proc(GdkEvent *event)
|
|||
}
|
||||
break;
|
||||
case GDK_EXPOSE:
|
||||
case GDK_DAMAGE: {
|
||||
TimeStop tm;
|
||||
fullrefresh = false;
|
||||
GdkEventExpose *e = (GdkEventExpose *)event;
|
||||
SystemDraw w(gdk_cairo_create(top->window->window));
|
||||
painting = true;
|
||||
UpdateArea(w, RectC(e->area.x, e->area.y, e->area.width, e->area.height));
|
||||
cairo_destroy(w);
|
||||
painting = false;
|
||||
DDUMP(tm);
|
||||
case GDK_DAMAGE:
|
||||
if(top) {
|
||||
fullrefresh = false;
|
||||
GdkEventExpose *e = (GdkEventExpose *)event;
|
||||
SystemDraw w(gdk_cairo_create(gdk()));
|
||||
painting = true;
|
||||
UpdateArea(w, RectC(e->area.x, e->area.y, e->area.width, e->area.height));
|
||||
cairo_destroy(w);
|
||||
painting = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GDK_MOTION_NOTIFY: {
|
||||
GdkEventMotion *e = (GdkEventMotion *)event;
|
||||
DispatchMouse(MOUSEMOVE, Point((int)e->x, (int)e->y));
|
||||
|
|
@ -197,7 +196,7 @@ bool Ctrl::Proc(GdkEvent *event)
|
|||
GdkEventConfigure *e = (GdkEventConfigure *)event;
|
||||
Rect rect = RectC(e->x, e->y, e->width, e->height);
|
||||
LLOG("ConfigureNotify " << rect << ", GetRect() " << GetRect());
|
||||
// if(GetRect() != rect)
|
||||
if(GetRect() != rect)
|
||||
SetWndRect(rect);
|
||||
// TODO: Add DHCtrl support
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,24 +19,25 @@ Size GetScreenSize()
|
|||
}
|
||||
*/
|
||||
|
||||
static uint64 sGetAniPat(uint64 src, int pos)
|
||||
{
|
||||
uint64 out = 0;
|
||||
pos &= 7;
|
||||
for(int i = 8; --i >= 0;) {
|
||||
byte sr = (byte)(src >> (8 * ((7 - i - pos) & 7)));
|
||||
out = (out << 8) | (byte)((sr | (sr << 8)) >> pos);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void DrawDragRect(Ctrl& q, const Rect& rect1, const Rect& rect2, const Rect& clip, int n,
|
||||
Color color, int type, int animation)
|
||||
{
|
||||
ViewDraw w(&q);
|
||||
uint64 pattern = type == DRAWDRAGRECT_DASHED ? I64(0xf0783c1e0f87c3e1) :
|
||||
w.Clip(clip);
|
||||
cairo_t *cr = w;
|
||||
double dashes[] = { 1, 1, 1, 1, 1, 1, 1, 1 };
|
||||
w.SetColor(color);
|
||||
cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE);
|
||||
cairo_set_dash(cr, dashes, 8, 0);
|
||||
cairo_set_line_width(cr, 1);
|
||||
cairo_rectangle(cr, rect1.left + 0.5, rect1.top + 0.5, rect1.GetWidth() + 0.5, rect1.GetHeight() + 0.5);
|
||||
cairo_stroke(cr);
|
||||
cairo_rectangle(cr, rect2.left + 0.5, rect2.top + 0.5, rect2.GetWidth() + 0.5, rect2.GetHeight() + 0.5);
|
||||
cairo_stroke(cr);
|
||||
w.End();
|
||||
/* uint64 pattern = type == DRAWDRAGRECT_DASHED ? I64(0xf0783c1e0f87c3e1) :
|
||||
type == DRAWDRAGRECT_NORMAL ? I64(0x55aa55aa55aa55aa) : 0;
|
||||
DrawDragRect(w, rect1, rect2, clip, n, color, sGetAniPat(pattern, animation));
|
||||
DrawDragRect(w, rect1, rect2, clip, n, color, sGetAniPat(pattern, animation));*/
|
||||
}
|
||||
|
||||
GdkRect::GdkRect(const Rect& r)
|
||||
|
|
|
|||
|
|
@ -533,17 +533,22 @@ void Ctrl::WndScrollView0(const Rect& r, int dx, int dy)
|
|||
gdk_window_invalidate_rect(gdk(), GdkRect(r), true);
|
||||
}
|
||||
|
||||
Rect Ctrl::GetDefaultWindowRect() {
|
||||
Rect Ctrl::GetDefaultWindowRect() // ToDo!
|
||||
{
|
||||
return Rect(0, 0, 100, 100);
|
||||
}
|
||||
|
||||
ViewDraw::ViewDraw(Ctrl *ctrl)
|
||||
{
|
||||
EnterGuiMutex();
|
||||
Ctrl *top = ctrl->GetTopCtrl();
|
||||
cr = gdk_cairo_create(top->gdk());
|
||||
Clipoff(ctrl->GetScreenView() - top->GetScreenRect().TopLeft());
|
||||
}
|
||||
|
||||
ViewDraw::~ViewDraw()
|
||||
{
|
||||
cairo_destroy(cr);
|
||||
LeaveGuiMutex();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -157,6 +157,32 @@ struct MyApp2 : TopWindow {
|
|||
}
|
||||
};
|
||||
|
||||
struct MyApp3 : TopWindow {
|
||||
Rect rect;
|
||||
|
||||
typedef MyApp3 CLASSNAME;
|
||||
|
||||
virtual void Paint(Draw& w)
|
||||
{
|
||||
Size sz = GetSize();
|
||||
w.DrawRect(sz, SColorPaper());
|
||||
DrawFrame(w, rect, Black());
|
||||
}
|
||||
|
||||
virtual void LeftDown(Point p, dword keyflags) {
|
||||
RectTracker tr(*this);
|
||||
Size sz = GetSize();
|
||||
tr.Normal();
|
||||
rect = tr.Track(rect, ALIGN_RIGHT, ALIGN_BOTTOM);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
MyApp3() {
|
||||
rect = RectC(100, 100, 100, 100);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
#if 0
|
||||
|
|
@ -166,8 +192,8 @@ GUI_APP_MAIN
|
|||
return;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
MyApp2().Run();
|
||||
#if 1
|
||||
MyApp3().Run();
|
||||
return;
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue