Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
darbyjohnston committed Mar 9, 2025
1 parent 1323c04 commit ec109e2
Show file tree
Hide file tree
Showing 40 changed files with 1,529 additions and 726 deletions.
2 changes: 1 addition & 1 deletion etc/SuperBuild/cmake/Modules/Builddtk-deps.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include(ExternalProject)

set(dtk_GIT_REPOSITORY "https://github.com/darbyjohnston/dtk.git")
set(dtk_GIT_TAG "3871dd96c38b55322dacca7a2a855e3a3fe54c07")
set(dtk_GIT_TAG "c901c9cb776aa8551d061e823d795dea28168c07")

set(dtk-deps_ARGS
-Ddtk_API=${dtk_API}
Expand Down
2 changes: 1 addition & 1 deletion etc/SuperBuild/cmake/Modules/Builddtk.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include(ExternalProject)

set(dtk_GIT_REPOSITORY "https://github.com/darbyjohnston/dtk.git")
set(dtk_GIT_TAG "3871dd96c38b55322dacca7a2a855e3a3fe54c07")
set(dtk_GIT_TAG "c901c9cb776aa8551d061e823d795dea28168c07")

set(dtk_DEPS dtk-deps)
set(dtk_ARGS
Expand Down
64 changes: 55 additions & 9 deletions lib/tlPlayApp/Actions/AudioActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@
#include <tlPlayApp/Models/AudioModel.h>
#include <tlPlayApp/App.h>

#include <dtk/core/Format.h>

namespace tl
{
namespace play
{
struct AudioActions::Private
{
std::map<std::string, std::shared_ptr<dtk::Action> > actions;

std::shared_ptr<dtk::ValueObserver<KeyShortcutsSettings> > keyShortcutsSettingsObserver;
};

void AudioActions::_init(
Expand All @@ -23,10 +27,8 @@ namespace tl
DTK_P();

auto appWeak = std::weak_ptr<App>(app);
p.actions["VolumeUp"] = std::make_shared<dtk::Action>(
p.actions["VolumeUp"] = dtk::Action::create(
"Volume Up",
dtk::Key::Period,
0,
[appWeak]
{
if (auto app = appWeak.lock())
Expand All @@ -35,10 +37,8 @@ namespace tl
}
});

p.actions["VolumeDown"] = std::make_shared<dtk::Action>(
p.actions["VolumeDown"] = dtk::Action::create(
"Volume Down",
dtk::Key::Comma,
0,
[appWeak]
{
if (auto app = appWeak.lock())
Expand All @@ -47,18 +47,23 @@ namespace tl
}
});

p.actions["Mute"] = std::make_shared<dtk::Action>(
p.actions["Mute"] = dtk::Action::create(
"Mute",
"Mute",
dtk::Key::M,
0,
[appWeak](bool value)
{
if (auto app = appWeak.lock())
{
app->getAudioModel()->setMute(value);
}
});

p.keyShortcutsSettingsObserver = dtk::ValueObserver<KeyShortcutsSettings>::create(
app->getSettingsModel()->observeKeyShortcuts(),
[this](const KeyShortcutsSettings& value)
{
_keyShortcutsUpdate(value);
});
}

AudioActions::AudioActions() :
Expand All @@ -81,5 +86,46 @@ namespace tl
{
return _p->actions;
}

void AudioActions::_keyShortcutsUpdate(const KeyShortcutsSettings& value)
{
DTK_P();
const std::map<std::string, std::string> tooltips =
{
{
"VolumeUp",
"Increase the audio volume.\n"
"\n"
"Shortcut: {0}"
},
{
"VolumeDown",
"Decrease the audio volume.\n"
"\n"
"Shortcut: {0}"
},
{
"Mute",
"Toggle the autio mute.\n"
"\n"
"Shortcut: {0}"
},
};
for (const auto& i : p.actions)
{
auto j = value.shortcuts.find(dtk::Format("Audio/{0}").arg(i.first));
if (j != value.shortcuts.end())
{
i.second->setShortcut(j->second.key);
i.second->setShortcutModifiers(j->second.modifiers);
const auto k = tooltips.find(i.first);
if (k != tooltips.end())
{
i.second->setTooltip(dtk::Format(k->second).
arg(dtk::getShortcutLabel(j->second.key, j->second.modifiers)));
}
}
}
}
}
}
4 changes: 4 additions & 0 deletions lib/tlPlayApp/Actions/AudioActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#pragma once

#include <tlPlayApp/Models/SettingsModel.h>

#include <dtk/ui/Action.h>

namespace tl
Expand Down Expand Up @@ -34,6 +36,8 @@ namespace tl
const std::map<std::string, std::shared_ptr<dtk::Action> >& getActions() const;

private:
void _keyShortcutsUpdate(const KeyShortcutsSettings&);

DTK_PRIVATE();
};
}
Expand Down
Loading

0 comments on commit ec109e2

Please sign in to comment.