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 "window-main.hpp"
  19. class QListWidgetItem;
  20. #include "ui_OBSBasic.h"
  21. class OBSBasic : public OBSMainWindow {
  22. Q_OBJECT
  23. private:
  24. std::unordered_map<obs_source_t, int> sourceSceneRefs;
  25. obs_scene_t GetCurrentScene();
  26. void AddSceneItem(obs_sceneitem_t item);
  27. void RemoveSceneItem(obs_sceneitem_t item);
  28. void AddScene(obs_source_t scene);
  29. void RemoveScene(obs_source_t scene);
  30. void UpdateSources(obs_scene_t scene);
  31. void UpdateSceneSelection(obs_source_t source);
  32. /* OBS Callbacks */
  33. static void SceneItemAdded(void *data, calldata_t params);
  34. static void SceneItemRemoved(void *data, calldata_t params);
  35. static void SourceAdded(void *data, calldata_t params);
  36. static void SourceDestroyed(void *data, calldata_t params);
  37. static void ChannelChanged(void *data, calldata_t params);
  38. void ResizePreview(uint32_t cx, uint32_t cy);
  39. void AddSource(obs_scene_t scene, const char *id);
  40. void AddSourcePopupMenu(const QPoint &pos);
  41. bool InitGraphics();
  42. bool InitAudio();
  43. void NewProject();
  44. void SaveProject();
  45. void LoadProject();
  46. protected:
  47. virtual void closeEvent(QCloseEvent *event) override;
  48. virtual void changeEvent(QEvent *event) override;
  49. virtual void resizeEvent(QResizeEvent *event) override;
  50. private slots:
  51. void on_action_New_triggered();
  52. void on_action_Open_triggered();
  53. void on_action_Save_triggered();
  54. void on_scenes_itemChanged(QListWidgetItem *item);
  55. void on_scenes_customContextMenuRequested(const QPoint &pos);
  56. void on_actionAddScene_triggered();
  57. void on_actionRemoveScene_triggered();
  58. void on_actionSceneProperties_triggered();
  59. void on_actionSceneUp_triggered();
  60. void on_actionSceneDown_triggered();
  61. void on_sources_itemChanged(QListWidgetItem *item);
  62. void on_sources_customContextMenuRequested(const QPoint &pos);
  63. void on_actionAddSource_triggered();
  64. void on_actionRemoveSource_triggered();
  65. void on_actionSourceProperties_triggered();
  66. void on_actionSourceUp_triggered();
  67. void on_actionSourceDown_triggered();
  68. void on_settingsButton_clicked();
  69. public:
  70. explicit OBSBasic(QWidget *parent = 0);
  71. ~OBSBasic();
  72. virtual void OBSInit() override;
  73. private:
  74. std::unique_ptr<Ui::OBSBasic> ui;
  75. };