Added the panel choice list
This commit is contained in:
parent
bb38e5fb76
commit
fff605e6d8
10 changed files with 109 additions and 12 deletions
|
|
@ -27,9 +27,8 @@ namespace gui {
|
|||
namespace panels {
|
||||
|
||||
ResourcesPanel::ResourcesPanel(workspace::WorkspaceWindow &workspace_window) :
|
||||
Panel(workspace_window, "resources", get_title(), "panel_resources")
|
||||
Panel(workspace_window, "resources", get_title(), get_stock_id())
|
||||
{
|
||||
|
||||
notebook.append_page(media, _("Media"));
|
||||
notebook.append_page(clips, _("Clips"));
|
||||
notebook.append_page(effects, _("Effects"));
|
||||
|
|
@ -44,5 +43,11 @@ ResourcesPanel::get_title()
|
|||
return _("Resources");
|
||||
}
|
||||
|
||||
const gchar*
|
||||
ResourcesPanel::get_stock_id()
|
||||
{
|
||||
return "panel_resources";
|
||||
}
|
||||
|
||||
} // namespace panels
|
||||
} // namespace gui
|
||||
|
|
|
|||
|
|
@ -47,6 +47,12 @@ public:
|
|||
**/
|
||||
static const char* get_title();
|
||||
|
||||
/**
|
||||
* Get the stock id for this type panel.
|
||||
* @return Returns a pointer to the string stock id of the panel.
|
||||
**/
|
||||
static const gchar* get_stock_id();
|
||||
|
||||
protected:
|
||||
Gtk::Notebook notebook;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ const int TimelinePanel::ZoomToolSteps = 2; // 2 seems comfortable
|
|||
|
||||
TimelinePanel::TimelinePanel(workspace::WorkspaceWindow
|
||||
&workspace_window) :
|
||||
Panel(workspace_window, "timeline", get_title(), "panel_timeline"),
|
||||
Panel(workspace_window, "timeline", get_title(), get_stock_id()),
|
||||
timeIndicator(),
|
||||
timeIndicatorButton(),
|
||||
previousButton(Stock::MEDIA_PREVIOUS),
|
||||
|
|
@ -136,6 +136,12 @@ TimelinePanel::get_title()
|
|||
return _("Timeline");
|
||||
}
|
||||
|
||||
const gchar*
|
||||
TimelinePanel::get_stock_id()
|
||||
{
|
||||
return "panel_timeline";
|
||||
}
|
||||
|
||||
void
|
||||
TimelinePanel::on_play_pause()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -62,6 +62,12 @@ public:
|
|||
* @return Returns a pointer to the string title of the panel.
|
||||
**/
|
||||
static const char* get_title();
|
||||
|
||||
/**
|
||||
* Get the stock id for this type panel.
|
||||
* @return Returns a pointer to the string stock id of the panel.
|
||||
**/
|
||||
static const gchar* get_stock_id();
|
||||
|
||||
private:
|
||||
//----- Event Handlers -----//
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace gui {
|
|||
namespace panels {
|
||||
|
||||
ViewerPanel::ViewerPanel(workspace::WorkspaceWindow &workspace_window) :
|
||||
Panel(workspace_window, "viewer", get_title(), "panel_viewer")
|
||||
Panel(workspace_window, "viewer", get_title(), get_stock_id())
|
||||
{
|
||||
//----- Pack in the Widgets -----//
|
||||
pack_start(display, PACK_EXPAND_WIDGET);
|
||||
|
|
@ -55,6 +55,12 @@ ViewerPanel::get_title()
|
|||
return _("Viewer");
|
||||
}
|
||||
|
||||
const gchar*
|
||||
ViewerPanel::get_stock_id()
|
||||
{
|
||||
return "panel_viewer";
|
||||
}
|
||||
|
||||
void
|
||||
ViewerPanel::on_frame(void *buffer)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -52,6 +52,12 @@ public:
|
|||
**/
|
||||
static const char* get_title();
|
||||
|
||||
/**
|
||||
* Get the stock id for this type panel.
|
||||
* @return Returns a pointer to the string stock id of the panel.
|
||||
**/
|
||||
static const gchar* get_stock_id();
|
||||
|
||||
protected:
|
||||
|
||||
void on_frame(void *buffer);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
* *****************************************************/
|
||||
|
||||
#include "panel-bar.hpp"
|
||||
#include "../workspace/panel-manager.hpp"
|
||||
#include "../panels/panel.hpp"
|
||||
#include "../util/rectangle.hpp"
|
||||
|
||||
|
|
@ -31,6 +32,7 @@ using namespace Gtk;
|
|||
using namespace Glib;
|
||||
using namespace sigc;
|
||||
using namespace std;
|
||||
using namespace gui::workspace;
|
||||
|
||||
namespace gui {
|
||||
namespace widgets {
|
||||
|
|
@ -55,7 +57,18 @@ PanelBar::setup_panel_button()
|
|||
{
|
||||
Menu& menu = panelButton.get_menu();
|
||||
Menu::MenuList& list = menu.items();
|
||||
|
||||
// Add items for each type of panel
|
||||
for(int i = 0; i < PanelManager::get_panel_description_count(); i++)
|
||||
{
|
||||
list.push_back( Menu_Helpers::StockMenuElem(
|
||||
StockID(PanelManager::get_panel_stock_id(i)),
|
||||
bind(mem_fun(*this, &PanelBar::on_panel_type), i) ));
|
||||
}
|
||||
|
||||
list.push_back( Menu_Helpers::SeparatorElem() );
|
||||
|
||||
// Add extra commands
|
||||
list.push_back( Menu_Helpers::MenuElem(_("_Hide"),
|
||||
mem_fun(*this, &PanelBar::on_hide) ) );
|
||||
}
|
||||
|
|
@ -112,6 +125,12 @@ PanelBar::on_size_allocate(Gtk::Allocation& allocation)
|
|||
HBox::on_size_allocate(allocation);
|
||||
}
|
||||
|
||||
void
|
||||
PanelBar::on_panel_type(int type_index)
|
||||
{
|
||||
g_message("on_panel_type %d", type_index);
|
||||
}
|
||||
|
||||
void
|
||||
PanelBar::on_hide()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ private:
|
|||
|
||||
private:
|
||||
|
||||
void on_panel_type(int type_index);
|
||||
|
||||
void on_hide();
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -111,6 +111,19 @@ PanelManager::get_dock_bar() const
|
|||
return dockBar;
|
||||
}
|
||||
|
||||
int
|
||||
PanelManager::get_panel_description_count()
|
||||
{
|
||||
return sizeof(panelDescriptionList) / sizeof(PanelDescription);
|
||||
}
|
||||
|
||||
const gchar*
|
||||
PanelManager::get_panel_stock_id(int index)
|
||||
{
|
||||
REQUIRE(index >= 0 && index < get_panel_description_count());
|
||||
return panelDescriptionList[index].get_stock_id();
|
||||
}
|
||||
|
||||
void
|
||||
PanelManager::create_panels()
|
||||
{
|
||||
|
|
@ -144,11 +157,8 @@ PanelManager::create_panels()
|
|||
shared_ptr<panels::Panel>
|
||||
PanelManager::create_panel_by_name(const char* class_name)
|
||||
{
|
||||
const int panelDescriptionCount =
|
||||
sizeof(panelDescriptionList) /
|
||||
sizeof(PanelDescription);
|
||||
|
||||
for(int i = 0; i < panelDescriptionCount; i++)
|
||||
const int count = get_panel_description_count();
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
if(strstr(panelDescriptionList[i].get_class_name(), class_name))
|
||||
return shared_ptr<panels::Panel>(panelDescriptionList[i].create(
|
||||
|
|
|
|||
|
|
@ -75,6 +75,20 @@ public:
|
|||
* @remarks Note that this must not be called before setup_dock.
|
||||
**/
|
||||
GdlDockBar* get_dock_bar() const;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Gets the number of panel descriptions.
|
||||
**/
|
||||
static int get_panel_description_count();
|
||||
|
||||
/**
|
||||
* Gets a panel description.
|
||||
* @param index The index of the panel to retrieve.
|
||||
* @return Returns the stock id of a panel at this index.
|
||||
**/
|
||||
static const gchar* get_panel_stock_id(int index);
|
||||
|
||||
private:
|
||||
|
||||
|
|
@ -139,14 +153,17 @@ private:
|
|||
* @param class_name The name of the Panel class
|
||||
* @param title The localized title that will be shown on the
|
||||
* panel.
|
||||
* @param stock_id The Stock ID for this type of panel.
|
||||
* @param create_panel_proc A pointer to a function that will
|
||||
* instantiate the panel object.
|
||||
**/
|
||||
PanelDescription(const char* class_name, const char *title,
|
||||
const gchar *stock_id,
|
||||
boost::shared_ptr<panels::Panel> (*const create_panel_proc)(
|
||||
WorkspaceWindow&)) :
|
||||
className(class_name),
|
||||
titleName(title),
|
||||
stockID(stock_id),
|
||||
createPanelProc(create_panel_proc)
|
||||
{
|
||||
REQUIRE(className);
|
||||
|
|
@ -171,6 +188,15 @@ private:
|
|||
ENSURE(titleName);
|
||||
return titleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Stock ID for this type of panel.
|
||||
**/
|
||||
const gchar* get_stock_id() const
|
||||
{
|
||||
ENSURE(stockID);
|
||||
return stockID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of this panel.
|
||||
|
|
@ -186,12 +212,17 @@ private:
|
|||
/**
|
||||
* A pointer to the string name of class.
|
||||
**/
|
||||
const char* className;
|
||||
const char* const className;
|
||||
|
||||
/**
|
||||
* The localized title that will be shown on the panel.
|
||||
**/
|
||||
const char* titleName;
|
||||
const char* const titleName;
|
||||
|
||||
/**
|
||||
* The Stock ID for this type of panel.
|
||||
**/
|
||||
const gchar* const stockID;
|
||||
|
||||
/**
|
||||
* A pointer to a function that will instantiate the panel object.
|
||||
|
|
@ -213,7 +244,7 @@ private:
|
|||
**/
|
||||
Panel() :
|
||||
PanelDescription(typeid(P).name(), P::get_title(),
|
||||
Panel::create_panel)
|
||||
P::get_stock_id(), Panel::create_panel)
|
||||
{}
|
||||
|
||||
private:
|
||||
|
|
|
|||
Loading…
Reference in a new issue