Skip to content

Commit 39f2e0d

Browse files
committed
[pad] move special fill attributes handling to TPad::PaintBorder
There are several pad fill attributes which only relevan for pad. It it fill style 4000..4100 or fillcolor 10 for fillstyle 3000..3100 Move all these special attribute only to TPad::PaintBorder to exclude misuse of these attributes in different classes
1 parent 16e4cb4 commit 39f2e0d

1 file changed

Lines changed: 40 additions & 62 deletions

File tree

graf2d/gpad/src/TPad.cxx

Lines changed: 40 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -744,13 +744,9 @@ void TPad::Clear(Option_t *option)
744744
}
745745

746746
auto pp = GetPainter();
747-
// If pad painter uses PS, ClearDrawable() start new page
748-
if (pp) {
749-
if (pp->IsNative())
750-
pp->ClearDrawable();
751-
else if (this == GetCanvas())
752-
pp->NewPage();
753-
}
747+
// If pad painter uses PS, TPad::Clear() start new page
748+
if (pp && pp->GetPS())
749+
pp->NewPage();
754750

755751
PaintBorder(GetFillColor(), kTRUE);
756752
fCrosshairPos = 0;
@@ -3660,23 +3656,44 @@ void TPad::PaintBorder(Color_t color, Bool_t /* tops */)
36603656
pp->OnPad(this);
36613657

36623658
if (color >= 0) {
3663-
TAttLine::Modify(); //Change line attributes only if necessary
3664-
TAttFill::Modify(); //Change fill area attributes only if necessary
3665-
3666-
//With Cocoa we have a transparency. But we also have
3667-
//pixmaps, and if you just paint a new content over the old one
3668-
//with alpha < 1., you'll be able to see the old content.
3669-
if (pp->IsNative() && pp->IsCocoa())
3659+
if (pp->IsNative())
36703660
pp->ClearDrawable();
36713661

3672-
PaintBox(fX1, fY1, fX2, fY2);
3673-
}
3674-
if (color < 0)
3662+
Bool_t do_paint_box = kTRUE;
3663+
3664+
Style_t style = GetFillStyle();
3665+
3666+
if ((style >= 4000) && (style <= 4100) && pp->IsNative()) {
3667+
if (this == fMother) {
3668+
style = 1001;
3669+
} else if (pp->IsCocoa()) {
3670+
auto col = gROOT->GetColor(color);
3671+
if (col)
3672+
color = TColor::GetColor(col->GetRed(), col->GetGreen(), col->GetBlue(), (style - 4000) / 100.);
3673+
style = 1001;
3674+
} else {
3675+
// copy all pixmaps
3676+
do_paint_box = kFALSE;
3677+
int px, py;
3678+
XYtoAbsPixel(fX1, fY2, px, py);
3679+
if (fMother) {
3680+
fMother->CopyBackgroundPixmap(px, py);
3681+
CopyBackgroundPixmaps(fMother, this, px, py);
3682+
}
3683+
pp->SetOpacity(style - 4000);
3684+
}
3685+
} else if ((color == 10) && (style > 3000) && (style < 3100))
3686+
color = 1;
3687+
3688+
if (do_paint_box) {
3689+
pp->SetAttFill({color, style});
3690+
pp->SetAttLine(*this);
3691+
PaintBox(fX1, fY1, fX2, fY2);
3692+
}
3693+
} else
36753694
color = -color;
3676-
if (IsTransparent())
3677-
return;
36783695

3679-
if (fBorderMode == 0)
3696+
if (IsTransparent() || (fBorderMode == 0))
36803697
return;
36813698

36823699
// then paint 3d frame (depending on bordermode)
@@ -3802,14 +3819,8 @@ void TPad::PaintModified()
38023819
fPadPaint = 1;
38033820
{
38043821
TContext ctxt(this, kTRUE);
3805-
if (IsModified() || IsTransparent()) {
3806-
if ((fFillStyle < 3026) && (fFillStyle > 3000)) {
3807-
auto pp = GetPainter();
3808-
if (pp && pp->IsNative())
3809-
pp->ClearDrawable();
3810-
}
3822+
if (IsModified() || IsTransparent())
38113823
PaintBorder(GetFillColor(), kTRUE);
3812-
}
38133824

38143825
PaintDate();
38153826

@@ -3894,42 +3905,9 @@ void TPad::PaintBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Option_t
38943905
} else if ((style >= 1000) && (style < 2000)) {
38953906
draw_fill = kTRUE;
38963907
} else if (style > 3000 && style < 3100) {
3897-
if (style < 3026)
3898-
pp->DrawBox(x1, y1, x2, y2, TVirtualPadPainter::kFilled);
3899-
//special case for TAttFillCanvas on real display
3900-
if (att.GetFillColor() == 10) {
3901-
// SL: reproduce old sequence of painting calls, can have some side effects on opaque pads
3902-
att.SetFillColor(1);
3903-
pp->SetAttFill(att);
3904-
pp->DrawBox(x1, y1, x2, y2, TVirtualPadPainter::kFilled);
3905-
att.SetFillColor(10);
3906-
pp->SetAttFill(att);
3907-
}
3908+
draw_fill = style < 3026;
39083909
} else if (style >= 4000 && style <= 4100) {
3909-
// For style >=4000 we make the window transparent.
3910-
// From 4000 to 4100 the window is 100% transparent to 100% opaque
3911-
3912-
//ignore this style option when this is the canvas itself
3913-
if (this == fMother) {
3914-
//It's clear, that virtual X checks a style (4000) and will render a hollow rect!
3915-
if (pp->IsCocoa()) {
3916-
style0 = style;
3917-
att.SetFillStyle(1000);
3918-
pp->SetAttFill(att);
3919-
}
3920-
draw_fill = kTRUE;
3921-
} else {
3922-
//draw background by blitting all bottom pads
3923-
int px, py;
3924-
XYtoAbsPixel(fX1, fY2, px, py);
3925-
3926-
if (fMother) {
3927-
fMother->CopyBackgroundPixmap(px, py);
3928-
CopyBackgroundPixmaps(fMother, this, px, py);
3929-
}
3930-
3931-
pp->SetOpacity(style - 4000);
3932-
}
3910+
// only used by pad, ignored by all other objects
39333911
} else if (style > 0)
39343912
draw_border = kTRUE;
39353913

0 commit comments

Comments
 (0)