Skip to content

Commit 92f4e8a

Browse files
SG-41060 & SG-41061 - Prevent drag and drop of media and RV session when media_category is blocked (#987)
### SG-41060 & SG-41061 - Prevent drag and drop of media and RV session when media_category is blocked ### Linked issues n/a ### Summarize your change. Prevent the drag and drop of media and RV session when the `media_category` is blocked. ### Describe the reason for the change. The drag and drop was not controlled by the categories filtering. ### Describe what you have tested and on which operating system. MacOS ### Add a list of changes, and note any that might need special attention during the review. ### If possible, provide screenshots. <img width="447" height="323" alt="Screenshot 2025-11-13 at 12 41 48 PM" src="https://github.com/user-attachments/assets/0ae6427f-01f9-4bdb-a6e8-ad54b1280f90" /> <img width="447" height="323" alt="Screenshot 2025-11-13 at 12 41 27 PM" src="https://github.com/user-attachments/assets/0f5f0975-b855-4a07-8d5e-ad52a976a774" /> --------- Signed-off-by: Cédrik Fuoco <[email protected]>
1 parent f315af7 commit 92f4e8a

File tree

2 files changed

+209
-91
lines changed

2 files changed

+209
-91
lines changed

src/lib/app/mu_rvui/glyph.mu

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,47 @@ operator: & (Glyph; Glyph a, Glyph b)
739739
inregion;
740740
}
741741

742+
\: drawBlockedRegions (void;
743+
int w,
744+
int h,
745+
int x,
746+
int y,
747+
int margin,
748+
string[] descriptors)
749+
{
750+
let m = margins(),
751+
devicePixelRatio=devicePixelRatio(),
752+
bsize = (h - m[2] - m[3]) / descriptors.size();
753+
754+
// Take device pixel ratio into account
755+
x *= devicePixelRatio;
756+
y *= devicePixelRatio;
757+
margin *= devicePixelRatio;
758+
759+
for_index (i; descriptors)
760+
{
761+
gltext.size(20*devicePixelRatio);
762+
763+
let y0 = bsize * i + margin + m[3],
764+
x0 = m[0] + margin,
765+
y1 = bsize * (i+1) - margin + m[3],
766+
x1 = w - margin - m[1],
767+
t = descriptors[i] + " (Blocked)",
768+
b = gltext.bounds(t),
769+
tw = b[2] + b[0],
770+
fg = Color(.4, .4, .4, 1), // Gray text for disabled
771+
bg = Color(0.3, 0, 0, .85); // Dark red background
772+
773+
drawRoundedBox(x0, y0, x1, y1, 10, bg, fg);
774+
775+
// Draw text
776+
gltext.color(fg);
777+
gltext.writeAt((x1 - x0 - tw) * .5 + x0,
778+
math_util.lerp(y0, y1, 0.5),
779+
t);
780+
}
781+
}
782+
742783
\: wrapValue(string; string value, int wrap)
743784
{
744785
if (wrap <= 0) return value;

src/lib/app/mu_rvui/rvui.mu

Lines changed: 168 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -5230,9 +5230,18 @@ global let enterFrame = startTextEntryMode(\: (string;) {"Go To Frame: ";}, goto
52305230
state.ddFileKind == MovieFileKind ||
52315231
state.ddFileKind == DirectoryFileKind)
52325232
{
5233-
state.ddRegion = drawDropRegions(w, h, x, y, 20,
5234-
string[] {"Add as Layer",
5235-
"Add Source to Session"});
5233+
string[] regions = string[] {"Add as Layer", "Add Source to Session"};
5234+
bool mediaAllowed = isEventCategoryEnabled("media_category");
5235+
5236+
if (mediaAllowed)
5237+
{
5238+
state.ddRegion = drawDropRegions(w, h, x, y, 20, regions);
5239+
}
5240+
else
5241+
{
5242+
drawBlockedRegions(w, h, x, y, 20, regions);
5243+
state.ddRegion = -1; // No valid drop region
5244+
}
52365245

52375246
(void;string) F = if state.ddRegion == 0
52385247
then addToClosestSource(,"drop")
@@ -5271,80 +5280,114 @@ global let enterFrame = startTextEntryMode(\: (string;) {"Go To Frame: ";}, goto
52715280
}
52725281
else if (state.ddFileKind == CDLFileKind)
52735282
{
5274-
state.ddRegion = drawDropRegions(w, h, x, y, 20,
5275-
string[] {"Set File CDL",
5276-
"Set Look CDL"});
5277-
5278-
let N = if state.ddRegion == 0
5279-
then "#RVLinearize"
5280-
else if state.ddRegion == 1
5281-
then "#RVColor"
5282-
else "";
5283-
5284-
state.ddDropFunc = \: (void; int a, string s)
5285-
{
5286-
if (N == "")
5287-
{
5288-
ddCancelled(s);
5289-
}
5290-
else
5291-
{
5292-
try
5283+
bool sourceAllowed = isEventCategoryEnabled("source_category");
5284+
5285+
if (sourceAllowed)
5286+
{
5287+
state.ddRegion = drawDropRegions(w, h, x, y, 20,
5288+
string[] {"Set File CDL",
5289+
"Set Look CDL"});
5290+
5291+
let N = if state.ddRegion == 0
5292+
then "#RVLinearize"
5293+
else if state.ddRegion == 1
5294+
then "#RVColor"
5295+
else "";
5296+
5297+
state.ddDropFunc = \: (void; int a, string s)
5298+
{
5299+
if (N == "")
52935300
{
5294-
readCDL(s, N, true);
5295-
displayFeedback("%s CDL" % path.basename(s));
5301+
ddCancelled(s);
52965302
}
5297-
catch (exception exc)
5303+
else
52985304
{
5299-
let sexc = string(exc);
5300-
displayFeedback("Unable to read CDL %s: %s" % (path.basename(s), sexc));
5305+
try
5306+
{
5307+
readCDL(s, N, true);
5308+
displayFeedback("%s CDL" % path.basename(s));
5309+
}
5310+
catch (exception exc)
5311+
{
5312+
let sexc = string(exc);
5313+
displayFeedback("Unable to read CDL %s: %s" % (path.basename(s), sexc));
5314+
}
53015315
}
5302-
}
5303-
};
5316+
};
5317+
}
5318+
else
5319+
{
5320+
// Show blocked regions when source category is disabled
5321+
drawBlockedRegions(w, h, x, y, 20, string[] {"Set File CDL", "Set Look CDL"});
5322+
state.ddRegion = -1;
5323+
}
53045324
}
53055325
else if (state.ddFileKind == LUTFileKind)
53065326
{
5307-
state.ddRegion = drawDropRegions(w, h, x, y, 20,
5308-
string[] {"Set Display LUT",
5309-
"Set File LUT",
5310-
"Set Look LUT"});
5311-
5312-
let N = if state.ddRegion == 0
5313-
then "@RVDisplayColor"
5314-
else if state.ddRegion == 1
5315-
then "#RVLinearize"
5316-
else if state.ddRegion == 2
5317-
then "#RVLookLUT"
5318-
else "";
5327+
// Check if source modifications are allowed
5328+
bool sourceAllowed = isEventCategoryEnabled("source_category");
5329+
5330+
if (sourceAllowed)
5331+
{
5332+
state.ddRegion = drawDropRegions(w, h, x, y, 20,
5333+
string[] {"Set Display LUT",
5334+
"Set File LUT",
5335+
"Set Look LUT"});
5336+
5337+
let N = if state.ddRegion == 0
5338+
then "@RVDisplayColor"
5339+
else if state.ddRegion == 1
5340+
then "#RVLinearize"
5341+
else if state.ddRegion == 2
5342+
then "#RVLookLUT"
5343+
else "";
53195344

5320-
state.ddDropFunc = \: (void; int a, string s)
5321-
{
5322-
if (N == "")
5323-
{
5324-
ddCancelled(s);
5325-
}
5326-
else
5327-
{
5328-
try
5345+
state.ddDropFunc = \: (void; int a, string s)
5346+
{
5347+
if (N == "")
53295348
{
5330-
readLUT(s, N, true);
5331-
displayFeedback("%s LUT" % path.basename(s));
5349+
ddCancelled(s);
53325350
}
5333-
catch (exception exc)
5351+
else
53345352
{
5335-
let sexc = string(exc);
5336-
displayFeedback("Unable to read LUT %s: %s" % (path.basename(s), sexc));
5353+
try
5354+
{
5355+
readLUT(s, N, true);
5356+
displayFeedback("%s LUT" % path.basename(s));
5357+
}
5358+
catch (exception exc)
5359+
{
5360+
let sexc = string(exc);
5361+
displayFeedback("Unable to read LUT %s: %s" % (path.basename(s), sexc));
5362+
}
53375363
}
5338-
}
5339-
};
5364+
};
5365+
}
5366+
else
5367+
{
5368+
// Show blocked regions when source category is disabled
5369+
drawBlockedRegions(w, h, x, y, 20, string[] {"Set Display LUT", "Set File LUT", "Set Look LUT"});
5370+
state.ddRegion = -1;
5371+
}
53405372
}
53415373
else if (state.ddFileKind == RVFileKind)
53425374
{
5343-
state.ddProgressiveDrop = true;
5344-
state.ddRegion = drawDropRegions(w, h, x, y, 20,
5345-
string[] {"Replace Session"});
5375+
bool mediaAllowed = isEventCategoryEnabled("media_category");
5376+
5377+
if (mediaAllowed)
5378+
{
5379+
state.ddProgressiveDrop = true;
5380+
state.ddRegion = drawDropRegions(w, h, x, y, 20,
5381+
string[] {"Replace Session"});
53465382

5347-
state.ddDropFunc = \: (void; int a, string s) { addSources(string[] {s}, "drop"); };
5383+
state.ddDropFunc = \: (void; int a, string s) { addSources(string[] {s}, "drop"); };
5384+
}
5385+
else
5386+
{
5387+
// Show blocked regions when media category is disabled
5388+
drawBlockedRegions(w, h, x, y, 20, string[] {"Replace Session"});
5389+
state.ddRegion = -1;
5390+
}
53485391
}
53495392
else
53505393
{
@@ -5377,46 +5420,80 @@ global let enterFrame = startTextEntryMode(\: (string;) {"Go To Frame: ";}, goto
53775420
state.ddFileKind == MovieFileKind ||
53785421
state.ddFileKind == DirectoryFileKind)
53795422
{
5380-
state.ddProgressiveDrop = true;
5381-
state.ddRegion = drawDropRegions(w, h, x, y, 20,
5382-
string[] {"Add Source to Session"});
5383-
state.ddDropFunc = \: (void; int a, string s)
5384-
{
5385-
let f = frameEnd(),
5386-
empty = sources().size() == 0;
5423+
bool mediaAllowed = isEventCategoryEnabled("media_category");
5424+
5425+
if (mediaAllowed)
5426+
{
5427+
state.ddProgressiveDrop = true;
5428+
state.ddRegion = drawDropRegions(w, h, x, y, 20,
5429+
string[] {"Add Source to Session"});
5430+
state.ddDropFunc = \: (void; int a, string s)
5431+
{
5432+
let f = frameEnd(),
5433+
empty = sources().size() == 0;
53875434

5388-
addSources(string[] {s}, "drop");
5435+
addSources(string[] {s}, "drop");
53895436

5390-
if (empty)
5391-
{
5392-
setFrame(frameStart());
5393-
}
5394-
else
5395-
{
5396-
setFrame(f + 1);
5397-
//markFrame(f + 1, true);
5398-
//markFrame(frameStart(), true);
5399-
}
5400-
redraw();
5401-
};
5437+
if (empty)
5438+
{
5439+
setFrame(frameStart());
5440+
}
5441+
else
5442+
{
5443+
setFrame(f + 1);
5444+
//markFrame(f + 1, true);
5445+
//markFrame(frameStart(), true);
5446+
}
5447+
redraw();
5448+
};
5449+
}
5450+
else
5451+
{
5452+
// Show blocked regions when media category is disabled
5453+
drawBlockedRegions(w, h, x, y, 20, string[] {"Add Source to Session"});
5454+
state.ddRegion = -1;
5455+
}
54025456
}
54035457
else if (state.ddFileKind == RVFileKind)
54045458
{
5405-
state.ddProgressiveDrop = true;
5406-
state.ddRegion = drawDropRegions(w, h, x, y, 20,
5407-
string[] {"Load Session"});
5459+
bool mediaAllowed = isEventCategoryEnabled("media_category");
5460+
5461+
if (mediaAllowed)
5462+
{
5463+
state.ddProgressiveDrop = true;
5464+
state.ddRegion = drawDropRegions(w, h, x, y, 20,
5465+
string[] {"Load Session"});
54085466

5409-
state.ddDropFunc = \: (void; int a, string s) { addSources(string[] {s}, "drop"); };
5467+
state.ddDropFunc = \: (void; int a, string s) { addSources(string[] {s}, "drop"); };
5468+
}
5469+
else
5470+
{
5471+
// Show blocked regions when media category is disabled
5472+
drawBlockedRegions(w, h, x, y, 20, string[] {"Load Session"});
5473+
state.ddRegion = -1;
5474+
}
54105475
}
54115476
else if (state.ddFileKind == LUTFileKind)
54125477
{
5413-
state.ddRegion = drawDropRegions(w, h, x, y, 20,
5414-
string[] {"Set Display LUT"});
5478+
// Check if source modifications are allowed
5479+
bool sourceAllowed = isEventCategoryEnabled("source_category");
5480+
5481+
if (sourceAllowed)
5482+
{
5483+
state.ddRegion = drawDropRegions(w, h, x, y, 20,
5484+
string[] {"Set Display LUT"});
54155485

5416-
state.ddDropFunc = \: (void; int a, string s)
5417-
{
5418-
readLUT(s, "@RVDisplayColor", true);
5419-
};
5486+
state.ddDropFunc = \: (void; int a, string s)
5487+
{
5488+
readLUT(s, "@RVDisplayColor", true);
5489+
};
5490+
}
5491+
else
5492+
{
5493+
// Show blocked regions when source category is disabled
5494+
drawBlockedRegions(w, h, x, y, 20, string[] {"Set Display LUT"});
5495+
state.ddRegion = -1;
5496+
}
54205497
}
54215498
else
54225499
{

0 commit comments

Comments
 (0)