Merge pull request #1894 from Rosuav/lock-unlock-event
libobs/UI: Implement an item_locked event
This commit is contained in:
commit
6a795d52ea
@ -130,6 +130,7 @@ void SourceTreeItem::DisconnectSignals()
|
|||||||
itemRemoveSignal.Disconnect();
|
itemRemoveSignal.Disconnect();
|
||||||
deselectSignal.Disconnect();
|
deselectSignal.Disconnect();
|
||||||
visibleSignal.Disconnect();
|
visibleSignal.Disconnect();
|
||||||
|
lockedSignal.Disconnect();
|
||||||
renameSignal.Disconnect();
|
renameSignal.Disconnect();
|
||||||
removeSignal.Disconnect();
|
removeSignal.Disconnect();
|
||||||
}
|
}
|
||||||
@ -177,6 +178,18 @@ void SourceTreeItem::ReconnectSignals()
|
|||||||
Q_ARG(bool, visible));
|
Q_ARG(bool, visible));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto itemLocked = [] (void *data, calldata_t *cd)
|
||||||
|
{
|
||||||
|
SourceTreeItem *this_ = reinterpret_cast<SourceTreeItem*>(data);
|
||||||
|
obs_sceneitem_t *curItem =
|
||||||
|
(obs_sceneitem_t*)calldata_ptr(cd, "item");
|
||||||
|
bool locked = calldata_bool(cd, "locked");
|
||||||
|
|
||||||
|
if (curItem == this_->sceneitem)
|
||||||
|
QMetaObject::invokeMethod(this_, "LockedChanged",
|
||||||
|
Q_ARG(bool, locked));
|
||||||
|
};
|
||||||
|
|
||||||
auto itemDeselect = [] (void *data, calldata_t *cd)
|
auto itemDeselect = [] (void *data, calldata_t *cd)
|
||||||
{
|
{
|
||||||
SourceTreeItem *this_ = reinterpret_cast<SourceTreeItem*>(data);
|
SourceTreeItem *this_ = reinterpret_cast<SourceTreeItem*>(data);
|
||||||
@ -200,6 +213,7 @@ void SourceTreeItem::ReconnectSignals()
|
|||||||
sceneRemoveSignal.Connect(signal, "remove", removeItem, this);
|
sceneRemoveSignal.Connect(signal, "remove", removeItem, this);
|
||||||
itemRemoveSignal.Connect(signal, "item_remove", removeItem, this);
|
itemRemoveSignal.Connect(signal, "item_remove", removeItem, this);
|
||||||
visibleSignal.Connect(signal, "item_visible", itemVisible, this);
|
visibleSignal.Connect(signal, "item_visible", itemVisible, this);
|
||||||
|
lockedSignal.Connect(signal, "item_locked", itemLocked, this);
|
||||||
|
|
||||||
if (obs_sceneitem_is_group(sceneitem)) {
|
if (obs_sceneitem_is_group(sceneitem)) {
|
||||||
obs_source_t *source = obs_sceneitem_get_source(sceneitem);
|
obs_source_t *source = obs_sceneitem_get_source(sceneitem);
|
||||||
@ -368,6 +382,11 @@ void SourceTreeItem::VisibilityChanged(bool visible)
|
|||||||
vis->setChecked(visible);
|
vis->setChecked(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SourceTreeItem::LockedChanged(bool locked)
|
||||||
|
{
|
||||||
|
lock->setChecked(locked);
|
||||||
|
}
|
||||||
|
|
||||||
void SourceTreeItem::Renamed(const QString &name)
|
void SourceTreeItem::Renamed(const QString &name)
|
||||||
{
|
{
|
||||||
label->setText(name);
|
label->setText(name);
|
||||||
|
@ -68,6 +68,7 @@ private:
|
|||||||
OBSSignal groupReorderSignal;
|
OBSSignal groupReorderSignal;
|
||||||
OBSSignal deselectSignal;
|
OBSSignal deselectSignal;
|
||||||
OBSSignal visibleSignal;
|
OBSSignal visibleSignal;
|
||||||
|
OBSSignal lockedSignal;
|
||||||
OBSSignal renameSignal;
|
OBSSignal renameSignal;
|
||||||
OBSSignal removeSignal;
|
OBSSignal removeSignal;
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ private slots:
|
|||||||
void ExitEditMode(bool save);
|
void ExitEditMode(bool save);
|
||||||
|
|
||||||
void VisibilityChanged(bool visible);
|
void VisibilityChanged(bool visible);
|
||||||
|
void LockedChanged(bool locked);
|
||||||
void Renamed(const QString &name);
|
void Renamed(const QString &name);
|
||||||
|
|
||||||
void ExpandClicked(bool checked);
|
void ExpandClicked(bool checked);
|
||||||
|
@ -94,6 +94,8 @@ VisibilityItemWidget::VisibilityItemWidget(obs_sceneitem_t *item_)
|
|||||||
this);
|
this);
|
||||||
signal_handler_connect(signal, "item_visible", OBSSceneItemVisible,
|
signal_handler_connect(signal, "item_visible", OBSSceneItemVisible,
|
||||||
this);
|
this);
|
||||||
|
signal_handler_connect(signal, "item_locked", OBSSceneItemLocked,
|
||||||
|
this);
|
||||||
|
|
||||||
connect(vis, SIGNAL(clicked(bool)),
|
connect(vis, SIGNAL(clicked(bool)),
|
||||||
this, SLOT(VisibilityClicked(bool)));
|
this, SLOT(VisibilityClicked(bool)));
|
||||||
@ -121,6 +123,8 @@ void VisibilityItemWidget::DisconnectItemSignals()
|
|||||||
this);
|
this);
|
||||||
signal_handler_disconnect(signal, "item_visible", OBSSceneItemVisible,
|
signal_handler_disconnect(signal, "item_visible", OBSSceneItemVisible,
|
||||||
this);
|
this);
|
||||||
|
signal_handler_disconnect(signal, "item_locked", OBSSceneItemLocked,
|
||||||
|
this);
|
||||||
|
|
||||||
sceneRemoved = true;
|
sceneRemoved = true;
|
||||||
}
|
}
|
||||||
|
@ -139,6 +139,10 @@ Scene Signals
|
|||||||
|
|
||||||
Called when a scene item's visibility state changes.
|
Called when a scene item's visibility state changes.
|
||||||
|
|
||||||
|
**item_locked** (ptr scene, ptr item, bool locked)
|
||||||
|
|
||||||
|
Called when a scene item has been locked or unlocked.
|
||||||
|
|
||||||
**item_select** (ptr scene, ptr item)
|
**item_select** (ptr scene, ptr item)
|
||||||
**item_deselect** (ptr scene, ptr item)
|
**item_deselect** (ptr scene, ptr item)
|
||||||
|
|
||||||
@ -406,6 +410,13 @@ Scene Item Functions
|
|||||||
|
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|
.. function:: bool obs_sceneitem_set_locked(obs_sceneitem_t *item, bool locked)
|
||||||
|
bool obs_sceneitem_locked(const obs_sceneitem_t *item)
|
||||||
|
|
||||||
|
Sets/gets the locked/unlocked state of the scene item.
|
||||||
|
|
||||||
|
---------------------
|
||||||
|
|
||||||
.. function:: void obs_sceneitem_set_crop(obs_sceneitem_t *item, const struct obs_sceneitem_crop *crop)
|
.. function:: void obs_sceneitem_set_crop(obs_sceneitem_t *item, const struct obs_sceneitem_crop *crop)
|
||||||
void obs_sceneitem_get_crop(const obs_sceneitem_t *item, struct obs_sceneitem_crop *crop)
|
void obs_sceneitem_get_crop(const obs_sceneitem_t *item, struct obs_sceneitem_crop *crop)
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ static const char *obs_scene_signals[] = {
|
|||||||
"void item_select(ptr scene, ptr item)",
|
"void item_select(ptr scene, ptr item)",
|
||||||
"void item_deselect(ptr scene, ptr item)",
|
"void item_deselect(ptr scene, ptr item)",
|
||||||
"void item_transform(ptr scene, ptr item)",
|
"void item_transform(ptr scene, ptr item)",
|
||||||
|
"void item_locked(ptr scene, ptr item, bool locked)",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2118,6 +2119,9 @@ bool obs_sceneitem_locked(const obs_sceneitem_t *item)
|
|||||||
|
|
||||||
bool obs_sceneitem_set_locked(obs_sceneitem_t *item, bool lock)
|
bool obs_sceneitem_set_locked(obs_sceneitem_t *item, bool lock)
|
||||||
{
|
{
|
||||||
|
struct calldata cd;
|
||||||
|
uint8_t stack[256];
|
||||||
|
|
||||||
if (!item)
|
if (!item)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -2129,6 +2133,12 @@ bool obs_sceneitem_set_locked(obs_sceneitem_t *item, bool lock)
|
|||||||
|
|
||||||
item->locked = lock;
|
item->locked = lock;
|
||||||
|
|
||||||
|
calldata_init_fixed(&cd, stack, sizeof(stack));
|
||||||
|
calldata_set_ptr(&cd, "item", item);
|
||||||
|
calldata_set_bool(&cd, "locked", lock);
|
||||||
|
|
||||||
|
signal_parent(item->parent, "item_locked", &cd);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user