Implemented copy, cut and paste frame
[dashstudio.git] / src / components / timeline / timelinewidget.cpp
blobc451a77d8f6ea1564d6105c2ed3576aebae02d1b
1 /***************************************************************************
2 * Copyright (C) 2007 by Jorge Cuadrado *
3 * kuadrosxx@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "timelinewidget.h"
23 #include "layermanager.h"
24 #include "framestable.h"
26 #include <QStackedWidget>
27 #include <QTreeWidget>
28 #include <QHeaderView>
29 #include <QLayout>
30 #include <QTimer>
32 #include <dgui/iconloader.h>
33 #include <dgui/imagebutton.h>
35 #include <dcore/debug.h>
37 #include "ui_frames.h"
38 #include "ui_layers.h"
39 #include "ui_scenes.h"
41 namespace Dash {
42 namespace Component {
44 struct TimeLineWidget::Private
46 Ui::Frames frames;
47 Ui::Layers layers;
48 Ui::Scenes scenes;
50 QButtonGroup actions;
52 QTimer timer;
55 TimeLineWidget::Event createEvent(TimeLineWidget *tl, TimeLineWidget::Action action)
57 Event event;
58 event.action = Action(action);
59 event.scene = tl->scene();
60 event.layer = tl->layer();
61 event.frame = tl->frame();
62 return event;
66 /**
67 * @~spanish
68 * Constructor
70 TimeLineWidget::TimeLineWidget(QWidget * parent)
71 : QSplitter(Qt::Horizontal, parent), d(new Private)
73 QWidget *scenesWidget = new QWidget;
74 d->scenes.setupUi(scenesWidget);
75 addWidget(scenesWidget);
77 QWidget *layersWidget = new QWidget;
78 d->layers.setupUi(layersWidget);
79 addWidget(layersWidget);
81 QWidget *framesWidget = new QWidget;
82 d->frames.setupUi(framesWidget);
83 addWidget(framesWidget);
85 d->scenes.container->setHeaderLabels(QStringList() << tr("Scene"));
86 connect(d->scenes.container, SIGNAL(itemClicked( QTreeWidgetItem *, int)), this, SLOT(onItemClicked(QTreeWidgetItem *, int)));
88 connect(d->scenes.container, SIGNAL(itemChanged( QTreeWidgetItem *, int)), this, SLOT(onItemChanged(QTreeWidgetItem *, int)));
90 connect(&d->actions, SIGNAL(buttonClicked(int)), this, SLOT(onButtonClicked(int)));
92 connect(&d->timer, SIGNAL(timeout()), this, SLOT(nextFrame()));
94 setupButtons();
96 setSizes(QList<int>() << 100 << 200 << 800);
101 * @~spanish
102 * Destructor
104 TimeLineWidget::~TimeLineWidget()
106 delete d;
110 * @~spanish
111 * Obtiene la posición de la escena actualmente seleccionada.
113 int TimeLineWidget::scene()
115 if(d->scenes.container->topLevelItemCount() == 0)
116 return -1;
118 return d->scenes.container->indexOfTopLevelItem(d->scenes.container->currentItem());
122 * @~spanish
123 * Obtiene la posición del layer actualmente seleccionad0.
125 int TimeLineWidget::layer()
127 const LayerManager *layers = layerManager(scene());
129 if(layers )
131 if( layers->rowCount() == 0 )
133 return -1;
135 if(layers->currentRow() == -1)
137 return -2;
139 return layers->visualRow(layers->currentRow());
141 return -1;
145 * @~spanish
146 * Obtiene la posición del frame actualmente seleccionado.
148 int TimeLineWidget::frame()
150 FramesTable *frames = framesTable(scene());
151 if(frames)
153 if(frames->columnCount() == 0)
155 return -1;
158 if(frames->currentColumn() == -1)
160 return -2;
163 return frames->visualColumn(frames->currentColumn());
165 return -1;
169 * @~spanish
170 * Inserta una escena el la posición @p position y con el nombre @p name.
172 void TimeLineWidget::insertScene(int position, const QString &name)
174 if ( position < 0 || position > d->scenes.container->topLevelItemCount())
176 return;
179 LayerManager *layerManager = new LayerManager( d->layers.container );
181 connect(layerManager, SIGNAL(layerRenamed(int, const QString &)), this, SLOT(onLayerRenamed(int , const QString &)));
182 connect(layerManager, SIGNAL(layerLocked(int, bool)), this, SLOT(onLayerLocked(int , bool)));
183 connect(layerManager, SIGNAL(layerVisibilityChanged(int, bool)), this, SLOT(onLayerVisibilityChanged(int , bool)));
185 layerManager->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
187 FramesTable *framesTable = new FramesTable();
189 connect(framesTable, SIGNAL(frameSelected(int , int)), this, SLOT(onFrameSelected(int , int )));
190 connect(framesTable, SIGNAL(layerSelected(int)), this, SLOT(onLayerSelected(int)));
191 connect(framesTable, SIGNAL(requestInsertFrame(int, int)), this, SLOT(onRequestInsertFrame(int, int)));
192 connect(framesTable, SIGNAL(requestRemoveFrame(int, int)), this, SLOT(onRequestRemoveFrame(int, int)));
194 connect(framesTable, SIGNAL(requestCopyFrame(int, int)), this, SLOT(onRequestCopyFrame(int, int)));
195 connect(framesTable, SIGNAL(requestPasteFrame(int, int)), this, SLOT(onRequestPasteFrame(int, int)));
196 connect(framesTable, SIGNAL(requestCutFrame(int, int)), this, SLOT(onRequestCutFrame(int, int)));
198 connect(framesTable, SIGNAL(requestChangeFrameVisibility(int, int, bool)), this, SLOT(onRequestChangeFrameVisibility(int, int, bool)));
199 connect(framesTable, SIGNAL(requestLockFrame(int, int, bool)), this, SLOT(onRequestLockFrame(int, int, bool)));
201 connect(framesTable, SIGNAL(requestExpandFrame(int, int, int)), this, SLOT(onRequestExpandFrame(int, int, int)));
203 framesTable->setItemSize( 10, 20);
204 layerManager->setRowHeight( 20 );
206 connect(layerManager->verticalScrollBar(), SIGNAL(valueChanged (int)), framesTable->verticalScrollBar(), SLOT(setValue(int)));
207 connect(framesTable->verticalScrollBar(), SIGNAL(valueChanged (int)), layerManager->verticalScrollBar(), SLOT(setValue(int)));
210 d->frames.container->insertWidget(position, framesTable);
211 d->layers.container->insertWidget(position, layerManager);
213 QTreeWidgetItem *newScene = new QTreeWidgetItem;
214 newScene->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled);
215 newScene->setText(0, name);
216 d->scenes.container->insertTopLevelItem(position, newScene);
221 * @~spanish
222 * Elimina la escena que esta en la posición @p position.
224 void TimeLineWidget::removeScene(int position)
226 if ( position >= 0 && position < d->frames.container->count() && position < d->layers.container->count() )
228 QWidget *w = d->frames.container->widget(position);
229 d->frames.container->removeWidget(w);
230 delete w;
232 w = d->layers.container->widget(position);
233 d->layers.container->removeWidget(w);
234 delete w;
236 delete d->scenes.container->topLevelItem(position);
242 * @~spanish
243 * Cambia el nombre de la escena que esta en la posición @p position a @p name.
245 void TimeLineWidget::renameScene(int position, const QString &name)
247 if(position < 0 || position >= d->scenes.container->topLevelItemCount() ) return;
248 d->scenes.container->topLevelItem(position)->setText(0, name);
252 * @~spanish
253 * Mueve la escena de la posición @p from a la posición @p to.
255 void TimeLineWidget::moveScene(int from, int to)
257 if(to < from)
259 int swap = to;
260 to = from;
261 from = swap;
264 for(int i = from; i < to; i++)
266 d->scenes.container->insertTopLevelItem(i, d->scenes.container->takeTopLevelItem(i+1) );
268 d->frames.container->insertWidget(i, d->frames.container->widget(i+1));
270 d->layers.container->insertWidget(i, d->layers.container->widget(i+1));
275 * @~spanish
276 * Selecciona la escena que esta en la posición @p position.
278 void TimeLineWidget::setScene(int position)
280 QTreeWidgetItem *item = d->scenes.container->topLevelItem ( position );
281 if(item)
283 d->scenes.container->setCurrentItem(item);
286 d->frames.container->setCurrentIndex(position);
287 d->layers.container->setCurrentIndex(position);
292 * @~spanish
293 * Cierra todas las escenas.
295 void TimeLineWidget::closeAllScenes()
297 while(d->frames.container->currentWidget())
299 delete d->frames.container->currentWidget();
302 while(d->layers.container->currentWidget())
304 delete d->layers.container->currentWidget();
306 d->scenes.container->clear();
310 * @~spanish
311 * Inserta un layer en la posición @p position de la escena @p scenePos, con el nombre @p name.
313 void TimeLineWidget::insertLayer(int scenePos, int position, const QString &name)
315 LayerManager *layerManager = this->layerManager(scenePos);
316 if(layerManager)
318 layerManager->insertLayer(position, name);
321 FramesTable *fst = framesTable( scenePos );
322 if( fst )
324 fst->insertLayer(position, name);
329 * @~spanish
330 * Inserta un layer de audio en la posición @p position de la escena @p scenePos, con el nombre @p name y la posición del frame donde inicia el audio.
332 void TimeLineWidget::insertAudioLayer(int scenePos, int position, const QString &name, int startFrame)
334 LayerManager *layerManager = this->layerManager(scenePos);
335 if(layerManager)
337 layerManager->insertSoundLayer(position, name);
340 FramesTable *fst = framesTable( scenePos );
341 if( fst )
343 fst->insertSoundLayer(position, name);
344 for(int i = startFrame; i < fst->columnCount(); i++)
346 fst->insertFrame(position, i, tr(" "));
352 * @~spanish
353 * Elimina el layer que esta en la posicion @p position de la escena @p scenePos.
355 void TimeLineWidget::removeLayer(int scenePos, int position)
357 LayerManager *layerManager = this->layerManager(scenePos);
358 if(layerManager)
360 layerManager->removeLayer(position);
363 FramesTable *fst = framesTable( scenePos );
364 if( fst )
366 fst->removeLayer(position);
371 * @~spanish
372 * Cambia el nombre del layer que se encuentra en la posicion @p layerPos de la escena @p scenePos, por @p name.
374 void TimeLineWidget::renameLayer(int scenePos, int layerPos, const QString &name)
376 LayerManager *layerManager = this->layerManager(scenePos);
377 if(layerManager)
379 layerManager->renameLayer(layerPos, name);
384 * @~spanish
385 * Cambia el estado de visibilidad del layer que esta en la posición @p position de la escena @p scenePos, si @p isVisible es verdadero muestra el layer como visible y si es falso lo muestra como no visible.
387 void TimeLineWidget::setLayerVisibility(int scenePos, int position, bool isVisible)
389 LayerManager *layerManager = this->layerManager(scenePos);
390 layerManager->blockSignals(true);
391 if(layerManager)
393 QTableWidgetItem *item = layerManager->item(layerManager->visualRow(position), 2);
394 if(isVisible)
396 item->setCheckState(Qt::Checked);
398 else
400 item->setCheckState(Qt::Unchecked);
404 layerManager->blockSignals(false);
408 * @~spanish
409 * Cambia el estado de bloqueo del layer que esta en la posición @p position de la escena @p scenePos, si @p locked es verdadero muestra el layer como bloqueado y si es falso lo muestra como desbloqueado.
411 void TimeLineWidget::setLayerLocked(int scenePos, int position, bool locked)
413 LayerManager *layerManager = this->layerManager(scenePos);
414 layerManager->blockSignals(true);
415 if(layerManager)
417 QTableWidgetItem *item = layerManager->item(layerManager->visualRow( position ), 1);
418 if(locked)
420 item->setCheckState(Qt::Checked);
422 else
424 item->setCheckState(Qt::Unchecked);
427 layerManager->blockSignals(false);
431 * @~spanish
432 * Mueve el layer de la posición @p from a la posición @p to.
434 void TimeLineWidget::moveLayer(int scenePos, int from, int to)
436 LayerManager *layerManager = this->layerManager( scenePos );
437 if ( layerManager )
439 layerManager->moveLayer( from, to);
442 FramesTable *framesTable = this->framesTable( scenePos );
443 if ( framesTable )
445 framesTable->moveLayer(from, to);
450 * @~spanish
451 * Selecciona el layer que esta en la posición @p position, de la escena @p scenePos.
453 void TimeLineWidget::setLayer(int scenePos, int position)
455 setScene(scenePos);
457 LayerManager *layerManager = this->layerManager( scenePos );
458 if(layerManager)
460 layerManager->setCurrentCell(layerManager->verticalHeader()->logicalIndex(position) , 0);
465 * @~spanish
466 * Inserta un frame en la posición @p position, del layer @p layerPos de la escena @p scenePos, con nombre @p name.
468 void TimeLineWidget::insertFrame(int scenePos, int layerPos, int position, const QString &name)
470 FramesTable *framesTable = this->framesTable( scenePos );
471 if ( framesTable )
473 framesTable->insertFrame(layerPos, position, name);
478 * @~spanish
479 * Elimina el frame que se encuentra en la posición @p position, del layer @p layerPos de la escena @p scenePos.
481 void TimeLineWidget::removeFrame(int scenePos, int layerPos, int position)
483 FramesTable *framesTable = this->framesTable( scenePos );
484 if ( framesTable )
486 framesTable->removeFrame( layerPos, position );
491 * @~spanish
492 * Cambia el nombre del frame que se encuentra en la posición @p position, del layer @p layerPos de la escena @p scenePos, por @p name.
494 void TimeLineWidget::renameFrame(int scenePos, int layerPos, int position, const QString &name)
496 Q_UNUSED(layerPos);
497 Q_UNUSED(position);
498 Q_UNUSED(name);
499 FramesTable *framesTable = this->framesTable( scenePos );
500 if ( framesTable )
502 // framesTable->renameFrame( layerPos, position );
503 //TODO: poner nombre en el item
508 * @~spanish
509 * Mueve el frame de la posición @p from a la posición @p to.
511 void TimeLineWidget::moveFrame(int scenePos, int layerPos, int from, int to)
513 FramesTable *framesTable = this->framesTable( scenePos );
514 if ( framesTable )
516 framesTable->moveFrame(layerPos, from, to);
521 * @~spanish
522 * Selecciona el frame que se encuentra en la posición @p position, del layer @p layerPos de la escena @p scenePos.
524 void TimeLineWidget::setFrame(int scenePos, int layerPos, int position)
526 setLayer(scenePos, layerPos);
528 FramesTable *framesTable = this->framesTable( scenePos );
529 if ( framesTable )
531 framesTable->setCurrentCell( framesTable->visualRow(layerPos), position );
536 * @~spanish
537 * Cambia el estado de visibilidad del frame que se encuentra en la posición @p position, del layer @p layerPos de la escena @p scenePos por @p isVisible, si es verdadero el frame se mostrara como visible, de lo contrario se mostrara como no visible.
539 void TimeLineWidget::setFrameVisibility(int scenePos, int layerPos, int position, bool isVisible)
541 FramesTable *framesTable = this->framesTable( scenePos );
542 if ( framesTable )
544 framesTable->setFrameVisibility(layerPos, position, isVisible);
549 * @~spanish
550 * Cambia el estado de bloqueo del frame que se encuentra en la posición @p position, del layer @p layerPos de la escena @p scenePos por @p locked, si es verdadero el frame se mostrara como bloqueado, de lo contrario se mostrara como desbloqueado.
552 void TimeLineWidget::setFrameLocked(int scenePos, int layerPos, int position, bool locked)
554 FramesTable *framesTable = this->framesTable( scenePos );
555 if ( framesTable )
557 framesTable->lockFrame(layerPos, position, locked);
562 * @~spanish
563 * Agrupa los frames desde la posición @p from hasta la posición @p to.
565 void TimeLineWidget::groupFrames(int scenePos, int layerPos, int from, int to)
567 FramesTable *framesTable = this->framesTable( scenePos );
568 if ( framesTable )
570 framesTable->groupFrames(layerPos, from, to);
575 * @~spanish
576 * Aumenta la duración del frame que se encuentra en la posición @p position, del layer @p layerPos de la escena @p scenePos a @p size.
578 void TimeLineWidget::expandFrame(int scenePos, int layerPos, int position, int size)
580 FramesTable *framesTable = this->framesTable( scenePos );
581 if ( framesTable )
583 framesTable->expandFrame(layerPos, position, size);
588 * @~spanish
589 * Destruye el grupo de frames que se encuentra en la posición @p position, del layer @p layerPos de la escena @p scenePos.
591 void TimeLineWidget::destroyGroupFrames(int scenePos, int layerPos, int position, int size)
593 FramesTable *framesTable = this->framesTable( scenePos );
594 if ( framesTable )
596 framesTable->destroyGroupFrames(layerPos, position, size);
603 void TimeLineWidget::playScene()
605 if(d->timer.isActive ())
607 d->timer.stop();
608 d->scenes.play->setIcon(DGui::IconLoader::self()->load("media-playback-start.svg"));
609 return;
612 int scenePos = scene();
614 FramesTable *framesTable = this->framesTable( scenePos );
615 int layer = 0;
616 if ( framesTable )
618 int maxFrames = 0;
620 for(int i = 0; i < framesTable->rowCount(); i++)
622 int lastFrame = framesTable->lastFrameByLayer(i);
624 if(maxFrames < lastFrame && !framesTable->isSoundLayer(i))
626 maxFrames = lastFrame;
627 layer = i;
631 setFrame(scenePos, layer, frame());
632 d->scenes.play->setIcon(DGui::IconLoader::self()->load("media-playback-pause.svg"));
633 d->timer.start(200);
638 * @internal
640 void TimeLineWidget::onItemClicked(QTreeWidgetItem *item, int)
642 int index = d->scenes.container->indexOfTopLevelItem(item);
643 d->frames.container->setCurrentIndex(index);
644 d->layers.container->setCurrentIndex(index);
648 * @internal
650 void TimeLineWidget::onItemChanged(QTreeWidgetItem *item, int column)
652 Event event;
653 event.scene = d->scenes.container->indexOfTopLevelItem(item);
654 event.action = RenameScene;
655 event.data = item->text(column);
656 emit postEvent(event);
660 * @internal
662 void TimeLineWidget::onFrameSelected(int layerPosition, int framePosition)
664 // int lastFrame = 0;
666 emit frameSelected(d->frames.container->currentIndex(), layerPosition, framePosition);
667 setLayer(d->frames.container->currentIndex(), layerPosition);
671 * @internal
673 void TimeLineWidget::onLayerSelected(int layerPosition)
675 setLayer(d->frames.container->currentIndex(), layerPosition);
679 * @internal
681 void TimeLineWidget::onLayerRenamed(int layerPosition, const QString &newName)
683 Event event;
684 event.scene = d->layers.container->currentIndex();
685 event.layer = layerPosition;
686 event.action = RenameLayer;
687 event.data = newName;
689 emit postEvent(event);
693 * @internal
695 void TimeLineWidget::onLayerLocked(int layerPosition, bool locked)
697 Event event;
698 event.scene = d->layers.container->currentIndex();
699 event.layer = layerPosition;
700 event.action = LockLayer;
701 event.data = locked;
703 emit postEvent(event);
707 * @internal
709 void TimeLineWidget::onLayerVisibilityChanged(int layerPosition, bool isVisible)
711 Event event;
712 event.scene = d->layers.container->currentIndex();
713 event.layer = layerPosition;
714 event.action = ChangeLayerVisibility;
715 event.data = isVisible;
717 emit postEvent(event);
721 * @internal
723 void TimeLineWidget::onButtonClicked(int action)
725 Event e = d->createEvent(this, Action(action));
727 if(e.action == InsertFrame)
729 int lastFrame = 0;
731 FramesTable *frames = framesTable(scene());
732 if(frames)
734 lastFrame = frames->lastFrameByLayer(e.layer);
737 int frame = e.frame;
739 if(lastFrame < e.frame )
741 for(int i = lastFrame+1; i < frame+1; i++)
743 e.frame = i;
744 emit postEvent(e);
746 return;
748 else
750 e.frame++;
754 emit postEvent(e);
759 * @internal
761 void TimeLineWidget::onRequestInsertFrame(int layerPosition, int framePosition)
763 Event e = d->createEvent(this, InsertFrame);
765 int lastFrame = 0;
767 FramesTable *frames = framesTable(scene());
768 if(frames)
770 lastFrame = frames->lastFrameByLayer(e.layer);
773 int frame = e.frame;
775 if(lastFrame < e.frame )
777 for(int i = lastFrame+1; i < frame+1; i++)
779 e.frame = i;
780 emit postEvent(e);
782 return;
784 else
786 e.frame++;
789 emit postEvent(e);
793 * @internal
795 void TimeLineWidget::onRequestRemoveFrame(int layerPosition, int framePosition)
797 Event event;
798 event.scene = d->layers.container->currentIndex();
799 event.layer = layerPosition;
800 event.frame = framePosition;
801 event.action = RemoveFrame;
803 emit postEvent(event);
807 * @internal
809 void TimeLineWidget::onRequestCopyFrame(int layerPosition, int framePosition)
811 Event event;
812 event.scene = d->layers.container->currentIndex();
813 event.layer = layerPosition;
814 event.frame = framePosition;
815 event.action = CopyFrame;
817 emit postEvent(event);
821 * @internal
823 void TimeLineWidget::onRequestPasteFrame(int layerPosition, int framePosition)
825 Event e = d->createEvent(this, PasteFrame);
827 int lastFrame = 0;
829 FramesTable *frames = framesTable(scene());
830 if(frames)
832 lastFrame = frames->lastFrameByLayer(e.layer);
835 int frame = e.frame;
837 if(lastFrame < e.frame )
839 for(int i = lastFrame+1; i < frame+1; i++)
841 e.frame = i;
842 emit postEvent(e);
844 return;
846 else
848 e.frame++;
851 emit postEvent(e);
853 Event event;
854 event.scene = d->layers.container->currentIndex();
855 event.layer = layerPosition;
856 event.frame = framePosition;
857 event.action = PasteFrame;
859 emit postEvent(event);*/
863 * @internal
865 void TimeLineWidget::onRequestCutFrame(int layerPosition, int framePosition)
867 Event event;
868 event.scene = d->layers.container->currentIndex();
869 event.layer = layerPosition;
870 event.frame = framePosition;
871 event.action = CutFrame;
873 emit postEvent(event);
877 * @internal
879 void TimeLineWidget::onRequestLockFrame(int layerPosition, int framePosition, bool locked)
881 Event event;
882 event.scene = d->layers.container->currentIndex();
883 event.layer = layerPosition;
884 event.frame = framePosition;
885 event.action = LockFrame;
886 event.data = locked;
888 emit postEvent(event);
892 * @internal
894 void TimeLineWidget::onRequestChangeFrameVisibility(int layerPosition, int framePosition, bool visibility)
896 Event event;
897 event.scene = d->layers.container->currentIndex();
898 event.layer = layerPosition;
899 event.frame = framePosition;
900 event.action = ChangeFrameVisibility;
901 event.data = visibility;
903 emit postEvent(event);
907 * @internal
909 void TimeLineWidget::onRequestExpandFrame(int layerPosition, int framePosition, int size)
911 Event event;
912 event.scene = d->layers.container->currentIndex();
913 event.layer = layerPosition;
914 event.frame = framePosition;
915 event.action = ExpandFrame;
917 event.data = size;
919 emit postEvent(event);
923 * @internal
925 void TimeLineWidget::nextFrame()
927 int scenePos = scene();
928 int layerPos = layer();
929 int framePos = frame();
931 FramesTable *framesTable = this->framesTable(scenePos);
933 if(framesTable)
935 if(framePos < framesTable->lastFrameByLayer(layerPos))
937 setFrame(scenePos, layerPos, framePos+1);
939 else
941 setFrame(scenePos, layerPos, 0);
942 d->scenes.play->setIcon(DGui::IconLoader::self()->load("media-playback-start.svg"));
943 d->timer.stop();
949 * @internal
951 LayerManager *TimeLineWidget::layerManager(int sceneIndex)
953 return qobject_cast<LayerManager *>(d->layers.container->widget(sceneIndex));
957 * @internal
959 FramesTable *TimeLineWidget::framesTable(int sceneIndex)
961 return qobject_cast<FramesTable *>(d->frames.container->widget(sceneIndex));
965 * @internal
967 void TimeLineWidget::setupButtons()
969 d->scenes.insert->setIcon(DGui::IconLoader::self()->load("list-add.svg"));
970 d->scenes.insert->setToolTip(tr("Insert a scene"));
972 d->scenes.remove->setIcon(DGui::IconLoader::self()->load("list-remove.svg"));
973 d->scenes.remove->setToolTip(tr("Remove the scene"));
975 d->scenes.up->setIcon(DGui::IconLoader::self()->load("go-up.svg"));
976 d->scenes.up->setToolTip(tr("Move up scene"));
978 d->scenes.down->setIcon(DGui::IconLoader::self()->load("go-down.svg"));
979 d->scenes.down->setToolTip(tr("Move down scene"));
981 d->scenes.play->setIcon(DGui::IconLoader::self()->load("media-playback-start.svg"));
982 d->scenes.play->setToolTip(tr("Play scene"));
984 connect(d->scenes.play, SIGNAL(clicked()), this, SLOT(playScene()));
986 d->layers.insert->setIcon(DGui::IconLoader::self()->load("add-layer.svg"));
987 d->layers.insert->setToolTip(tr("Insert a layer"));
989 d->layers.remove->setIcon(DGui::IconLoader::self()->load("list-remove.svg"));
990 d->layers.remove->setToolTip(tr("Remove the layer"));
992 d->layers.up->setIcon(DGui::IconLoader::self()->load("go-up.svg"));
993 d->layers.up->setToolTip(tr("Move up layer"));
995 d->layers.down->setIcon(DGui::IconLoader::self()->load("go-down.svg"));
996 d->layers.down->setToolTip(tr("Move down layer"));
998 d->frames.insert->setIcon(DGui::IconLoader::self()->load("list-add.svg"));
999 d->frames.insert->setToolTip(tr("Insert a frame"));
1001 d->frames.remove->setIcon(DGui::IconLoader::self()->load("list-remove.svg"));
1002 d->frames.remove->setToolTip(tr("Remove the frame"));
1004 d->frames.up->setIcon(DGui::IconLoader::self()->load("go-previous.svg"));
1005 d->frames.up->setToolTip(tr("Move up frame"));
1007 d->frames.down->setIcon(DGui::IconLoader::self()->load("go-next.svg"));
1008 d->frames.down->setToolTip(tr("Move down frame"));
1010 d->actions.addButton(d->scenes.insert, InsertScene);
1011 d->actions.addButton(d->scenes.remove, RemoveScene);
1012 d->actions.addButton(d->scenes.up, MoveSceneUp);
1013 d->actions.addButton(d->scenes.down, MoveSceneDown);
1015 d->actions.addButton(d->layers.insert, InsertLayer);
1016 d->actions.addButton(d->layers.remove, RemoveLayer);
1017 d->actions.addButton(d->layers.up, MoveLayerUp);
1018 d->actions.addButton(d->layers.down, MoveLayerDown);
1020 d->actions.addButton(d->frames.insert, InsertFrame);
1021 d->actions.addButton(d->frames.remove, RemoveFrame);
1022 d->actions.addButton(d->frames.up, MoveFrameUp);
1023 d->actions.addButton(d->frames.down, MoveFrameDown);