Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 238200 Details for
Bug 423607
[CSS] Gradient in background-color is not applied to children
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Alternative fix for the issue (playing with sub-images)
alternative_fix_for_gradient_issue.patch (text/plain), 2.87 KB, created by
Daniel Rolka
on 2013-12-10 07:57:11 EST
(
hide
)
Description:
Alternative fix for the issue (playing with sub-images)
Filename:
MIME Type:
Creator:
Daniel Rolka
Created:
2013-12-10 07:57:11 EST
Size:
2.87 KB
patch
obsolete
>diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/GradientBackgroundListener.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/GradientBackgroundListener.java >index 78c56d7..d145889 100644 >--- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/GradientBackgroundListener.java >+++ b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/GradientBackgroundListener.java >@@ -84,12 +84,28 @@ > control.removeDisposeListener(disposeListener); > if (control.getBackgroundImage() == gradientImage) { > control.setBackgroundImage(null); >+ if (control instanceof Composite) { >+ disposeChildrenBackgroundImage((Composite) control, >+ gradientImage); >+ } > } > } > if (gradientImage != null && !gradientImage.isDisposed()) { > gradientImage.dispose(); > } > gradientImage = null; >+ } >+ >+ private void disposeChildrenBackgroundImage(Composite parent, Image image) { >+ for (Control child : parent.getChildren()) { >+ Image oldImage = child.getBackgroundImage(); >+ if (oldImage != null && !oldImage.isDisposed()) { >+ child.setBackgroundImage(null); >+ if (oldImage != image) { >+ oldImage.dispose(); >+ } >+ } >+ } > } > > public static void handle(Control control, Gradient grad) { >@@ -187,12 +203,51 @@ > > private void setBackgroundImageForChildren(Composite parent, Image image) { > for (Control child : parent.getChildren()) { >- if (child.getBackgroundImage() != image) { >+ Image oldImage = child.getBackgroundImage(); >+ if (oldImage != null && !oldImage.isDisposed() && image != oldImage) { >+ oldImage.dispose(); >+ } >+ >+ Point loc = child.getLocation(); >+ Point size = child.getSize(); >+ Rectangle imageBounds = image.getBounds(); >+ >+ if (loc.x >= 0 >+ && loc.y >= 0 >+ && isValidSize(size.x, size.y) >+ && isValidSize(imageBounds.height, imageBounds.width) >+ && isValidImageSize(loc.x, loc.y, size.x, size.y, >+ imageBounds.width, imageBounds.height)) { >+ >+ // Almost entire widget will be filled out with image so we use >+ // the original image for it >+ if (loc.x <= 5) { >+ child.setBackgroundImage(image); >+ continue; >+ } >+ >+ Image newImage = new Image(child.getDisplay(), size.x, size.y); >+ GC gc = new GC(newImage); >+ gc.drawImage(image, loc.x, loc.y, size.x, size.y, 0, 0, size.x, >+ size.y); >+ gc.dispose(); >+ >+ child.setBackgroundImage(newImage); >+ } else { > child.setBackgroundImage(image); > } > } > } > >+ private boolean isValidSize(int x, int y) { >+ return x > 0 && y > 0; >+ } >+ >+ private boolean isValidImageSize(int srcX, int srcY, int srcWidth, >+ int srcHeight, int imageWidth, int imageHeigth) { >+ return srcX + srcWidth <= imageWidth && srcY + srcHeight <= imageHeigth; >+ } >+ > /* > * Fills a gradient rectangle in the specified gc with the specified colors > * and percentages.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 423607
:
238170
|
238183
|
238198
|
238199
| 238200