Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- Resolved a "Slow operations are prohibited on EDT" exception on Flutter Project creation (#8446, #8447, #8448)
- Made dev release daily instead of weekly
- Set the device selector component to opaque during its creation to avoid an unexpected background color (#8471)

## 87.1.0

Expand Down
35 changes: 35 additions & 0 deletions src/io/flutter/actions/DeviceSelectorAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.ui.JBColor;
import com.intellij.util.ModalityUiUtil;
import icons.FlutterIcons;
import io.flutter.FlutterBundle;
Expand All @@ -29,6 +30,7 @@
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.awt.Component;
import java.util.*;

public class DeviceSelectorAction extends ComboBoxAction implements DumbAware {
Expand All @@ -45,6 +47,39 @@ public class DeviceSelectorAction extends ComboBoxAction implements DumbAware {
return ActionUpdateThread.BGT;
}

@Override
public @NotNull JComponent createCustomComponent(@NotNull Presentation presentation, @NotNull String place) {
final JComponent component = super.createCustomComponent(presentation, place);
// Set component to be transparent to match other toolbar actions
component.setOpaque(false);
// Update child components.
updateComponentChildrenStyles(component);
return component;
}

private void updateComponentChildrenStyles(@NotNull JComponent parent) {
final @Nullable Component[] children = parent.getComponents();
if (children == null) {
return;
}

for (Component child : children) {
if (child instanceof JComponent jComponent) {
jComponent.setOpaque(false);

if (child instanceof JButton jButton) {
jButton.setBorderPainted(false);
jButton.setRolloverEnabled(true);
// Make sure the button uses correct background & foreground.
jButton.setBackground(JBColor.background());
jButton.setForeground(JBColor.foreground());
}

updateComponentChildrenStyles(jComponent);
}
}
}

@Override
protected @NotNull DefaultActionGroup createPopupActionGroup(@NotNull JComponent button, @NotNull DataContext dataContext) {
final DefaultActionGroup group = new DefaultActionGroup();
Expand Down