most solid commit
This commit is contained in:
@@ -67,41 +67,36 @@ class WaveformWidget(Gtk.Box):
|
||||
cr.line_to(width, mid_y)
|
||||
cr.stroke()
|
||||
|
||||
# Draw peaks
|
||||
if self._peaks is not None and len(self._peaks) > 0 and duration > 0:
|
||||
# Draw peaks — always stretch to fill full width
|
||||
if self._peaks is not None and len(self._peaks) > 0:
|
||||
n_peaks = len(self._peaks)
|
||||
# Map peaks to pixel columns
|
||||
peak_duration = n_peaks * self._bucket_duration
|
||||
max_peak = np.max(self._peaks) if np.max(self._peaks) > 0 else 1.0
|
||||
|
||||
for x in range(width):
|
||||
# Time at this pixel
|
||||
t = (x / width) * duration
|
||||
# Corresponding peak index
|
||||
idx = int(t / self._bucket_duration)
|
||||
idx = int((x / width) * n_peaks)
|
||||
if 0 <= idx < n_peaks:
|
||||
val = self._peaks[idx] / max_peak
|
||||
bar_h = val * (height * 0.45) # 90% of half-height
|
||||
# Green gradient based on amplitude
|
||||
bar_h = val * (height * 0.45)
|
||||
cr.set_source_rgba(0.2, 0.6 + val * 0.4, 0.3, 0.85)
|
||||
cr.rectangle(x, mid_y - bar_h, 1, bar_h * 2)
|
||||
cr.fill()
|
||||
|
||||
# Scene markers
|
||||
if duration > 0:
|
||||
cr.set_source_rgba(1.0, 1.0, 0.3, 0.3)
|
||||
cr.set_line_width(1)
|
||||
for marker in state.scene_markers:
|
||||
mx = (marker / duration) * width
|
||||
# Scene markers and playhead use timeline duration
|
||||
x_duration = max(duration, 0.1)
|
||||
|
||||
cr.set_source_rgba(1.0, 1.0, 0.3, 0.3)
|
||||
cr.set_line_width(1)
|
||||
for marker in state.scene_markers:
|
||||
mx = (marker / x_duration) * width
|
||||
if 0 <= mx <= width:
|
||||
cr.move_to(mx, 0)
|
||||
cr.line_to(mx, height)
|
||||
cr.stroke()
|
||||
|
||||
# Playhead
|
||||
if duration > 0:
|
||||
px = (state.cursor / duration) * width
|
||||
cr.set_source_rgba(1.0, 0.3, 0.3, 0.9)
|
||||
cr.set_line_width(2)
|
||||
cr.move_to(px, 0)
|
||||
cr.line_to(px, height)
|
||||
cr.stroke()
|
||||
px = (state.cursor / x_duration) * width
|
||||
cr.set_source_rgba(1.0, 0.3, 0.3, 0.9)
|
||||
cr.set_line_width(2)
|
||||
cr.move_to(px, 0)
|
||||
cr.line_to(px, height)
|
||||
cr.stroke()
|
||||
|
||||
Reference in New Issue
Block a user