mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-06-30 06:12:22 -06:00
Removed ScrollView
This commit is contained in:
parent
f5613f8931
commit
ce2b59db08
6 changed files with 2 additions and 251 deletions
|
|
@ -19,7 +19,6 @@
|
|||
#define GUIPLATFORM_KEYCODES_INCLUDE <Turtle/Keys.h>
|
||||
//need to make SDL_keysym.h known before K_ enum
|
||||
#define GUIPLATFORM_INCLUDE <Turtle/Turtle.h>
|
||||
#define GUIPLATFORM_NOSCROLL
|
||||
#define PLATFORM_TURTLE
|
||||
#define TURTLE
|
||||
#elif VIRTUALGUI
|
||||
|
|
@ -27,7 +26,6 @@
|
|||
#define GUIPLATFORM_INCLUDE <VirtualGui/VirtualGui.h>
|
||||
#elif PLATFORM_COCOA
|
||||
#define GUIPLATFORM_INCLUDE "Coco.h"
|
||||
#define GUIPLATFORM_NOSCROLL
|
||||
#elif PLATFORM_WIN32
|
||||
#define GUIPLATFORM_INCLUDE "Win32Gui.h"
|
||||
#else
|
||||
|
|
@ -499,12 +497,6 @@ private:
|
|||
Rect GetView() const { return Rect16(view.left, view.top, view.right, view.bottom); }
|
||||
};
|
||||
|
||||
struct Scroll : Moveable<Scroll> {
|
||||
Rect rect;
|
||||
int dx;
|
||||
int dy;
|
||||
};
|
||||
|
||||
struct MoveCtrl : Moveable<MoveCtrl> {
|
||||
Ptr<Ctrl> ctrl;
|
||||
Rect from;
|
||||
|
|
@ -515,9 +507,6 @@ private:
|
|||
|
||||
struct Top {
|
||||
GUIPLATFORM_CTRL_TOP_DECLS
|
||||
Vector<Scroll> scroll;
|
||||
VectorMap<Ctrl *, MoveCtrl> move;
|
||||
VectorMap<Ctrl *, MoveCtrl> scroll_move;
|
||||
Ptr<Ctrl> owner;
|
||||
};
|
||||
|
||||
|
|
@ -623,7 +612,6 @@ private:
|
|||
void UpdateRect(bool sync = true);
|
||||
void SetPos0(LogPos p, bool inframe);
|
||||
void SetWndRect(const Rect& r);
|
||||
void SyncMoves();
|
||||
|
||||
static void EndIgnore();
|
||||
static void LRep();
|
||||
|
|
@ -683,11 +671,7 @@ private:
|
|||
static void DnDLeave();
|
||||
|
||||
void SyncLayout(int force = 0);
|
||||
bool AddScroll(const Rect& sr, int dx, int dy);
|
||||
Rect GetClippedView();
|
||||
void ScrollRefresh(const Rect& r, int dx, int dy);
|
||||
void ScrollCtrl(Top *top, Ctrl *q, const Rect& r, Rect cr, int dx, int dy);
|
||||
void SyncScroll();
|
||||
void Refresh0(const Rect& area);
|
||||
void PaintCaret(SystemDraw& w);
|
||||
void CtrlPaint(SystemDraw& w, const Rect& clip);
|
||||
|
|
@ -732,8 +716,6 @@ private:
|
|||
|
||||
void WndInvalidateRect(const Rect& r);
|
||||
|
||||
void WndScrollView(const Rect& r, int dx, int dy);
|
||||
|
||||
void SetWndForeground();
|
||||
bool IsWndForeground() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -76,46 +76,6 @@ void Ctrl::RefreshFrame() {
|
|||
RefreshFrame(Rect(GetRect().Size()).Inflated(overpaint));
|
||||
}
|
||||
|
||||
void Ctrl::ScrollRefresh(const Rect& r, int dx, int dy)
|
||||
{
|
||||
sCheckGuiLock();
|
||||
GuiLock __; // Beware: Even if we have ThreadHasGuiLock ASSERT, we still can be the main thread!
|
||||
LLOG("ScrollRefresh " << r << " " << dx << " " << dy);
|
||||
if(!IsOpen() || !IsVisible() || r.IsEmpty()) return;
|
||||
int tdx = tabs(dx), tdy = tabs(dy);
|
||||
if(dx) WndInvalidateRect(RectC(dx >= 0 ? r.left : r.right - tdx, r.top - tdy, tdx, r.Height()));
|
||||
if(dy) WndInvalidateRect(RectC(r.left - tdx, dy >= 0 ? r.top : r.bottom - tdy, r.Width(), tdy));
|
||||
}
|
||||
|
||||
bool Ctrl::AddScroll(const Rect& sr, int dx, int dy)
|
||||
{
|
||||
GuiLock __;
|
||||
Top *top = GetTop();
|
||||
if(!top)
|
||||
return true;
|
||||
for(int i = 0; i < top->scroll.GetCount(); i++) {
|
||||
Scroll& sc = top->scroll[i];
|
||||
if(sc.rect == sr && sgn(dx) == sgn(sc.dx) && sgn(dy) == sgn(sc.dy)) {
|
||||
sc.dx += dx;
|
||||
sc.dy += dy;
|
||||
ScrollRefresh(sc.rect, sc.dx, sc.dy);
|
||||
return false;
|
||||
}
|
||||
if(sc.rect.Intersects(sr)) {
|
||||
sc.rect |= sr;
|
||||
sc.dx = sc.dy = 0;
|
||||
WndInvalidateRect(sc.rect);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Scroll& sc = top->scroll.Add();
|
||||
sc.rect = sr;
|
||||
sc.dx = dx;
|
||||
sc.dy = dy;
|
||||
ScrollRefresh(sc.rect, sc.dx, sc.dy);
|
||||
return false;
|
||||
}
|
||||
|
||||
Rect Ctrl::GetClippedView()
|
||||
{
|
||||
GuiLock __;
|
||||
|
|
@ -131,84 +91,11 @@ Rect Ctrl::GetClippedView()
|
|||
return view - GetScreenRect().TopLeft();
|
||||
}
|
||||
|
||||
void Ctrl::ScrollCtrl(Top *top, Ctrl *q, const Rect& r, Rect cr, int dx, int dy)
|
||||
{
|
||||
if(top && r.Intersects(cr)) { // Uno: Contains -> Intersetcs
|
||||
Rect to = cr;
|
||||
GetTopRect(to, false);
|
||||
if(r.Intersects(cr.Offseted(-dx, -dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs
|
||||
Rect from = cr.Offseted(-dx, -dy);
|
||||
GetTopRect(from, false);
|
||||
MoveCtrl *m = FindMoveCtrlPtr(top->move, q);
|
||||
if(m && m->from == from && m->to == to) {
|
||||
LLOG("ScrollView Matched " << from << " -> " << to);
|
||||
m->ctrl = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(r.Intersects(cr.Offseted(dx, dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs
|
||||
Rect from = to;
|
||||
to = cr.Offseted(dx, dy);
|
||||
GetTopRect(to, false);
|
||||
MoveCtrl& m = top->scroll_move.Add(q);
|
||||
m.from = from;
|
||||
m.to = to;
|
||||
m.ctrl = q;
|
||||
LLOG("ScrollView Add " << UPP::Name(q) << from << " -> " << to);
|
||||
return;
|
||||
}
|
||||
cr &= r;
|
||||
if(!cr.IsEmpty()) {
|
||||
Refresh(cr);
|
||||
Refresh(cr + Point(dx, dy));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Ctrl::ScrollView(const Rect& _r, int dx, int dy)
|
||||
{
|
||||
GuiLock __;
|
||||
LLOG("ScrollView " << _r << " " << dx << " " << dy);
|
||||
#ifdef GUIPLATFORM_NOSCROLL
|
||||
LLOG("NOSCROLL");
|
||||
Refresh(_r);
|
||||
#else
|
||||
if(IsFullRefresh() || !IsVisible())
|
||||
return;
|
||||
if(IsDHCtrl()) {
|
||||
Refresh(_r);
|
||||
return;
|
||||
}
|
||||
Size vsz = GetSize();
|
||||
dx = sgn(dx) * min(abs(dx), vsz.cx);
|
||||
dy = sgn(dy) * min(abs(dy), vsz.cy);
|
||||
Rect r = _r & vsz;
|
||||
LLOG("ScrollView2 " << r << " " << dx << " " << dy);
|
||||
Ctrl *w;
|
||||
for(w = this; w->GetParent(); w = w->GetParent())
|
||||
if(w->InFrame()) {
|
||||
Refresh();
|
||||
return;
|
||||
}
|
||||
if(!w || !w->top) return;
|
||||
Rect view = InFrame() ? GetView() : GetClippedView();
|
||||
Rect sr = (r + view.TopLeft()) & view;
|
||||
sr += GetScreenRect().TopLeft() - w->GetScreenRect().TopLeft();
|
||||
if(w->AddScroll(sr, dx, dy))
|
||||
Refresh();
|
||||
else {
|
||||
LTIMING("ScrollCtrls1");
|
||||
Top *top = GetTopCtrl()->GetTop();
|
||||
for(Ctrl *q = GetFirstChild(); q; q = q->GetNext())
|
||||
if(q->InView())
|
||||
ScrollCtrl(top, q, r, q->GetRect(), dx, dy);
|
||||
if(GetParent())
|
||||
for(Ctrl *q = GetParent()->GetFirstChild(); q; q = q->GetNext())
|
||||
if(q->InView() && q != this)
|
||||
ScrollCtrl(top, q, r, q->GetScreenRect() - GetScreenView().TopLeft(), dx, dy);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Ctrl::ScrollView(int x, int y, int cx, int cy, int dx, int dy) {
|
||||
|
|
@ -219,30 +106,6 @@ void Ctrl::ScrollView(int dx, int dy) {
|
|||
ScrollView(Rect(GetSize()), dx, dy);
|
||||
}
|
||||
|
||||
void Ctrl::SyncScroll()
|
||||
{
|
||||
GuiLock __;
|
||||
Top *top = GetTop();
|
||||
if(!top)
|
||||
return;
|
||||
Vector<Scroll> scroll = pick(top->scroll);
|
||||
top->scroll.Clear();
|
||||
if(IsFullRefresh())
|
||||
return;
|
||||
for(int i = 0; i < scroll.GetCount(); i++) {
|
||||
Scroll& sc = scroll[i];
|
||||
if(abs(sc.dx) > 3 * sc.rect.Width() / 4 || abs(sc.dy) > 3 * sc.rect.Height() / 4) {
|
||||
LLOG("Sync scroll Invalidate rect" << sc.rect);
|
||||
WndInvalidateRect(sc.rect);
|
||||
}
|
||||
else
|
||||
if(sc.dx || sc.dy) {
|
||||
LLOG("WndScrollView " << sc.rect);
|
||||
WndScrollView(sc.rect, sc.dx, sc.dy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rect Ctrl::GetOpaqueRect() const
|
||||
{
|
||||
return IsTransparent() ? Rect(0, 0, 0, 0) : GetSize();
|
||||
|
|
@ -496,10 +359,8 @@ void Ctrl::DoSync(Ctrl *q, Rect r, bool inframe)
|
|||
ASSERT(q);
|
||||
LLOG("DoSync " << UPP::Name(q) << " " << r);
|
||||
Ctrl *top = q->GetTopRect(r, inframe);
|
||||
if(top && top->IsOpen()) {
|
||||
top->SyncScroll();
|
||||
if(top && top->IsOpen())
|
||||
top->WndUpdate(r);
|
||||
}
|
||||
}
|
||||
|
||||
void Ctrl::Sync()
|
||||
|
|
@ -509,7 +370,6 @@ void Ctrl::Sync()
|
|||
Ctrl *parent = GetParent();
|
||||
if(top && IsOpen()) {
|
||||
LLOG("Sync UpdateWindow " << Name());
|
||||
SyncScroll();
|
||||
WndUpdate();
|
||||
}
|
||||
else
|
||||
|
|
@ -559,30 +419,6 @@ void Ctrl::DrawCtrl(Draw& w, int x, int y)
|
|||
w.End();
|
||||
}
|
||||
|
||||
void Ctrl::SyncMoves()
|
||||
{
|
||||
GuiLock __;
|
||||
Top *top = GetTop();
|
||||
if(!top)
|
||||
return;
|
||||
for(int i = 0; i < top->move.GetCount(); i++) {
|
||||
MoveCtrl& m = top->move[i];
|
||||
if(m.ctrl) {
|
||||
RefreshFrame(m.from);
|
||||
RefreshFrame(m.to);
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < top->scroll_move.GetCount(); i++) {
|
||||
MoveCtrl& s = top->scroll_move[i];
|
||||
if(s.ctrl) {
|
||||
RefreshFrame(s.from);
|
||||
RefreshFrame(s.to);
|
||||
}
|
||||
}
|
||||
top->move.Clear();
|
||||
top->scroll_move.Clear();
|
||||
}
|
||||
|
||||
void Ctrl::GlobalBackPaint(bool b)
|
||||
{
|
||||
GuiLock __;
|
||||
|
|
|
|||
|
|
@ -228,18 +228,6 @@ void Ctrl::SetPos0(LogPos p, bool _inframe)
|
|||
Rect to = GetRect().Size();
|
||||
UpdateRect0();
|
||||
GetTopRect(to, true);
|
||||
MoveCtrl *s = FindMoveCtrlPtr(top->scroll_move, this);
|
||||
if(s && s->from == from && s->to == to) {
|
||||
s->ctrl = NULL;
|
||||
LLOG("SetPos Matched " << from << " -> " << to);
|
||||
}
|
||||
else {
|
||||
MoveCtrl& m = top->move.Add(this);
|
||||
m.ctrl = this;
|
||||
m.from = from;
|
||||
m.to = to;
|
||||
LLOG("SetPos Add " << UPP::Name(this) << from << " -> " << to);
|
||||
}
|
||||
StateH(POSITION);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -417,8 +417,6 @@ LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
|
|||
ASSERT(hwnd);
|
||||
if(hwnd) {
|
||||
PAINTSTRUCT ps;
|
||||
if(IsVisible())
|
||||
SyncScroll();
|
||||
HDC dc = BeginPaint(hwnd, &ps);
|
||||
fullrefresh = false;
|
||||
if(IsVisible()) {
|
||||
|
|
|
|||
|
|
@ -680,10 +680,7 @@ LRESULT CALLBACK Ctrl::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
|||
int ticks = msecs();
|
||||
String wname = w->Name();
|
||||
#endif
|
||||
Ptr<Ctrl> pw = w;
|
||||
l = w->WindowProc(message, wParam, lParam);
|
||||
if(pw)
|
||||
pw->SyncMoves();
|
||||
#if LOGTIMING
|
||||
String msgname;
|
||||
for(WinMsg *m = sWinMsg; m->ID; m++)
|
||||
|
|
@ -1159,20 +1156,6 @@ void Ctrl::WndUpdate(const Rect& r)
|
|||
}
|
||||
}
|
||||
|
||||
void Ctrl::WndScrollView(const Rect& r, int dx, int dy)
|
||||
{
|
||||
GuiLock __;
|
||||
LLOG("WndScrollView " << UPP::Name(this));
|
||||
if(caretCtrl && caretCtrl->GetTopCtrl() == this)
|
||||
RefreshCaret();
|
||||
#ifdef PLATFORM_WINCE
|
||||
::ScrollWindowEx(GetHWND(), dx, dy, r, r, NULL, NULL, 0);
|
||||
#else
|
||||
::ScrollWindow(GetHWND(), dx, dy, r, r);
|
||||
#endif
|
||||
SyncCaret();
|
||||
}
|
||||
|
||||
void Ctrl::PopUpHWND(HWND owner, bool savebits, bool activate, bool dropshadow, bool topmost)
|
||||
{
|
||||
LLOG("PopUpHWND " << UPP::Name(this) << ", owner: " << owner << ", activate: " << activate);
|
||||
|
|
|
|||
|
|
@ -1700,52 +1700,16 @@ Actual repaint is deferred for performance reasons.&]
|
|||
[s5;:Ctrl`:`:ScrollView`(const Rect`&`,int`,int`):%- [@(0.0.255) void]_[* ScrollView]([@(0.0.255) c
|
||||
onst]_[_^Rect^ Rect][@(0.0.255) `&]_[*@3 r], [@(0.0.255) int]_[*@3 dx],
|
||||
[@(0.0.255) int]_[*@3 dy])&]
|
||||
[s2; Marks requested view rectangle for repainting, indicating that
|
||||
part of this repaint can be done by scrolling current content
|
||||
of rectangle. Note that actual scroll is deferred to repaint
|
||||
and that U`+`+ is still allowed to solve the situation by repainting
|
||||
rather than scrolling.&]
|
||||
[s7;i1120;a17; [%-*C@3 r]-|Area for repainting.&]
|
||||
[s7;i1120;a17; [%-*C@3 dx]-|Horizontal scroll.&]
|
||||
[s7;i1120;a17; [%-*C@3 dy]-|Vertical scroll.&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:Ctrl`:`:ScrollView`(int`,int`,int`,int`,int`,int`):%- [@(0.0.255) void]_[* ScrollVie
|
||||
w]([@(0.0.255) int]_[*@3 x], [@(0.0.255) int]_[*@3 y], [@(0.0.255) int]_[*@3 cx],
|
||||
[@(0.0.255) int]_[*@3 cy], [@(0.0.255) int]_[*@3 dx], [@(0.0.255) int]_[*@3 dy])&]
|
||||
[s2;b17;a17; Marks requested view rectangle for repainting, indicating
|
||||
that part of this repaint can be done by scrolling current content
|
||||
of rectangle. Note that actual scroll is deferred to repaint
|
||||
and that U`+`+ is still allowed to solve the situation by repainting
|
||||
rather than scrolling.&]
|
||||
[s7;i1120;a17; [%-*C@3 r]-|Area for repainting.&]
|
||||
[s7;i1120;a17; [%-*C@3 x]-|Left position of rectangle.&]
|
||||
[s7;i1120;a17; [%-*C@3 y]-|Top position of rectangle.&]
|
||||
[s7;i1120;a17; [%-*C@3 cx]-|Width.&]
|
||||
[s7;i1120;a17; [%-*C@3 cy]-|Height.&]
|
||||
[s7;i1120;a17; [%-*C@3 dx]-|Horizontal scroll.&]
|
||||
[s7;i1120;a17; [%-*C@3 dy]-|Vertical scroll.&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:Ctrl`:`:ScrollView`(int`,int`):%- [@(0.0.255) void]_[* ScrollView]([@(0.0.255) int]_[*@3 d
|
||||
x], [@(0.0.255) int]_[*@3 dy])&]
|
||||
[s2;b17;a17; Marks while view area for repainting, indicating that
|
||||
part of this repaint can be done by scrolling current content
|
||||
of rectangle. Note that actual scroll is deferred to repaint
|
||||
and that U`+`+ is still allowed to solve the situation by repainting
|
||||
rather than scrolling.&]
|
||||
[s7;i1120;a17; [%-*C@3 dx]-|Horizontal scroll.&]
|
||||
[s7;i1120;a17; [%-*C@3 dy]-|Vertical scroll.&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:Ctrl`:`:ScrollView`(const Rect`&`,Size`):%- [@(0.0.255) void]_[* ScrollView]([@(0.0.255) c
|
||||
onst]_[_^`:`:Rect^ Rect][@(0.0.255) `&]_[*@3 r], [_^`:`:Size^ Size]_[*@3 delta])&]
|
||||
[s2;b17;a17; Same as ScrollView(r, delta.cx, delta.cy).&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:Ctrl`:`:ScrollView`(Size`):%- [@(0.0.255) void]_[* ScrollView]([_^`:`:Size^ Size]_[*@3 d
|
||||
elta])&]
|
||||
[s2;b17;a17; Same as ScrollView(delta.cx, delta.cy).&]
|
||||
[s2;b17;a17; Deprecated. Same as calling Refresh().&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:Ctrl`:`:Sync`(`):%- [@(0.0.255) void]_[* Sync]()&]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue