CtrlLib: Chameleon now can draw ink masks, EditField look improved

git-svn-id: svn://ultimatepp.org/upp/trunk@13899 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2020-01-16 12:18:50 +00:00
parent 7435416964
commit 99c123287c
17 changed files with 204 additions and 348 deletions

View file

@ -266,89 +266,7 @@ struct sDrawLevelCheck {
#define LEVELCHECK(w, q)
#define DOLEVELCHECK
#endif
#if defined(flagWINGL) || defined(flagLINUXGL)
void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) {
GuiLock __;
LEVELCHECK(w, this);
LTIMING("CtrlPaint");
Rect rect = GetRect().GetSize();
Rect orect = rect.Inflated(overpaint);
if(!IsShown() || orect.IsEmpty() || clip.IsEmpty() || !clip.Intersects(orect))
return;
w.PushContext();
//glPushMatrix();
ApplyTransform(TS_BEFORE_CTRL_PAINT);
Ctrl *q;
Rect view = rect;
for(int i = 0; i < frame.GetCount(); i++) {
LEVELCHECK(w, NULL);
frame[i].frame->FramePaint(w, view);
view = frame[i].view;
}
Rect oview = view.Inflated(overpaint);
bool hasviewctrls = false;
bool viewexcluded = false;
for(q = firstchild; q; q = q->next)
if(q->IsShown())
if(q->InFrame()) {
if(!viewexcluded && IsTransparent() && q->GetRect().Intersects(view)) {
w.Begin();
w.ExcludeClip(view);
viewexcluded = true;
}
LEVELCHECK(w, q);
Point off = q->GetRect().TopLeft();
w.Offset(off);
q->CtrlPaint(w, clip - off);
w.End();
}
else
hasviewctrls = true;
if(viewexcluded)
w.End();
//DOLEVELCHECK;
if(!oview.IsEmpty() && oview.Intersects(clip)) {
LEVELCHECK(w, this);
if(cliptobounds)
w.Clip(overpaint ? oview : view);
w.Offset(view.left, view.top);
Paint(w);
PaintCaret(w);
w.End();
if(hasviewctrls && !view.IsEmpty()) {
Rect cl = clip & view;
for(q = firstchild; q; q = q->next)
if(q->IsShown() && q->InView()) {
Rect rr(q->popup ? clip : cl);
LEVELCHECK(w, q);
Rect qr = q->GetRect();
Point off = qr.TopLeft() + view.TopLeft();
Rect ocl = cl - off;
if(ocl.Intersects(Rect(qr.GetSize()).Inflated(overpaint))) {
w.Offset(off);
q->CtrlPaint(w, rr - off);
w.End();
}
}
}
if(cliptobounds)
w.End();
}
ApplyTransform(TS_AFTER_CTRL_PAINT);
//glPopMatrix();
w.PopContext();
DOLEVELCHECK;
}
#else
void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) {
GuiLock __;
LEVELCHECK(w, this);
@ -426,7 +344,6 @@ void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) {
}
DOLEVELCHECK;
}
#endif
int sShowRepaint;

View file

@ -591,13 +591,8 @@ Image Ctrl::DispatchMouse(int e, Point p, int zd) {
Image Ctrl::DispatchMouseEvent(int e, Point p, int zd) {
GuiLock __;
#if defined(flagWINGL) || defined(flagLINUXGL)
if(!IsEnabled() && this != (Ctrl*) &infoPanel)
return Image::Arrow();
#else
if(!IsEnabled())
return Image::Arrow();
#endif
if(captureCtrl && captureCtrl != this && captureCtrl->IsMouseActive())
return captureCtrl->MEvent0(e, p + GetScreenRect().TopLeft() -
captureCtrl->GetScreenRect().TopLeft(), zd);

View file

@ -1,7 +1,8 @@
- Possible issue with Capture (e.g. ide about box)
- Issue with editfield text clipping in the right
- DropChoice STDSIZE (.TopPosZ(10))
- LeftRoundness with DropChoice (DropChoiceRdO)
- Possible issue with Capture (e.g. ide about box)
- DnD crash?
- GUILock docs
@ -11,7 +12,6 @@ CH:
- Improve scrollbars button borders
- spinbutton cosmetics
- Error state (red) EditField cosmetics
- Pushbutton push does not look nice
- DarkCold: problem slight problem with scrollbars
@ -75,3 +75,4 @@ DONE:
- ide menu in X11 ch
- TrayIconGtk warnings
- Disabled empty combobox (FileSel::SelectDir) does not look nice
- Error state (red) EditField cosmetics

View file

@ -834,19 +834,30 @@ DataPusher::DataPusher()
{
convert = &NoConvert();
display = &StdDisplay();
SetFrame(EditFieldFrame());
SyncEdge();
SetFrame(edge);
}
void DataPusher::SyncEdge()
{
edge.Set(this, EditField::StyleDefault().edge, EditField::StyleDefault().activeedge);
edge.Mouse(HasMouse());
edge.Push(IsPush());
RefreshFrame();
}
DataPusher::DataPusher(const Convert& convert, const Display& display)
: convert(&convert), display(&display)
{
SetFrame(EditFieldFrame());
SyncEdge();
SetFrame(edge);
}
DataPusher::DataPusher(const Display& display)
: convert(&NoConvert()), display(&display)
{
SetFrame(EditFieldFrame());
SyncEdge();
SetFrame(edge);
}
void DataPusher::PerformAction()
@ -926,4 +937,14 @@ void DataPusher::SetDataAction(const Value& value)
UpdateActionRefresh();
}
void DataPusher::RefreshPush()
{
SyncEdge();
}
void DataPusher::RefreshFocus()
{
SyncEdge();
}
}

View file

@ -287,12 +287,18 @@ void ChSynthetic(Image button100x100[4], Color text[4])
roundness = GetRoundness(m) ? DPI(3) : 0;
CtrlsImg::Set(CtrlsImg::I_EFE, WithHotSpots(MakeButton(roundness, SColorPaper(), DPI(1), ink), DPI(3), DPI(1), 0, 0));
CtrlsImg::Set(CtrlsImg::I_VE, WithHotSpots(MakeButton(DPI(0), SColorPaper(), DPI(1), ink), DPI(2), DPI(2), 0, 0));
EditField::StyleDefault().Write().edge[CTRL_DISABLED] = WithHotSpots(MakeButton(roundness, SColorFace(), DPI(1), ink), DPI(3), DPI(1), 0, 0);
EditField::StyleDefault().Write().activeedge = true;
LabelBox::SetLook(WithHotSpots(MakeButton(2 * roundness / 3, Image(), DPI(1), ink), DPI(3), DPI(3), 0, 0));
}
Size sz = m.GetSize();
m = Crop(m, sz.cx / 8, sz.cy / 8, 6 * sz.cx / 8, 6 * sz.cy / 8);
{
EditField::Style& s = EditField::StyleDefault().Write();
s.activeedge = true;
s.edge[i] = WithHotSpots(MakeButton(roundness, i == CTRL_DISABLED ? SColorFace() : SColorPaper(), DPI(1), ink),
DPI(3), DPI(1), 0, 0);
if(i == 0)
s.coloredge = WithHotSpots(MakeButton(roundness, Black(), DPI(2), Null), DPI(3), DPI(1), 0, 0);
}
{
auto Set = [&](Button::Style& s, const Image& arrow = Null) {
Value l = MakeButton(0, m, DPI(1), ink, 0);

View file

@ -36,24 +36,6 @@ void ViewEdge_Write(Value);
CtrlFrame& EditFieldFrame();
CtrlFrame& ViewFrame();
class ActiveEdgeFrame : public CtrlFrame {
public:
virtual void FrameLayout(Rect& r);
virtual void FramePaint(Draw& w, const Rect& r);
virtual void FrameAddSize(Size& sz);
private:
const Value *edge;
const Ctrl *ctrl;
bool mousein;
public:
void Set(const Ctrl *ctrl, const Value *edge, bool active);
void Mouse(bool in) { mousein = in; }
ActiveEdgeFrame() { edge = NULL; mousein = false; }
};
class EditField : public Ctrl, private TextArrayOps {
public:
virtual void Layout();
@ -90,7 +72,8 @@ public:
Color text, textdisabled;
Color selected, selectedtext;
Color selected0, selectedtext0; // If does not have focus...
Value edge[4];
Value edge[4]; // border (for various active edge states)
Value coloredge; // border mask for adding color, e.g. round borders with red Error
bool activeedge;
int vfm;
};
@ -147,7 +130,7 @@ protected:
bool FrameIsEdge();
void SetEdge(int i);
void SyncEdge();
void RefreshAll();
int LowChar(int c) const { return 0x25af /*c + 0x2400*/; }
int GetCharWidth(int c) const { return font[c < 32 ? LowChar(c) : c]; }
int GetTextCx(const wchar *text, int n, bool password, Font fnt) const;
@ -163,6 +146,7 @@ protected:
int GetTy() const;
void StdPasteFilter(WString&);
void SelSource();
Color GetPaper();
protected:
virtual void HighlightText(Vector<Highlight>& hl);
@ -223,7 +207,7 @@ public:
void Clear();
void Reset();
void Error(bool error = true) { if(errorbg != error) { errorbg = error; Refresh(); } }
void Error(bool error = true) { if(errorbg != error) { errorbg = error; RefreshAll(); } }
EditField& Password(bool pwd = true) { password = pwd; Finish(); return *this; }
bool IsPassword() const { return password; }

View file

@ -67,15 +67,6 @@ int64 TextArrayOps::GetPrevWord(int64 cursor)
return c;
}
Rect LookMargins(const Rect& r, const Value& ch)
{
Rect m = ChMargins(ch);
int fcy = GetStdFontCy();
if(m.top + m.bottom + fcy > r.GetHeight())
m.top = m.bottom = max((r.GetHeight() - fcy) / 2, 0);
return m;
}
void LookFrame::FrameLayout(Rect& r)
{
Rect m = LookMargins(r, Get());
@ -97,40 +88,6 @@ void LookFrame::FrameAddSize(Size& sz)
sz.cy += m.top + m.bottom;
}
void ActiveEdgeFrame::FrameLayout(Rect& r)
{
Rect m = LookMargins(r, edge[0]);
r.left += m.left;
r.right -= m.right;
r.top += m.top;
r.bottom -= m.bottom;
}
void ActiveEdgeFrame::FramePaint(Draw& w, const Rect& r)
{
int i = 0;
if(ctrl) {
i = !ctrl->IsEnabled() || ctrl->IsReadOnly() ? CTRL_DISABLED
: ctrl->HasFocus() ? CTRL_PRESSED
: mousein ? CTRL_HOT
: CTRL_NORMAL;
}
ChPaintEdge(w, r, edge[i]);
}
void ActiveEdgeFrame::FrameAddSize(Size& sz)
{
Rect m = ChMargins(edge[0]);
sz.cx += m.left + m.right;
sz.cy += m.top + m.bottom;
}
void ActiveEdgeFrame::Set(const Ctrl *ctrl_, const Value *edge_, bool active)
{
ctrl = active ? ctrl_ : NULL;
edge = edge_;
}
CH_STYLE(EditField, Style, StyleDefault)
{
paper = SColorPaper();
@ -154,22 +111,22 @@ bool EditField::FrameIsEdge()
return &GetFrame() == &edge;
}
void EditField::SyncEdge()
void EditField::RefreshAll()
{
if(FrameIsEdge() && style->activeedge)
RefreshFrame();
edge.SetColor(style->coloredge, GetPaper());
RefreshFrame();
}
void EditField::MouseEnter(Point p, dword keyflags)
{
edge.Mouse(true);
SyncEdge();
RefreshAll();
}
void EditField::MouseLeave()
{
edge.Mouse(false);
SyncEdge();
RefreshAll();
}
EditField& EditField::SetStyle(const Style& s)
@ -177,7 +134,7 @@ EditField& EditField::SetStyle(const Style& s)
style = &s;
edge.Set(this, style->edge, style->activeedge);
RefreshLayout();
RefreshFrame();
RefreshAll();
return *this;
}
@ -302,16 +259,24 @@ void EditField::Paints(Draw& w, int& x, int fcy, const wchar *&txt,
x += cx;
}
Color EditField::GetPaper()
{
bool enabled = IsShowEnabled();
Color paper = enabled && !IsReadOnly() ? (HasFocus() ? style->focus : style->paper)
: style->disabled;
if(nobg)
paper = Null;
if(enabled && (convert && convert->Scan(text).IsError() || errorbg))
paper = style->invalid;
return paper;
}
void EditField::Paint(Draw& w)
{
Size sz = GetSize();
bool enabled = IsShowEnabled();
Color paper = enabled && !IsReadOnly() ? (HasFocus() ? style->focus : style->paper) : style->disabled;
if(nobg)
paper = Null;
Color paper = GetPaper();
Color ink = enabled ? Nvl(textcolor, style->text) : style->textdisabled;
if(enabled && (convert && convert->Scan(text).IsError() || errorbg))
paper = style->invalid;
int fcy = font.GetCy();
int yy = GetTy();
if(!no_internal_margin) {
@ -429,14 +394,14 @@ void EditField::Finish(bool refresh)
int wx = x + font.GetRightSpace('o');
if(wx > sz.cx + sc - 1) {
sc = wx - sz.cx + 1;
Refresh();
RefreshAll();
}
if(x < sc) {
sc = x;
Refresh();
RefreshAll();
}
if(refresh)
Refresh();
RefreshAll();
SyncCaret();
}
@ -470,7 +435,7 @@ void EditField::GotFocus()
}
SelSource();
Finish();
SyncEdge();
RefreshAll();
}
void EditField::LostFocus()
@ -487,8 +452,7 @@ void EditField::LostFocus()
anchor = -1;
cursor = sc = 0;
}
Refresh();
SyncEdge();
RefreshAll();
}
void EditField::LeftDown(Point p, dword flags)

View file

@ -451,4 +451,49 @@ Point GetDragScroll(Ctrl *ctrl, Point p, int max)
return GetDragScroll(ctrl, p, Size(max, max));
}
Rect LookMargins(const Rect& r, const Value& ch)
{
Rect m = ChMargins(ch);
int fcy = GetStdFontCy();
if(m.top + m.bottom + fcy > r.GetHeight())
m.top = m.bottom = max((r.GetHeight() - fcy) / 2, 0);
return m;
}
void ActiveEdgeFrame::FrameLayout(Rect& r)
{
Rect m = LookMargins(r, edge[0]);
r.left += m.left;
r.right -= m.right;
r.top += m.top;
r.bottom -= m.bottom;
}
void ActiveEdgeFrame::FramePaint(Draw& w, const Rect& r)
{
int i = 0;
if(ctrl) {
i = !ctrl->IsEnabled() || ctrl->IsReadOnly() ? CTRL_DISABLED
: button ? push : ctrl->HasFocus() ? CTRL_PRESSED
: mousein ? CTRL_HOT
: CTRL_NORMAL;
}
ChPaintEdge(w, r, edge[i]);
if(!IsNull(coloredge))
ChPaintEdge(w, r, coloredge, color);
}
void ActiveEdgeFrame::FrameAddSize(Size& sz)
{
Rect m = ChMargins(edge[0]);
sz.cx += m.left + m.right;
sz.cy += m.top + m.bottom;
}
void ActiveEdgeFrame::Set(const Ctrl *ctrl_, const Value *edge_, bool active)
{
ctrl = active ? ctrl_ : NULL;
edge = edge_;
}
}

View file

@ -110,3 +110,29 @@ public:
virtual ~LabelBase();
};
Rect LookMargins(const Rect& r, const Value& ch);
class ActiveEdgeFrame : public CtrlFrame {
public:
virtual void FrameLayout(Rect& r);
virtual void FramePaint(Draw& w, const Rect& r);
virtual void FrameAddSize(Size& sz);
private:
const Value *edge;
const Ctrl *ctrl;
Value coloredge;
Color color;
bool mousein = false;
bool push = false;
bool button = false;
public:
void Set(const Ctrl *ctrl, const Value *edge, bool active);
void Mouse(bool in) { mousein = in; }
void Push(bool b) { button = true; push = b; }
void SetColor(const Value& ce, Color c) { coloredge = ce; color = c; }
ActiveEdgeFrame() { edge = NULL; mousein = false; }
};

View file

@ -374,7 +374,13 @@ private:
Color nullink;
Font nullfont;
ActiveEdgeFrame edge;
void SyncEdge();
protected:
virtual void RefreshPush();
virtual void RefreshFocus();
virtual void PerformAction();
virtual void DoAction();

View file

@ -89,9 +89,6 @@ LabelBox::LabelBox()
color = Null;
LabelBase::SetInk(LabelBoxTextColor(), LabelBoxDisabledTextColor());
SetVAlign(ALIGN_TOP);
#if defined(flagWINGL) || defined(flagLINUXGL)
ClipToBounds(false);
#endif
}
void LabelBox::AssignAccessKeys(dword used)

View file

@ -22,55 +22,26 @@ namespace Upp {
#define LTIMING(x) // RTIMING(x)
struct ChImageMaker : ImageMaker {
Size sz;
Rect sr;
Image img;
virtual String Key() const;
virtual Image Make() const;
};
String ChImageMaker::Key() const
{
LTIMING("ChImageMaker::Key");
StringBuffer b;
int64 id = img.GetSerialId();
b.Cat((const char *)&id, sizeof(id));
b.Cat((const char *)&sz.cx, sizeof(sz.cx));
b.Cat((const char *)&sz.cy, sizeof(sz.cy));
b.Cat((const char *)&sr.left, sizeof(sr.left));
b.Cat((const char *)&sr.right, sizeof(sr.right));
b.Cat((const char *)&sr.top, sizeof(sr.top));
b.Cat((const char *)&sr.bottom, sizeof(sr.bottom));
return b;
}
Image ChImageMaker::Make() const
{
LTIMING("ChImageMaker::Make");
return Rescale(img, sz, sr);
}
void ChDraw(Draw& w, int x, int y, int cx, int cy, const Image& img, const Rect& src)
void ChDraw(Draw& w, int x, int y, int cx, int cy, const Image& img, const Rect& src, Color ink)
{
LTIMING("ChDraw");
if(cx > 0 && cy > 0) {
#if defined(flagWINGL) || defined(flagLINUXGL)
w.DrawImage(x, y, cx, cy, img, src);
#else
ChImageMaker m;
m.sz = Size(cx, cy);
m.sr = src;
m.img = img;
w.DrawImage(x, y, MakeImage(m));
#endif
Image m = CachedRescale(img, Size(cx, cy), src);
if(IsNull(ink))
w.DrawImage(x, y, m);
else
w.DrawImage(x, y, m, ink);
}
}
void ChDraw(Draw& w, const Rect& r, const Image& img, const Rect& src)
void ChDraw(Draw& w, int x, int y, const Image& img, const Rect& src, Color ink)
{
ChDraw(w, r.left, r.top, r.GetWidth(), r.GetHeight(), img, src);
ChDraw(w, x, y, src.GetWidth(), src.GetHeight(), img, src, ink);
}
void ChDraw(Draw& w, const Rect& r, const Image& img, const Rect& src, Color ink)
{
ChDraw(w, r.left, r.top, r.GetWidth(), r.GetHeight(), img, src, ink);
}
struct sChLookWith {
@ -115,7 +86,7 @@ Value ChLookWith(const Value& look, const Image& img, Color (*color)(int i), int
return RawToValue(x);
}
Value sChOp(Draw& w, const Rect& r, const Value& v, int op);
Value sChOp(Draw& w, const Rect& r, const Value& v, int op, Color ink = Null);
struct sChBorder {
const ColorF *border;
@ -182,7 +153,7 @@ static void sDrawScrollbarThumb(Draw& w, int x, int y, int cx, int cy, const Ima
DrawPart(ter, ecx); // right ending
}
Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op)
Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op, Color ink)
{
if(IsType<sChLookWith>(v)) {
const sChLookWith& x = ValueTo<sChLookWith>(v);
@ -313,11 +284,7 @@ Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op)
}
if(op == LOOK_PAINT || op == LOOK_PAINTEDGE) {
LTIMING("ChPaint Image");
#if defined(flagWINGL) || defined(flagLINUXGL)
w.Offset(r.TopLeft());
#else
w.Clipoff(r);
#endif
Rect sr(p, p2);
Size sz2(isz.cx - sr.right, isz.cy - sr.bottom);
Rect r = RectC(p.x, p.y, sz.cx - sr.left - sz2.cx, sz.cy - sr.top - sz2.cy);
@ -328,15 +295,14 @@ Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op)
int right = minmax(sz.cx - left, 0, isz.cx);
int xx = isz.cx - right;
if(!r.IsEmpty()) {
w.DrawImage(0, 0, img, RectC(0, 0, p.x, p.y));
w.DrawImage(0, r.bottom, img, RectC(0, sr.bottom, p.x, sz2.cy));
w.DrawImage(r.right, 0, img, RectC(sr.right, 0, sz2.cx, p.y));
w.DrawImage(r.right, r.bottom, img, RectC(sr.right, sr.bottom, sz2.cx, sz2.cy));
ChDraw(w, p.x, 0, r.Width(), p.y, img, RectC(p.x, 0, sr.Width(), p.y));
ChDraw(w, p.x, r.bottom, r.Width(), sz2.cy, img, RectC(p.x, sr.bottom, sr.Width(), sz2.cy));
ChDraw(w, 0, p.y, p.x, r.Height(), img, RectC(0, p.y, p.x, sr.Height()));
ChDraw(w, r.right, p.y, sz2.cx, r.Height(), img,
RectC(sr.right, p.y, sz2.cx, sr.Height()));
ChDraw(w, 0, 0, img, RectC(0, 0, p.x, p.y), ink);
ChDraw(w, 0, r.bottom, img, RectC(0, sr.bottom, p.x, sz2.cy), ink);
ChDraw(w, r.right, 0, img, RectC(sr.right, 0, sz2.cx, p.y), ink);
ChDraw(w, r.right, r.bottom, img, RectC(sr.right, sr.bottom, sz2.cx, sz2.cy), ink);
ChDraw(w, p.x, 0, r.Width(), p.y, img, RectC(p.x, 0, sr.Width(), p.y), ink);
ChDraw(w, p.x, r.bottom, r.Width(), sz2.cy, img, RectC(p.x, sr.bottom, sr.Width(), sz2.cy), ink);
ChDraw(w, 0, p.y, p.x, r.Height(), img, RectC(0, p.y, p.x, sr.Height()), ink);
ChDraw(w, r.right, p.y, sz2.cx, r.Height(), img, RectC(sr.right, p.y, sz2.cx, sr.Height()), ink);
if(op == LOOK_PAINT) {
if(IsNull(r) || IsNull(sr)) {
w.End();
@ -348,12 +314,8 @@ Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op)
Size sz;
sz.cx = (tile & 1 ? sr : r).GetWidth();
sz.cy = (tile & 2 ? sr : r).GetHeight();
#if defined(flagWINGL) || defined(flagLINUXGL)
DrawTiles(w, r, img, sz, sr);
#else
img = Rescale(img, sz, sr);
DrawTiles(w, r, img);
#endif
}
else {
static VectorMap<int64, int> btc;
@ -384,19 +346,7 @@ Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op)
}
case 0:
default:
ChDraw(w, r, img, sr);
break;
LTIMING("Ch-linedup");
img = CachedRescalePaintOnly(
img,
Size((q & IMAGECONTENT_HORZDUP) ? max(min(40, r.GetWidth()), sr.GetWidth())
: r.GetWidth(),
(q & IMAGECONTENT_VERTDUP) ? max(min(40, r.GetHeight()), sr.GetHeight())
: r.GetHeight()),
sr
);
LTIMING("Ch-linedup-drawtiles");
DrawTiles(w, r, img);
ChDraw(w, r, img, sr, ink);
break;
}
}
@ -404,27 +354,27 @@ Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op)
}
else
if(r.left < r.right) {
w.DrawImage(0, 0, img, RectC(0, 0, p.x, top));
w.DrawImage(0, sz.cy - bottom, img, RectC(0, yy, p.x, bottom));
w.DrawImage(r.right, 0, img, RectC(sr.right, 0, sz2.cx, top));
w.DrawImage(r.right, sz.cy - bottom, img, RectC(sr.right, yy, sz2.cx, bottom));
ChDraw(w, p.x, 0, r.Width(), top, img, RectC(p.x, 0, sr.Width(), top));
ChDraw(w, p.x, sz.cy - bottom, r.Width(), bottom, img, RectC(p.x, yy, sr.Width(), bottom));
ChDraw(w, 0, 0, img, RectC(0, 0, p.x, top), ink);
ChDraw(w, 0, sz.cy - bottom, img, RectC(0, yy, p.x, bottom), ink);
ChDraw(w, r.right, 0, img, RectC(sr.right, 0, sz2.cx, top), ink);
ChDraw(w, r.right, sz.cy - bottom, img, RectC(sr.right, yy, sz2.cx, bottom), ink);
ChDraw(w, p.x, 0, r.Width(), top, img, RectC(p.x, 0, sr.Width(), top), ink);
ChDraw(w, p.x, sz.cy - bottom, r.Width(), bottom, img, RectC(p.x, yy, sr.Width(), bottom), ink);
}
else
if(r.top < r.bottom) {
w.DrawImage(0, 0, img, RectC(0, 0, left, p.y));
w.DrawImage(0, r.bottom, img, RectC(0, sr.bottom, left, sz2.cy));
w.DrawImage(sz.cx - right, 0, img, RectC(xx, 0, right, p.y));
w.DrawImage(sz.cx - right, r.bottom, img, RectC(xx, sr.bottom, right, sz2.cy));
ChDraw(w, 0, p.y, left, r.Height(), img, RectC(0, p.y, left, sr.Height()));
ChDraw(w, sz.cx - right, p.y, right, r.Height(), img, RectC(xx, p.y, right, sr.Height()));
ChDraw(w, 0, 0, img, RectC(0, 0, left, p.y), ink);
ChDraw(w, 0, r.bottom, img, RectC(0, sr.bottom, left, sz2.cy), ink);
ChDraw(w, sz.cx - right, 0, img, RectC(xx, 0, right, p.y), ink);
ChDraw(w, sz.cx - right, r.bottom, img, RectC(xx, sr.bottom, right, sz2.cy), ink);
ChDraw(w, 0, p.y, left, r.Height(), img, RectC(0, p.y, left, sr.Height()), ink);
ChDraw(w, sz.cx - right, p.y, right, r.Height(), img, RectC(xx, p.y, right, sr.Height()), ink);
}
else {
w.DrawImage(0, 0, img, RectC(0, 0, left, top));
w.DrawImage(0, sz.cy - bottom, img, RectC(0, yy, left, top));
w.DrawImage(sz.cx - right, 0, img, RectC(xx, 0, right, top));
w.DrawImage(sz.cx - right, sz.cy - bottom, img, RectC(xx, yy, right, bottom));
ChDraw(w, 0, 0, img, RectC(0, 0, left, top), ink);
ChDraw(w, 0, sz.cy - bottom, img, RectC(0, yy, left, top), ink);
ChDraw(w, sz.cx - right, 0, img, RectC(xx, 0, right, top), ink);
ChDraw(w, sz.cx - right, sz.cy - bottom, img, RectC(xx, yy, right, bottom), ink);
}
w.End();
return 1;
@ -433,7 +383,7 @@ Value StdChLookFn(Draw& w, const Rect& r, const Value& v, int op)
return Null;
}
typedef Value (*ChPainterFn)(Draw& w, const Rect& r, const Value& v, int op);
typedef Value (*ChPainterFn)(Draw& w, const Rect& r, const Value& v, int op, Color ink);
Vector<ChPainterFn>& sChps()
{
@ -441,7 +391,7 @@ Vector<ChPainterFn>& sChps()
return x;
}
void ChLookFn(Value (*fn)(Draw& w, const Rect& r, const Value& v, int op))
void ChLookFn(Value (*fn)(Draw& w, const Rect& r, const Value& v, int op, Color ink))
{
if(FindIndex(sChps(), fn) < 0)
sChps().Add(fn);
@ -510,50 +460,50 @@ void ChFinish()
sLabelTextColorMismatch = IsDark(SColorText()) != IsDark(SColorLabel());
}
Value sChOp(Draw& w, const Rect& r, const Value& v, int op)
Value sChOp(Draw& w, const Rect& r, const Value& v, int op, Color ink)
{
Value q;
if(!IsNull(v))
for(int i = sChps().GetCount() - 1; i >= 0; i--) {
q = (*sChps()[i])(w, r, v, op);
q = (*sChps()[i])(w, r, v, op, ink);
if(!IsNull(q))
break;
}
return q;
}
void ChPaint(Draw& w, const Rect& r, const Value& look)
void ChPaint(Draw& w, const Rect& r, const Value& look, Color ink)
{
sChOp(w, r, look, LOOK_PAINT);
sChOp(w, r, look, LOOK_PAINT, ink);
}
void ChPaint(Draw& w, int x, int y, int cx, int cy, const Value& look)
void ChPaint(Draw& w, int x, int y, int cx, int cy, const Value& look, Color ink)
{
sChOp(w, RectC(x, y, cx, cy), look, LOOK_PAINT);
sChOp(w, RectC(x, y, cx, cy), look, LOOK_PAINT, ink);
}
void ChPaintEdge(Draw& w, const Rect& r, const Value& look)
void ChPaintEdge(Draw& w, const Rect& r, const Value& look, Color ink)
{
sChOp(w, r, look, LOOK_PAINTEDGE);
sChOp(w, r, look, LOOK_PAINTEDGE, ink);
}
void ChPaintEdge(Draw& w, int x, int y, int cx, int cy, const Value& look)
void ChPaintEdge(Draw& w, int x, int y, int cx, int cy, const Value& look, Color ink)
{
sChOp(w, RectC(x, y, cx, cy), look, LOOK_PAINTEDGE);
sChOp(w, RectC(x, y, cx, cy), look, LOOK_PAINTEDGE, ink);
}
void ChPaintBody(Draw& w, const Rect& r, const Value& look)
void ChPaintBody(Draw& w, const Rect& r, const Value& look, Color ink)
{
Rect m = ChMargins(look);
w.Clip(r);
ChPaint(w, Rect(r.left - m.left, r.top - m.top, r.right + m.right, r.bottom + m.bottom),
look);
look, ink);
w.End();
}
void ChPaintBody(Draw& w, int x, int y, int cx, int cy, const Value& look)
void ChPaintBody(Draw& w, int x, int y, int cx, int cy, const Value& look, Color ink)
{
ChPaintBody(w, RectC(x, y, cx, cy), look);
ChPaintBody(w, RectC(x, y, cx, cy), look, ink);
}
Rect ChMargins(const Value& look)

View file

@ -10,7 +10,7 @@ enum {
CH_SCROLLBAR_IMAGE = -1000 // special Image hotspot x value for ChPaint of scrollbar
};
void ChLookFn(Value (*fn)(Draw& w, const Rect& r, const Value& look, int lookop));
void ChLookFn(Value (*fn)(Draw& w, const Rect& r, const Value& look, int lookop, Color ink));
Image AdjustColors(const Image& img);
@ -20,12 +20,12 @@ void ColoredOverride(Iml& target, Iml& source);
void ChReset();
void ChFinish();
void ChPaint(Draw& w, const Rect& r, const Value& look);
void ChPaint(Draw& w, int x, int y, int cx, int cy, const Value& look);
void ChPaintEdge(Draw& w, const Rect& r, const Value& look);
void ChPaintEdge(Draw& w, int x, int y, int cx, int cy, const Value& look);
void ChPaintBody(Draw& w, const Rect& r, const Value& look);
void ChPaintBody(Draw& w, int x, int y, int cx, int cy, const Value& look);
void ChPaint(Draw& w, const Rect& r, const Value& look, Color ink = Null);
void ChPaint(Draw& w, int x, int y, int cx, int cy, const Value& look, Color ink = Null);
void ChPaintEdge(Draw& w, const Rect& r, const Value& look, Color ink = Null);
void ChPaintEdge(Draw& w, int x, int y, int cx, int cy, const Value& look, Color ink = Null);
void ChPaintBody(Draw& w, const Rect& r, const Value& look, Color ink = Null);
void ChPaintBody(Draw& w, int x, int y, int cx, int cy, const Value& look, Color ink = Null);
Rect ChMargins(const Value& look);
bool ChIsOpaque(const Value& look);
bool ChIsBodyOpaque(const Value& look);
@ -117,9 +117,6 @@ struct ChValue : ChStyle<ChValue> { Value value; };
struct ChImage : ChStyle<ChImage> { Image value; };
#define CH_IMAGE(name, init) CH_VAR(ChImage, Image, name, init)
void ChPaint(Draw& w, const Rect& r, const Value& element);
void ChPaint(Draw& w, int x, int y, int cx, int cy, const Value& element);
Value ChLookWith(const Value& look, const Image& img, Point offset = Point(0, 0));
Value ChLookWith(const Value& look, const Image& img, Color color, Point offset = Point(0, 0));
Value ChLookWith(const Value& look, const Image& img, Color (*color)(int i), int i, Point offset = Point(0, 0));

View file

@ -888,10 +888,6 @@ void AddRefreshRect(Vector<Rect>& invalid, const Rect& _r);
void DrawRect(Draw& w, const Rect& rect, const Image& img, bool ralgn = false); //??? TODO
void DrawRect(Draw& w, int x, int y, int cx, int cy, const Image& img, bool ra = false);
#if defined(flagWINGL) || defined(flagLINUXGL)
void DrawTiles(Draw& w, int x, int y, int cx, int cy, const Image& img, const Size& isz, const Rect& src);
void DrawTiles(Draw& w, const Rect& rect, const Image& img, const Size& isz, const Rect& src);
#endif
void DrawTiles(Draw& w, int x, int y, int cx, int cy, const Image& img);
void DrawTiles(Draw& w, const Rect& rect, const Image& img);

View file

@ -2,11 +2,6 @@
namespace Upp {
#if defined(flagWINGL) || defined(flagLINUXGL)
#include <CoreGl/FontGl.h>
#include <CoreGl/ResGl.h>
#endif
#define LLOG(x) // LOG(x)
#define LTIMING(x) // TIMING(x)
@ -215,9 +210,6 @@ void Draw::DrawText(int x, int y, const String& text, Font font, Color ink, cons
Size GetTextSize(const wchar *text, Font font, int n)
{
#if defined(flagWINGL) || defined(flagLINUXGL)
return GetTextSize(text, resources.GetFont(font), n);
#else
FontInfo fi = font.Info();
if(n < 0)
n = wstrlen(text);
@ -232,7 +224,6 @@ Size GetTextSize(const wchar *text, Font font, int n)
}
sz.cy = fi.GetHeight();
return sz;
#endif
}
Size GetTextSize(const WString& text, Font font)

View file

@ -329,31 +329,6 @@ void DrawRect(Draw& w, const Rect& rect, const Image& img, bool ralgn)
DrawRect(w, rect.left, rect.top, rect.Width(), rect.Height(), img, ralgn);
}
#if defined(flagWINGL) || defined(flagLINUXGL)
void DrawTiles(Draw& w, int x, int y, int cx, int cy, const Image& img, const Size& isz, const Rect& src) {
w.Clip(x, y, cx, cy);
Size sz = isz;
for(int a = x; a < x + cx; a += sz.cx)
for(int b = y; b < y + cy; b += sz.cy)
w.DrawImage(a, b, isz.cx, isz.cy, img, src);
w.End();
}
void DrawTiles(Draw& w, const Rect& rect, const Image& img, const Size& isz, const Rect& src)
{
DrawTiles(w, rect.left, rect.top, rect.GetWidth(), rect.GetHeight(), img, isz, src);
}
void DrawTiles(Draw& w, int x, int y, int cx, int cy, const Image& img)
{
DrawTiles(w, x, y, cx, cy, img, img.GetSize(), img.GetSize());
}
void DrawTiles(Draw& w, const Rect& rect, const Image& img)
{
DrawTiles(w, rect, img, img.GetSize(), img.GetSize());
}
#else
void DrawTiles(Draw& w, int x, int y, int cx, int cy, const Image& img) {
w.Clip(x, y, cx, cy);
Size sz = img.GetSize();
@ -367,7 +342,6 @@ void DrawTiles(Draw& w, const Rect& rect, const Image& img)
{
DrawTiles(w, rect.left, rect.top, rect.GetWidth(), rect.GetHeight(), img);
}
#endif
void DrawHighlightImage(Draw& w, int x, int y, const Image& img, bool highlight,
bool enabled, Color maskcolor)

View file

@ -181,19 +181,6 @@ Vector<FaceInfo> GetAllFacesSys()
#define GLYPHINFOCACHE 31
#ifdef flagWINGL
#include <CoreGl/FontGl.h>
#include <CoreGl/ResGl.h>
GlyphInfo GetGlyphInfoSys(Font font, int chr)
{
static GlyphInfo gi;
const OpenGLFont& fi = resources.GetFont(font);
gi.width = chr < fi.chars.GetCount() ? int(fi.chars[chr].xadvance * fi.scale + 0.5f) : 0;
gi.lspc = 0;
gi.rspc = 0;
return gi;
}
#else
GlyphInfo GetGlyphInfoSys(Font font, int chr)
{
static Font fnt[GLYPHINFOCACHE];
@ -265,7 +252,6 @@ GlyphInfo GetGlyphInfoSys(Font font, int chr)
}
return li[q][chr & 255];
}
#endif
String GetFontDataSys(Font font)
{