Skip to content

Conversation

@HeikoKlare
Copy link

When an image is created with SWT.IMAGE_GRAY or SWT.IMAGE_DISABLE, an adaptation of the loaded/created image data is performed to make it look grayed/disabled. The according functionality is currently applied by callers of loadImageData() right afterwards. Since for every consumption of an image data/handle the loadImageData() method needs to be called, this ensures that the image data is always adapted correctly.

In the implementation for an ImageGcDrawer, the adaptation for gray/disabled is currently executed within the loadImageData() method. The same applies to implementation for an existing handle and a plain image, as they will simply scale existing image data (which already have the gray/disabled adaptation applied).
Since consumers of that method perform the adaptation as well, this leads to an unnecessary duplicate application of the adaptation and to inconsistent behavior throughout the implementations of loadImageData().

This change streamlines the implementation in the Image class by properly assigning the responsibility for applying gray/disabled adaptations as follows:

  • the copy constructor accepting the gray/disabled flag applies the style to copied handles, just like it does now
  • on retrieval of new image data or handles for zoom/sizes, the loadImageData() and loadImageDataAtExactSize() method of the provider classes are responsible for delivering data with the styling being applied
    This relieves all consumers of those methods from taking care of applying the style and properly assign it to those two methods and the implementation.

@HeikoKlare HeikoKlare requested a review from Copilot January 23, 2026 14:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the application of gray/disabled image adaptations in the Win32 Image implementation to eliminate duplicate processing and improve consistency. Previously, both the loadImageData() methods and their callers were applying these adaptations, resulting in unnecessary duplicate transformations.

Changes:

  • Centralized gray/disabled adaptation responsibility to loadImageData() and loadImageDataAtExactSize() provider methods
  • Removed redundant adaptation calls from consumers of these methods
  • Added documentation clarifying that provider methods return pre-adapted image data

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

HeikoKlare and others added 6 commits January 23, 2026 16:31
When requesting an ImageList from a Display, the zoom is currently not
considered when scanning through the existing image lists for a matching
one. This can lead to an image list with a wrong zoom being used, such
that the contained image handles are not properly fitting in size and
thus need to be scaled.

This changes includes the zoom into the identification of whether one of
a Display's image lists fits to the requested properties or not. To this
end, the whole validation logic is moved to the ImageList class itself,
such that it's style and zoom do not need to be exposed unnecessarily.
…atform#2119

Control: don't send MouseMove events with stateMask set for BUTTON1
before the MouseDown event was sent

These events are already added to the dragDetectionQueue, so there is no
need to send/post them now.
The Tray implementation uses the default constructor of the Widget
class. When using that constructor, the nativeZoom of the widget is not
initialized. In case of a Tray, contained TrayItems inherit that zoom
and will fail to get an image set because the zoom is zero.
With this change, a TrayItem will initialize its native zoom based on
the zoom of the context device.
When an image is created with SWT.IMAGE_GRAY or SWT.IMAGE_DISABLE, an
adaptation of the loaded/created image data is performed to make it look
grayed/disabled. The according functionality is currently applied by
callers of loadImageData() right afterwards. Since for every consumption
of an image data/handle the loadImageData() method needs to be called,
this ensures that the image data is always adapted correctly.

In the implementation for an ImageGcDrawer, the adaptation for
gray/disabled is currently executed within the loadImageData() method.
The same applies to implementation for an existing handle and a plain
image, as they will simply scale existing image data (which already have
the gray/disabled adaptation applied).
Since consumers of that method perform the adaptation as well, this
leads to an unnecessary duplicate application of the adaptation and to
inconsistent behavior throughout the implementations of loadImageData().

This change streamlines the implementation in the Image class by
properly assigning the responsibility for applying gray/disabled
adaptations as follows:
- the copy constructor accepting the gray/disabled flag applies the
style to copied handles, just like it does now
- on retrieval of new image data or handles for zoom/sizes, the
loadImageData() and loadImageDataAtExactSize() method of the provider
classes are responsible for delivering data with the styling being
applied
This relieves all consumers of those methods from taking care of
applying the style and properly assign it to those two methods and the
implementation.
@HeikoKlare HeikoKlare force-pushed the streamline-adaptgraydisabled-inloadimagedata branch from 40d0ca8 to 1bafbae Compare January 26, 2026 16:00
@HeikoKlare HeikoKlare closed this Jan 26, 2026
@HeikoKlare HeikoKlare deleted the streamline-adaptgraydisabled-inloadimagedata branch January 26, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants