mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
*Draw, CtrlLib: Fixed transparency of Paintings in Picture
git-svn-id: svn://ultimatepp.org/upp/trunk@5115 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
3cfe5186a4
commit
d811e18dba
7 changed files with 33 additions and 13 deletions
|
|
@ -245,9 +245,18 @@ Size ImageCtrl::GetMinSize() const
|
|||
return img.GetSize();
|
||||
}
|
||||
|
||||
|
||||
Picture& Picture::Background(Color color)
|
||||
{
|
||||
background = color;
|
||||
Transparent(IsNull(color));
|
||||
Refresh();
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Picture::Paint(Draw& w) {
|
||||
Size sz = GetSize();
|
||||
w.DrawRect(0, 0, sz.cx, sz.cy, background);
|
||||
_DBG_ // w.DrawRect(0, 0, sz.cx, sz.cy, background);
|
||||
if(!picture) return;
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
|
|
|
|||
|
|
@ -127,12 +127,13 @@ protected:
|
|||
public:
|
||||
Drawing Get() const { return picture; }
|
||||
|
||||
Picture& Background(Color color) { background = color; Refresh(); return *this; }
|
||||
Picture& Background(Color color);
|
||||
Picture& KeepRatio(bool keep = true) { ratio = keep; Refresh(); return *this; }
|
||||
Picture& NoKeepRatio() { return KeepRatio(false); }
|
||||
Picture& Set(const Drawing& _picture) { picture = _picture; Refresh(); return *this; }
|
||||
|
||||
Picture& operator=(const Drawing& _picture) { return Set(_picture); }
|
||||
Picture& operator=(const Painting& _picture) { return Set(AsDrawing(_picture)); }
|
||||
|
||||
Picture();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -155,6 +155,10 @@ olor]_[*@3 color])&]
|
|||
[s2; Sets background [%-*@3 color]. Default is white.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:Picture`:`:Get`(`)const:%- [_^Drawing^ Drawing]_[* Get]()_[@(0.0.255) const]&]
|
||||
[s2; Returns Drawing assigned to Picture.&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:Picture`:`:KeepRatio`(bool`):%- [_^Picture^ Picture][@(0.0.255) `&]_[* KeepRatio]([@(0.0.255) b
|
||||
ool]_[*@3 keep]_`=_[@(0.0.255) true])&]
|
||||
[s2; If active, Picture keeps the aspect ratio of Drawing. Default
|
||||
|
|
@ -171,6 +175,10 @@ onst]_[_^Drawing^ Drawing][@(0.0.255) `&]_[*@3 `_picture])&]
|
|||
rator`=]([@(0.0.255) const]_[_^Drawing^ Drawing][@(0.0.255) `&]_[*@3 `_picture])&]
|
||||
[s2; Assigns the Drawing.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:Picture`:`:operator`=`(const Painting`&`):%- [_^Picture^ Picture][@(0.0.255) `&]_[* op
|
||||
erator`=]([@(0.0.255) const]_[_^Painting^ Painting][@(0.0.255) `&]_[*@3 `_picture])&]
|
||||
[s2; Assigns [%-*@3 `_picture], converted to Drawing.&]
|
||||
[s0; &]
|
||||
[s0; &]
|
||||
[s0;%- &]
|
||||
|
|
@ -210,4 +218,4 @@ is a simple structure with two fields:&]
|
|||
[s7; [*@5 l1]-|the first margin&]
|
||||
[s7;%- [*@5 l2]-|the second margin&]
|
||||
[s3; &]
|
||||
[s0; ]
|
||||
[s0; ]]
|
||||
|
|
@ -401,7 +401,7 @@ void Draw::DrawPaintingOp(const Rect& target, const Painting& pw)
|
|||
while(yy < sz.cy) {
|
||||
int ccy = min(sz.cy - yy, 100);
|
||||
ImageBuffer ib(sz.cx, ccy);
|
||||
Fill(~ib, White(), ib.GetLength());
|
||||
Fill(~ib, IsPrinter() ? White() : Null, ib.GetLength());
|
||||
PaintImageBuffer(ib, pw, sz, Point(0, yy), true);
|
||||
DrawImageBandRLE(*this, target.left, target.top + yy, ib, 16);
|
||||
yy += ccy;
|
||||
|
|
@ -409,7 +409,7 @@ void Draw::DrawPaintingOp(const Rect& target, const Painting& pw)
|
|||
}
|
||||
else {
|
||||
ImageBuffer ib(sz);
|
||||
Fill(~ib, IsPrinter() ? White() : SColorPaper(), ib.GetLength());
|
||||
Fill(~ib, IsPrinter() ? White() : Null, ib.GetLength());
|
||||
PaintImageBuffer(ib, pw, sz, Point(0, 0), IsPrinter());
|
||||
DrawImage(target.left, target.top, ib);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,6 +373,8 @@ void SColorDkShadow_Write(Color c);
|
|||
inline Color InvertColor() { return Color(255, 0); }
|
||||
inline Color DefaultInk() { return Black(); } //TODO!
|
||||
|
||||
Drawing AsDrawing(const Painting& pw);
|
||||
|
||||
class Painting : public ValueType<Painting, 48, Moveable<Painting> > {
|
||||
String cmd;
|
||||
ValueArray data;
|
||||
|
|
|
|||
|
|
@ -290,4 +290,12 @@ void PaintingPainter::Create(Sizef sz)
|
|||
Create(sz.cx, sz.cy);
|
||||
}
|
||||
|
||||
Drawing AsDrawing(const Painting& pw)
|
||||
{
|
||||
Size sz = pw.GetSize();
|
||||
DrawingDraw dw(sz);
|
||||
dw.DrawPainting(sz, pw);
|
||||
return dw.GetResult();
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -376,14 +376,6 @@ void RichObjectTypeDrawingCls::Paint(const Value& data, Draw& w, Size sz) const
|
|||
w.DrawDrawing(Rect(sz), ValueTo<Data>(data).drawing);
|
||||
}
|
||||
|
||||
Drawing AsDrawing(const Painting& pw)
|
||||
{
|
||||
Size sz = pw.GetSize();
|
||||
DrawingDraw dw(sz);
|
||||
dw.DrawPainting(sz, pw);
|
||||
return dw.GetResult();
|
||||
}
|
||||
|
||||
RichObject CreatePaintingObject(const Painting& pw, Size dot_size, Size out_size)
|
||||
{
|
||||
return CreateDrawingObject(AsDrawing(pw), dot_size, out_size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue