[SCM] calf/master: + GUI: more style related work (doesn't fully work yet)
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:39:38 UTC 2013
The following commit has been merged in the master branch:
commit b376deb046adaa3d81ce19eadf3084558cfa2cbd
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Tue Oct 13 00:27:59 2009 +0100
+ GUI: more style related work (doesn't fully work yet)
diff --git a/gui/calf.rc b/gui/calf.rc
index 1e537d5..b5f943f 100644
--- a/gui/calf.rc
+++ b/gui/calf.rc
@@ -1,4 +1,4 @@
-style "calf"
+style "calf_default"
{
fg[NORMAL] = { 0.2, 0.2, 0.2 }
fg[ACTIVE] = { 0.2, 0.2, 0.2 }
@@ -18,4 +18,28 @@ style "calf"
}
}
-class "GtkWidget" style "calf"
+style "frame" = "calf_default"
+{
+ xthickness = 10
+ ythickness = 15
+}
+
+style "inverse" = "calf_default"
+{
+ fg[NORMAL] = { 0.86, 0.86, 0.87 }
+ fg[ACTIVE] = { 0.86, 0.86, 0.87 }
+ fg[PRELIGHT] = { 0.86, 0.86, 0.87 }
+ fg[SELECTED] = { 0.86, 0.86, 0.87 }
+ fg[INSENSITIVE] = { 0.86, 0.86, 0.87 }
+
+ bg[NORMAL] = { 0.2, 0.2, 0.2 }
+ bg[ACTIVE] = { 0.2, 0.2, 0.2 }
+ bg[PRELIGHT] = { 0.2, 0.2, 0.2 }
+ bg[SELECTED] = { 0.2, 0.2, 0.2 }
+ bg[INSENSITIVE] = { 0.2, 0.2, 0.2 }
+}
+
+widget "calf-plugin*inverted*" style "inverse"
+widget "calf-plugin*frame*" style "frame"
+widget "calf-plugin*" style "calf_default"
+widget "calf-rack*" style "calf_default"
diff --git a/gui/gui-filter.xml b/gui/gui-filter.xml
index 96c5b42..1f28a3b 100644
--- a/gui/gui-filter.xml
+++ b/gui/gui-filter.xml
@@ -1,10 +1,10 @@
-<table border="10" rows="3" cols="1">
+<table border="10" rows="3" cols="1" >
<table attach-x="0" attach-y="0" shrink-y="1" expand-x="1" cols="3" rows="1" >
- <label param="mode" attach-x="0" attach-y="0" shrink-x="1"/>
- <label attach-x="1" attach-y="0" shrink-x="1" pad-x="10"/>
- <combo param="mode" attach-x="2" attach-y="0"/>
+ <label param="mode" attach-x="0" attach-y="0" shrink-x="1" widget-name="inverted"/>
+ <label attach-x="1" attach-y="0" shrink-x="1" pad-x="10" />
+ <combo param="mode" attach-x="2" attach-y="0" />
</table>
- <hbox attach-x="0" attach-y="1" shrink-y="1" expand-x="1" fill-x="1">
+ <hbox attach-x="0" attach-y="1" shrink-y="1" expand-x="1" fill-x="1" widget-name="default">
<vbox border="10">
<label param="res" />
<knob param="res" />
@@ -22,7 +22,7 @@
</vbox>
</hbox>
<if cond="directlink">
- <frame label="Freq. response" expand-x="1" fill-x="1" attach-x="0" attach-y="2">
+ <frame label="Freq. response" expand-x="1" fill-x="1" attach-x="0" attach-y="2" widget-name="frame">
<line-graph refresh="1" width="160" height="160" param="freq"/>
</frame>
</if>
diff --git a/src/calf/gui.h b/src/calf/gui.h
index 87a8555..0d46efe 100644
--- a/src/calf/gui.h
+++ b/src/calf/gui.h
@@ -44,6 +44,8 @@ struct control_base
void require_int_attribute(const char *name);
int get_int(const char *name, int def_value = 0);
float get_float(const char *name, float def_value = 0.f);
+ /// called after creation, so that all standard properties can be set
+ virtual void set_std_properties() = 0;
};
#define _GUARD_CHANGE_ if (in_change) return; guard_change __gc__(this);
@@ -77,6 +79,7 @@ struct param_control: public control_base
virtual void configure(const char *key, const char *value) {}
virtual void hook_params();
virtual void on_idle() {}
+ virtual void set_std_properties();
virtual ~param_control();
};
@@ -86,6 +89,7 @@ struct control_container: public control_base
virtual GtkWidget *create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes)=0;
virtual void add(GtkWidget *w, control_base *base) { gtk_container_add(container, w); }
+ virtual void set_std_properties();
virtual ~control_container() {}
};
diff --git a/src/gui.cpp b/src/gui.cpp
index 974d383..69cc3d0 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -35,6 +35,28 @@ using namespace std;
/******************************** control base classes **********************/
+void control_container::set_std_properties()
+{
+ if (attribs.find("widget-name") != attribs.end())
+ {
+ string name = attribs["widget-name"];
+ if (container) {
+ gtk_widget_set_name(GTK_WIDGET(container), name.c_str());
+ }
+ }
+}
+
+void param_control::set_std_properties()
+{
+ if (attribs.find("widget-name") != attribs.end())
+ {
+ string name = attribs["widget-name"];
+ if (widget) {
+ gtk_widget_set_name(widget, name.c_str());
+ }
+ }
+}
+
GtkWidget *param_control::create_label()
{
label = gtk_label_new ("");
@@ -129,114 +151,6 @@ float control_base::get_float(const char *name, float def_value)
return value;
}
-/******************************** GtkTable container ********************************/
-
-GtkWidget *table_container::create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes)
-{
- require_int_attribute("rows");
- require_int_attribute("cols");
- int homog = get_int("homogeneous", 0);
- GtkWidget *table = gtk_table_new(get_int("rows", 1), get_int("cols", 1), false);
- if(homog > 0) {
- gtk_table_set_homogeneous(GTK_TABLE(table), TRUE);
- }
- container = GTK_CONTAINER(table);
- return table;
-}
-
-void table_container::add(GtkWidget *widget, control_base *base)
-{
- base->require_int_attribute("attach-x");
- base->require_int_attribute("attach-y");
- int x = base->get_int("attach-x"), y = base->get_int("attach-y");
- int w = base->get_int("attach-w", 1), h = base->get_int("attach-h", 1);
- int shrinkx = base->get_int("shrink-x", 0);
- int shrinky = base->get_int("shrink-y", 0);
- int fillx = (base->get_int("fill-x", !shrinkx) ? GTK_FILL : 0) | (base->get_int("expand-x", !shrinkx) ? GTK_EXPAND : 0) | (shrinkx ? GTK_SHRINK : 0);
- int filly = (base->get_int("fill-y", !shrinky) ? GTK_FILL : 0) | (base->get_int("expand-y", !shrinky) ? GTK_EXPAND : 0) | (base->get_int("shrink-y", 0) ? GTK_SHRINK : 0);
- int padx = base->get_int("pad-x", 2);
- int pady = base->get_int("pad-y", 2);
- gtk_table_attach(GTK_TABLE(container), widget, x, x + w, y, y + h, (GtkAttachOptions)fillx, (GtkAttachOptions)filly, padx, pady);
-}
-
-/******************************** alignment contaner ********************************/
-
-GtkWidget *alignment_container::create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes)
-{
- GtkWidget *align = gtk_alignment_new(get_float("align-x", 0.5), get_float("align-y", 0.5), get_float("scale-x", 0), get_float("scale-y", 0));
- container = GTK_CONTAINER(align);
- return align;
-}
-
-/******************************** GtkFrame contaner ********************************/
-
-GtkWidget *frame_container::create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes)
-{
- GtkWidget *frame = gtk_frame_new(attribs["label"].c_str());
- container = GTK_CONTAINER(frame);
- return frame;
-}
-
-/******************************** GtkBox type of containers ********************************/
-
-void box_container::add(GtkWidget *w, control_base *base)
-{
- gtk_container_add_with_properties(container, w, "expand", get_int("expand", 1), "fill", get_int("fill", 1), NULL);
-}
-
-/******************************** GtkHBox container ********************************/
-
-GtkWidget *hbox_container::create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes)
-{
- GtkWidget *hbox = gtk_hbox_new(false, get_int("spacing", 2));
- container = GTK_CONTAINER(hbox);
- return hbox;
-}
-
-/******************************** GtkVBox container ********************************/
-
-GtkWidget *vbox_container::create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes)
-{
- GtkWidget *vbox = gtk_vbox_new(false, get_int("spacing", 2));
- container = GTK_CONTAINER(vbox);
- return vbox;
-}
-
-/******************************** GtkNotebook container ********************************/
-
-GtkWidget *notebook_container::create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes)
-{
- GtkWidget *nb = gtk_notebook_new();
- container = GTK_CONTAINER(nb);
- return nb;
-}
-
-void notebook_container::add(GtkWidget *w, control_base *base)
-{
- gtk_notebook_append_page(GTK_NOTEBOOK(container), w, gtk_label_new_with_mnemonic(base->attribs["page"].c_str()));
-}
-
-/******************************** GtkNotebook container ********************************/
-
-GtkWidget *scrolled_container::create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes)
-{
- GtkAdjustment *horiz = NULL, *vert = NULL;
- int width = get_int("width", 0), height = get_int("height", 0);
- if (width)
- horiz = GTK_ADJUSTMENT(gtk_adjustment_new(get_int("x", 0), 0, width, get_int("step-x", 1), get_int("page-x", width / 10), 100));
- if (height)
- vert = GTK_ADJUSTMENT(gtk_adjustment_new(get_int("y", 0), 0, width, get_int("step-y", 1), get_int("page-y", height / 10), 10));
- GtkWidget *sw = gtk_scrolled_window_new(horiz, vert);
- gtk_widget_set_size_request(sw, get_int("req-x", -1), get_int("req-y", -1));
- container = GTK_CONTAINER(sw);
- return sw;
-}
-
-void scrolled_container::add(GtkWidget *w, control_base *base)
-{
- gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(container), w);
-}
-
/******************************** GUI proper ********************************/
param_control *plugin_gui::create_control_from_xml(const char *element, const char *attributes[])
@@ -340,6 +254,7 @@ void plugin_gui::xml_element_start(const char *element, const char *attributes[]
{
cc->attribs = xam;
cc->create(this, element, xam);
+ cc->set_std_properties();
gtk_container_set_border_width(cc->container, cc->get_int("border"));
container_stack.push_back(cc);
@@ -364,6 +279,7 @@ void plugin_gui::xml_element_start(const char *element, const char *attributes[]
if (param_no != -1)
current_control->param_variable = plugin->get_param_props(param_no)->short_name;
current_control->create(this, param_no);
+ current_control->set_std_properties();
current_control->init_xml(element);
current_control->set();
current_control->hook_params();
@@ -653,6 +569,7 @@ void plugin_gui_window::create(plugin_ctl_iface *_jh, const char *title, const c
{
toplevel = GTK_WINDOW(gtk_window_new (GTK_WINDOW_TOPLEVEL));
gtk_window_set_default_icon_name("calf");
+ gtk_widget_set_name(GTK_WIDGET(toplevel), "calf-plugin");
gtk_window_set_type_hint(toplevel, GDK_WINDOW_TYPE_HINT_DIALOG);
GtkVBox *vbox = GTK_VBOX(gtk_vbox_new(false, 5));
diff --git a/src/gui_controls.cpp b/src/gui_controls.cpp
index bf3f2e2..c77073d 100644
--- a/src/gui_controls.cpp
+++ b/src/gui_controls.cpp
@@ -818,3 +818,111 @@ void listview_param_control::on_editing_canceled(GtkCellRenderer *renderer, list
gtk_widget_grab_focus(pThis->widget);
}
+/******************************** GtkTable container ********************************/
+
+GtkWidget *table_container::create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes)
+{
+ require_int_attribute("rows");
+ require_int_attribute("cols");
+ int homog = get_int("homogeneous", 0);
+ GtkWidget *table = gtk_table_new(get_int("rows", 1), get_int("cols", 1), false);
+ if(homog > 0) {
+ gtk_table_set_homogeneous(GTK_TABLE(table), TRUE);
+ }
+ container = GTK_CONTAINER(table);
+ return table;
+}
+
+void table_container::add(GtkWidget *widget, control_base *base)
+{
+ base->require_int_attribute("attach-x");
+ base->require_int_attribute("attach-y");
+ int x = base->get_int("attach-x"), y = base->get_int("attach-y");
+ int w = base->get_int("attach-w", 1), h = base->get_int("attach-h", 1);
+ int shrinkx = base->get_int("shrink-x", 0);
+ int shrinky = base->get_int("shrink-y", 0);
+ int fillx = (base->get_int("fill-x", !shrinkx) ? GTK_FILL : 0) | (base->get_int("expand-x", !shrinkx) ? GTK_EXPAND : 0) | (shrinkx ? GTK_SHRINK : 0);
+ int filly = (base->get_int("fill-y", !shrinky) ? GTK_FILL : 0) | (base->get_int("expand-y", !shrinky) ? GTK_EXPAND : 0) | (base->get_int("shrink-y", 0) ? GTK_SHRINK : 0);
+ int padx = base->get_int("pad-x", 2);
+ int pady = base->get_int("pad-y", 2);
+ gtk_table_attach(GTK_TABLE(container), widget, x, x + w, y, y + h, (GtkAttachOptions)fillx, (GtkAttachOptions)filly, padx, pady);
+}
+
+/******************************** alignment contaner ********************************/
+
+GtkWidget *alignment_container::create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes)
+{
+ GtkWidget *align = gtk_alignment_new(get_float("align-x", 0.5), get_float("align-y", 0.5), get_float("scale-x", 0), get_float("scale-y", 0));
+ container = GTK_CONTAINER(align);
+ return align;
+}
+
+/******************************** GtkFrame contaner ********************************/
+
+GtkWidget *frame_container::create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes)
+{
+ GtkWidget *frame = gtk_frame_new(attribs["label"].c_str());
+ container = GTK_CONTAINER(frame);
+ return frame;
+}
+
+/******************************** GtkBox type of containers ********************************/
+
+void box_container::add(GtkWidget *w, control_base *base)
+{
+ gtk_container_add_with_properties(container, w, "expand", get_int("expand", 1), "fill", get_int("fill", 1), NULL);
+}
+
+/******************************** GtkHBox container ********************************/
+
+GtkWidget *hbox_container::create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes)
+{
+ GtkWidget *hbox = gtk_hbox_new(false, get_int("spacing", 2));
+ container = GTK_CONTAINER(hbox);
+ return hbox;
+}
+
+/******************************** GtkVBox container ********************************/
+
+GtkWidget *vbox_container::create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes)
+{
+ GtkWidget *vbox = gtk_vbox_new(false, get_int("spacing", 2));
+ container = GTK_CONTAINER(vbox);
+ return vbox;
+}
+
+/******************************** GtkNotebook container ********************************/
+
+GtkWidget *notebook_container::create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes)
+{
+ GtkWidget *nb = gtk_notebook_new();
+ container = GTK_CONTAINER(nb);
+ return nb;
+}
+
+void notebook_container::add(GtkWidget *w, control_base *base)
+{
+ gtk_notebook_append_page(GTK_NOTEBOOK(container), w, gtk_label_new_with_mnemonic(base->attribs["page"].c_str()));
+}
+
+/******************************** GtkNotebook container ********************************/
+
+GtkWidget *scrolled_container::create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes)
+{
+ GtkAdjustment *horiz = NULL, *vert = NULL;
+ int width = get_int("width", 0), height = get_int("height", 0);
+ if (width)
+ horiz = GTK_ADJUSTMENT(gtk_adjustment_new(get_int("x", 0), 0, width, get_int("step-x", 1), get_int("page-x", width / 10), 100));
+ if (height)
+ vert = GTK_ADJUSTMENT(gtk_adjustment_new(get_int("y", 0), 0, width, get_int("step-y", 1), get_int("page-y", height / 10), 10));
+ GtkWidget *sw = gtk_scrolled_window_new(horiz, vert);
+ gtk_widget_set_size_request(sw, get_int("req-x", -1), get_int("req-y", -1));
+ container = GTK_CONTAINER(sw);
+ return sw;
+}
+
+void scrolled_container::add(GtkWidget *w, control_base *base)
+{
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(container), w);
+}
+
diff --git a/src/main_win.cpp b/src/main_win.cpp
index c116b32..34369b7 100644
--- a/src/main_win.cpp
+++ b/src/main_win.cpp
@@ -307,6 +307,7 @@ std::string main_window::make_plugin_list(GtkActionGroup *actions)
void main_window::create()
{
toplevel = GTK_WINDOW(gtk_window_new (GTK_WINDOW_TOPLEVEL));
+ gtk_widget_set_name(GTK_WIDGET(toplevel), "calf-rack");
gtk_window_set_default_icon_name("calf");
is_closed = false;
gtk_window_set_resizable(toplevel, false);
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list