Skip to content

Commit

Permalink
pluginui
Browse files Browse the repository at this point in the history
settings

done
  • Loading branch information
Shaji Khan committed Oct 11, 2024
1 parent fde3c4e commit ef99e45
Show file tree
Hide file tree
Showing 34 changed files with 87 additions and 69 deletions.
Binary file added FileWriter.o
Binary file not shown.
Binary file added LockFreeQueue.o
Binary file not shown.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ amprack: version.o FileWriter.o main.o rack.o presets.o SharedLibrary.o engine.o
c++ *.o -o amprack $(GTK) $(LV2) $(JACK) $(OPTIMIZE) $(SNDFILE) $(OPUS) -l:libmp3lame.a $(GTKMM) $(LAME)

main.o: main.cc main.h rack.o presets.o
g++ main.cc -c $(GTKMM) $(GTK) $(LV2) $(OPTIMIZE)
g++ main.cc -c $(GTKMM) $(GTK) $(LV2) $(OPTIMIZE) -Wno-deprecated-declarations

rack.o: rack.cc rack.h pluginui.cpp pluginui.h knob.o
g++ rack.cc pluginui.cpp settings.cc -c $(GTKMM) $(GTK) $(LV2) $(OPTIMIZE)
rack.o: rack.cc rack.h knob.o settings.cc settings.h pluginui.o
g++ rack.cc settings.cc -c $(GTKMM) $(GTK) $(LV2) $(OPTIMIZE)

pluginui.o: pluginui.cpp pluginui.h
g++ pluginui.cpp -c $(GTKMM) $(GTK) $(LV2) -Wno-deprecated-declarations

presets.o: presets.cc presets.h
g++ presets.cc -c $(GTKMM) $(GTK) $(OPTIMIZE) $(LV2)

Expand Down
Binary file added Plugin.o
Binary file not shown.
Binary file added PluginControl.o
Binary file not shown.
Binary file added SharedLibrary.o
Binary file not shown.
Binary file added amprack
Binary file not shown.
Binary file added cairo.o
Binary file not shown.
4 changes: 2 additions & 2 deletions callback_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include "engine.h"

typedef struct {
Gtk::Widget * card ;
Gtk::Box * parent ;
GtkBox * card ;
GtkBox * parent ;
GtkWidget * dropdown ;
int index ;
int control ;
Expand Down
Binary file added dictionary.o
Binary file not shown.
Binary file added engine.o
Binary file not shown.
Binary file added jack.o
Binary file not shown.
Binary file added knob.o
Binary file not shown.
Binary file added lv2_ext.o
Binary file not shown.
3 changes: 2 additions & 1 deletion main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ MyWindow::MyWindow(GtkApplication * _app)
stack_box.set_orientation (Gtk::Orientation::VERTICAL);

pane.set_position (370);
pane.set_position (800);
//~ g_signal_connect (pane.gobj (), "notify::position", (GCallback) position_changed, NULL);

stack = Gtk::Stack () ;
Expand Down Expand Up @@ -111,7 +112,7 @@ MyWindow::MyWindow(GtkApplication * _app)
presets->my () ;

Settings settings = Settings (rack);
gtk_notebook_append_page (presets->notebook.gobj (), (GtkWidget *)settings.gobj (), gtk_label_new ("Settings"));
gtk_notebook_append_page (presets->notebook.gobj (), (GtkWidget *)settings . grid, gtk_label_new ("Settings"));


CB * cb = new CB () ;
Expand Down
Binary file added main.o
Binary file not shown.
Binary file added mem.o
Binary file not shown.
Binary file added objects.o
Binary file not shown.
Binary file added pango.o
Binary file not shown.
105 changes: 59 additions & 46 deletions pluginui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void select_model (GtkDropDown * down, int event, PluginUI * ui) {
}

const char * filename = gtk_string_object_get_string ((GtkStringObject *)gtk_drop_down_get_selected_item ((GtkDropDown *)down));
std::string dir = std::string (getenv ("HOME")).append ("/amprack/models/").append (std::string (ui -> name.get_text ())).append ("/").append (std::string (filename));
std::string dir = std::string (getenv ("HOME")).append ("/amprack/models/").append (std::string (gtk_label_get_text (ui -> name))).append ("/").append (std::string (filename));
wtf ("[model] %s\n", dir.c_str ());

if (ui -> engine -> activePlugins -> at (ui -> index) -> loadedFileType)
Expand Down Expand Up @@ -40,7 +40,7 @@ void callback (void * p, void *c) {
GtkButton * b = (GtkButton *) p ;
CallbackData *cd = (CallbackData *) c ;

cd -> parent -> remove (*cd -> card);
gtk_box_remove (cd -> parent, (GtkWidget *)cd -> card);
cd -> engine -> activePlugins -> erase(cd -> engine->activePlugins->begin() + cd -> index);
cd->engine->buildPluginChain();
// printf ("%s\n", cd -> card -> get_name ());
Expand Down Expand Up @@ -76,7 +76,7 @@ void control_changed ( void * p, void * c) {
PluginUI * ui = (PluginUI *) cd -> ui;

float val = gtk_adjustment_get_value (adj) ;
wtf ("[%s] %d : %d-> %f\n", ui -> name.get_text ().c_str (), ui -> get_index (), cd -> control, val);
wtf ("[%s] %d : %d-> %f\n", gtk_label_get_text (ui -> name), ui -> get_index (), cd -> control, val);
if (cd->dropdown != nullptr) {
gtk_drop_down_set_selected ((GtkDropDown *)cd -> dropdown, val);
}
Expand Down Expand Up @@ -159,7 +159,7 @@ int PluginUI::get_index () {
//~ return index ;
if (! gtk_widget_get_realized (card_))
return index ;
return gtk_widget_get_name ((GtkWidget *) card.gobj ()) [0] - 48 ;
return gtk_widget_get_name ((GtkWidget *) card) [0] - 48 ;
}

float
Expand Down Expand Up @@ -190,31 +190,32 @@ PluginUI::PluginUI (Engine * _engine, Plugin * _plugin, Gtk::Box * _parent, std:
index = _index ;
index_p = (int *) malloc (sizeof (int));
*index_p = index ;
parent = _parent ;
parent = _parent->gobj () ;

char * s = (char *) malloc (pluginName.size () + 3) ;
sprintf (s, "%d %s", index, pluginName.c_str ());
//~ printf ("[plugin ui] %d %s", index, pluginName.c_str ());
// name = Gtk::Label (s) ;
name = Gtk::Label (pluginName);
name = (GtkLabel *)gtk_label_new (pluginName.c_str ());
Gtk::Box nb = Gtk::Box (Gtk::Orientation::HORIZONTAL, 10);
nb.set_hexpand (true);
name.set_wrap (true);
nb.append (name);
gtk_label_set_wrap (name, true);
gtk_box_append (nb.gobj (), (GtkWidget *)name);
//~ nb.append (name);
nb.set_halign (Gtk::Align::START);

auto n = std::string ("<big><b>").append (pluginName).append ("</b></big>");
name.set_markup (n.c_str ());
gtk_label_set_markup (name, n.c_str ());
free (s);
card = Gtk::Box (Gtk::Orientation::VERTICAL, 0);
card_ = (GtkWidget *)card.gobj () ;
card = (GtkBox *)gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
card_ = (GtkWidget *)card ;

card.set_orientation (Gtk::Orientation::VERTICAL);
//~ card.set_orientation (Gtk::Orientation::VERTICAL);
//~ gtk_widget_add_css_class ((GtkWidget *) card.gobj (), "xwindow");

Gtk::Box container = Gtk::Box (Gtk::Orientation::VERTICAL, 10);

card.append (container);
gtk_box_append (card, (GtkWidget *)container.gobj ());
container.set_name ("plugin");

//~ set_random_background ((GtkWidget *)container.gobj ());
Expand All @@ -223,39 +224,50 @@ PluginUI::PluginUI (Engine * _engine, Plugin * _plugin, Gtk::Box * _parent, std:
container.append (header);
header.set_hexpand (true);
//~ name.set_hexpand (true);
name.set_justify (Gtk::Justification::LEFT);
gtk_label_set_justify (name, GTK_JUSTIFY_LEFT);
header.append (nb);
header.set_margin (10);
header.set_margin_start (0);

onoff = Gtk::Switch () ;
onoff.set_active (true);
onoff = (GtkSwitch *) gtk_switch_new ();
gtk_switch_set_active (onoff, true);
Gtk::Box o_o = Gtk::Box (Gtk::Orientation::VERTICAL, 10);
o_o.append (onoff);
gtk_box_append (o_o.gobj (), (GtkWidget *) onoff);
header.append (o_o) ;
onoff.set_halign (Gtk::Align::END);
name.set_halign (Gtk::Align::START);
gtk_widget_set_halign ((GtkWidget *) onoff, GTK_ALIGN_END);
gtk_widget_set_halign ((GtkWidget *)name, GTK_ALIGN_START);

card.set_margin (20);
card.set_margin_bottom (0);
gtk_widget_set_margin_start ((GtkWidget *)card, 20);
gtk_widget_set_margin_end ((GtkWidget *)card, 20);
gtk_widget_set_margin_top ((GtkWidget *)card, 20);
gtk_widget_set_margin_bottom ((GtkWidget *)card, 0);

Gtk::Button up = Gtk::Button ("");
Gtk::Button down = Gtk::Button ("");
up = (GtkButton *) gtk_button_new_with_label ("");
down = (GtkButton *) gtk_button_new_with_label ("");


del = Gtk::Button ("Delete") ;
del.set_name ("delete");

del.set_halign (Gtk::Align::END);
del.set_valign (Gtk::Align::END);
del.set_margin (10);

up.set_halign (Gtk::Align::START);
up.set_valign (Gtk::Align::START);
up.set_margin (5);
down.set_halign (Gtk::Align::START);
down.set_valign (Gtk::Align::START);
down.set_margin (5);
del = (GtkButton *) gtk_button_new_with_label ("Delete") ;
gtk_widget_set_name ((GtkWidget *) del, "delete");

gtk_widget_set_halign ((GtkWidget *) del, GTK_ALIGN_END);
gtk_widget_set_valign ((GtkWidget *) del, GTK_ALIGN_END);
gtk_widget_set_margin_top ((GtkWidget *) del, 10);
gtk_widget_set_margin_start ((GtkWidget *) del, 10);
gtk_widget_set_margin_bottom ((GtkWidget *) del, 10);
gtk_widget_set_margin_end ((GtkWidget *) del, 10);

gtk_widget_set_halign ((GtkWidget *)up, GTK_ALIGN_START);
gtk_widget_set_valign ((GtkWidget *)up, GTK_ALIGN_START);
gtk_widget_set_margin_top ((GtkWidget *) up, 5);
gtk_widget_set_margin_start ((GtkWidget *) up, 5);
gtk_widget_set_margin_bottom ((GtkWidget *) up, 5);
gtk_widget_set_margin_end ((GtkWidget *) up, 5);
gtk_widget_set_halign ((GtkWidget *)down, GTK_ALIGN_START);
gtk_widget_set_valign ((GtkWidget *)down, GTK_ALIGN_START);
gtk_widget_set_margin_top ((GtkWidget *) down, 5);
gtk_widget_set_margin_start ((GtkWidget *) down, 5);
gtk_widget_set_margin_bottom ((GtkWidget *) down, 5);
gtk_widget_set_margin_end ((GtkWidget *) down, 5);

Gtk::Button load_file = Gtk::Button ("Load file") ;

Expand All @@ -268,7 +280,7 @@ PluginUI::PluginUI (Engine * _engine, Plugin * _plugin, Gtk::Box * _parent, std:
// del.signal_clicked().connect(sigc::ptr_fun(&callback));
CallbackData * cd = (CallbackData *) malloc (sizeof (CallbackData));
cd->index = index ;
cd -> card = & card ;
cd -> card = card ;
cd -> parent = parent ;
cd->engine = engine;
cd -> ui = (void*)this ;
Expand All @@ -277,11 +289,11 @@ PluginUI::PluginUI (Engine * _engine, Plugin * _plugin, Gtk::Box * _parent, std:
name [0] = index + 48 ;
name [1] = 0 ;

card.set_name (name);
gtk_widget_set_name ((GtkWidget * )card, name);

g_signal_connect (del.gobj (), "clicked", (GCallback) callback, cd);
g_signal_connect (up.gobj (), "clicked", (GCallback) pu_move_up, this);
g_signal_connect (down.gobj (), "clicked", (GCallback) pu_move_down, this);
g_signal_connect (del, "clicked", (GCallback) callback, cd);
g_signal_connect (up, "clicked", (GCallback) pu_move_up, this);
g_signal_connect (down, "clicked", (GCallback) pu_move_down, this);

GtkBox * currentBox = NULL ;
int row = 0, col = 0 ;
Expand Down Expand Up @@ -465,7 +477,7 @@ PluginUI::PluginUI (Engine * _engine, Plugin * _plugin, Gtk::Box * _parent, std:

CallbackData * cd = (CallbackData *) malloc (sizeof (CallbackData));
cd->index = index ;
cd -> card = & card ;
cd -> card = card ;
cd -> parent = parent ;
cd->engine = engine;
cd->control = i ;
Expand All @@ -480,18 +492,19 @@ PluginUI::PluginUI (Engine * _engine, Plugin * _plugin, Gtk::Box * _parent, std:
box.set_spacing (0);

g_signal_connect (scale.gobj (), "value-changed", (GCallback) control_changed, cd) ;
g_signal_connect (onoff.gobj (), "state-set", (GCallback) bypass, cd) ;
g_signal_connect (onoff, "state-set", (GCallback) bypass, cd) ;

container.append (box);
}

Gtk::Box bbox = Gtk::Box (Gtk::Orientation::HORIZONTAL, 0);
bbox.set_halign (Gtk::Align::START);

container.append (del);
gtk_box_append (container.gobj (), (GtkWidget *)del);
container.append (bbox);
bbox.append (up);
bbox.append (down);
gtk_box_append (bbox.gobj (), (GtkWidget *)up);
gtk_box_append (bbox.gobj (), (GtkWidget *)down);

if (has_file_chooser) {
wtf ("[file chooser] mmmmph\n");
GtkWidget * box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
Expand Down
10 changes: 5 additions & 5 deletions pluginui.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ class PluginUI {
nullptr
} ;

Gtk::Label name ;
Gtk::Switch onoff ;
Gtk::Button del, up, down ;
GtkLabel * name ;
GtkSwitch * onoff ;
GtkButton * del, * up, * down ;
Engine * engine ;
void * rack ;
Plugin * plugin ;
Gtk::Box card ;
GtkBox * card ;
GtkWidget * card_ ;
Gtk::Box * parent ;
GtkBox * parent ;
int index, * index_p ;
PluginFileType * pType ;
std::vector <GtkScale *> sliders ;
Expand Down
Binary file added pluginui.o
Binary file not shown.
Binary file added presets.o
Binary file not shown.
Binary file added process.o
Binary file not shown.
10 changes: 5 additions & 5 deletions rack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void Rack::move_down (PluginUI * ui) {
if (index >= engine -> activePlugins->size ())
return ;

GtkWidget * lower = (GtkWidget *) ui -> card.gobj () ;
GtkWidget * lower = (GtkWidget *) ui -> card ;
GtkWidget * upper = gtk_widget_get_next_sibling (lower);

//~ auto it = plugs.begin() + ui -> index;
Expand Down Expand Up @@ -218,7 +218,7 @@ void Rack::move_up (PluginUI * ui) {
if (index == 0)
return ;

GtkWidget * lower = (GtkWidget *) ui -> card.gobj () ;
GtkWidget * lower = (GtkWidget *) ui -> card ;
GtkWidget * upper = gtk_widget_get_prev_sibling (lower);

//~ auto it = plugs.begin() + ui -> index;
Expand Down Expand Up @@ -303,9 +303,9 @@ PluginUI * Rack::addPluginByName (char * requested) {
// ui.index = index ;
list_box.set_orientation (Gtk::Orientation::VERTICAL);
list_box.set_vexpand (true);
list_box.append (ui->card);
gtk_box_append (list_box.gobj (), (GtkWidget *)ui->card);
HERE
plugs.push_back ((GtkWidget * ) ui->card.gobj ());
plugs.push_back ((GtkWidget * ) ui->card);
uiv.push_back (ui);
OUT
return ui ;
Expand Down Expand Up @@ -381,7 +381,7 @@ void Rack::add () {
// ui.index = index ;
list_box.set_orientation (Gtk::Orientation::VERTICAL);
list_box.set_vexpand (true);
list_box.append (ui->card);
gtk_box_append (list_box.gobj (), (GtkWidget *) ui->card);
}

GtkWidget * Rack::createPluginDialog () {
Expand Down
Binary file added rack.o
Binary file not shown.
9 changes: 5 additions & 4 deletions settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ void switch_theme (GtkDropDown * dropdown, int event, Rack * rack) {
}

Settings::Settings (Rack * rack) {
set_name ("plugin");
grid = gtk_grid_new () ;
gtk_widget_set_name ((GtkWidget *) grid, "plugin");
GtkLabel * l1 = (GtkLabel *)gtk_label_new ("Theme");
char * themes [5] = {
const char * themes [5] = {
"TubeAmp",
"Classic",
"Modern",
Expand All @@ -31,6 +32,6 @@ Settings::Settings (Rack * rack) {

g_signal_connect (theme, "notify::selected", (GCallback) switch_theme, rack);

gtk_grid_attach (gobj (), (GtkWidget *)l1, 0, 0, 1, 1);
gtk_grid_attach (gobj (), (GtkWidget *)theme, 1, 0, 1, 1);
gtk_grid_attach ((GtkGrid *) grid, (GtkWidget *)l1, 0, 0, 1, 1);
gtk_grid_attach ((GtkGrid *) grid, (GtkWidget *)theme, 1, 0, 1, 1);
}
4 changes: 2 additions & 2 deletions settings.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifndef SETTINGS_H
#define SETTINGS_H

#include <gtkmm.h>
#include <gtk/gtk.h>
#include "rack.h"

class Settings : public Gtk::Grid {
class Settings {
public:
GtkWidget * grid ;
Settings (Rack *) ;
};

Expand Down
Binary file added settings.o
Binary file not shown.
Binary file added snd.o
Binary file not shown.
Binary file added upwaker.o
Binary file not shown.
Binary file added util.o
Binary file not shown.
2 changes: 1 addition & 1 deletion version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define VERSION 127
#define VERSION 128
Binary file added vringbuffer.o
Binary file not shown.

0 comments on commit ef99e45

Please sign in to comment.