Skip to content

Commit c7e0d7c

Browse files
markreidvfxpbergeron-adskbernie-laberge
authored
SG-40371: Presentation Mode Enhancements (#850)
### Summarize your change. This PR add some features to aid in automating Presentation mode #### Add command to set the presentation device Add new command `setPresentationDevice`. You can do this with the writeSettings command but that requires a restart of RV or opening of the preference window to trigger the the preference being applied. #### Fix Video Format Overlay View->Presentation Settings->Video Format overlay was disable because it was causing a crash in `RV-4.0+`. I fixed the crash and it works again. It is useful for debugging presentation devices. <img width="1382" height="380" alt="image" src="https://github.com/user-attachments/assets/75b53c6c-a934-4a74-8f06-1cd0d65cf1ab" /> <img width="1445" height="839" alt="image" src="https://github.com/user-attachments/assets/4ec4410b-7fb4-4ed9-ac93-a49adc8c0af4" /> #### Presentation device additional options This is pretty funny, **disable** the rich text option on this widget. don't think this widget needs bold, underline text, colors etc. Can happen if you are copy pasting text into widget <img width="701" height="231" alt="image" src="https://github.com/user-attachments/assets/4baca019-86f6-44c5-8f23-201c0a381236" /> #### Add command to apply preferences `rv.commands.writeSetting` command does not immediately apply the preferences you set. It only saves them to the configuration file. A restart of RV or opening of the preference window is required to trigger the changes to take effect. The `loadSettingsIntoOptions` command addresses this issue by allowing preferences to be applied. I used the same name as the c++ function for the command. This name might not be ideal, I’m open to suggestions for a better name. This command has proven to be very useful, for setting additional preferences like modifying `Treat Stylus Events as Mouse Events` which currently not possible. ### Describe what you have tested and on which operating system. Linux, macOS --------- Signed-off-by: Mark Reid <[email protected]> Signed-off-by: Bernard Laberge <[email protected]> Co-authored-by: pbergeron-adsk <[email protected]> Co-authored-by: Bernard Laberge <[email protected]>
1 parent 2787ab2 commit c7e0d7c

File tree

5 files changed

+141
-64
lines changed

5 files changed

+141
-64
lines changed

src/lib/app/RvCommon/MuUICommands.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,13 @@ namespace Rv
476476
new Function(c, "presentationMode", presentationMode, None, Return,
477477
"bool", End),
478478

479+
new Function(c, "setPresentationDevice", setPresentationDevice,
480+
None, Return, "void", Parameters,
481+
new Param(c, "name", "string"), End),
482+
483+
new Function(c, "loadSettingsIntoOptions", loadSettingsIntoOptions,
484+
None, Return, "void", End),
485+
479486
new Function(c, "packageListFromSetting", packageListFromSetting,
480487
None, Return, "string[]", Parameters,
481488
new Param(c, "settingName", "string"), End),
@@ -2261,6 +2268,57 @@ namespace Rv
22612268
NODE_RETURN(RvApp()->isInPresentationMode());
22622269
}
22632270

2271+
NODE_IMPLEMENTATION(setPresentationDevice, void)
2272+
{
2273+
StringType::String* deviceName = NODE_ARG_OBJECT(0, StringType::String);
2274+
Rv::Options& opts = Rv::Options::sharedOptions();
2275+
2276+
if (!deviceName)
2277+
throwBadArgumentException(NODE_THIS, NODE_THREAD,
2278+
"Nil setting name.");
2279+
2280+
if (VideoDevice* d =
2281+
RvApp()->findPresentationDevice(deviceName->c_str()))
2282+
{
2283+
bool presenting = RvApp()->isInPresentationMode();
2284+
Session* s = Session::currentSession();
2285+
Session::CachingMode mode = s->cachingMode();
2286+
2287+
if (presenting)
2288+
{
2289+
s->setCaching(Session::NeverCache);
2290+
RvApp()->setPresentationMode(false);
2291+
}
2292+
2293+
RV_QSETTINGS;
2294+
settings.beginGroup("Video");
2295+
settings.setValue("presentationDevice",
2296+
QString::fromUtf8(deviceName->c_str()));
2297+
settings.endGroup();
2298+
2299+
Rv::RvPreferences::loadSettingsIntoOptions(opts);
2300+
2301+
RvApp()->setVideoDeviceStateFromSettings(d);
2302+
2303+
if (presenting)
2304+
{
2305+
RvApp()->setPresentationMode(true);
2306+
s->setCaching(mode);
2307+
}
2308+
}
2309+
else
2310+
{
2311+
throwBadArgumentException(NODE_THIS, NODE_THREAD,
2312+
"device not found");
2313+
}
2314+
}
2315+
2316+
NODE_IMPLEMENTATION(loadSettingsIntoOptions, void)
2317+
{
2318+
Rv::Options& opts = Rv::Options::sharedOptions();
2319+
Rv::RvPreferences::loadSettingsIntoOptions(opts);
2320+
}
2321+
22642322
NODE_IMPLEMENTATION(packageListFromSetting, Pointer)
22652323
{
22662324
StringType::String* setting = NODE_ARG_OBJECT(0, StringType::String);

src/lib/app/RvCommon/RvCommon/MuUICommands.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ namespace Rv
7878
NODE_DECLARATION(setDriverAttribute, void);
7979
NODE_DECLARATION(setPresentationMode, void);
8080
NODE_DECLARATION(presentationMode, bool);
81+
NODE_DECLARATION(setPresentationDevice, void);
82+
NODE_DECLARATION(loadSettingsIntoOptions, void);
8183
NODE_DECLARATION(packageListFromSetting, Mu::Pointer);
8284
NODE_DECLARATION(showTopViewToolbar, void);
8385
NODE_DECLARATION(showBottomViewToolbar, void);

src/lib/app/RvCommon/ui/RvPreferences/Qt5/RvPreferences.ui

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,11 @@
17191719
</widget>
17201720
</item>
17211721
<item row="19" column="1">
1722-
<widget class="QTextEdit" name="additionalOptionsEdit"/>
1722+
<widget class="QTextEdit" name="additionalOptionsEdit">
1723+
<property name="acceptRichText">
1724+
<bool>false</bool>
1725+
</property>
1726+
</widget>
17231727
</item>
17241728
<item row="3" column="0">
17251729
<widget class="QLabel" name="label_22">

src/lib/app/mu_rvui/presentation_mode.mu

Lines changed: 74 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,79 @@ class: PresentationControlMinorMode : MinorMode
235235
runtime.gc.pop_api();
236236
}
237237

238+
method: _drawFormat (void; Event event)
239+
{
240+
if (!_showFormat) return;
241+
let vstate = videoState();
242+
if (vstate eq nil) return;
243+
244+
let domain = event.domain(),
245+
width = domain.x,
246+
height = domain.y,
247+
h = height / 4,
248+
w = width * 0.6,
249+
m = (width - w) / 2;
250+
251+
setupProjection(domain.x, domain.y, event.domainVerticalFlip());
252+
253+
\: init (void; FormatText t, string text, int w, int h)
254+
{
255+
if (text eq nil || text.size() == 0) text = " ";
256+
t.text = "%s" % text;
257+
t.fontSize = fitTextInBox(text, w, h);
258+
259+
gltext.size(t.fontSize);
260+
261+
let b = gltext.bounds(text);
262+
t.width = b[0] + b[2];
263+
t.height = -b[1] + b[3];
264+
t.valid = true;
265+
}
266+
267+
if (!_deviceText.valid)
268+
{
269+
runtime.gc.push_api(0);
270+
init(_deviceText, "%s/%s" % (vstate.module, vstate.device), w, h);
271+
init(_formatText, vstate.videoFormat, w, h);
272+
init(_dataFormatText, vstate.dataFormat, w, h);
273+
init(_audioFormatText, vstate.audioFormat, w, h);
274+
275+
_totalHeight = _deviceText.height + _formatText.height +
276+
_dataFormatText.height + _audioFormatText.height;
277+
278+
runtime.gc.pop_api();
279+
}
280+
281+
glEnable(GL_BLEND);
282+
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
283+
let hm = (height - _totalHeight) / 2,
284+
sep = (height / 4.0) * 0.1;
285+
286+
int y = height - hm;
287+
288+
drawRoundedBox(m, y - _totalHeight - sep * 4,
289+
width - m, y,
290+
20,
291+
Color(0,0,0,.75), Color(0,0,0,1));
292+
293+
for_each (t; [_deviceText, _formatText, _dataFormatText, _audioFormatText])
294+
{
295+
y -= t.height;
296+
297+
gltext.size(t.fontSize);
298+
299+
gltext.color(Color(0,0,0,.1)); gltext.writeAt(m - 2, y - 2, t.text);
300+
gltext.color(Color(0,0,0,.1)); gltext.writeAt(m + 2, y + 2, t.text);
301+
gltext.color(Color(0,0,0,.1)); gltext.writeAt(m - 2, y + 2, t.text);
302+
gltext.color(Color(0,0,0,.25)); gltext.writeAt(m + 4, y - 4, t.text);
303+
gltext.color(Color(.75,.75,.75,1)); gltext.writeAt(m, y, t.text);
304+
305+
y -= sep;
306+
}
307+
308+
glDisable(GL_BLEND);
309+
}
310+
238311
method: render (void; Event event)
239312
{
240313
event.reject();
@@ -313,67 +386,7 @@ class: PresentationControlMinorMode : MinorMode
313386
setupProjection(domain.x, domain.y, event.domainVerticalFlip());
314387

315388
_drawPointer (event, state);
316-
317-
if (_showFormat)
318-
{
319-
let vstate = videoState(),
320-
h = vstate.height / 4,
321-
w = vstate.width * 0.6,
322-
m = (vstate.width - w) / 2;
323-
324-
\: init (void; FormatText t, string text, int w, int h)
325-
{
326-
t.text = text;
327-
t.fontSize = fitTextInBox(text, w, h);
328-
329-
gltext.size(t.fontSize);
330-
331-
let b = gltext.bounds(text);
332-
t.width = b[0] + b[2];
333-
t.height = -b[1] + b[3];
334-
t.valid = true;
335-
}
336-
337-
if (!_deviceText.valid)
338-
{
339-
init(_deviceText, "%s/%s" % (vstate.module, vstate.device), w, h);
340-
init(_formatText, vstate.videoFormat, w, h);
341-
init(_dataFormatText, vstate.dataFormat, w, h);
342-
init(_audioFormatText, vstate.audioFormat, w, h);
343-
344-
_totalHeight = _deviceText.height + _formatText.height +
345-
_dataFormatText.height + _audioFormatText.height;
346-
}
347-
348-
glEnable(GL_BLEND);
349-
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
350-
let hm = (vstate.height - _totalHeight) / 2,
351-
sep = (vstate.height / 4.0) * 0.1;
352-
353-
int y = vstate.height - hm;
354-
355-
drawRoundedBox(m, y - _totalHeight - sep * 4,
356-
vstate.width - m, y,
357-
20,
358-
Color(0,0,0,.75), Color(0,0,0,1));
359-
360-
for_each (t; [_deviceText, _formatText, _dataFormatText, _audioFormatText])
361-
{
362-
y -= t.height;
363-
364-
gltext.size(t.fontSize);
365-
366-
gltext.color(Color(0,0,0,.1)); gltext.writeAt(m - 2, y - 2, t.text);
367-
gltext.color(Color(0,0,0,.1)); gltext.writeAt(m + 2, y + 2, t.text);
368-
gltext.color(Color(0,0,0,.1)); gltext.writeAt(m - 2, y + 2, t.text);
369-
gltext.color(Color(0,0,0,.25)); gltext.writeAt(m + 4, y - 4, t.text);
370-
gltext.color(Color(.75,.75,.75,1)); gltext.writeAt(m, y, t.text);
371-
372-
y -= sep;
373-
}
374-
375-
glDisable(GL_BLEND);
376-
}
389+
_drawFormat (event);
377390

378391
}
379392
catch (object obj)
@@ -510,8 +523,6 @@ class: PresentationControlMinorMode : MinorMode
510523
subMenu("Presentation Settings", MenuItem[] {
511524
menuText("Show"),
512525
menuItem(" Pointer", "", "presentation_category", togglePointer, pointerState),
513-
// XXX
514-
// This errors in pres mode in rv4, crashes rvsdi, turn off for now
515526
menuItem(" Video Format", "", "presentation_category", toggleFormat, formatState),
516527
menuSeparator(),
517528
menuText("Mirror"),

src/lib/app/py_rvui/rv_commands_setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@
177177
"ioParameters",
178178
"propertyInfo",
179179
"setPresentationMode",
180+
"setPresentationDevice",
181+
"loadSettingsIntoOptions",
180182
"optionsPlay",
181183
"addSource",
182184
"addSourceBegin",

0 commit comments

Comments
 (0)