window-main-basic.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. #include <obs.hpp>
  15. #include "obs-app.hpp"
  16. #include "wx-wrappers.hpp"
  17. #include "window-settings-basic.hpp"
  18. #include "window-main-basic.hpp"
  19. bool OBSBasic::Init()
  20. {
  21. if (!obs_startup())
  22. return false;
  23. if (!InitGraphics())
  24. return false;
  25. return true;
  26. }
  27. OBSBasic::~OBSBasic()
  28. {
  29. obs_shutdown();
  30. }
  31. bool OBSBasic::InitGraphics()
  32. {
  33. wxSize size = previewPanel->GetClientSize();
  34. struct obs_video_info ovi;
  35. wxGetApp().GetConfigFPS(ovi.fps_num, ovi.fps_den);
  36. ovi.graphics_module = wxGetApp().GetRenderModule();
  37. ovi.window_width = size.x;
  38. ovi.window_height = size.y;
  39. ovi.base_width = (uint32_t)config_get_uint(GetGlobalConfig(),
  40. "Video", "BaseCX");
  41. ovi.base_height = (uint32_t)config_get_uint(GetGlobalConfig(),
  42. "Video", "BaseCY");
  43. ovi.output_width = (uint32_t)config_get_uint(GetGlobalConfig(),
  44. "Video", "OutputCX");
  45. ovi.output_height = (uint32_t)config_get_uint(GetGlobalConfig(),
  46. "Video", "OutputCY");
  47. ovi.output_format = VIDEO_FORMAT_RGBA;
  48. ovi.adapter = 0;
  49. ovi.window = WxToGSWindow(previewPanel);
  50. if (!obs_reset_video(&ovi))
  51. return false;
  52. //required to make opengl display stuff on osx(?)
  53. SendSizeEvent();
  54. return true;
  55. }
  56. void OBSBasic::OnClose(wxCloseEvent &event)
  57. {
  58. wxGetApp().ExitMainLoop();
  59. event.Skip();
  60. }
  61. void OBSBasic::OnMinimize(wxIconizeEvent &event)
  62. {
  63. event.Skip();
  64. }
  65. void OBSBasic::OnSize(wxSizeEvent &event)
  66. {
  67. struct obs_video_info ovi;
  68. event.Skip();
  69. if (!obs_get_video_info(&ovi))
  70. return;
  71. /* resize preview panel to fix to the top section of the window */
  72. wxSize targetSize = GetPreviewContainer()->GetSize();
  73. double targetAspect = double(targetSize.x) / double(targetSize.y);
  74. double baseAspect = double(ovi.base_width) / double(ovi.base_height);
  75. if (targetAspect > baseAspect)
  76. GetPreviewPanel()->SetMinSize(wxSize(targetSize.y * baseAspect,
  77. targetSize.y));
  78. else
  79. GetPreviewPanel()->SetMinSize(wxSize(targetSize.x,
  80. targetSize.x / baseAspect));
  81. }
  82. void OBSBasic::fileNewClicked(wxCommandEvent &event)
  83. {
  84. }
  85. void OBSBasic::fileOpenClicked(wxCommandEvent &event)
  86. {
  87. }
  88. void OBSBasic::fileSaveClicked(wxCommandEvent &event)
  89. {
  90. }
  91. void OBSBasic::fileExitClicked(wxCommandEvent &event)
  92. {
  93. wxGetApp().ExitMainLoop();
  94. }
  95. void OBSBasic::scenesRDown(wxMouseEvent &event)
  96. {
  97. }
  98. void OBSBasic::sceneAddClicked(wxCommandEvent &event)
  99. {
  100. }
  101. void OBSBasic::sceneRemoveClicked(wxCommandEvent &event)
  102. {
  103. }
  104. void OBSBasic::scenePropertiesClicked(wxCommandEvent &event)
  105. {
  106. }
  107. void OBSBasic::sceneUpClicked(wxCommandEvent &event)
  108. {
  109. }
  110. void OBSBasic::sceneDownClicked(wxCommandEvent &event)
  111. {
  112. }
  113. void OBSBasic::sourcesRDown(wxMouseEvent &event)
  114. {
  115. }
  116. void OBSBasic::sourceAddClicked(wxCommandEvent &event)
  117. {
  118. }
  119. void OBSBasic::sourceRemoveClicked(wxCommandEvent &event)
  120. {
  121. }
  122. void OBSBasic::sourcePropertiesClicked(wxCommandEvent &event)
  123. {
  124. }
  125. void OBSBasic::sourceUpClicked(wxCommandEvent &event)
  126. {
  127. }
  128. void OBSBasic::sourceDownClicked(wxCommandEvent &event)
  129. {
  130. }
  131. void OBSBasic::settingsClicked(wxCommandEvent &event)
  132. {
  133. OBSBasicSettings test(this);
  134. test.ShowModal();
  135. }
  136. void OBSBasic::exitClicked(wxCommandEvent &event)
  137. {
  138. wxGetApp().ExitMainLoop();
  139. }