Skip to content

Commit

Permalink
Soporte de combobox para MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Israel-ICM committed Oct 21, 2021
1 parent 6d6b210 commit 43eb538
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 47 deletions.
Binary file modified build/classes/icm/sphynx/ui/components/metro/UIComboBox.class
Binary file not shown.
Binary file modified build/classes/icm/sphynx/ui/components/metro/UITools.class
Binary file not shown.
29 changes: 3 additions & 26 deletions nbproject/private/private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,9 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/MetroUIConfigTheme.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UITabbedPane.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UIPanel.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UILabel.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UITools.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UIButton.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UIToggleButton.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UIComboBox.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UIFormattedTextField.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UIPasswordField.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UITextField.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/styles/MetroUI.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UICheckBox.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/tools/ToolsHeaderCellRendererTable.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/tools/IconsMetroUI.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UIList.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UIProgressBar.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UISplitPane.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UISlider.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UITableHeader.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UIRadioButton.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/styles/MyStyles.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UITextArea.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/tools/StyleColorsMetro.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UITable.java</file>
<file>file:/C:/Users/josue2/Documents/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/MetroUIComponent.java</file>
<file>file:/Users/israel-icm/NetBeansProjects/MyStyles/src/icm/sphynx/styles/MetroUI.java</file>
<file>file:/Users/israel-icm/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UITools.java</file>
<file>file:/Users/israel-icm/NetBeansProjects/MyStyles/src/icm/sphynx/ui/components/metro/UIComboBox.java</file>
</group>
</open-files>
</project-private>
51 changes: 30 additions & 21 deletions src/icm/sphynx/ui/components/metro/UIComboBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,13 @@ protected ComboPopup createPopup() {
BasicComboPopup popupCombobox = new BasicComboPopup(comboBox) {
@Override
protected Rectangle computePopupBounds(int x, int y, int width, int height) {
// Aquí subimos un poco la posición en "y" del popup del combobox
return super.computePopupBounds(x - borde, y - (comboBox.getHeight() + borde) - 4, width + (borde * 2), height + (borde));
if (UITools.isMacOS()) {
return super.computePopupBounds(x, y - comboBox.getHeight(), width, height);
}
else {
// Aquí subimos un poco la posición en "y" del popup del combobox
return super.computePopupBounds(x - borde, y - (comboBox.getHeight() + borde) - 4, width + (borde * 2), height + (borde));
}
}

@Override
Expand All @@ -148,27 +153,31 @@ protected void togglePopup() {
@Override
public void show() {
JComponent a = this;

new Thread() {
@Override
public void run() {
// Animación de apertura
float crecer = getPopupHeightForRowCount(comboBox.getMaximumRowCount()) + 30;
int height = 0;
int velocidad = 7;
for (int i = 0; i < velocidad; i++) {
hide();
executePopupCombobox(a, height);
if (UITools.isMacOS()) {
super.show();
}
else {
new Thread() {
@Override
public void run() {
// Animación de apertura
float crecer = getPopupHeightForRowCount(comboBox.getMaximumRowCount()) + 30;
int height = 0;
int velocidad = 7;
for (int i = 0; i < velocidad; i++) {
hide();
executePopupCombobox(a, height);

try {
Thread.sleep(10);
} catch (InterruptedException ex) { }
height += Math.ceil(crecer / velocidad); // El ceil redondea al inmediato superior
if (i == (velocidad - 2)) // Esto es para que la ultima iteración siempre el height tenga el tamaño total
height = (int)crecer;
try {
Thread.sleep(10);
} catch (InterruptedException ex) { }
height += Math.ceil(crecer / velocidad); // El ceil redondea al inmediato superior
if (i == (velocidad - 2)) // Esto es para que la ultima iteración siempre el height tenga el tamaño total
height = (int)crecer;
}
}
}
}.start();
}.start();
}
}
public void executePopupCombobox(JComponent c, int height) {
c.setPreferredSize(new Dimension(comboBox.getWidth() + 20, height));
Expand Down
4 changes: 4 additions & 0 deletions src/icm/sphynx/ui/components/metro/UITools.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public class UITools {

public static final String PATH_IMAGE = "/sphynx/ui/components/img/";

public static boolean isMacOS() {
return System.getProperty("os.name").contains("Mac");
}

public static String aclararColor(String colorHex) {
return aclararColor(colorHex, 1);
}
Expand Down

0 comments on commit 43eb538

Please sign in to comment.