Skip to content

Commit

Permalink
Sneak resizable waveform windows into the release.
Browse files Browse the repository at this point in the history
This was quick enough I could accommodate Teo Tormo. ^_^
  • Loading branch information
brunchboy committed Nov 25, 2019
1 parent a81f7c9 commit 9067e94
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Nothing so far.
mixer by responding to its MIDI messages.
- There is also an example Show that can take over the players and
perform simple mixes when the DJ needs to take an urgent break.
- Clicking on the scrolling waveform detail in the Player Status
window now opens an independent, resizable window containing that
scrolling waveform, in case you want a larger view (for example to
use as an overlay in a live stream).
- Expression editors have been greatly improved, with new features in
the context menu, and a new menu bar:
- They now allow you to load or insert files into the expression
Expand Down
15 changes: 15 additions & 0 deletions doc/modules/ROOT/pages/Players.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ connected to, then you can use the "On-Air" indication above the
player number as an additional hint about when you need to pay
attention to it.

=== Larger Waveform Windows

If you would like to display an even more detailed view of a track
waveform, for example because you are live streaming a performance and
want to overlay that on your video feed, you can open up a resizable
window containing just the scrolling waveform details. If you move the
mouse over the scrolling waveform in the Player Status window, the
cursor becomes a magnifying glass. Clicking on the waveform opens it
in a separate window that you can resize, position, and zoom
indepentently. Each player's waveform detail window will remember how
you have sized and positioned it so that the next time you open it you
will find it configured the same way. If the window is already open
when you click on the waveform in the Player Status window, it will
simply be brought to the front if it was hidden.

=== Non-rekordbox Metadata

The Player Status window is a lot less useful if non-rekordbox tracks
Expand Down
Binary file added resources/images/Magnify-cursor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 45 additions & 1 deletion src/beat_link_trigger/players.clj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
[]
((resolve 'beat-link-trigger.triggers/real-player?)))

(def magnify-cursor
"A custom cursor that indicates something can be magnified."
(.createCustomCursor (java.awt.Toolkit/getDefaultToolkit)
(.getImage (seesaw/icon "images/Magnify-cursor.png"))
(java.awt.Point. 6 6)
"Magnify"))

(defonce ^{:private true
:doc "Keeps track of whether we have already warned about
Expand Down Expand Up @@ -561,6 +567,37 @@
(when item
(.label item)))

(defonce ^{:private true
:doc "Holds any waveform detail windows that the user has open,
indexed by player number."}

waveform-windows (atom {}))

(defn open-waveform-window
"Creates a standalone, resizable window displaying a player waveform,
given a player number.."
[n parent]
(if-let [existing (get @waveform-windows n)]
(.toFront existing) ; Already open, just bring to front.
(let [key (keyword (str "waveform-detail-" n)) ; Not open yet, so create.
wave (WaveformDetailComponent. n)
zoom-slider (seesaw/slider :id :zoom :min 1 :max 32 :value 2
:listen [:state-changed #(.setScale wave (seesaw/value %))])
zoom-panel (seesaw/border-panel :background "#000"
:center zoom-slider :east (seesaw/label :text " Zoom "))
panel (seesaw/border-panel :background "#000" :north zoom-panel :center wave)
root (seesaw/frame :title (str "Player " n " Waveform Detail")
:on-close :dispose
:width 600 :height 200
:content panel)]
(swap! waveform-windows assoc n root)
(.setScale wave 2)
(util/restore-window-position root key parent)
(seesaw/listen root :component-moved (fn [e] (util/save-window-position root key)))
(seesaw/listen root :window-closed (fn [e] (swap! waveform-windows dissoc n)))
(seesaw/show! root)
(.toFront root))))

(defn- update-metadata-labels
"Updates the track title and artist name when the metadata has
changed. Let the user know if they are not going to be able to get
Expand Down Expand Up @@ -785,6 +822,11 @@
(seesaw/config! button :icon (seesaw/icon "images/Gear-outline.png") :enabled? true)
(seesaw/config! label :text (media-description slot-reference)))))))]

;; Display the magnify cursor over the waveform detail component,
;; and open a standalone window on the waveform when it is clicked.
(.setCursor detail magnify-cursor)
(seesaw/listen detail :mouse-clicked (fn [e] (open-waveform-window n detail)))

;; Show the slot cache popup menus on ordinary mouse presses on the buttons too.
(seesaw/listen usb-gear
:mouse-pressed (fn [e]
Expand Down Expand Up @@ -953,7 +995,9 @@
(>!! shutdown-chan :done)
(reset! player-window nil)
(.removeDeviceAnnouncementListener device-finder dev-listener)
(.removeLifecycleListener virtual-cdj stop-listener)))
(.removeLifecycleListener virtual-cdj stop-listener)
(doseq [detail (vals @waveform-windows)]
(.dispose detail))))
(seesaw/listen root :component-moved (fn [e] (util/save-window-position root :player-status true)))
(seesaw/pack! root)
(.setResizable root @allow-ugly-resizing)
Expand Down

0 comments on commit 9067e94

Please sign in to comment.