File indexing completed on 2025-02-02 04:11:33

0001 /*
0002  * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #pragma once
0008 
0009 #include <memory>
0010 #include <QWidget>
0011 
0012 #include "model/document.hpp"
0013 
0014 class QAbstractItemModel;
0015 class QItemSelection;
0016 
0017 namespace glaxnimate::gui {
0018 
0019 class GlaxnimateWindow;
0020 class TimelineWidget;
0021 
0022 class CompoundTimelineWidget : public QWidget
0023 {
0024     Q_OBJECT
0025     
0026 public:
0027     CompoundTimelineWidget(QWidget* parent = nullptr);
0028     ~CompoundTimelineWidget();
0029     
0030     void set_current_node(model::DocumentNode* node);
0031     void set_document(model::Document* document);
0032     void set_composition(model::Composition* comp);
0033     void clear_document();
0034     QByteArray save_state() const;
0035     void load_state(const QByteArray& state);
0036 #ifndef MOBILE_UI
0037     void set_controller(GlaxnimateWindow* window);
0038 #endif
0039     QAbstractItemModel* filtered_model() const;
0040     QAbstractItemModel* raw_model() const;
0041     TimelineWidget* timeline() const;
0042     model::DocumentNode* current_node() const;
0043     QModelIndex current_index_raw() const;
0044     QModelIndex current_index_filtered() const;
0045 
0046     void reset_view();
0047 
0048     void select(const std::vector<model::VisualNode*>& selected,  const std::vector<model::VisualNode*>& deselected);
0049 
0050 Q_SIGNALS:
0051     void switch_composition(model::Composition* comp, int index);
0052     void current_node_changed(model::VisualNode* node);
0053     void selection_changed(const std::vector<model::VisualNode*>& selected,  const std::vector<model::VisualNode*>& deselected);
0054     
0055 protected:
0056     void changeEvent ( QEvent* e ) override;
0057     bool eventFilter(QObject *watched, QEvent *event) override;
0058     
0059 private Q_SLOTS:
0060     void select_index(const QModelIndex& index);
0061     void _on_selection_changed(const QItemSelection &selected, const QItemSelection &deselected);
0062     void select_line(quintptr id, bool selected, bool replace_selection);
0063     void custom_context_menu(const QPoint& p);
0064     void add_keyframe();
0065     void remove_keyframe();
0066     void on_scroll(int amount);
0067     void keyframe_action_enter();
0068     void keyframe_action_exit();
0069     void copy_keyframe();
0070     void collapse_index(const QModelIndex& index);
0071     void expand_index(const QModelIndex& index);
0072     void click_index ( const QModelIndex& index );
0073     void rows_removed( const QModelIndex& index, int first, int last );
0074     
0075 private:
0076     class Private;
0077     std::unique_ptr<Private> d;
0078 };
0079 
0080 } // namespace glaxnimate::gui