Merge pull request #240 from DSheirer/234-long-alias-names-cause-audio-label-to-wrap

Long alias names cause audio label to wrap
This commit is contained in:
Denny Sheirer
2017-03-31 01:13:17 +00:00
committed by GitHub
2 changed files with 23 additions and 13 deletions

View File

@@ -90,7 +90,8 @@ public class AudioChannelPanel extends JPanel
private void init() private void init()
{ {
setLayout(new MigLayout("align center center, insets 0 0 0 0", "[][][align right]0[grow,fill]", "")); setLayout(new MigLayout("align center center, insets 0 0 0 0",
"[][][align right]0[grow,fill]", ""));
setBackground(mBackgroundColor); setBackground(mBackgroundColor);
mMutedLabel.setFont(mFont); mMutedLabel.setFont(mFont);
@@ -109,7 +110,7 @@ public class AudioChannelPanel extends JPanel
mTo.setFont(mFont); mTo.setFont(mFont);
mTo.setForeground(mValueColor); mTo.setForeground(mValueColor);
add(mTo); add(mTo,"wmin 10lp");
} }
@Override @Override
@@ -159,30 +160,40 @@ public class AudioChannelPanel extends JPanel
* does not occur on the Swing event thread -- wrap any calls to this * does not occur on the Swing event thread -- wrap any calls to this
* method with an event thread call. * method with an event thread call.
*/ */
private void updateLabel(JLabel valueLabel, String value, JLabel aliasLabel, Alias alias) private void updateLabel(JLabel textLabel, String value, JLabel iconLabel, Alias alias)
{ {
if(value != null) if(value != null)
{ {
if(alias != null) if(alias != null)
{ {
valueLabel.setText(alias.getName()); iconLabel.setIcon(mIconManager.getIcon(alias.getIconName(), 18));
aliasLabel.setIcon(mIconManager.getIcon(alias.getIconName(), 18));
String aliasName = alias.getName();
//Truncate label if length exceeds 33 characters - hack!
if(aliasName.length() > 33)
{
textLabel.setText(aliasName.substring(0,30) + "...");
}
else
{
textLabel.setText(aliasName);
}
} }
else else
{ {
valueLabel.setText(value); iconLabel.setIcon(null);
aliasLabel.setIcon(null); textLabel.setText(value);
} }
} }
else else
{ {
valueLabel.setText("-----"); iconLabel.setIcon(null);
aliasLabel.setIcon(null); textLabel.setText("-----");
} }
} }
/** /**
* Processes audio metadata to update this panel's display values * Processes audio metadata to update this panel's display values
*/ */

View File

@@ -33,8 +33,7 @@ public class AudioChannelsPanel extends JPanel
public AudioChannelsPanel(IconManager iconManager, SettingsManager settingsManager, IAudioController controller) public AudioChannelsPanel(IconManager iconManager, SettingsManager settingsManager, IAudioController controller)
{ {
// setLayout(new MigLayout("insets 0 0 0 0", "[][grow,fill][][grow,fill]", "[grow,fill]")); setLayout(new MigLayout("insets 0 0 0 0", "[][sg abc,grow,fill][][sg abc,grow,fill]", "[grow,fill]"));
setLayout(new MigLayout("insets 0 0 0 0", "[][sg,grow,fill][][sg,grow,fill]", "[grow,fill]"));
setBackground(Color.BLACK); setBackground(Color.BLACK);
@@ -44,7 +43,7 @@ public class AudioChannelsPanel extends JPanel
for(int x = 0; x < outputs.size(); x++) for(int x = 0; x < outputs.size(); x++)
{ {
add(new AudioChannelPanel(iconManager, settingsManager, outputs.get(x)), "growx"); add(new AudioChannelPanel(iconManager, settingsManager, outputs.get(x)));
if(x < outputs.size() - 1) if(x < outputs.size() - 1)
{ {