Skip to content

Commit

Permalink
Scaling combo text according to zoom level
Browse files Browse the repository at this point in the history
Registering the comboDpiChange handler and applying change manually to
text, image and arrow

Contributes to #62 and #127
  • Loading branch information
ShahzaibIbrahim committed Jun 19, 2024
1 parent f708ac3 commit c9c43d0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
* Contributors:
* Yatta Solutions - initial API and implementation
*******************************************************************************/
package org.eclipse.swt.internal;
package org.eclipse.swt.custom;

import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.widgets.*;

/**
Expand All @@ -31,6 +32,7 @@ public class CommonWidgetsDPIChangeHandlers {

public static void registerCommonHandlers() {
DPIZoomChangeRegistry.registerHandler(CommonWidgetsDPIChangeHandlers::handleItemDPIChange, Item.class);
DPIZoomChangeRegistry.registerHandler(CommonWidgetsDPIChangeHandlers::handleCComboDPIChange, CCombo.class);
}

private static void handleItemDPIChange(Widget widget, int newZoom, float scalingFactor) {
Expand All @@ -43,4 +45,15 @@ private static void handleItemDPIChange(Widget widget, int newZoom, float scalin
item.setImage(image);
}
}

private static void handleCComboDPIChange(Widget widget, int newZoom, float scalingFactor) {
if (!(widget instanceof CCombo)) {
return;
}
CCombo combo = (CCombo) widget;

DPIZoomChangeRegistry.applyChange(combo.text, newZoom, scalingFactor);
DPIZoomChangeRegistry.applyChange(combo.list, newZoom, scalingFactor);
DPIZoomChangeRegistry.applyChange(combo.arrow, newZoom, scalingFactor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.function.*;

import org.eclipse.swt.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.ole.win32.*;
Expand Down

0 comments on commit c9c43d0

Please sign in to comment.