Merge branch 'gui' of git://git.lumiera.org/LUMIERA into doxygen_fixes

This commit is contained in:
Mano Stienen 2008-07-17 00:38:20 +02:00
commit 4184dcf253
11 changed files with 261 additions and 202 deletions

View file

@ -21,27 +21,38 @@
* *****************************************************/
#include "panel.hpp"
#include "../gtk-lumiera.hpp"
namespace lumiera {
namespace gui {
namespace panels {
Panel::Panel(const gchar *name, const gchar *long_name, GdlDockItemBehavior behavior)
Panel::Panel(const gchar *name, const gchar *long_name,
GdlDockItemBehavior behavior)
{
dock_item = (GdlDockItem*)gdl_dock_item_new (name, long_name, behavior);
dock_item = (GdlDockItem*)gdl_dock_item_new (
name, long_name, behavior);
internal_setup();
ENSURE(dock_item != NULL);
}
Panel::Panel(const gchar *name, const gchar *long_name, const gchar *stock_id,
GdlDockItemBehavior behavior)
{
dock_item = (GdlDockItem*)gdl_dock_item_new_with_stock (name, long_name, stock_id, behavior);
dock_item = (GdlDockItem*)gdl_dock_item_new_with_stock (
name, long_name, stock_id, behavior);
g_object_ref(dock_item);
internal_setup();
ENSURE(dock_item != NULL);
}
Panel::~Panel()
{
#warning Im not sure that dock_item is freed - is it self deleting?
REQUIRE(dock_item != NULL);
g_object_unref(dock_item);
dock_item = NULL;
}
GdlDockItem*
@ -53,6 +64,7 @@ Panel::get_dock_item() const
void
Panel::show(bool show)
{
REQUIRE(dock_item != NULL);
if(show) gdl_dock_item_show_item (dock_item);
else gdl_dock_item_hide_item (dock_item);
}
@ -60,12 +72,17 @@ Panel::show(bool show)
bool
Panel::is_shown() const
{
REQUIRE(dock_item != NULL);
return GTK_WIDGET_VISIBLE((GtkWidget*)dock_item);
}
void
Panel::internal_setup()
{
REQUIRE(dock_item != NULL);
REQUIRE(gobj() != NULL);
gdl_dock_item_hide_grip(dock_item);
gtk_container_add ((GtkContainer*)dock_item, (GtkWidget*)gobj());
gtk_widget_show ((GtkWidget*)dock_item);
}

View file

@ -30,8 +30,17 @@ namespace gui {
namespace panels {
TimelinePanel::TimelinePanel() :
Panel("timeline", _("Timeline"), "timeline_panel")
Panel("timeline", _("Timeline"), "timeline_panel"),
button(Stock::OK)
{
// Setup the toolbar
toolbar.append(button);
toolbar.set_icon_size(IconSize(ICON_SIZE_MENU));
toolbar.set_toolbar_style(TOOLBAR_ICONS);
// Add the toolbar
pack_start(toolbar, PACK_SHRINK);
pack_start(timeline_widget, PACK_EXPAND_WIDGET);
}

View file

@ -41,7 +41,13 @@ namespace panels {
TimelinePanel();
protected:
// Widgets
Gtk::Toolbar toolbar;
TimelineWidget timeline_widget;
// Toolbar Widgets
Gtk::ToolButton button;
};
} // namespace panels

View file

@ -210,7 +210,7 @@ TimelineWidget::zoom_view(int point, int zoom_size)
void
TimelineWidget::on_mouse_move_in_body(int x, int y)
{
ruler.set_mouse_chevron_time(x * timeScale + timeOffset);
ruler.set_mouse_chevron_offset(x);
}
} // namespace widgets

View file

@ -66,7 +66,7 @@ TimelineBody::on_realize()
Widget::on_realize();
// We wish to receive all event notifications
add_events(Gdk::POINTER_MOTION_MASK);
add_events(Gdk::POINTER_MOTION_MASK | Gdk::SCROLL_MASK);
}
void
@ -140,7 +140,7 @@ TimelineBody::on_expose_event(GdkEventExpose* event)
// Prepare to render via cairo
Glib::RefPtr<Style> style = get_style();
Gtk::Allocation allocation = get_allocation();
const Allocation allocation = get_allocation();
Cairo::RefPtr<Cairo::Context> cairo = window->create_cairo_context();
REQUIRE(style);

View file

@ -43,16 +43,15 @@ namespace timeline {
TimelineRuler::TimelineRuler() :
Glib::ObjectBase("TimelineRuler"),
timeOffset(0),
timeOffset(-1),
timeScale(1),
mouseChevronTime(0),
mouseChevronOffset(0),
annotationHorzMargin(0),
annotationVertMargin(0),
majorTickHeight(0),
minorLongTickHeight(0),
minorShortTickHeight(0),
minDivisionWidth(100),
mouseChevronSize(0)
minDivisionWidth(100)
{
// Install style properties
register_styles();
@ -76,9 +75,9 @@ TimelineRuler::set_time_scale(int64_t time_scale)
}
void
TimelineRuler::set_mouse_chevron_time(gavl_time_t time)
TimelineRuler::set_mouse_chevron_offset(int offset)
{
mouseChevronTime = time;
mouseChevronOffset = offset;
queue_draw();
}
@ -88,7 +87,7 @@ TimelineRuler::on_realize()
Widget::on_realize();
// Set event notifications
add_events(Gdk::POINTER_MOTION_MASK);
add_events(Gdk::POINTER_MOTION_MASK | Gdk::SCROLL_MASK);
// Load styles
read_styles();
@ -144,7 +143,7 @@ TimelineRuler::on_motion_notify_event(GdkEventMotion *event)
{
REQUIRE(event != NULL);
set_mouse_chevron_time(event->x * timeScale + timeOffset);
set_mouse_chevron_offset(event->x);
return true;
}
@ -248,16 +247,20 @@ TimelineRuler::draw_mouse_chevron(Cairo::RefPtr<Cairo::Context> cairo,
REQUIRE(ruler_rect.get_width() > 0);
REQUIRE(ruler_rect.get_height() > 0);
// Is the mouse chevron in view?
if(mouseChevronOffset < 0 ||
mouseChevronOffset >= ruler_rect.get_width())
return;
// Set the source colour
Glib::RefPtr<Style> style = get_style();
Gdk::Cairo::set_source_color(cairo, style->get_fg(STATE_NORMAL));
const int x = (mouseChevronTime - timeOffset) / timeScale;
cairo->move_to(x + 0.5,
cairo->move_to(mouseChevronOffset + 0.5,
ruler_rect.get_height());
cairo->line_to(x + mouseChevronSize + 0.5,
cairo->line_to(mouseChevronOffset + mouseChevronSize + 0.5,
ruler_rect.get_height() - mouseChevronSize);
cairo->line_to(x - mouseChevronSize + 0.5,
cairo->line_to(mouseChevronOffset - mouseChevronSize + 0.5,
ruler_rect.get_height() - mouseChevronSize);
cairo->fill();

View file

@ -53,7 +53,12 @@ public:
*/
void set_time_scale(int64_t time_scale);
void set_mouse_chevron_time(gavl_time_t time);
/**
* Sets the offset of the mouse chevron in pixels from the left
* edge of the widget. If offset is less than 0 or greater than the
* width, the chevron will not be visible.
*/
void set_mouse_chevron_offset(int offset);
/* ===== Events ===== */
protected:
@ -86,7 +91,9 @@ private:
// View values
gavl_time_t timeOffset;
int64_t timeScale;
int mouseChevronTime;
// Indicated values
int mouseChevronOffset;
// Style values
int annotationHorzMargin;

View file

@ -28,6 +28,7 @@
using namespace Gtk;
using namespace Glib;
using namespace sigc;
using namespace lumiera::gui;
namespace lumiera {
@ -35,10 +36,14 @@ namespace gui {
namespace workspace {
Actions::Actions(WorkspaceWindow &workspace_window) :
workspaceWindow(workspace_window)
workspaceWindow(workspace_window),
is_updating_action_state(false)
{
register_stock_items();
workspace_window.signal_show ().connect_notify(mem_fun(this, &Actions::update_action_state));
//----- Create the Action Group -----//
actionGroup = ActionGroup::create();
// File menu
@ -84,9 +89,6 @@ namespace workspace {
actionGroup->add(Action::create("HelpMenu", _("_Help")) );
actionGroup->add(Action::create("HelpAbout", Stock::ABOUT),
sigc::mem_fun(*this, &Actions::on_menu_help_about) );
// Refresh the UI state
update_action_state();
}
void
@ -129,9 +131,15 @@ namespace workspace {
void
Actions::update_action_state()
{
assetsPanelAction->set_active(workspaceWindow.assets_panel.is_shown());
timelinePanelAction->set_active(workspaceWindow.timeline_panel.is_shown());
viewerPanelAction->set_active(workspaceWindow.viewer_panel.is_shown());
REQUIRE(workspaceWindow.assets_panel);
REQUIRE(workspaceWindow.timeline_panel);
REQUIRE(workspaceWindow.viewer_panel);
is_updating_action_state = true;
assetsPanelAction->set_active(workspaceWindow.assets_panel->is_shown());
timelinePanelAction->set_active(workspaceWindow.timeline_panel->is_shown());
viewerPanelAction->set_active(workspaceWindow.viewer_panel->is_shown());
is_updating_action_state = false;
}
/* ===== File Menu Event Handlers ===== */
@ -175,22 +183,22 @@ namespace workspace {
void
Actions::on_menu_view_assets()
{
workspaceWindow.assets_panel.show(!workspaceWindow.assets_panel.is_shown());
update_action_state();
if(!is_updating_action_state)
workspaceWindow.assets_panel->show(assetsPanelAction->get_active());
}
void
Actions::on_menu_view_timeline()
{
workspaceWindow.timeline_panel.show(!workspaceWindow.timeline_panel.is_shown());
update_action_state();
if(!is_updating_action_state)
workspaceWindow.timeline_panel->show(timelinePanelAction->get_active());
}
void
Actions::on_menu_view_viewer()
{
workspaceWindow.viewer_panel.show(!workspaceWindow.viewer_panel.is_shown());
update_action_state();
if(!is_updating_action_state)
workspaceWindow.viewer_panel->show(viewerPanelAction->get_active());
}
void

View file

@ -94,6 +94,10 @@ class WorkspaceWindow;
Glib::RefPtr<Gtk::ToggleAction> timelinePanelAction;
Glib::RefPtr<Gtk::ToggleAction> viewerPanelAction;
/* ===== Internals ===== */
private:
bool is_updating_action_state;
friend class WorkspaceWindow;
};

View file

@ -128,7 +128,12 @@ WorkspaceWindow::create_ui()
toolbar->set_toolbar_style(TOOLBAR_ICONS);
base_container.pack_start(*toolbar, Gtk::PACK_SHRINK);
//----- Create the dock -----//
//----- Create the Panels -----//
assets_panel = Glib::RefPtr<AssetsPanel>(new AssetsPanel());
viewer_panel = Glib::RefPtr<ViewerPanel>(new ViewerPanel());
timeline_panel = Glib::RefPtr<TimelinePanel>(new TimelinePanel());
//----- Create the Dock -----//
dock = Glib::wrap(gdl_dock_new());
layout = gdl_dock_layout_new((GdlDock*)dock->gobj());
@ -139,15 +144,15 @@ WorkspaceWindow::create_ui()
dock_container.pack_end(*dock, PACK_EXPAND_WIDGET);
base_container.pack_start(dock_container, PACK_EXPAND_WIDGET);
gdl_dock_add_item ((GdlDock*)dock->gobj(), assets_panel.get_dock_item(), GDL_DOCK_LEFT);
gdl_dock_add_item ((GdlDock*)dock->gobj(), viewer_panel.get_dock_item(), GDL_DOCK_RIGHT);
gdl_dock_add_item ((GdlDock*)dock->gobj(), timeline_panel.get_dock_item(), GDL_DOCK_BOTTOM);
gdl_dock_add_item ((GdlDock*)dock->gobj(), assets_panel->get_dock_item(), GDL_DOCK_LEFT);
gdl_dock_add_item ((GdlDock*)dock->gobj(), viewer_panel->get_dock_item(), GDL_DOCK_RIGHT);
gdl_dock_add_item ((GdlDock*)dock->gobj(), timeline_panel->get_dock_item(), GDL_DOCK_BOTTOM);
// Manually dock and move around some of the items
gdl_dock_item_dock_to (timeline_panel.get_dock_item(), assets_panel.get_dock_item(),
GDL_DOCK_BOTTOM, -1);
gdl_dock_item_dock_to (viewer_panel.get_dock_item(), assets_panel.get_dock_item(),
GDL_DOCK_RIGHT, -1);
gdl_dock_item_dock_to (timeline_panel->get_dock_item(),
assets_panel->get_dock_item(), GDL_DOCK_BOTTOM, -1);
gdl_dock_item_dock_to (viewer_panel->get_dock_item(),
assets_panel->get_dock_item(), GDL_DOCK_RIGHT, -1);
show_all_children();

View file

@ -77,9 +77,9 @@ namespace workspace {
/* ===== Panels ===== */
private:
AssetsPanel assets_panel;
ViewerPanel viewer_panel;
TimelinePanel timeline_panel;
Glib::RefPtr<AssetsPanel> assets_panel;
Glib::RefPtr<ViewerPanel> viewer_panel;
Glib::RefPtr<TimelinePanel> timeline_panel;
/* ===== Helpers ===== */
private: