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();
@ -60,7 +59,7 @@ TimelineRuler::TimelineRuler() :
void
TimelineRuler::set_time_offset(gavl_time_t time_offset)
{
{
timeOffset = time_offset;
rulerImage.clear();
queue_draw();
@ -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,200 +28,208 @@
using namespace Gtk;
using namespace Glib;
using namespace sigc;
using namespace lumiera::gui;
namespace lumiera {
namespace gui {
namespace workspace {
Actions::Actions(WorkspaceWindow &workspace_window) :
workspaceWindow(workspace_window)
Actions::Actions(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
actionGroup->add(Action::create("FileMenu", _("_File")));
actionGroup->add(Action::create("FileNewProject", Stock::NEW, _("_New Project...")),
sigc::mem_fun(*this, &Actions::on_menu_file_new_project));
actionGroup->add(Action::create("FileOpenProject", Stock::OPEN, _("_Open Project...")),
sigc::mem_fun(*this, &Actions::on_menu_file_open_project));
actionGroup->add(Action::create("FileRender", _("_Render...")),
Gtk::AccelKey("<shift>R"),
sigc::mem_fun(*this, &Actions::on_menu_file_render));
actionGroup->add(Action::create("FileQuit", Stock::QUIT),
sigc::mem_fun(*this, &Actions::on_menu_file_quit));
// Edit menu
actionGroup->add(Action::create("EditMenu", _("_Edit")));
actionGroup->add(Action::create("EditCopy", Stock::COPY),
sigc::mem_fun(*this, &Actions::on_menu_others));
actionGroup->add(Action::create("EditPaste", Stock::PASTE),
sigc::mem_fun(*this, &Actions::on_menu_others));
actionGroup->add(Action::create("EditPreferences", Stock::PREFERENCES),
sigc::mem_fun(*this, &Actions::on_menu_edit_preferences));
// View Menu
actionGroup->add(Action::create("ViewMenu", _("_View")));
assetsPanelAction = ToggleAction::create("ViewAssets", Gtk::StockID("assets_panel"));
assetsPanelAction->signal_toggled().connect(
sigc::mem_fun(*this, &Actions::on_menu_view_assets));
actionGroup->add(assetsPanelAction);
timelinePanelAction = ToggleAction::create("ViewTimeline", Gtk::StockID("timeline_panel"));
timelinePanelAction->signal_toggled().connect(
sigc::mem_fun(*this, &Actions::on_menu_view_timeline));
actionGroup->add(timelinePanelAction);
viewerPanelAction = ToggleAction::create("ViewViewer", Gtk::StockID("viewer_panel"));
viewerPanelAction->signal_toggled().connect(
sigc::mem_fun(*this, &Actions::on_menu_view_viewer));
actionGroup->add(viewerPanelAction);
// Help Menu
actionGroup->add(Action::create("HelpMenu", _("_Help")) );
actionGroup->add(Action::create("HelpAbout", Stock::ABOUT),
sigc::mem_fun(*this, &Actions::on_menu_help_about) );
}
void
Actions::register_stock_items()
{
RefPtr<IconFactory> factory = IconFactory::create();
add_stock_item(factory, "assets-panel.png", "assets_panel", _("_Assets"));
add_stock_item(factory, "timeline-panel.png", "timeline_panel", _("_Timeline"));
add_stock_item(factory, "viewer-panel.png", "viewer_panel", _("_Viewer"));
factory->add_default(); //Add factory to list of factories.
}
void
Actions::add_stock_item(const Glib::RefPtr<IconFactory>& factory,
const Glib::ustring& filepath,
const Glib::ustring& id, const Glib::ustring& label)
{
Gtk::IconSource source;
try
{
register_stock_items();
actionGroup = ActionGroup::create();
// File menu
actionGroup->add(Action::create("FileMenu", _("_File")));
actionGroup->add(Action::create("FileNewProject", Stock::NEW, _("_New Project...")),
sigc::mem_fun(*this, &Actions::on_menu_file_new_project));
actionGroup->add(Action::create("FileOpenProject", Stock::OPEN, _("_Open Project...")),
sigc::mem_fun(*this, &Actions::on_menu_file_open_project));
actionGroup->add(Action::create("FileRender", _("_Render...")),
Gtk::AccelKey("<shift>R"),
sigc::mem_fun(*this, &Actions::on_menu_file_render));
actionGroup->add(Action::create("FileQuit", Stock::QUIT),
sigc::mem_fun(*this, &Actions::on_menu_file_quit));
// Edit menu
actionGroup->add(Action::create("EditMenu", _("_Edit")));
actionGroup->add(Action::create("EditCopy", Stock::COPY),
sigc::mem_fun(*this, &Actions::on_menu_others));
actionGroup->add(Action::create("EditPaste", Stock::PASTE),
sigc::mem_fun(*this, &Actions::on_menu_others));
actionGroup->add(Action::create("EditPreferences", Stock::PREFERENCES),
sigc::mem_fun(*this, &Actions::on_menu_edit_preferences));
// View Menu
actionGroup->add(Action::create("ViewMenu", _("_View")));
assetsPanelAction = ToggleAction::create("ViewAssets", Gtk::StockID("assets_panel"));
assetsPanelAction->signal_toggled().connect(
sigc::mem_fun(*this, &Actions::on_menu_view_assets));
actionGroup->add(assetsPanelAction);
timelinePanelAction = ToggleAction::create("ViewTimeline", Gtk::StockID("timeline_panel"));
timelinePanelAction->signal_toggled().connect(
sigc::mem_fun(*this, &Actions::on_menu_view_timeline));
actionGroup->add(timelinePanelAction);
viewerPanelAction = ToggleAction::create("ViewViewer", Gtk::StockID("viewer_panel"));
viewerPanelAction->signal_toggled().connect(
sigc::mem_fun(*this, &Actions::on_menu_view_viewer));
actionGroup->add(viewerPanelAction);
// Help Menu
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();
//This throws an exception if the file is not found:
source.set_pixbuf( Gdk::Pixbuf::create_from_file(filepath) );
}
catch(const Glib::Exception& ex)
{
g_message(ex.what().c_str());
}
void
Actions::register_stock_items()
{
RefPtr<IconFactory> factory = IconFactory::create();
add_stock_item(factory, "assets-panel.png", "assets_panel", _("_Assets"));
add_stock_item(factory, "timeline-panel.png", "timeline_panel", _("_Timeline"));
add_stock_item(factory, "viewer-panel.png", "viewer_panel", _("_Viewer"));
factory->add_default(); //Add factory to list of factories.
}
source.set_size(Gtk::ICON_SIZE_SMALL_TOOLBAR);
source.set_size_wildcarded(); //Icon may be scaled.
void
Actions::add_stock_item(const Glib::RefPtr<IconFactory>& factory,
const Glib::ustring& filepath,
const Glib::ustring& id, const Glib::ustring& label)
{
Gtk::IconSource source;
try
{
//This throws an exception if the file is not found:
source.set_pixbuf( Gdk::Pixbuf::create_from_file(filepath) );
}
catch(const Glib::Exception& ex)
{
g_message(ex.what().c_str());
}
Gtk::IconSet icon_set;
icon_set.add_source(source); //More than one source per set is allowed.
source.set_size(Gtk::ICON_SIZE_SMALL_TOOLBAR);
source.set_size_wildcarded(); //Icon may be scaled.
const Gtk::StockID stock_id(id);
factory->add(stock_id, icon_set);
Gtk::Stock::add(Gtk::StockItem(stock_id, label));
}
Gtk::IconSet icon_set;
icon_set.add_source(source); //More than one source per set is allowed.
void
Actions::update_action_state()
{
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;
}
const Gtk::StockID stock_id(id);
factory->add(stock_id, icon_set);
Gtk::Stock::add(Gtk::StockItem(stock_id, label));
}
/* ===== File Menu Event Handlers ===== */
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());
}
void
Actions::on_menu_file_new_project()
{
g_message("A File|New menu item was selecteda.");
}
/* ===== File Menu Event Handlers ===== */
void
Actions::on_menu_file_open_project()
{
g_message("A File|Open menu item was selecteda.");
}
void
Actions::on_menu_file_new_project()
{
g_message("A File|New menu item was selecteda.");
}
void
Actions::on_menu_file_render()
{
dialogs::Render dialog(workspaceWindow);
dialog.run();
}
void
Actions::on_menu_file_open_project()
{
g_message("A File|Open menu item was selecteda.");
}
void
Actions::on_menu_file_quit()
{
workspaceWindow.hide(); // Closes the main window to stop the Gtk::Main::run().
}
void
Actions::on_menu_file_render()
{
dialogs::Render dialog(workspaceWindow);
dialog.run();
}
/* ===== Edit Menu Event Handlers ===== */
void
Actions::on_menu_file_quit()
{
workspaceWindow.hide(); // Closes the main window to stop the Gtk::Main::run().
}
void
Actions::on_menu_edit_preferences()
{
dialogs::PreferencesDialog dialog(workspaceWindow);
dialog.run();
}
/* ===== Edit Menu Event Handlers ===== */
/* ===== View Menu Event Handlers ===== */
void
Actions::on_menu_edit_preferences()
{
dialogs::PreferencesDialog dialog(workspaceWindow);
dialog.run();
}
void
Actions::on_menu_view_assets()
{
if(!is_updating_action_state)
workspaceWindow.assets_panel->show(assetsPanelAction->get_active());
}
/* ===== View Menu Event Handlers ===== */
void
Actions::on_menu_view_timeline()
{
if(!is_updating_action_state)
workspaceWindow.timeline_panel->show(timelinePanelAction->get_active());
}
void
Actions::on_menu_view_assets()
{
workspaceWindow.assets_panel.show(!workspaceWindow.assets_panel.is_shown());
update_action_state();
}
void
Actions::on_menu_view_viewer()
{
if(!is_updating_action_state)
workspaceWindow.viewer_panel->show(viewerPanelAction->get_active());
}
void
Actions::on_menu_view_timeline()
{
workspaceWindow.timeline_panel.show(!workspaceWindow.timeline_panel.is_shown());
update_action_state();
}
void
Actions::on_menu_help_about()
{
// Configure the about dialog
AboutDialog dialog;
//dialog.set_program_name(AppTitle);
dialog.set_version(AppVersion);
//dialog.set_version(Appconfig::get("version"));
dialog.set_copyright(AppCopyright);
dialog.set_website(AppWebsite);
dialog.set_authors(StringArrayHandle(AppAuthors,
sizeof(AppAuthors) / sizeof(gchar*),
OWNERSHIP_NONE));
void
Actions::on_menu_view_viewer()
{
workspaceWindow.viewer_panel.show(!workspaceWindow.viewer_panel.is_shown());
update_action_state();
}
void
Actions::on_menu_help_about()
{
// Configure the about dialog
AboutDialog dialog;
//dialog.set_program_name(AppTitle);
dialog.set_version(AppVersion);
//dialog.set_version(Appconfig::get("version"));
dialog.set_copyright(AppCopyright);
dialog.set_website(AppWebsite);
dialog.set_authors(StringArrayHandle(AppAuthors,
sizeof(AppAuthors) / sizeof(gchar*),
OWNERSHIP_NONE));
dialog.set_transient_for(workspaceWindow);
// Show the about dialog
dialog.run();
}
dialog.set_transient_for(workspaceWindow);
// Show the about dialog
dialog.run();
}
//----- Temporary junk
void
Actions::on_menu_others()
{
g_message("A menu item was selected.");
}
//----- Temporary junk
void
Actions::on_menu_others()
{
g_message("A menu item was selected.");
}
} // namespace workspace
} // namespace gui

View file

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

View file

@ -47,7 +47,7 @@ WorkspaceWindow::WorkspaceWindow(Project *source_project) :
actions(*this)
{
REQUIRE(source_project != NULL);
layout = NULL;
create_ui();
@ -60,7 +60,7 @@ WorkspaceWindow::~WorkspaceWindow()
void
WorkspaceWindow::create_ui()
{
{
//----- Configure the Window -----//
set_title(AppTitle);
set_default_size(1024, 768);
@ -127,8 +127,13 @@ WorkspaceWindow::create_ui()
ASSERT(toolbar != NULL);
toolbar->set_toolbar_style(TOOLBAR_ICONS);
base_container.pack_start(*toolbar, Gtk::PACK_SHRINK);
//----- 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 -----//
//----- 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: