Commit graph

53 commits

Author SHA1 Message Date
Matt Gajownik 74c3781554 libobs, UI: Add support for button properties as links
This adds support for a button property that opens a URL, after showing
a confirmation dialog to the user. Both the Type and URL must be set.
2021-07-09 17:32:09 +12:00
Exeldro edc439b0a5 libobs: fix property group check 2021-03-30 03:44:23 -07:00
Anton Bershanskiy fc9716f0dd libobs: fix property group check 2021-03-20 12:37:00 -07:00
jpark37 b80919f65f libobs: Support color picker with alpha 2021-01-11 11:52:50 -08:00
Jim d13f204488
Merge pull request #2257 from Xaymar/fix-remove_by_name-corruption
libobs: Don't corrupt obs_properties in ..._remove_by_name
2020-02-15 20:03:58 -08:00
Matt Gajownik 62504dc651 libobs/UI: Support monospace font in multiline text property 2019-12-30 10:11:17 +11:00
Michael Fabian 'Xaymar' Dirks 77f1b05d28 libobs: Fix corrupted pointers when removing properties
When obs_properties_remove_by_name is called on any obs_properties_t*,
it corrupts the pointers for first_property and last which end up
pointing at either unallocated memory or randomly into the heap memory.
Neither of these is a good thing, and it usually leads to rapid
unscheduled program behavior, also known as crashing and security
issues.

This fixes the issue by first checking if the pointer stored in
props->last is identical to &cur->next, then checking if we are the
only element (cur is also prev element), and if we are then the pointer
is fixed to point back at props->first_property. Additionally fixes
props->first_property which was never updated either.
2019-12-22 08:35:27 +01:00
Michael Fabian 'Xaymar' Dirks a1cc453996 libobs: Fix apply_settings & remove_by_name for groups
'obs_properties_apply_settings' and 'obs_properties_remove_by_name'
would incorrectly ignore property groups and not call the callbacks
or remove the property, resulting in quite glitchy UI.

This fix works by splitting the internal logic of ...apply_settings
into an extra function to call, while keeping the API the same. The
change to ...remove_by_name is to simply recursively going into the
group content with the same function call.
2019-08-13 17:13:10 +02:00
jp9000 f53df7da64 clang-format: Apply formatting
Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed.  Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
2019-06-23 23:49:10 -07:00
James Park 4afdf70fd5 libobs: Fix crashes from wrong types 2019-05-02 19:09:34 -07:00
Clayton Groeneveld 8789b3469b libobs: Add ability to set spinbox property suffix 2019-05-02 08:54:14 -07:00
Michael Fabian 'Xaymar' Dirks 6b6ea575ff libobs: Add property groups
Property groups allow multiple properties to be combined into a single
visual group and thus can be used to reduce visual clutter and improve
user experience by giving additional context to a property. The name of
a child of a group is not affected by the group and thus all property
names must still be unique.

A new parent field has been added to obs_properties_t to ease the
tracking of existing properties. That way properties inside a group will
also be able to verify that they have a unique name.
2019-04-18 06:37:36 -07:00
Michael Fabian 'Xaymar' Dirks 9bb276feab libobs: Add function to remove properties
Allows removing a property from a properties list in get_properties or
modified callback to enable dynamic property generation. The behavior
is undefined if the UI properties list is not refreshed by returning
true from the modified callback.
2019-04-06 15:33:46 +02:00
Michael Fabian 'Xaymar' Dirks 3cac828a3e libobs: Fix obs_property_float_set_limits
This function incorrectly checked for an Integer type instead of a
Float type, causing it to do nothing.
2019-03-16 04:30:33 +01:00
jamacanbacn 8a59d68e47 libobs: Fix property text typo
(This commit also modifies UI)

Closes jp9000/obs-studio#1204
2018-02-27 05:37:40 -08:00
jp9000 fd9e5d45a3 libobs: Add obs_property_set_modified_callback2
Allows the ability to pass private data to a callback (useful
specifically for scripting purposes).
2018-01-03 17:04:04 -08:00
jp9000 6d628c1ceb libobs: Add obs_properties_add_button2
Allows passing button-specific private data to the button callback
rather than just passing the private data of the properties object.
2018-01-03 17:04:04 -08:00
jp9000 ad64f7834d libobs: Store string copies in properties
Individual property objects would store pointers to strings rather than
copies of the strings and assume that memory would continue to exist, so
instead just duplicate the strings.
2018-01-03 17:04:02 -08:00
Richard Stanway 8b640fae24
Fix various null pointer issues detected by Coverity 2017-02-25 16:45:45 +01:00
jp9000 c99f65a0df libobs: Add property functions to mod. int/double limits 2016-09-19 07:04:00 -07:00
Michael Fabian Dirks 99b0acf4f0 libobs: Fix possible null pointer dereference 2016-08-02 21:04:55 +02:00
jp9000 ac4bd2aa80 libobs: Add long description to properties
Allows setting a "long" description for detailed explanation of certain
properties that may need them, but don't want to display them on the
user interface by default.
2016-07-20 08:09:45 -07:00
jp9000 07a26b1720 libobs: Add more editable list types
(Note: This commit also modifies the UI)

The editable list only had two types: A type that allows both files and
URLS, and a type that only allows strings.

This changes it so the editable list can have a "files only" type, a
"files and URLs" type, and a "strings only" type.
2016-05-26 10:55:51 -07:00
Palana 1b078f57d8 libobs: Add frame rate property 2015-11-14 15:37:59 +01:00
jp9000 a746c8cdd1 libobs: Remove potential NULL pointer dereference 2015-09-13 11:53:33 -07:00
jp9000 a752b32b83 libobs: Add editable list property
Add an editable list property, primarily used for adding files to a
playlist for example.
2015-06-02 17:01:38 -07:00
jp9000 0a8e3a643c libobs: Add int/float slider properties
This optionally specifies that the int/float value should be displayed
with a slider rather than and up/down control.  UIs are not necessarily
required to implement it, it's meant to be more of a hint.
2015-03-22 19:18:06 -07:00
jp9000 ef4ee1fd1a libobs: Implement flags for properties
OBS_PROPERTIES_DEFER_UPDATE: Makes it so the properties are not updated
until editing of the properties is complete.
2015-03-19 15:57:03 -05:00
jp9000 5d30f268a0 libobs: Return NULL on ending property list string
Instead of returning a valid string value when there are no more strings
available in the list, return NULL to indicate failure.  An empty string
should really be allowed to be a valid value for the list.
2015-01-06 01:27:16 -08:00
jp9000 32ca251bb0 libobs: Add obs_property_set_description
This allows us to change the visible UI name of a property after it's
been created (particularly for a case where I want to change an
'Activate' button to 'Deactivate')
2015-01-03 20:46:18 -08:00
jp9000 a69524a271 libobs: Add obs_property_list_insert_* functions
These functions allow you to insert items at a specific index in a list
instead of being forced to always append to the end.
2014-12-09 14:21:02 -08:00
jp9000 c9df41c1e2 (API Change) Remove pointers from all typedefs
Typedef pointers are unsafe.  If you do:
typedef struct bla *bla_t;
then you cannot use it as a constant, such as: const bla_t, because
that constant will be to the pointer itself rather than to the
underlying data.  I admit this was a fundamental mistake that must
be corrected.

All typedefs that were pointer types will now have their pointers
removed from the type itself, and the pointers will be used when they
are actually used as variables/parameters/returns instead.

This does not break ABI though, which is pretty nice.
2014-09-25 21:48:11 -07:00
jp9000 0bf9736ddd Add font property
Adds the following function:
------------------------------
obs_properties_add_font

This function creates a 'font' property to allow selection of a system
font.  Implementation by the UI should treat the setting as an obs_data
sub-object with four sub-items:
 - face:   face name (string)
 - style:  style name (string)
 - size:   size (integer)
 - flags:  font flags (integer)

'flags' can be any combination of the following values:
 - OBS_FONT_BOLD
 - OBS_FONT_ITALIC
 - OBS_FONT_UNDERLINE
 - OBS_FONT_STRIKEOUT
2014-08-18 00:14:02 -07:00
jp9000 4812a6130c libobs: Fill in rest of 'path' property code
A path should have a filter, default search directory, and a way to
indicate whether or not a directory or file is desired.
2014-06-28 10:12:57 -07:00
jp9000 74b4743bce Remove 'locale' from properties
Having the value stored here is somewhat pointless, so this is one step
in fixing the locale handling.  Locale should be handled by the modules
themselves with their own loaded locale lookup information.
2014-06-25 12:36:26 -07:00
Palana e007d02c21 Allow property list entries to be disabled
This allows, for example, disconnected devices for dshow/avcapture to
be listed (and to stay selected in the user config) while making them
unavailable for selection in new sources
2014-06-17 17:03:27 +02:00
Palana ed7b37b522 Return index of added property list entry 2014-06-17 17:03:27 +02:00
jp9000 85dcfcaa34 libobs: Add button support to properties
This adds button support to properties, which will allow a properties
pane to let the user click a button to activate something with a
particular obs context.  When pressed, the button will execute the
callback given, with the context's private data as a parameter.
2014-05-30 02:16:46 -07:00
jp9000 7a60694159 obs-properties: Add a few features
Just wanted the ability to be able to add private data to the properties
data.  Makes it a little easier to manage data if you get updates from
controls.
2014-04-19 20:29:11 -07:00
jp9000 1bca7e0a3e Improve properties API
Improve the properties API so that it can actually respond somewhat to
user input.  Maybe later this might be further improved or replaced with
something script-based.

When creating a property, you can now add a callback to that property
that notifies when the property has been changed in the user interface.
Return true if you want the properties to be refreshed, or false if not.
Though now that I think about it I doubt there would ever be a case
where you would have this callback and *not* refresh the properties.

Regardless, this allows functions to change the values of properties or
settings, or enable/disable/hide other property controls from view
dynamically.
2014-04-04 00:30:37 -07:00
jp9000 4a652ec82d obs-output module: Fill out more functions
- Add start/stop code to obs-output module

 - Use a circular buffer for the buffered encoder packets instead of a
   dynamic array

 - Add pthreads.lib as a dependency to obs-output module on windows in
   visual studio project files

 - Fix an windows export bug for avc parsing functions on windows.
   Also, rename those functions to be more consistent with each other.

 - Make outputs use a single function for encoded data rather than
   multiple functions

 - Add the ability to make 'text' properties be passworded
2014-04-02 00:42:12 -07:00
jp9000 d9251f9e87 Add source properties window (very preliminary)
- Add a properties window for sources so that you can now actually edit
   the settings for sources.  Also, display the source by itself in the
   window (Note: not working on mac, and possibly not working on linux).

   When changing the settings for a source, it will call
   obs_source_update on that source when you have modified any values
   automatically.

 - Add a properties 'widget', eventually I want to turn this in to a
   regular nice properties view like you'd see in the designer, but
   right now it just uses a form layout in a QScrollArea with regular
   controls to display the properties.  It's clunky but works for the
   time being.

 - Make it so that swap chains and the main graphics subsystem will
   automatically use at least one backbuffer if none was specified

 - Fix bug where displays weren't added to the main display array

 - Make it so that you can get the properties of a source via the actual
   pointer of a source/encoder/output in addition to being able to look
   up properties via identifier.

 - When registering source types, check for required functions (wasn't
   doing it before).  getheight/getwidth should not be optional if it's
   a video source as well.

 - Add an RAII OBSObj wrapper to obs.hpp for non-reference-counted
   libobs pointers

 - Add an RAII OBSSignal wrapper to obs.hpp for libobs signals to
   automatically disconnect them on destruction

 - Move the "scale and center" calculation in window-basic-main.cpp to
   its own function and in its own source file

 - Add an 'update' callback to WASAPI audio sources
2014-03-23 01:07:54 -07:00
jp9000 a9f5959b3c Fix an error and a few warnings
The strings didn't have ending double quotes.  No clue why this didn't
fail in GCC and VC.  Well, VC is horrible but I expected better out of
GCC.
2014-03-07 17:19:26 -07:00
jp9000 2448d0f229 Load up the lists of audio devices in settings
It will now load up a the list of audio input/output devices in the
combo boxes in audio settings.
2014-03-06 07:02:25 -07:00
jp9000 348588254c Add WASAPI audio capture
- Add WASAPI audio capture for windows, input and output

 - Check for null pointer in os_dlopen

 - Add exception-safe 'WinHandle' and 'CoTaskMemPtr' helper classes that
   will automatically call CloseHandle on handles and call CoTaskMemFree
   on certain types of memory returned from windows functions

 - Changed the wide <-> MBS/UTF8 conversion functions so that you use
   buffers (like these functions are *supposed* to behave), and changed
   the ones that allocate to a different naming scheme to be safe
2014-03-04 07:07:13 -07:00
jp9000 9c6da6f52d Split output/input audio capture sources
- Split input and output audio captures so that they're different
   sources.  This allows easier handling and enumeration of audio
   devices without having to do some sort of string processing.

   This way the user interface code can handle this a bit more easily,
   and so that it doesn't confuse users either.  This should be done for
   all audio capture sources for all operating systems.  You don't have
   to duplicate any code, you just need to create input/output wrapper
   functions to designate the audio as input or output before creation.

 - Make it detect soundflower and wavtap devices as mac "output" devices
   (even though they're actually input) for the mac output capture, and
   make it so that users can select a default output capture and
   automatically use soundflower or wavtap.

   I'm not entirely happy about having to do this, but because mac is
   designed this way, this is really the only way to handle it that
   makes it easier for users and UI code to deal with.

   Note that soundflower and wavtap are still also designated as input
   devices, so will still show up in input device enumeration.

 - Remove pragma messages because they were kind polluting the other
   compiler messages and just getting in the way.  In the future we can
   just do a grep for TODO to find them.

 - Redo list property again, this time using a safer internal array,
   rather than requiring sketchy array inputs.  Having functions handle
   everything behind the scenes is much safer.

 - Remove the reference counter debug log code, as it was included
   unintentionally in a commit.
2014-03-03 02:56:54 -07:00
jp9000 b4ef6cee91 Remove categories from properties
Categories added an unnecessary complexity to making properties, and
would very likely almost never be used in most cases, and were more of a
display feature.  The main issue is that it made property data more
complex to work with, and I just didn't feel comfortable with that.

Also, added a function to allow you to retrieve a porperty just by its
name.
2014-03-02 21:19:44 -07:00
jp9000 9db52da6a1 Fix non-VS compile issues
As usual, microsoft treats all enums as integers, rather than actually
even checking the enum type.  Worthless compiler.  Just complete
garbage.
2014-03-02 07:41:55 -07:00
jp9000 1eeece5b97 Simplify and improve 'list' property
When a source/output/etc has a property of a 'list' type, there was no
way to get the names associated with its values.  That, and it only
supported lists of either text, or enums (0..[value] only).

Now, you can associate translated names with those values, and use
integer, float, or string values.  Put it all in to one function as well
to simplify its usage.

I plan on using this to help get enumerations from devices/etc for
certain types of sources.  For example, if I get the properties of an
audio source, I'd like to have a list of available devices with it as
well.
2014-03-02 06:32:47 -07:00
jp9000 268e4e7811 Add more checks for NULL pointers 2014-02-23 22:39:33 -07:00