0

我正在使用一个包含多个列的树视图,如果音频正在播放或暂停,还有一个显示 pixbuf。如果用户双击某一行,音频播放开始并且需要重新渲染该行以显示 pixbuf 图标。我为此使用了 QueueDraw,但这仅在光标离开当前行时才有效。如何直接更新 pixbuf?

代码:

protected void trvMainCuesheetRowActivated (object o, RowActivatedArgs args)
    {
        log.debug("trvMainCuesheetRowActivated called");
        TreeIter ti = TreeIter.Zero;
        this.lsCuesheetData.GetIter(out ti,args.Path);
        if (this.lsCuesheetData.GetValue(ti,0) != null)
        {
            Track tCurTrack = (Track)this.lsCuesheetData.GetValue(ti,0);
            if (this.objProgram.getAudioManager().getPlayState() == AudioCuesheetEditor.AudioBackend.PlayState.Stopped)
            {
                this.objProgram.getAudioManager().play(tCurTrack);
                this.refresh();
            }
            else
            {
                if (this.objProgram.getAudioManager().getPlayState() == AudioCuesheetEditor.AudioBackend.PlayState.Playing)
                {
                    this.objProgram.getAudioManager().seek(tCurTrack);
                    this.refresh();
                }
            }
        }
    }


private void renderPlaying(TreeViewColumn _tvcColumn, CellRenderer _crCell, TreeModel _tmModel, TreeIter _tiIter)
    {
        Track tCurTrack = (Track)_tmModel.GetValue (_tiIter, 0);
        //Just display an icon, if we are playing
        if (this.objProgram.getAudioManager().getPlayState() == AudioCuesheetEditor.AudioBackend.PlayState.Playing)
        {
            if (this.objProgram.getAudioManager().getCurrentlyPlayingTrack() == tCurTrack)
            {
                Gdk.Pixbuf icon = this.RenderIcon(Stock.MediaPlay, IconSize.SmallToolbar, null);
                (_crCell as CellRendererPixbuf).Pixbuf = icon;
            } 
            else
            {
                (_crCell as CellRendererPixbuf).Pixbuf = null;
            }
        }
        else
        {
            if (this.objProgram.getAudioManager().getPlayState() == AudioCuesheetEditor.AudioBackend.PlayState.Paused)
            {
                if (this.objProgram.getAudioManager().getCurrentlyPlayingTrack() == tCurTrack)
                {
                    Gdk.Pixbuf icon = this.RenderIcon(Stock.MediaPause, IconSize.SmallToolbar, null);
                    (_crCell as CellRendererPixbuf).Pixbuf = icon;
                }
                else
                {
                    (_crCell as CellRendererPixbuf).Pixbuf = null;
                }
            }
            else
            {
                (_crCell as CellRendererPixbuf).Pixbuf = null;
            }
        }
    }

//Purpose: Function used to refresh the MainWindow depending on new options set.
public void refresh()
{
    //QueueDraw is needed since it fires a signal to cellrenderers to update
    this.trvMainCuesheet.QueueDraw();
    this.sbMainWindow.Visible = this.objProgram.getObjOption().getBShowStatusbar();
    this.mwToolbar.Visible = this.objProgram.getObjOption().getBToolbarVisible();
}

问候斯文

4

1 回答 1

0

自己发现了错误。

this.objProgram.getAudioManager().getCurrentlyPlayingTrack()

并不总是返回我期望的轨道,因此渲染器工作正常。错误已修复,无论如何谢谢;)。

于 2014-07-16T09:47:46.357 回答