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()
{
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);
mMutedLabel.setFont(mFont);
@@ -109,7 +110,7 @@ public class AudioChannelPanel extends JPanel
mTo.setFont(mFont);
mTo.setForeground(mValueColor);
add(mTo);
add(mTo,"wmin 10lp");
}
@Override
@@ -159,30 +160,40 @@ public class AudioChannelPanel extends JPanel
* does not occur on the Swing event thread -- wrap any calls to this
* 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(alias != null)
{
valueLabel.setText(alias.getName());
aliasLabel.setIcon(mIconManager.getIcon(alias.getIconName(), 18));
iconLabel.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
{
valueLabel.setText(value);
aliasLabel.setIcon(null);
iconLabel.setIcon(null);
textLabel.setText(value);
}
}
else
{
valueLabel.setText("-----");
aliasLabel.setIcon(null);
iconLabel.setIcon(null);
textLabel.setText("-----");
}
}
/**
* 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)
{
// setLayout(new MigLayout("insets 0 0 0 0", "[][grow,fill][][grow,fill]", "[grow,fill]"));
setLayout(new MigLayout("insets 0 0 0 0", "[][sg,grow,fill][][sg,grow,fill]", "[grow,fill]"));
setLayout(new MigLayout("insets 0 0 0 0", "[][sg abc,grow,fill][][sg abc,grow,fill]", "[grow,fill]"));
setBackground(Color.BLACK);
@@ -44,7 +43,7 @@ public class AudioChannelsPanel extends JPanel
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)
{