Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file scripts/docker/Ubuntu22
run: docker build . --file scripts/docker/Ubuntu24
13 changes: 7 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.5)
project(glight)

find_package(PkgConfig)
pkg_check_modules(GTKMM gtkmm-3.0>=3.0.0 REQUIRED)
pkg_check_modules(GTKMM gtkmm-4.0>=4.0.0 REQUIRED)
pkg_check_modules(SIGCXX2 sigc++-2.0 REQUIRED)
pkg_check_modules(FLACPP flac++ REQUIRED)
pkg_check_modules(ALSA alsa REQUIRED)
Expand Down Expand Up @@ -33,10 +33,10 @@ set(CMAKE_CXX_CLANG_TIDY "clang-tidy;--fix-errors;-checks=*,-llvmlibc*,\
endif()

add_compile_options(
-DGTKMM_DISABLE_DEPRECATED
-DGDKMM_DISABLE_DEPRECATED
-DGLIBMM_DISABLE_DEPRECATED
-DGIOMM_DISABLE_DEPRECATED
# -DGTKMM_DISABLE_DEPRECATED
# -DGDKMM_DISABLE_DEPRECATED
# -DGLIBMM_DISABLE_DEPRECATED
# -DGIOMM_DISABLE_DEPRECATED
-O3
-Wall
-Wvla
Expand Down Expand Up @@ -73,18 +73,19 @@ include_directories(SYSTEM ${AUBIO_INCLUDE_DIR})

set(GUIFILES
gui/application.cpp
gui/components/nameframe.cpp
gui/functions.cpp
gui/instance.cpp
gui/renderengine.cpp
gui/components/audiowidget.cpp
gui/components/beatinput.cpp
gui/components/colorselectwidget.cpp
gui/components/colorsequencewidget.cpp
gui/components/controlbutton.cpp
gui/components/durationinput.cpp
gui/components/fixturelist.cpp
gui/components/foldercombo.cpp
gui/components/iconbutton.cpp
gui/components/nameframe.cpp
gui/components/objectlist.cpp
gui/components/powermonitor.cpp
gui/components/propertiesbox.cpp
Expand Down
6 changes: 5 additions & 1 deletion gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ void Application::Run(int argc, char *argv[]) {
if (argc > 1) {
window.OpenFile(argv[1]);
}
run(window, 1, argv);
signal_activate().connect([&window, this]() {
add_window(window);
window.present();
});
run();
snd_config_update_free_global();
}

Expand Down
2 changes: 1 addition & 1 deletion gui/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace glight::gui {
class Application : public Gtk::Application {
public:
Application()
: Gtk::Application("org.glight", Gio::APPLICATION_HANDLES_OPEN) {}
: Gtk::Application("org.glight", Gio::Application::Flags::HANDLES_OPEN) {}
void Run(int argc, char *argv[]);
};

Expand Down
19 changes: 11 additions & 8 deletions gui/components/audiowidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <cairomm/context.h>

#include <gdkmm/general.h> // set_source_pixbuf()
#include <gtkmm/gestureclick.h>

namespace {

Expand Down Expand Up @@ -67,12 +68,15 @@ AudioWidget::AudioWidget()
_chunkBuffer(kChunkSize) {
set_size_request(50, 50);

add_events(Gdk::BUTTON_PRESS_MASK);

signal_button_press_event().connect(
auto gesture = Gtk::GestureClick::create();
gesture->set_button(1);
gesture->signal_pressed().connect(
sigc::mem_fun(*this, &AudioWidget::onButtonPressed));
add_controller(gesture);

signal_draw().connect(sigc::mem_fun(*this, &AudioWidget::onExpose));
set_draw_func([&](const Cairo::RefPtr<Cairo::Context> &cairo, int, int) {
AudioWidget::onExpose(cairo);
});
}

AudioWidget::~AudioWidget() = default;
Expand Down Expand Up @@ -124,7 +128,7 @@ void AudioWidget::ResizeBuffer() {
_height = get_height();
if (_width > 0) {
_buffer =
Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, false, 8, _width, _height);
Gdk::Pixbuf::create(Gdk::Colorspace::RGB, false, 8, _width, _height);
} else {
_buffer.reset();
}
Expand Down Expand Up @@ -209,12 +213,11 @@ void AudioWidget::bufferToScreen(const Cairo::RefPtr<Cairo::Context> &context) {
context->fill();
}

bool AudioWidget::onButtonPressed(GdkEventButton *event) {
void AudioWidget::onButtonPressed(int, double x, double y) {
const int position = std::clamp<int>(
static_cast<int>(event->x) + _renderStartPosition, 0, DataSize() - 1);
static_cast<int>(x) + _renderStartPosition, 0, DataSize() - 1);
_signalClicked.emit(static_cast<double>(position) * kChunkSize /
(44.100 * 4.0));
return true;
}

void AudioWidget::SetScene(theatre::Scene &scene) {
Expand Down
2 changes: 1 addition & 1 deletion gui/components/audiowidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class AudioWidget : public Gtk::DrawingArea {
if (_buffer) bufferToScreen(context);
return true;
}
bool onButtonPressed(GdkEventButton *event);
void onButtonPressed(int, double, double);
void verticalLine(guint8 *dataPtr, size_t rowStride, int x, unsigned char r,
unsigned char g, unsigned char b) {
if (x >= 0 && x < _width) {
Expand Down
16 changes: 8 additions & 8 deletions gui/components/beatinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <sstream>

#include <gtkmm/adjustment.h>

namespace glight::gui {
namespace {
inline constexpr size_t kNValues = 10;
Expand All @@ -14,17 +16,17 @@ inline const std::string kStringValues[kNValues]{
BeatInput::BeatInput(double value)
: scale_(Gtk::Adjustment::create(
0, 0, static_cast<double>(kNValues - 1) + 0.1, 1),
Gtk::ORIENTATION_HORIZONTAL) {
Gtk::Orientation::HORIZONTAL) {
Initialize(value);
}

BeatInput::BeatInput(const std::string &label, double value)
: caption_label_(label),
scale_(Gtk::Adjustment::create(
0, 0, static_cast<double>(kNValues - 1) + 0.1, 1),
Gtk::ORIENTATION_HORIZONTAL) {
caption_label_.set_halign(Gtk::ALIGN_END);
pack_start(caption_label_, false, false);
Gtk::Orientation::HORIZONTAL) {
caption_label_.set_halign(Gtk::Align::END);
append(caption_label_);

Initialize(value);
}
Expand All @@ -36,13 +38,11 @@ void BeatInput::Initialize(double value) {
scale_.set_round_digits(0);
scale_.set_draw_value(false);
scale_.signal_value_changed().connect([&]() { OnScaleChanged(); });
pack_start(scale_, true, true);
append(scale_);

SetValueLabel(index);
value_label_.set_width_chars(3);
pack_end(value_label_, false, false);

show_all_children();
append(value_label_);
}

double BeatInput::ValueToScale(double value) {
Expand Down
2 changes: 1 addition & 1 deletion gui/components/beatinput.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace glight::gui {

class BeatInput : public Gtk::HBox {
class BeatInput : public Gtk::Box {
public:
BeatInput(double value);

Expand Down
17 changes: 9 additions & 8 deletions gui/components/colorbutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define GLIGHT_GUI_COMPONENTS_DISPLAY_COLOR_H_

#include <gtkmm/drawingarea.h>
#include <gtkmm/gestureclick.h>

#include "theatre/color.h"

Expand All @@ -11,15 +12,15 @@ class ColorButton : public Gtk::DrawingArea {
public:
ColorButton(const theatre::Color& color = theatre::Color::White())
: color_(color) {
signal_draw().connect([&](const Cairo::RefPtr<Cairo::Context>& cr) {
DrawColor(cr);
return true;
});
set_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
signal_button_release_event().connect([&](GdkEventButton*) {
signal_clicked_();
return false;
set_draw_func([&](const Cairo::RefPtr<Cairo::Context>& cairo, int, int) {
DrawColor(cairo);
});

auto gesture = Gtk::GestureClick::create();
gesture->set_button(1);
gesture->signal_released().connect(
[this](int, double, double) { signal_clicked_(); });
add_controller(gesture);
}

void SetColor(const theatre::Color& color) {
Expand Down
68 changes: 33 additions & 35 deletions gui/components/colorselectwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,29 @@ ColorSelectWidget::ColorSelectWidget(Gtk::Window *parent, bool allow_variable)
static_button_("Static"),
variable_button_("Variable"),
set_button_("Set...") {
Gtk::RadioButton::Group group;
static_button_.set_group(group);
static_button_.signal_clicked().connect([&]() {
static_button_.signal_toggled().connect([&]() {
if (variable_label_.get_parent()) {
remove(set_button_);
remove(variable_label_);
pack_end(color_button_, true, true, 5);
append(color_button_);
color_button_.show();
signal_color_changed_();
}
});
pack_start(static_button_, false, false, 0);
static_button_.show();
append(static_button_);

variable_button_.set_group(group);
variable_button_.signal_clicked().connect([&]() {
variable_button_.set_group(static_button_);
variable_button_.signal_toggled().connect([&]() {
if (color_button_.get_parent()) {
remove(color_button_);
pack_end(variable_label_);
append(variable_label_);
variable_label_.show();
pack_end(set_button_);
append(set_button_);
set_button_.show();
signal_color_changed_();
}
});
pack_start(variable_button_, true, true, 0);
variable_button_.show();
append(variable_button_);

set_button_.signal_clicked().connect([&]() {
if (static_button_.get_active())
Expand All @@ -52,20 +48,18 @@ ColorSelectWidget::ColorSelectWidget(Gtk::Window *parent, bool allow_variable)
});

color_button_.set_size_request(35, 35);
pack_end(color_button_, true, true, 5);
append(color_button_);
color_button_.SignalClicked().connect([&]() { OpenColorSelection(); });
color_button_.show();

SetAllowVariables(allow_variable);
}

void ColorSelectWidget::OpenColorSelection() {
const std::optional<theatre::Color> color =
OpenColorDialog(*parent_, color_button_.GetColor());
if (color) {
color_button_.SetColor(*color);
signal_color_changed_();
}
OpenColorDialog(dialog_, *parent_, color_button_.GetColor(),
[this](theatre::Color color) {
color_button_.SetColor(color);
signal_color_changed_();
});
}

void ColorSelectWidget::OpenVariableSelection() {
Expand All @@ -75,29 +69,33 @@ void ColorSelectWidget::OpenVariableSelection() {
dialog.SignalNewClicked().connect([&]() {
StringInputDialog string_dialog("New variable",
"Name of new variable:", "");
if (string_dialog.run() == Gtk::RESPONSE_OK) {
std::unique_ptr<theatre::Effect> effect =
std::make_unique<theatre::VariableEffect>();
theatre::Folder &parent = dialog.SelectedFolder();
effect->SetName(string_dialog.Value());
theatre::Management &management = Instance::Management();
system::ObservingPtr<theatre::Effect> added =
management.AddEffectPtr(std::move(effect), parent);
for (size_t i = 0; i != added->NInputs(); ++i)
management.AddSourceValue(*added, i);
Instance::Events().EmitUpdate();
dialog.SelectObject(*added);
}
string_dialog.signal_response().connect([&](int response) {
if (response == Gtk::ResponseType::OK) {
std::unique_ptr<theatre::Effect> effect =
std::make_unique<theatre::VariableEffect>();
theatre::Folder &parent = dialog.SelectedFolder();
effect->SetName(string_dialog.Value());
theatre::Management &management = Instance::Management();
system::ObservingPtr<theatre::Effect> added =
management.AddEffectPtr(std::move(effect), parent);
for (size_t i = 0; i != added->NInputs(); ++i)
management.AddSourceValue(*added, i);
Instance::Events().EmitUpdate();
dialog.SelectObject(*added);
}
});
string_dialog.show();
});
if (dialog.run() == Gtk::RESPONSE_OK) {
dialog.signal_response().connect([&](int response) {
theatre::VariableEffect *v =
dynamic_cast<theatre::VariableEffect *>(dialog.SelectedObject().Get());
if (v && v != variable_) {
variable_ = v;
SetVariableLabel();
signal_color_changed_();
}
}
});
dialog.show();
}

void ColorSelectWidget::SetVariableLabel() {
Expand Down
14 changes: 8 additions & 6 deletions gui/components/colorselectwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

#include <gtkmm/box.h>
#include <gtkmm/button.h>
#include <gtkmm/checkbutton.h>
#include <gtkmm/dialog.h>
#include <gtkmm/label.h>
#include <gtkmm/radiobutton.h>

#include "theatre/color.h"
#include "theatre/forwards.h"
Expand All @@ -21,7 +22,7 @@ class VariableEffect;

namespace glight::gui {

class ColorSelectWidget : public Gtk::HBox {
class ColorSelectWidget : public Gtk::Box {
public:
ColorSelectWidget(Gtk::Window *parent, bool allow_variable);
bool IsVariable() const { return variable_button_.get_active(); }
Expand Down Expand Up @@ -77,9 +78,9 @@ class ColorSelectWidget : public Gtk::HBox {
if (allow_variables != allow_variables_) {
allow_variables_ = allow_variables;
if (allow_variables) {
pack_start(static_button_, false, false, 0);
append(static_button_);
static_button_.show();
pack_start(variable_button_, true, true, 0);
append(variable_button_);
variable_button_.show();
static_button_.set_active(true);
variable_label_.set_visible(false);
Expand All @@ -95,14 +96,15 @@ class ColorSelectWidget : public Gtk::HBox {

private:
Gtk::Window *parent_;
Gtk::RadioButton static_button_;
Gtk::RadioButton variable_button_;
Gtk::CheckButton static_button_;
Gtk::CheckButton variable_button_;
components::ColorButton color_button_{theatre::Color::White()};
Gtk::Label variable_label_;
Gtk::Button set_button_;
bool allow_variables_ = true;
theatre::VariableEffect *variable_ = nullptr;
sigc::signal<void()> signal_color_changed_;
std::unique_ptr<Gtk::Dialog> dialog_;

void SetVariableLabel();

Expand Down
Loading