-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Issue #378 Null exception when dragging MixConsole while no song…
… opened. Implement Issue #375 "Add clone as user track" action. Add MidiMixManager.getExistingMix(Song). Add createEnterExitComponentLayer(). Add CornerLayout.
- Loading branch information
Showing
14 changed files
with
949 additions
and
66 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
modules/MixConsole/src/main/java/org/jjazz/mixconsole/PhraseViewerPanelRhythm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | ||
* | ||
* Copyright @2019 Jerome Lelasseux. All rights reserved. | ||
* | ||
* This file is part of the JJazzLab software. | ||
* | ||
* JJazzLab is free software: you can redistribute it and/or modify | ||
* it under the terms of the Lesser GNU General Public License (LGPLv3) | ||
* as published by the Free Software Foundation, either version 3 of the License, | ||
* or (at your option) any later version. | ||
* | ||
* JJazzLab is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with JJazzLab. If not, see <https://www.gnu.org/licenses/> | ||
* | ||
* Contributor(s): | ||
*/ | ||
package org.jjazz.mixconsole; | ||
|
||
import java.awt.BorderLayout; | ||
import java.util.function.Consumer; | ||
import java.util.logging.Logger; | ||
import javax.swing.Icon; | ||
import javax.swing.ImageIcon; | ||
import javax.swing.JPanel; | ||
import org.jjazz.midimix.api.MidiMix; | ||
import org.jjazz.rhythm.api.RhythmVoice; | ||
import org.jjazz.song.api.Song; | ||
import org.jjazz.flatcomponents.api.FlatButton; | ||
import org.jjazz.uiutilities.api.CornerLayout; | ||
import org.jjazz.uiutilities.api.UIUtilities; | ||
import org.jjazz.utilities.api.ResUtil; | ||
|
||
/** | ||
* Add "clone as user track" button which appears only when hovering component. | ||
*/ | ||
public class PhraseViewerPanelRhythm extends PhraseViewerPanel | ||
{ | ||
private static final Icon ICON_CLONE_AS_USER_TRACK = new ImageIcon(PhraseViewerPanelRhythm.class.getResource("resources/CloneTrack-10x10.png")); | ||
private final JPanel supportPanel; // Needed to use JLayer | ||
private final FlatButton fbtn_clone; | ||
private boolean buttonShown; | ||
private static final Logger LOGGER = Logger.getLogger(PhraseViewerPanelRhythm.class.getSimpleName()); | ||
|
||
public PhraseViewerPanelRhythm(Song song, MidiMix mMix, MixChannelPanelController controller, RhythmVoice rv) | ||
{ | ||
super(song, mMix, controller, rv); | ||
|
||
// Prepare the button | ||
fbtn_clone = new FlatButton(); | ||
fbtn_clone.setIcon(ICON_CLONE_AS_USER_TRACK); | ||
fbtn_clone.addActionListener(ae -> getController().cloneRhythmTrackAsUserTrack(getRhythmVoice())); | ||
fbtn_clone.setToolTipText(ResUtil.getString(getClass(), "PhraseViewerPanel.CloneAsUserTrackToolip")); | ||
|
||
|
||
// Prepare for the JLayer | ||
// We can't directly associate a JLayer to "this" JPanel object, so we add a support panel on which JLayer will be used | ||
supportPanel = new JPanel(); | ||
supportPanel.setLayout(new CornerLayout(BUTTONS_PADDING)); // Reuse layout of parent class | ||
supportPanel.setOpaque(false); // So we can see the PhraseViewerPanel background | ||
var enterExitConsumer = new Consumer<Boolean>() | ||
{ | ||
@Override | ||
public void accept(Boolean b) | ||
{ | ||
// LOGGER.log(Level.SEVERE, "this={0} accept() b={1} buttonShown={2}", new Object[] | ||
// { | ||
// PhraseViewerPanelRhythm.this, b, buttonShown | ||
// }); | ||
if (b && !buttonShown) | ||
{ | ||
buttonShown = true; | ||
supportPanel.add(fbtn_clone, CornerLayout.NORTH_EAST); | ||
supportPanel.revalidate(); | ||
supportPanel.repaint(); | ||
|
||
} else if (!b && buttonShown) | ||
{ | ||
buttonShown = false; | ||
supportPanel.remove(fbtn_clone); | ||
supportPanel.revalidate(); | ||
supportPanel.repaint(); | ||
} | ||
} | ||
}; | ||
var layer = UIUtilities.createEnterExitComponentLayer(supportPanel, enterExitConsumer); | ||
|
||
|
||
// Now add the JLayer so that it takes all the place | ||
setLayout(new BorderLayout()); | ||
add(layer, BorderLayout.CENTER); | ||
} | ||
|
||
|
||
// ---------------------------------------------------------------------------- | ||
// Private methods | ||
// ---------------------------------------------------------------------------- | ||
// ---------------------------------------------------------------------------- | ||
// Inner classes | ||
// ---------------------------------------------------------------------------- | ||
} |
Oops, something went wrong.