From 05994280450a57b3ebff4e98877cc9514a456f61 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Sun, 8 Mar 2009 16:50:23 +0000 Subject: [PATCH] Added initial PanelBar implementation --- src/gui/Makefile.am | 2 + src/gui/panels/panel.cpp | 11 ++++- src/gui/panels/panel.hpp | 4 ++ src/gui/widgets/menu-button.cpp | 25 ++++++++--- src/gui/widgets/menu-button.hpp | 6 +++ src/gui/widgets/panel-bar.cpp | 74 +++++++++++++++++++++++++++++++++ src/gui/widgets/panel-bar.hpp | 58 ++++++++++++++++++++++++++ 7 files changed, 173 insertions(+), 7 deletions(-) create mode 100644 src/gui/widgets/panel-bar.cpp create mode 100644 src/gui/widgets/panel-bar.hpp diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index d2a58c6bf..3414c9f60 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -83,6 +83,8 @@ gtk_gui_la_SOURCES = \ $(lumigui_srcdir)/widgets/menu-button.cpp \ $(lumigui_srcdir)/widgets/menu-button.hpp \ $(lumigui_srcdir)/widgets/mini-button.hpp \ + $(lumigui_srcdir)/widgets/panel-bar.cpp \ + $(lumigui_srcdir)/widgets/panel-bar.hpp \ $(lumigui_srcdir)/widgets/video-display-widget.cpp \ $(lumigui_srcdir)/widgets/video-display-widget.hpp \ $(lumigui_srcdir)/widgets/timeline-widget.cpp \ diff --git a/src/gui/panels/panel.cpp b/src/gui/panels/panel.cpp index aa600cafd..c6b0a8349 100644 --- a/src/gui/panels/panel.cpp +++ b/src/gui/panels/panel.cpp @@ -22,6 +22,7 @@ #include "panel.hpp" #include "../gtk-lumiera.hpp" +#include namespace gui { namespace panels { @@ -29,6 +30,7 @@ namespace panels { Panel::Panel(workspace::WorkspaceWindow &workspace_window, const gchar *name, const gchar *long_name, GdlDockItemBehavior behavior) : + bar(long_name), workspace(workspace_window) { REQUIRE(name != NULL); @@ -44,6 +46,7 @@ Panel::Panel(workspace::WorkspaceWindow &workspace_window, Panel::Panel(workspace::WorkspaceWindow &workspace_window, const gchar *name, const gchar *long_name, const gchar *stock_id, GdlDockItemBehavior behavior) : + bar(long_name, stock_id), workspace(workspace_window) { REQUIRE(name != NULL); @@ -90,9 +93,13 @@ void Panel::internal_setup() { REQUIRE(dock_item != NULL); - REQUIRE(gobj() != NULL); + REQUIRE(gobj() != NULL); - gdl_dock_item_hide_grip(dock_item); + //pack_start(bar); + GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP( + gdl_dock_item_get_grip(dock_item)); + gdl_dock_item_grip_set_label(grip, ((Widget&)bar).gobj()); + gtk_container_add ((GtkContainer*)dock_item, (GtkWidget*)gobj()); gtk_widget_show ((GtkWidget*)dock_item); } diff --git a/src/gui/panels/panel.hpp b/src/gui/panels/panel.hpp index 941afa0b8..6d8d5d848 100644 --- a/src/gui/panels/panel.hpp +++ b/src/gui/panels/panel.hpp @@ -30,6 +30,8 @@ #include "../gtk-lumiera.hpp" #include +#include "../widgets/panel-bar.hpp" + namespace gui { namespace workspace { @@ -102,6 +104,8 @@ protected: workspace::WorkspaceWindow &workspace; GdlDockItem* dock_item; + + widgets::PanelBar bar; }; } // namespace panels diff --git a/src/gui/widgets/menu-button.cpp b/src/gui/widgets/menu-button.cpp index ea2b50662..17ce30e60 100644 --- a/src/gui/widgets/menu-button.cpp +++ b/src/gui/widgets/menu-button.cpp @@ -27,6 +27,8 @@ using namespace Gtk; using namespace sigc; +const int CaptionPadding = 4; + namespace gui { namespace widgets { @@ -40,15 +42,24 @@ MenuButton::MenuButton() : setup_button(); } -MenuButton::MenuButton(const Gtk::StockID& stock_id) : - Button(stock_id), +MenuButton::MenuButton(const StockID& stock_id) : + Button(), + image(stock_id, ICON_SIZE_MENU), + caption(), arrow(arrowType, shadowType) { + StockItem stock_item; + REQUIRE(StockItem::lookup(stock_id, stock_item)); + caption.set_text_with_mnemonic(stock_item.get_label()); + + hBox.pack_start(image); + setup_button(); } MenuButton::MenuButton(const Glib::ustring& label, bool mnemonic) : - Button(label, mnemonic), + Button(), + caption(label), arrow(arrowType, shadowType) { setup_button(); @@ -71,8 +82,12 @@ void MenuButton::setup_button() { arrow.set(ARROW_DOWN, SHADOW_NONE); - set_image_position(POS_RIGHT); - set_image(arrow); + + hBox.pack_start(caption, PACK_EXPAND_WIDGET, CaptionPadding); + hBox.pack_start(arrow); + + add(hBox); + show_all(); } void diff --git a/src/gui/widgets/menu-button.hpp b/src/gui/widgets/menu-button.hpp index 4670cb718..9ab641dda 100644 --- a/src/gui/widgets/menu-button.hpp +++ b/src/gui/widgets/menu-button.hpp @@ -104,6 +104,12 @@ private: private: + Gtk::HBox hBox; + + Gtk::Image image; + + Gtk::Label caption; + /** * The internal menu object which is the popup menu of this widget. **/ diff --git a/src/gui/widgets/panel-bar.cpp b/src/gui/widgets/panel-bar.cpp new file mode 100644 index 000000000..e5875c597 --- /dev/null +++ b/src/gui/widgets/panel-bar.cpp @@ -0,0 +1,74 @@ +/* + panel-bar.hpp - Declaration of the panel bar widget + + Copyright (C) Lumiera.org + 2009, Joel Holdsworth + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +* *****************************************************/ + +#include "panel-bar.hpp" + +#include + +using namespace Gtk; +using namespace sigc; + +namespace gui { +namespace widgets { + +PanelBar::PanelBar(const gchar *name) : + HBox(), + panelButton(Glib::ustring("Hello"/*name*/)), + test(name) +{ + + internal_setup(); + + // Make the widget sensitive to mouse events + /*add_events( + Gdk::POINTER_MOTION_MASK | + Gdk::BUTTON_PRESS_MASK | + Gdk::BUTTON_RELEASE_MASK);*/ +} + +PanelBar::PanelBar(const gchar *name, const gchar *stock_id) : + HBox(), + panelButton(Gtk::StockID(stock_id)), + test(name) +{ + internal_setup(); +} + +void +PanelBar::internal_setup() +{ + panelButton.set_relief(RELIEF_NONE); + panelButton.unset_flags(CAN_FOCUS); + panelButton.show(); + pack_start(panelButton, PACK_SHRINK); + test.show(); + pack_start(test, PACK_EXPAND_WIDGET); + +} + +/*bool PanelBar::on_button_press_event (GdkEventButton* event) +{ + g_message("Hello"); + return EventBox::on_button_press_event(event); +}*/ +} // widgets +} // gui diff --git a/src/gui/widgets/panel-bar.hpp b/src/gui/widgets/panel-bar.hpp new file mode 100644 index 000000000..e739c8294 --- /dev/null +++ b/src/gui/widgets/panel-bar.hpp @@ -0,0 +1,58 @@ +/* + panel-bar.hpp - Declaration of the panel bar widget + + Copyright (C) Lumiera.org + 2009, Joel Holdsworth + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ +/** @file panel-bar.hpp + ** This file contains the definition of timeline widget + */ + +#ifndef PANEL_BAR_HPP +#define PANEL_BAR_HPP + +#include +#include "menu-button.hpp" + +namespace gui { +namespace widgets { + + +class PanelBar : public Gtk::HBox +{ +public: + + PanelBar(const gchar *name); + + PanelBar(const gchar *name, const gchar *stock_id); + + MenuButton panelButton; + Gtk::Label test; + + //virtual bool on_button_press_event (GdkEventButton* event); + +private: + + void internal_setup(); +}; + +} // gui +} // widgets + +#endif // PANEL_BAR_HPP +