Skip to content

Commit 92d9289

Browse files
kenmcgaughKen McGaugh
authored andcommitted
This adds hotkeys for changing the current OCIO view. The hotkeys are Ctrl+1 through Ctrl+9 (linux) and each select the the corresponding view for the current display. Under MacOS these are Cmd+1 through Cmd+9.
Signed-off-by: Ken McGaugh <[email protected]>
1 parent 2fde4fd commit 92d9289

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/plugin/colour_pipeline/ocio/src/ocio_plugin.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,18 @@ void OCIOColourPipeline::register_hotkeys() {
288288
channel_hotkeys_[hotkey_id] = hotkey_props.channel_name;
289289
}
290290

291+
for (int i = 1; i <= 9; ++i) {
292+
auto suffix = std::string(fmt::format(" #{}", i));
293+
auto hotkey_id = register_hotkey(
294+
int('0')+i,
295+
ui::MetaModifier,
296+
std::string("Change OCIO View Transform")+suffix,
297+
"Changes OCIO view transform",
298+
false,
299+
"Viewer");
300+
view_hotkeys_[hotkey_id] = i;
301+
}
302+
291303
reset_hotkey_ = register_hotkey(
292304
int('R'),
293305
ui::ControlModifier,
@@ -352,6 +364,18 @@ void OCIOColourPipeline::hotkey_pressed(
352364
} else if (hotkey_uuid == saturation_hotkey_) {
353365
saturation_->set_role_data(module::Attribute::Activated, true);
354366
grab_mouse_focus();
367+
} else {
368+
auto v = view_hotkeys_.find(hotkey_uuid);
369+
if (v != view_hotkeys_.end()) {
370+
const auto &views = display_views_[display_->value()];
371+
int idx = v->second-1;
372+
if (idx >= 0 and idx < views.size()) {
373+
const auto &new_view = views[idx];
374+
if (new_view != view_->value()) {
375+
view_->set_value(new_view);
376+
}
377+
}
378+
}
355379
}
356380
}
357381

src/plugin/colour_pipeline/ocio/src/ocio_plugin.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ class OCIOColourPipeline : public ColourPipeline {
148148
UiText ui_text_;
149149

150150
std::map<utility::Uuid, std::string> channel_hotkeys_;
151+
std::map<utility::Uuid, int> view_hotkeys_;
151152
utility::Uuid exposure_hotkey_;
152153
utility::Uuid gamma_hotkey_;
153154
utility::Uuid saturation_hotkey_;

0 commit comments

Comments
 (0)