[Summary] Extending DROPDOWN MENU

This commit is contained in:
VKamyshniy 2014-09-15 11:37:11 +03:00
parent 067bb24416
commit 2ff4c01ea5
6 changed files with 307 additions and 91 deletions

View file

@ -22,7 +22,10 @@
maxvalue="10"
step="0.2"
pagesize="2.0"/>
<HBox>
<HBox id="menu_bar_base"/>
<Eventbox bgnormal="#ff0000" width="10"/>
</HBox>
<EventBox bgnormal="#000000">
<VBox borderwidth="2" spacing ="1">
<EventBox bgnormal="#282828">

View file

@ -2,46 +2,68 @@
<Dialog title="Tracks Preferences" resizeable="false">
<style name="generic_control"
winfont ="Arial 10"
macfont ="Helvetica 10"/>
macfont ="Helvetica 10"
fgnormal="#BFBFBF"
bgnormal="#6C6C6C"
fgactive="#BFBFBF"
bgactive="#454545"
fghover="#CCCCCC"
bghover="#898989"
fgdisabled ="#959595"/>
<style name="generic_button"
style="generic_control"
fgnormal="#BFBFBF"
bgnormal="#6C6C6C"
fgactive="#BFBFBF"
bgactive="#454545"
fghover="#CCCCCC"
bghover="#898989"
fgdisabled ="#959595"
bordercolor="#7E7E7E"
borderwidth="1 1 0 0"/>
style="generic_control"
bordercolor="#7E7E7E"
borderwidth="1 1 0 0"/>
<style name="generic_dropdown"
style="generic_control"
bgdisabled="#373737"/>
<style name="generic_dropdown_menu"
bgnormal="#454545"/>
<Layout bgnormal="#1F1F1F" x="0" y="0" width="619" height="623">
<VBox x="2" y="1">
<EventBox bgnormal="#A0A0A0" width="107" height="1"/>
<Layout bgnormal="#1F1F1F"
x="0"
y="0"
width="619"
height="623">
<VBox x="2"
y="1">
<EventBox bgnormal="#A0A0A0"
width="107"
height="1"/>
<Iconbutton id="audio_settings_tab_button"
width="107"
height="65"
normalicon="preferences_audio_settings_tab_button"
activeicon="preferences_audio_settings_tab_button_active"
prelighticon="preferences_audio_settings_tab_button_prelight"/>
<EventBox bgnormal="#A0A0A0" width="107" height="1"/>
<EventBox bgnormal="#A0A0A0"
width="107"
height="1"/>
<Iconbutton id="midi_settings_tab_button"
width="107"
height="65"
normalicon="preferences_midi_settings_tab_button"
activeicon="preferences_midi_settings_tab_button_active"
prelighticon="preferences_midi_settings_tab_button_prelight"/>
<EventBox bgnormal="#A0A0A0" width="107" height="1"/>
<EventBox bgnormal="#A0A0A0"
width="107"
height="1"/>
<Iconbutton id="session_settings_tab_button"
width="107"
height="65"
normalicon="preferences_session_settings_tab_button"
activeicon="preferences_session_settings_tab_button_active"
prelighticon="preferences_session_settings_tab_button_prelight"/>
<EventBox bgnormal="#A0A0A0" width="107" height="1"/>
<EventBox bgnormal="#A0A0A0"
width="107"
height="1"/>
</VBox>
<Layout bgnormal="#565656" x="113" y="559" width="505" height="63">
<Layout bgnormal="#565656"
x="113"
y="559"
width="505"
height="63">
<Iconbutton id="ok_button"
style="generic_button"
x="275"
@ -70,8 +92,18 @@
activeicon="preferences_apply_button_active"
prelighticon="preferences_apply_button_prelight"/>
</Layout>
<Layout id="midi_settings_layout" bgnormal="#565656" x="113" y="1" width="505" height="557" visible="true">
<Layout bgnormal="#000000" x="21" y="20" width="291" height="19">
<Layout id="midi_settings_layout"
bgnormal="#565656"
x="113"
y="1"
width="505"
height="557"
visible="true">
<Layout bgnormal="#000000"
x="21"
y="20"
width="291"
height="19">
<Label style="generic_control"
text="MIDI PORTS"
fgnormal="#ffffff"
@ -123,7 +155,12 @@
</HBox>
</ScrolledWindow>
</Layout>
<Layout id="audio_settings_layout" bgnormal="#000000" x="113" y="1" width="505" height="558" visible="true">
<Layout id="audio_settings_layout"
bgnormal="#000000"
x="113" y="1"
width="505"
height="558"
visible="true">
<Layout bgnormal="#565656"
x="0"
y="0"
@ -135,7 +172,7 @@
y="15"
width="88"
horzalignment="end"/>
<Dropdown style="generic_button"
<Dropdown style="generic_dropdown"
id="engine_dropdown"
x="96"
y="12"
@ -144,7 +181,15 @@
normalicon="preference_device_dropdown"
activeicon="preference_device_dropdown_active"
prelighticon="preference_device_dropdown_prelight"
inactiveicon="preference_device_dropdown_inactive"/>
inactiveicon="preference_device_dropdown_inactive">
<HBox>
<VBox width="10"/>
<Label style="generic_control"
horzalignment="start"
width="93"/>
</HBox>
<DROPDOWNMENU style="generic_dropdown_menu"/>
</Dropdown>
<Label style="generic_control"
text="INTERFACE"
@ -152,7 +197,7 @@
y="43"
width="88"
horzalignment="end"/>
<Dropdown style="generic_button"
<Dropdown style="generic_dropdown"
id="device_dropdown"
x="96"
y="40"
@ -161,14 +206,22 @@
normalicon="preference_device_dropdown"
activeicon="preference_device_dropdown_active"
prelighticon="preference_device_dropdown_prelight"
inactiveicon="preference_device_dropdown_inactive"/>
inactiveicon="preference_device_dropdown_inactive">
<HBox>
<VBox width="10"/>
<Label style="generic_control"
horzalignment="start"
width="93"/>
</HBox>
<DROPDOWNMENU style="generic_dropdown_menu"/>
</Dropdown>
<Label style="generic_control"
text="SAMPLE RATE"
x="223"
y="15"
width="80"
horzalignment="end"/>
<Dropdown style="generic_button"
<Dropdown style="generic_dropdown"
id="sample_rate_dropdown"
x="311"
y="12"
@ -177,14 +230,22 @@
normalicon="preference_rate_buffer_dropdown"
activeicon="preference_rate_buffer_dropdown_active"
prelighticon="preference_rate_buffer_dropdown_prelight"
inactiveicon="preference_rate_buffer_dropdown_inactive"/>
inactiveicon="preference_rate_buffer_dropdown_inactive">
<HBox>
<VBox width="10"/>
<Label style="generic_control"
horzalignment="start"
width="57"/>
</HBox>
<DROPDOWNMENU style="generic_dropdown_menu"/>
</Dropdown>
<Label style="generic_control"
text="BUFFER SIZE"
x="223"
y="43"
width="80"
horzalignment="end"/>
<Dropdown style="generic_button"
<Dropdown style="generic_dropdown"
id="buffer_size_dropdown"
x="311"
y="40"
@ -193,7 +254,15 @@
normalicon="preference_rate_buffer_dropdown"
activeicon="preference_rate_buffer_dropdown_active"
prelighticon="preference_rate_buffer_dropdown_prelight"
inactiveicon="preference_rate_buffer_dropdown_inactive"/>
inactiveicon="preference_rate_buffer_dropdown_inactive">
<HBox>
<VBox width="10"/>
<Label style="generic_control"
horzalignment="start"
width="57"/>
</HBox>
<DROPDOWNMENU style="generic_dropdown_menu"/>
</Dropdown>
<Iconbutton id="control_panel_button"
style="generic_button"
@ -362,7 +431,7 @@
-->
<Label style="generic_control" text="FILE TYPE" x="24" y="40"/>
<Dropdown style="generic_button"
<Dropdown style="generic_dropdown"
id="file_type_dropdown"
x="215"
y="40"
@ -371,13 +440,25 @@
normalicon="preference_session_settings_dropdown"
activeicon="preference_session_settings_dropdown_active"
prelighticon="preference_session_settings_dropdown_prelight">
<dropdownitem title="Caf"/>
<dropdownitem title="BWav"/>
<dropdownitem title="Aiff"/>
<dropdownitem title="Wave64"/>
<HBox>
<VBox width="10"/>
<Label style="generic_control"
horzalignment="start"
width="117"/>
</HBox>
<DROPDOWNMENU style="generic_dropdown_menu">
<Dropdownitem title="Caf"
horzalignment="start"/>
<Dropdownitem title="BWav"
horzalignment="start"/>
<Dropdownitem title="Aiff"
horzalignment="start"/>
<Dropdownitem title="Wave64"
horzalignment="start"/>
</DROPDOWNMENU>
</Dropdown>
<Label style="generic_control" text="BIT DEPTH" x="24" y="70"/>
<Dropdown style="generic_button"
<Dropdown style="generic_dropdown"
id="bit_depth_dropdown"
x="215"
y="70"
@ -386,12 +467,23 @@
normalicon="preference_session_settings_dropdown"
activeicon="preference_session_settings_dropdown_active"
prelighticon="preference_session_settings_dropdown_prelight">
<dropdownitem title="16 bit"/>
<dropdownitem title="24 bit"/>
<dropdownitem title="32 bit floating point"/>
<HBox>
<VBox width="10"/>
<Label style="generic_control"
horzalignment="start"
width="117"/>
</HBox>
<DROPDOWNMENU style="generic_dropdown_menu">
<Dropdownitem title="16 bit"
horzalignment="start"/>
<Dropdownitem title="24 bit"
horzalignment="start"/>
<Dropdownitem title="32 bit floating point"
horzalignment="start"/>
</DROPDOWNMENU>
</Dropdown>
<Label style="generic_control" text="SESSION FRAME RATE" x="24" y="100"/>
<Dropdown style="generic_button"
<Dropdown style="generic_dropdown"
id="frame_rate_dropdown"
x="215"
y="100"
@ -400,13 +492,29 @@
normalicon="preference_session_settings_dropdown"
activeicon="preference_session_settings_dropdown_active"
prelighticon="preference_session_settings_dropdown_prelight">
<dropdownitem title="24 fps"/>
<dropdownitem title="25 fps"/>
<dropdownitem title="30 fps"/>
<dropdownitem title="23.976 fps"/>
<dropdownitem title="29.97 fps"/>
<HBox>
<VBox width="10"/>
<Label style="generic_control"
horzalignment="start"
width="117"/>
</HBox>
<DROPDOWNMENU style="generic_dropdown_menu">
<Dropdownitem title="24 fps"
horzalignment="start"/>
<Dropdownitem title="25 fps"
horzalignment="start"/>
<Dropdownitem title="30 fps"
horzalignment="start"/>
<Dropdownitem title="23.976 fps"
horzalignment="start"/>
<Dropdownitem title="29.97 fps"
horzalignment="start"/>
</DROPDOWNMENU>
</Dropdown>
<Label style="generic_control" text="AUTO LOCK TIMER" x="24" y="175"/>
<Label style="generic_control"
text="AUTO LOCK TIMER"
x="24"
y="175"/>
<Dropdown style="generic_button"
id="auto_lock_timer_dropdown"
x="215"
@ -416,12 +524,26 @@
normalicon="preference_session_settings_dropdown"
activeicon="preference_session_settings_dropdown_active"
prelighticon="preference_session_settings_dropdown_prelight">
<dropdownitem title="0 Min"/>
<dropdownitem title="1 Min"/>
<dropdownitem title="3 Min"/>
<dropdownitem title="5 Min"/>
<dropdownitem title="10 Min"/>
<dropdownitem title="15 Min"/>
<HBox>
<VBox width="10"/>
<Label style="generic_control"
horzalignment="start"
width="117"/>
</HBox>
<DROPDOWNMENU style="generic_dropdown_menu">
<Dropdownitem title="0 Min"
horzalignment="start"/>
<Dropdownitem title="1 Min"
horzalignment="start"/>
<Dropdownitem title="3 Min"
horzalignment="start"/>
<Dropdownitem title="5 Min"
horzalignment="start"/>
<Dropdownitem title="10 Min"
horzalignment="start"/>
<Dropdownitem title="15 Min"
horzalignment="start"/>
</DROPDOWNMENU>
</Dropdown>
<Label style="generic_control" text="AUTO SAVE TIMER" x="24" y="205"/>
<Dropdown style="generic_button"
@ -433,14 +555,31 @@
normalicon="preference_session_settings_dropdown"
activeicon="preference_session_settings_dropdown_active"
prelighticon="preference_session_settings_dropdown_prelight">
<dropdownitem title="0 Min"/>
<dropdownitem title="1 Min"/>
<dropdownitem title="3 Min"/>
<dropdownitem title="5 Min"/>
<dropdownitem title="10 Min"/>
<dropdownitem title="15 Min"/>
<HBox>
<VBox width="10"/>
<Label style="generic_control"
horzalignment="start"
width="117"/>
</HBox>
<DROPDOWNMENU style="generic_dropdown_menu">
<Dropdownitem title="0 Min"
horzalignment="start"/>
<Dropdownitem title="1 Min"
horzalignment="start"/>
<Dropdownitem title="3 Min"
horzalignment="start"/>
<Dropdownitem title="5 Min"
horzalignment="start"/>
<Dropdownitem title="10 Min"
horzalignment="start"/>
<Dropdownitem title="15 Min"
horzalignment="start"/>
</DROPDOWNMENU>
</Dropdown>
<Label style="generic_control" text="PRE RECORD BUFFER" x="24" y="235"/>
<Label style="generic_control"
text="PRE RECORD BUFFER"
x="24"
y="235"/>
<Dropdown style="generic_button"
id="pre_record_buffer_dropdown"
x="215"
@ -450,12 +589,25 @@
normalicon="preference_session_settings_dropdown"
activeicon="preference_session_settings_dropdown_active"
prelighticon="preference_session_settings_dropdown_prelight">
<dropdownitem title="0 Min"/>
<dropdownitem title="1 Min"/>
<dropdownitem title="2 Min"/>
<HBox>
<VBox width="10"/>
<Label style="generic_control"
horzalignment="start"
width="117"/>
</HBox>
<DROPDOWNMENU style="generic_dropdown_menu">
<Dropdownitem title="0 Min"
horzalignment="start"/>
<Dropdownitem title="1 Min"
horzalignment="start"/>
<Dropdownitem title="2 Min"
horzalignment="start"/>
</DROPDOWNMENU>
</Dropdown>
<Label style="generic_control" text="DEFAULT FOLDER FOR NEW SESSION" x = "24" y = "290"/>
<Label style="generic_control"
text="DEFAULT FOLDER FOR NEW SESSION"
x = "24"
y = "290"/>
<Iconbutton style = "generic_button"
id = "browse_default_folder"
x = "24"
@ -470,6 +622,8 @@
text=""
x = "105"
y = "315"/>
<dropdownitem title="MONO"/>
<dropdownitem title="STEREO"/>
</Layout>
</Layout>
</Dialog>

View file

@ -97,6 +97,10 @@ void
WavesButton::set_text (const std::string& str)
{
_text = str;
Gtk::Label* child = _find_label (this);
if (child) {
child->set_text (str);
}
_layout->set_text (str);
queue_resize ();
}
@ -169,7 +173,10 @@ void
WavesButton::render_text (cairo_t* cr)
{
// text, if any
if (!_text.empty()) {
if ((!_find_label (this)) &&
(!_text.empty ())) {
Glib::RefPtr<Gtk::Style> style = get_style();
cairo_save (cr);
@ -474,6 +481,16 @@ WavesButton::on_leave_notify_event (GdkEventCrossing* ev)
return CairoWidget::on_leave_notify_event (ev);
}
void
WavesButton::on_realize ()
{
Gtk::EventBox::on_realize ();
Gtk::Label* child = _find_label (this);
if (child) {
child->set_text (get_text());
}
}
void
WavesButton::action_sensitivity_changed ()
{
@ -516,3 +533,22 @@ WavesButton::set_rounded_corner_mask (int mask)
_corner_mask = mask;
queue_draw ();
}
Gtk::Label*
WavesButton::_find_label (Gtk::Container *container)
{
Gtk::Label* label = NULL;
if (container) {
std::list<Gtk::Widget*> children = container->get_children ();
for (std::list<Gtk::Widget*>::iterator i = children.begin(); i != children.end(); ++i) {
label = dynamic_cast<Gtk::Label*>(*i);
if (!label) {
label = _find_label (dynamic_cast<Gtk::Container*>(*i));
}
if (label) {
break;
}
}
}
return label;
}

View file

@ -71,14 +71,15 @@ class WavesButton : public CairoWidget , public Gtkmm2ext::Activatable
RGBA() : red (0), green (0), blue (0), alpha (0) {}
};
void render (cairo_t *, cairo_rectangle_t*);
void render_text (cairo_t *);
void render (cairo_t *, cairo_rectangle_t*);
void render_text (cairo_t *);
void on_size_request (Gtk::Requisition* req);
void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
void on_name_changed ();
bool on_enter_notify_event (GdkEventCrossing*);
bool on_leave_notify_event (GdkEventCrossing*);
void on_realize ();
void controllable_changed ();
PBD::ScopedConnection watch_connection;
@ -111,6 +112,7 @@ class WavesButton : public CairoWidget , public Gtkmm2ext::Activatable
private:
static void __prop_style_watcher(WavesButton *);
void _prop_style_watcher();
Gtk::Label* _find_label (Gtk::Container *child);
BindingProxy binding_proxy;

View file

@ -84,8 +84,6 @@ WavesIconButton::render (cairo_t* cr, cairo_rectangle_t*)
gdk_cairo_set_source_pixbuf (cr, pixbuf->gobj(), x, y);
cairo_fill (cr);
}
render_text (cr);
}
void

View file

@ -84,7 +84,7 @@ WavesUI::create_widget (const XMLNode& definition, const XMLNodeMap& styles)
} else if (widget_type == "DROPDOWN") {
child = manage (new WavesDropdown (text));
} else if (widget_type == "DROPDOWNITEM") {
child = manage (new WavesDropdown (text));
} else if (widget_type == "DROPDOWNMENU") {
} else if (widget_type == "ICON") {
std::string image_path;
Searchpath spath(ARDOUR::ardour_data_search_path ());
@ -444,18 +444,26 @@ WavesUI::add_dropdown_items (WavesDropdown &dropdown, const XMLNodeList& definit
}
std::string node_name = (**i).name ();
std::transform (node_name.begin (), node_name.end (), node_name.begin (), ::toupper);
if (node_name != "DROPDOWNITEM") {
continue;
}
std::string title = xml_property (**i, "title", styles, "");
if (title.empty ()) {
continue;
}
int itemdata = xml_property (**i, "data", styles, 0);
Gtk::MenuItem& menuitem = dropdown.add_menu_item (title, (void*)itemdata);
if (menuitem.get_child ()) {
set_attributes (*menuitem.get_child (), **i, styles);
}
if (node_name == "DROPDOWNMENU") {
set_attributes (dropdown.get_menu (), **i, styles);
const XMLNodeList& menuitems = (**i).children ();
for (XMLNodeList::const_iterator ii = menuitems.begin (); ii != menuitems.end (); ++ii) {
std::string node_name = (**ii).name ();
std::transform (node_name.begin (), node_name.end (), node_name.begin (), ::toupper);
if (node_name == "DROPDOWNITEM") {
std::string title = xml_property (**ii, "title", styles, "");
if (title.empty ()) {
continue;
}
int itemdata = xml_property (**ii, "data", styles, 0);
Gtk::MenuItem& menuitem = dropdown.add_menu_item (title, (void*)itemdata);
if (menuitem.get_child ()) {
set_attributes (*menuitem.get_child (), **ii, styles);
}
}
}
}
}
}
@ -467,11 +475,10 @@ WavesUI::create_ui (const XMLNodeList& definition, const XMLNodeMap& styles, Gtk
if (dropdown) {
add_dropdown_items (*dropdown, definition, styles);
} else {
for (XMLNodeList::const_iterator i = definition.begin (); i != definition.end (); ++i) {
if (!(**i).is_content()) {
WavesUI::add_widget (root, **i, styles);
}
}
for (XMLNodeList::const_iterator i = definition.begin (); i != definition.end (); ++i) {
if (!(**i).is_content()) {
WavesUI::add_widget (root, **i, styles);
}
}
}
@ -608,6 +615,27 @@ WavesUI::set_attributes (Gtk::Widget& widget, const XMLNode& definition, const X
widget.modify_fg(Gtk::STATE_PRELIGHT, Gdk::Color(property));
}
property = xml_property (definition, "state", styles, "");
if (!property.empty ()) {
Gtk::StateType state = Gtk::STATE_NORMAL;
if (property == "normal") {
state = Gtk::STATE_NORMAL;
} else if (property == "active") {
state = Gtk::STATE_ACTIVE;
} else if (property == "prelight") {
state = Gtk::STATE_PRELIGHT;
} else if (property == "selected") {
state = Gtk::STATE_SELECTED;
} else if (property == "insensitive") {
state = Gtk::STATE_INSENSITIVE;
} else if (property == "disabled") {
state = Gtk::STATE_INSENSITIVE;
} else {
dbg_msg ("Invalid state for Gtk::Widget !");
}
widget.set_state (state);
}
#if defined (PLATFORM_WINDOWS)
property = xml_property (definition, "winfont", styles, "");
#elif defined (__APPLE__)
@ -742,11 +770,6 @@ WavesUI::set_attributes (Gtk::Widget& widget, const XMLNode& definition, const X
}
}
WavesDropdown* dropdown = dynamic_cast<WavesDropdown*> (&widget);
if (dropdown) {
set_attributes (dropdown->get_menu (), definition, styles);
}
Gtk::Table* table = dynamic_cast<Gtk::Table*> (&widget);
if (table) {
table->set_col_spacings (xml_property (definition, "columnspacing", styles, 0));