window-basic-main.hpp 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /******************************************************************************
  2. Copyright (C) 2013 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #pragma once
  15. #include <obs.hpp>
  16. #include <unordered_map>
  17. #include <memory>
  18. #include <QMainWindow>
  19. class QListWidgetItem;
  20. namespace Ui {
  21. class OBSBasic;
  22. };
  23. class OBSBasic : public QMainWindow {
  24. Q_OBJECT
  25. private:
  26. std::unordered_map<obs_source_t, int> sourceSceneRefs;
  27. obs_scene_t GetCurrentScene();
  28. void AddSceneItem(obs_sceneitem_t item);
  29. void RemoveSceneItem(obs_sceneitem_t item);
  30. void AddScene(obs_source_t scene);
  31. void RemoveScene(obs_source_t scene);
  32. void UpdateSources(obs_scene_t scene);
  33. void UpdateSceneSelection(obs_source_t source);
  34. /* OBS Callbacks */
  35. static void SceneItemAdded(void *data, calldata_t params);
  36. static void SceneItemRemoved(void *data, calldata_t params);
  37. static void SourceAdded(void *data, calldata_t params);
  38. static void SourceDestroyed(void *data, calldata_t params);
  39. static void ChannelChanged(void *data, calldata_t params);
  40. void ResizePreview(uint32_t cx, uint32_t cy);
  41. void AddSource(obs_scene_t scene, const char *id);
  42. void AddSourcePopupMenu(const QPoint &pos);
  43. bool InitGraphics();
  44. bool InitAudio();
  45. void NewProject();
  46. void SaveProject();
  47. void LoadProject();
  48. protected:
  49. virtual void closeEvent(QCloseEvent *event);
  50. virtual void changeEvent(QEvent *event);
  51. virtual void resizeEvent(QResizeEvent *event);
  52. private slots:
  53. void on_action_New_triggered();
  54. void on_action_Open_triggered();
  55. void on_action_Save_triggered();
  56. void on_scenes_itemChanged(QListWidgetItem *item);
  57. void on_scenes_customContextMenuRequested(const QPoint &pos);
  58. void on_actionAddScene_triggered();
  59. void on_actionRemoveScene_triggered();
  60. void on_actionSceneProperties_triggered();
  61. void on_actionSceneUp_triggered();
  62. void on_actionSceneDown_triggered();
  63. void on_sources_itemChanged(QListWidgetItem *item);
  64. void on_sources_customContextMenuRequested(const QPoint &pos);
  65. void on_actionAddSource_triggered();
  66. void on_actionRemoveSource_triggered();
  67. void on_actionSourceProperties_triggered();
  68. void on_actionSourceUp_triggered();
  69. void on_actionSourceDown_triggered();
  70. void on_settingsButton_clicked();
  71. public:
  72. explicit OBSBasic(QWidget *parent = 0);
  73. ~OBSBasic();
  74. private:
  75. std::unique_ptr<Ui::OBSBasic> ui;
  76. };