Divorced ButtonBar from Toolbar

This commit is contained in:
Joel Holdsworth 2009-03-14 12:17:21 +00:00
parent 77022b3bcb
commit 2a66789773
8 changed files with 121 additions and 56 deletions

View file

@ -142,7 +142,7 @@ PKG_CHECK_MODULES(LUMIERA_COMMON_LIBS, [sigc++-2.0 >= 2.0.17])
PKG_CHECK_MODULES(LUMIERA_GUI, [
gtk+-2.0 >= 2.8
gtkmm-2.4 >= 2.8
gtkmm-2.4 >= 2.14
cairomm-1.0 >= 0.6.0
librsvg-2.0 >= 2.18.1
gdl-1.0 >= 0.6.1

View file

@ -82,6 +82,8 @@ gtk_gui_la_SOURCES = \
$(lumigui_srcdir)/widgets/button-bar.hpp \
$(lumigui_srcdir)/widgets/menu-button.cpp \
$(lumigui_srcdir)/widgets/menu-button.hpp \
$(lumigui_srcdir)/widgets/mini-button.cpp \
$(lumigui_srcdir)/widgets/mini-button.hpp \
$(lumigui_srcdir)/widgets/video-display-widget.cpp \
$(lumigui_srcdir)/widgets/video-display-widget.hpp \
$(lumigui_srcdir)/widgets/timeline-widget.cpp \

View file

@ -30,25 +30,14 @@ using namespace sigc;
namespace gui {
namespace widgets {
ButtonBar::ButtonBar() :
exposeEvent(NULL)
ButtonBar::ButtonBar()
{
}
bool
ButtonBar::on_expose_event(GdkEventExpose* event)
{
exposeEvent = event;
foreach(sigc::mem_fun(this, &ButtonBar::expose_each));
exposeEvent = NULL;
return false;
}
void
ButtonBar::expose_each(Gtk::Widget& widget)
ButtonBar::append(MiniButton& button)
{
REQUIRE(exposeEvent);
propagate_expose(widget, exposeEvent);
pack_start(button, PACK_SHRINK);
}
} // widgets

View file

@ -26,7 +26,7 @@
#ifndef BUTTON_BAR_HPP
#define BUTTON_BAR_HPP
#include <gtkmm.h>
#include "mini-button.hpp"
namespace gui {
namespace widgets {
@ -34,36 +34,15 @@ namespace widgets {
/**
* A modified toolbar widget for use in dialogs.
**/
class ButtonBar : public Gtk::Toolbar
class ButtonBar : public Gtk::HBox
{
public:
/**
* Constructor
**/
ButtonBar();
private:
/**
* The expose event handler.
* @remarks This event handler bypasses the Toolbar expose handler
* so that the toolbar background is not drawn.
**/
bool on_expose_event(GdkEventExpose* event);
/**
* A helper function that calles Container::propagate_expose on a
* widget.
* @param widget The widget to call propagate_expose on.
* @remarks This function should be used with Container::foreach.
**/
void expose_each(Gtk::Widget& widget);
/**
* A pointer to the expose event received in on_expose_event.
* @remarks This value is used by expose_each, and is only value
* during on_expose_event's foreach call.
**/
GdkEventExpose* exposeEvent;
void append(MiniButton& button);
};
} // gui

View file

@ -0,0 +1,43 @@
/*
mini-button.cpp - Implementation of the mini button widget
Copyright (C) Lumiera.org
2009, Joel Holdsworth <joel@airwebreathe.org.uk>
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 "mini-button.hpp"
#include <nobug.h>
using namespace Gtk;
using namespace sigc;
namespace gui {
namespace widgets {
MiniButton::MiniButton(const StockID& stock_id,
const IconSize icon_size) :
image(stock_id, icon_size)
{
add(image);
set_relief(RELIEF_NONE);
set_focus_on_click(false);
}
} // widgets
} // gui

View file

@ -0,0 +1,59 @@
/*
mini-button.hpp - Declaration of the mini button widget
Copyright (C) Lumiera.org
2009, Joel Holdsworth <joel@airwebreathe.org.uk>
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 mini-button.hpp
** This file contains the definition of mini button widget
*/
#ifndef MINI_BUTTON_HPP
#define MINI_BUTTON_HPP
#include <gtkmm.h>
namespace gui {
namespace widgets {
/**
* A ToolButton-like widget
**/
class MiniButton : public Gtk::Button
{
public:
/**
* Creates a new Button containing the image and text from a stock
* item.
* @remarks Stock ids have identifiers like Gtk::Stock::OK and
* Gtk::Stock::APPLY.
**/
MiniButton(const Gtk::StockID& stock_id,
const Gtk::IconSize icon_size);
private:
Gtk::Image image;
};
} // gui
} // widgets
#endif // MINI_BUTTON_HPP

View file

@ -46,29 +46,21 @@ Track::Track(TimelineWidget &timeline_widget,
expanded(true),
expandDirection(None),
headerWidget(*this),
enableButton(Gtk::StockID("track_enabled")),
lockButton(Gtk::StockID("track_unlocked"))
enableButton(Gtk::StockID("track_enabled"), WindowManager::MenuIconSize),
lockButton(Gtk::StockID("track_unlocked"), WindowManager::MenuIconSize)
{
REQUIRE(model_track);
titleMenuButton.set_relief(RELIEF_HALF);
titleMenuButton.unset_flags(CAN_FOCUS);
buttonBar.set_icon_size(WindowManager::MenuIconSize);
buttonBar.append(enableButton);
buttonBar.append(lockButton);
buttonBar.set_toolbar_style(TOOLBAR_ICONS);
#if 0
buttonBar.set_icon_size(WindowManager::MenuIconSize);
#else
TODO("This code soon be removed when we drop Etch compatibility");
// Temporary bodge for etch compatibility - will be removed soon
gtk_toolbar_set_icon_size (buttonBar.gobj(),
(GtkIconSize)(int)WindowManager::MenuIconSize);
#endif
//buttonBar.set_toolbar_style(TOOLBAR_ICONS);
headerWidget.set_child_widget(headerBox);
headerBox.pack_start(titleMenuButton, PACK_SHRINK);

View file

@ -26,6 +26,7 @@
#include "../../gtk-lumiera.hpp"
#include "../../model/track.hpp"
#include "../menu-button.hpp"
#include "../mini-button.hpp"
#include "../button-bar.hpp"
#include "timeline-header-container.hpp"
#include "timeline-header-widget.hpp"
@ -189,8 +190,8 @@ private:
MenuButton titleMenuButton;
Gtk::ToolButton enableButton;
Gtk::ToolButton lockButton;
MiniButton enableButton;
MiniButton lockButton;
Gtk::Entry titleBox;
ButtonBar buttonBar;