mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-03-06 15:46:13 -05:00
UI: Source Toolbar
The source toolbar allows quick and easy access to properties and filers, and shows common properties/features of a source type. For example, when you select a media source, VLC source, or the slideshow source, you'll get media controls to control playback of the media. If you select a text source you can edit the font, color, or text if applicable. Or if you select a capture source, you can select the display/window/etc to capture for that source. If the source toolbar is not desired and is viewed as taking up valuable space in the window, it can be disabled via the view menu. Co-authored-by: Clayton Groeneveld <claytong1214@gmail.com> Co-authored-by: Jim <obs.jim@gmail.com>
This commit is contained in:
@@ -52,10 +52,12 @@
|
||||
#include "window-projector.hpp"
|
||||
#include "window-remux.hpp"
|
||||
#include "qt-wrappers.hpp"
|
||||
#include "context-bar-controls.hpp"
|
||||
#include "display-helpers.hpp"
|
||||
#include "volume-control.hpp"
|
||||
#include "remote-text.hpp"
|
||||
#include "ui-validation.hpp"
|
||||
#include "media-controls.hpp"
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
@@ -355,6 +357,8 @@ OBSBasic::OBSBasic(QWidget *parent)
|
||||
|
||||
QPoint curPos;
|
||||
|
||||
UpdateContextBar();
|
||||
|
||||
//restore parent window geometry
|
||||
const char *geometry = config_get_string(App()->GlobalConfig(),
|
||||
"BasicWindow", "geometry");
|
||||
@@ -1721,6 +1725,18 @@ void OBSBasic::OBSInit()
|
||||
GetGlobalConfig(), "BasicWindow", "ShowSourceIcons");
|
||||
ui->toggleSourceIcons->setChecked(sourceIconsVisible);
|
||||
|
||||
if (config_has_user_value(App()->GlobalConfig(), "BasicWindow",
|
||||
"ShowContextToolbars")) {
|
||||
bool visible = config_get_bool(App()->GlobalConfig(),
|
||||
"BasicWindow",
|
||||
"ShowContextToolbars");
|
||||
ui->toggleContextBar->setChecked(visible);
|
||||
ui->contextContainer->setVisible(visible);
|
||||
} else {
|
||||
ui->toggleContextBar->setChecked(true);
|
||||
ui->contextContainer->setVisible(true);
|
||||
}
|
||||
|
||||
{
|
||||
ProfileScope("OBSBasic::Load");
|
||||
disableSaving--;
|
||||
@@ -1803,6 +1819,7 @@ void OBSBasic::OBSInit()
|
||||
|
||||
const char *dockStateStr = config_get_string(
|
||||
App()->GlobalConfig(), "BasicWindow", "DockState");
|
||||
|
||||
if (!dockStateStr) {
|
||||
on_resetUI_triggered();
|
||||
} else {
|
||||
@@ -2314,6 +2331,17 @@ void OBSBasic::CreateHotkeys()
|
||||
this, this);
|
||||
LoadHotkeyPair(togglePreviewHotkeys, "OBSBasic.EnablePreview",
|
||||
"OBSBasic.DisablePreview");
|
||||
|
||||
contextBarHotkeys = obs_hotkey_pair_register_frontend(
|
||||
"OBSBasic.ShowContextBar", Str("Basic.Main.ShowContextBar"),
|
||||
"OBSBasic.HideContextBar", Str("Basic.Main.HideContextBar"),
|
||||
MAKE_CALLBACK(!basic.ui->contextContainer->isVisible(),
|
||||
basic.ShowContextBar, "Showing Context Bar"),
|
||||
MAKE_CALLBACK(basic.ui->contextContainer->isVisible(),
|
||||
basic.HideContextBar, "Hiding Context Bar"),
|
||||
this, this);
|
||||
LoadHotkeyPair(contextBarHotkeys, "OBSBasic.ShowContextBar",
|
||||
"OBSBasic.HideContextBar");
|
||||
#undef MAKE_CALLBACK
|
||||
|
||||
auto togglePreviewProgram = [](void *data, obs_hotkey_id,
|
||||
@@ -2844,6 +2872,107 @@ void OBSBasic::RenameSources(OBSSource source, QString newName,
|
||||
obs_scene_t *scene = obs_scene_from_source(source);
|
||||
if (scene)
|
||||
OBSProjector::UpdateMultiviewProjectors();
|
||||
|
||||
UpdateContextBar();
|
||||
}
|
||||
|
||||
void OBSBasic::UpdateContextBar()
|
||||
{
|
||||
OBSSceneItem item = GetCurrentSceneItem();
|
||||
|
||||
QLayoutItem *la = ui->emptySpace->layout()->itemAt(0);
|
||||
if (la) {
|
||||
delete la->widget();
|
||||
ui->emptySpace->layout()->removeItem(la);
|
||||
}
|
||||
|
||||
if (item) {
|
||||
obs_source_t *source = obs_sceneitem_get_source(item);
|
||||
const char *id = obs_source_get_unversioned_id(source);
|
||||
uint32_t flags = obs_source_get_output_flags(source);
|
||||
|
||||
if (flags & OBS_SOURCE_CONTROLLABLE_MEDIA) {
|
||||
MediaControls *mediaControls =
|
||||
new MediaControls(ui->emptySpace);
|
||||
mediaControls->SetSource(source);
|
||||
|
||||
ui->emptySpace->layout()->addWidget(mediaControls);
|
||||
}
|
||||
|
||||
if (strcmp(id, "browser_source") == 0) {
|
||||
BrowserToolbar *c =
|
||||
new BrowserToolbar(ui->emptySpace, source);
|
||||
ui->emptySpace->layout()->addWidget(c);
|
||||
|
||||
} else if (strcmp(id, "wasapi_input_capture") == 0 ||
|
||||
strcmp(id, "wasapi_output_capture") == 0 ||
|
||||
strcmp(id, "coreaudio_input_capture") == 0 ||
|
||||
strcmp(id, "coreaudio_output_capture") == 0 ||
|
||||
strcmp(id, "pulse_input_capture") == 0 ||
|
||||
strcmp(id, "pulse_output_capture") == 0 ||
|
||||
strcmp(id, "alsa_input_capture") == 0) {
|
||||
AudioCaptureToolbar *c =
|
||||
new AudioCaptureToolbar(ui->emptySpace, source);
|
||||
c->Init();
|
||||
ui->emptySpace->layout()->addWidget(c);
|
||||
|
||||
} else if (strcmp(id, "window_capture") == 0 ||
|
||||
strcmp(id, "xcomposite_input") == 0) {
|
||||
WindowCaptureToolbar *c = new WindowCaptureToolbar(
|
||||
ui->emptySpace, source);
|
||||
c->Init();
|
||||
ui->emptySpace->layout()->addWidget(c);
|
||||
|
||||
} else if (strcmp(id, "monitor_capture") == 0 ||
|
||||
strcmp(id, "display_capture") == 0 ||
|
||||
strcmp(id, "xshm_input") == 0) {
|
||||
DisplayCaptureToolbar *c = new DisplayCaptureToolbar(
|
||||
ui->emptySpace, source);
|
||||
c->Init();
|
||||
ui->emptySpace->layout()->addWidget(c);
|
||||
|
||||
} else if (strcmp(id, "dshow_input") == 0 ||
|
||||
strcmp(id, "av_capture_input") == 0 ||
|
||||
strcmp(id, "v4l2_input") == 0) {
|
||||
DeviceCaptureToolbar *c = new DeviceCaptureToolbar(
|
||||
ui->emptySpace, source);
|
||||
c->Init();
|
||||
ui->emptySpace->layout()->addWidget(c);
|
||||
|
||||
} else if (strcmp(id, "game_capture") == 0) {
|
||||
GameCaptureToolbar *c =
|
||||
new GameCaptureToolbar(ui->emptySpace, source);
|
||||
ui->emptySpace->layout()->addWidget(c);
|
||||
|
||||
} else if (strcmp(id, "image_source") == 0) {
|
||||
ImageSourceToolbar *c =
|
||||
new ImageSourceToolbar(ui->emptySpace, source);
|
||||
ui->emptySpace->layout()->addWidget(c);
|
||||
|
||||
} else if (strcmp(id, "color_source") == 0) {
|
||||
ColorSourceToolbar *c =
|
||||
new ColorSourceToolbar(ui->emptySpace, source);
|
||||
ui->emptySpace->layout()->addWidget(c);
|
||||
|
||||
} else if (strcmp(id, "text_ft2_source") == 0 ||
|
||||
strcmp(id, "text_gdiplus") == 0) {
|
||||
TextSourceToolbar *c =
|
||||
new TextSourceToolbar(ui->emptySpace, source);
|
||||
ui->emptySpace->layout()->addWidget(c);
|
||||
}
|
||||
|
||||
const char *name = obs_source_get_name(source);
|
||||
ui->contextSourceLabel->setText(name);
|
||||
|
||||
ui->sourceFiltersButton->setEnabled(true);
|
||||
ui->sourcePropertiesButton->setEnabled(true);
|
||||
} else {
|
||||
ui->contextSourceLabel->setText(
|
||||
QTStr("ContextBar.NoSelectedSource"));
|
||||
|
||||
ui->sourceFiltersButton->setEnabled(false);
|
||||
ui->sourcePropertiesButton->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool SourceMixerHidden(obs_source_t *source)
|
||||
@@ -4221,6 +4350,8 @@ void OBSBasic::on_scenes_currentItemChanged(QListWidgetItem *current,
|
||||
if (api)
|
||||
api->on_event(OBS_FRONTEND_EVENT_PREVIEW_SCENE_CHANGED);
|
||||
|
||||
UpdateContextBar();
|
||||
|
||||
UNUSED_PARAMETER(prev);
|
||||
}
|
||||
|
||||
@@ -7146,6 +7277,23 @@ void OBSBasic::on_toggleListboxToolbars_toggled(bool visible)
|
||||
"ShowListboxToolbars", visible);
|
||||
}
|
||||
|
||||
void OBSBasic::ShowContextBar()
|
||||
{
|
||||
on_toggleContextBar_toggled(true);
|
||||
}
|
||||
|
||||
void OBSBasic::HideContextBar()
|
||||
{
|
||||
on_toggleContextBar_toggled(false);
|
||||
}
|
||||
|
||||
void OBSBasic::on_toggleContextBar_toggled(bool visible)
|
||||
{
|
||||
config_set_bool(App()->GlobalConfig(), "BasicWindow",
|
||||
"ShowContextToolbars", visible);
|
||||
this->ui->contextContainer->setVisible(visible);
|
||||
}
|
||||
|
||||
void OBSBasic::on_toggleStatusBar_toggled(bool visible)
|
||||
{
|
||||
ui->statusbar->setVisible(visible);
|
||||
@@ -8125,3 +8273,13 @@ void OBSBasic::UpdateProjectorAlwaysOnTop(bool top)
|
||||
for (size_t i = 0; i < projectors.size(); i++)
|
||||
SetAlwaysOnTop(projectors[i], top);
|
||||
}
|
||||
|
||||
void OBSBasic::on_sourcePropertiesButton_clicked()
|
||||
{
|
||||
on_actionSourceProperties_triggered();
|
||||
}
|
||||
|
||||
void OBSBasic::on_sourceFiltersButton_clicked()
|
||||
{
|
||||
OpenFilters();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user