diff --git a/Applications/SoundPlayer/SoundPlayerWidget.cpp b/Applications/SoundPlayer/SoundPlayerWidget.cpp index 28776ba274..2dfb4f44ac 100644 --- a/Applications/SoundPlayer/SoundPlayerWidget.cpp +++ b/Applications/SoundPlayer/SoundPlayerWidget.cpp @@ -26,7 +26,11 @@ SoundPlayerWidget::SoundPlayerWidget(GWindow& window, NonnullRefPtrset_size_policy(SizePolicy::Fixed, SizePolicy::Fill); m_elapsed->set_preferred_size(80, 0); - m_sample_widget = SampleWidget::construct(status_widget); + auto sample_widget_container = GWidget::construct(status_widget.ptr()); + sample_widget_container->set_layout(make(Orientation::Horizontal)); + sample_widget_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fill); + + m_sample_widget = SampleWidget::construct(sample_widget_container); m_remaining = GLabel::construct(status_widget); m_remaining->set_frame_shape(FrameShape::Container); @@ -82,6 +86,11 @@ SoundPlayerWidget::Slider::~Slider() { } +void SoundPlayerWidget::hide_scope(bool hide) +{ + m_sample_widget->set_visible(!hide); +} + void SoundPlayerWidget::open_file(String path) { if (!path.ends_with(".wav")) { diff --git a/Applications/SoundPlayer/SoundPlayerWidget.h b/Applications/SoundPlayer/SoundPlayerWidget.h index 6f144a5af2..f4c3b8b78e 100644 --- a/Applications/SoundPlayer/SoundPlayerWidget.h +++ b/Applications/SoundPlayer/SoundPlayerWidget.h @@ -13,6 +13,7 @@ class SoundPlayerWidget final : public GWidget { public: virtual ~SoundPlayerWidget() override; void open_file(String path); + void hide_scope(bool); PlaybackManager& manager() { return m_manager; } private: diff --git a/Applications/SoundPlayer/main.cpp b/Applications/SoundPlayer/main.cpp index f2699b969c..410b31fd8a 100644 --- a/Applications/SoundPlayer/main.cpp +++ b/Applications/SoundPlayer/main.cpp @@ -1,13 +1,13 @@ #include "SoundPlayerWidget.h" #include #include +#include #include #include #include #include #include #include -#include #include int main(int argc, char** argv) @@ -33,24 +33,30 @@ int main(int argc, char** argv) player->manager().play(); } + auto hide_scope = GAction::create("Hide scope", [&](GAction& action) { + action.set_checked(!action.is_checked()); + player->hide_scope(action.is_checked()); + }); + hide_scope->set_checkable(true); + app_menu->add_action(GCommonActions::make_open_action([&](auto&) { Optional path = GFilePicker::get_open_filepath("Open wav file..."); if (path.has_value()) { player->open_file(path.value()); } })); - + app_menu->add_action(move(hide_scope)); app_menu->add_separator(); app_menu->add_action(GCommonActions::make_quit_action([&](auto&) { app.quit(); })); - menubar->add_menu(move(app_menu)); - auto help_menu = make("Help"); help_menu->add_action(GAction::create("About", [](auto&) { GAboutDialog::show("SoundPlayer", GraphicsBitmap::load_from_file("/res/icons/32x32/app-sound-player.png")); })); + + menubar->add_menu(move(app_menu)); menubar->add_menu(move(help_menu)); app.set_menubar(move(menubar));