adjust gui code indentation
This commit is contained in:
parent
8b6177a1c5
commit
7bd3eafd46
17 changed files with 802 additions and 858 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
BusController - service for
|
||||
BusController - the UI-Bus service
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2015, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
|
@ -50,7 +50,9 @@ using util::contains;
|
|||
using util::isnil;
|
||||
|
||||
|
||||
|
||||
namespace gui {
|
||||
namespace controller {
|
||||
|
||||
namespace { // internal details
|
||||
|
||||
} // internal details
|
||||
|
|
@ -72,4 +74,6 @@ using util::isnil;
|
|||
{
|
||||
return "x"+id;
|
||||
}
|
||||
|
||||
}} // namespace gui::ctrl
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
bus-controller.hpp - service for
|
||||
BUS-CONTROLLER.hpp - the UI-Bus service
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2015, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
playback-controller.cpp - Implementation of the playback controller object
|
||||
PlaybackController - playback controller object
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
|
||||
|
|
@ -29,67 +29,66 @@
|
|||
|
||||
namespace gui {
|
||||
namespace controller {
|
||||
|
||||
|
||||
|
||||
PlaybackController::PlaybackController() :
|
||||
playing(false),
|
||||
viewerHandle_(0)
|
||||
{ }
|
||||
|
||||
|
||||
void
|
||||
PlaybackController::play()
|
||||
{
|
||||
if (playHandle)
|
||||
{
|
||||
playHandle.play(true);
|
||||
playing = true;
|
||||
}
|
||||
else if (viewerHandle_)
|
||||
try
|
||||
|
||||
|
||||
|
||||
PlaybackController::PlaybackController()
|
||||
: playing(false)
|
||||
, viewerHandle_(0)
|
||||
{ }
|
||||
|
||||
|
||||
void
|
||||
PlaybackController::play()
|
||||
{
|
||||
if (playHandle)
|
||||
{
|
||||
playHandle = lumiera::DummyPlayer::facade().start (viewerHandle_);
|
||||
playHandle.play(true);
|
||||
playing = true;
|
||||
}
|
||||
catch (lumiera::error::State& err)
|
||||
{
|
||||
WARN (gui, "failed to start playback: %s" ,err.what());
|
||||
lumiera_error();
|
||||
playing = false;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PlaybackController::pause()
|
||||
{
|
||||
if (playHandle)
|
||||
playHandle.play(false);
|
||||
playing = false;
|
||||
}
|
||||
|
||||
void
|
||||
PlaybackController::stop()
|
||||
{
|
||||
playHandle.close();
|
||||
playing = false;
|
||||
}
|
||||
|
||||
bool
|
||||
PlaybackController::is_playing()
|
||||
{
|
||||
return playing;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
PlaybackController::use_display (LumieraDisplaySlot display)
|
||||
{
|
||||
viewerHandle_ = display;
|
||||
}
|
||||
|
||||
|
||||
} // namespace controller
|
||||
} // namespace gui
|
||||
else if (viewerHandle_)
|
||||
try
|
||||
{
|
||||
playHandle = lumiera::DummyPlayer::facade().start (viewerHandle_);
|
||||
playing = true;
|
||||
}
|
||||
catch (lumiera::error::State& err)
|
||||
{
|
||||
WARN (gui, "failed to start playback: %s" ,err.what());
|
||||
lumiera_error();
|
||||
playing = false;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PlaybackController::pause()
|
||||
{
|
||||
if (playHandle)
|
||||
playHandle.play(false);
|
||||
playing = false;
|
||||
}
|
||||
|
||||
void
|
||||
PlaybackController::stop()
|
||||
{
|
||||
playHandle.close();
|
||||
playing = false;
|
||||
}
|
||||
|
||||
bool
|
||||
PlaybackController::is_playing()
|
||||
{
|
||||
return playing;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
PlaybackController::use_display (LumieraDisplaySlot display)
|
||||
{
|
||||
viewerHandle_ = display;
|
||||
}
|
||||
|
||||
|
||||
}} // namespace gui::ctrl
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
playback-controller.hpp - Declaration of the playback controller object
|
||||
PLAYBACK-CONTROLLER.hpp - playback controller object
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2009, Joel Holdsworth <joel@airwebreathe.org.uk>
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
*/
|
||||
|
||||
|
||||
/** @file controller/playback-controller.hpp
|
||||
** This file contains the definition of the playback controller object
|
||||
*/
|
||||
|
|
@ -37,43 +38,38 @@
|
|||
|
||||
namespace gui {
|
||||
namespace controller {
|
||||
|
||||
|
||||
|
||||
class PlaybackController
|
||||
: boost::noncopyable
|
||||
{
|
||||
|
||||
|
||||
|
||||
class PlaybackController
|
||||
: boost::noncopyable
|
||||
{
|
||||
public:
|
||||
|
||||
PlaybackController();
|
||||
|
||||
void play();
|
||||
|
||||
void pause();
|
||||
|
||||
void stop();
|
||||
|
||||
bool is_playing();
|
||||
|
||||
void use_display (LumieraDisplaySlot display);
|
||||
|
||||
private:
|
||||
|
||||
void on_frame();
|
||||
volatile bool playing;
|
||||
|
||||
lumiera::DummyPlayer::Process playHandle;
|
||||
|
||||
LumieraDisplaySlot viewerHandle_;
|
||||
|
||||
public:
|
||||
|
||||
PlaybackController();
|
||||
|
||||
void play();
|
||||
void pause();
|
||||
void stop();
|
||||
|
||||
bool is_playing();
|
||||
|
||||
void use_display (LumieraDisplaySlot display);
|
||||
|
||||
private:
|
||||
|
||||
void on_frame();
|
||||
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
|
||||
volatile bool playing;
|
||||
|
||||
lumiera::DummyPlayer::Process playHandle;
|
||||
|
||||
LumieraDisplaySlot viewerHandle_;
|
||||
|
||||
};
|
||||
|
||||
} // namespace controller
|
||||
} // namespace gui
|
||||
|
||||
}} // namespace gui::controller
|
||||
#endif // PLAYBACK_CONTROLLER_HPP
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
dialog.hpp - Definitions of globals for dialogs
|
||||
DIALOG.hpp - Definitions of globals for dialogs
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
|
||||
|
|
@ -20,29 +20,23 @@
|
|||
|
||||
*/
|
||||
|
||||
/** @file render.hpp
|
||||
** This file contains definitions of globals for dialogs
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DIALOG_HPP
|
||||
#define DIALOG_HPP
|
||||
#ifndef GUI_DIALOG_DIALOG_H
|
||||
#define GUI_DIALOG_DIALOG_H
|
||||
|
||||
namespace gui {
|
||||
namespace dialogs {
|
||||
|
||||
/**
|
||||
* The space in pixels to pad the border of Lumiera dialog boxes.
|
||||
*/
|
||||
static const int BorderPadding = 8;
|
||||
|
||||
/**
|
||||
* The spacing for VBoxes and HBoxes in Lumiera dialogs.
|
||||
*/
|
||||
static const int BoxSpacing = 6;
|
||||
|
||||
} // namespace dialogs
|
||||
} // namespace gui
|
||||
|
||||
#endif // DIALOG_HPP
|
||||
|
||||
/**
|
||||
* The space in pixels to pad the border of Lumiera dialog boxes.
|
||||
*/
|
||||
static const int BorderPadding = 8;
|
||||
|
||||
/**
|
||||
* The spacing for VBoxes and HBoxes in Lumiera dialogs.
|
||||
*/
|
||||
static const int BoxSpacing = 6;
|
||||
|
||||
|
||||
}} // namespace gui::dialog
|
||||
#endif /*GUI_DIALOG_DIALOG_H*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
name-chooser.cpp - Definition of the name chooser dialog object
|
||||
NameChooser - dialog to enter a string name
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
* *****************************************************/
|
||||
|
||||
|
||||
#include "gui/gtk-lumiera.hpp"
|
||||
#include "gui/dialogs/name-chooser.hpp"
|
||||
#include "gui/dialogs/dialog.hpp"
|
||||
|
|
@ -29,41 +30,38 @@ using namespace Glib;
|
|||
|
||||
namespace gui {
|
||||
namespace dialogs {
|
||||
|
||||
NameChooser::NameChooser(Window &parent, cuString title,
|
||||
cuString default_name) :
|
||||
Dialog::Dialog(title, parent, true),
|
||||
caption(_("Name:"))
|
||||
{
|
||||
// Add the controls
|
||||
name.set_text(default_name);
|
||||
name.set_activates_default();
|
||||
|
||||
hBox.pack_start(caption);
|
||||
hBox.pack_start(name);
|
||||
hBox.set_spacing(BoxSpacing);
|
||||
|
||||
Box* const v_box = get_vbox();
|
||||
REQUIRE(v_box != NULL);
|
||||
v_box->pack_start(hBox);
|
||||
NameChooser::NameChooser (Window &parent,
|
||||
cuString title,
|
||||
cuString default_name)
|
||||
: Dialog::Dialog(title, parent, true)
|
||||
, caption(_("Name:"))
|
||||
{
|
||||
// Add the controls
|
||||
name.set_text(default_name);
|
||||
name.set_activates_default();
|
||||
|
||||
hBox.pack_start (caption);
|
||||
hBox.pack_start (name);
|
||||
hBox.set_spacing (BoxSpacing);
|
||||
|
||||
Box* const v_box = get_vbox();
|
||||
REQUIRE (v_box != NULL);
|
||||
v_box->pack_start (hBox);
|
||||
|
||||
// Configure the dialog
|
||||
v_box->set_spacing (BoxSpacing);
|
||||
set_border_width (BorderPadding);
|
||||
set_resizable (false);
|
||||
|
||||
// Configure the Cancel and Render buttons
|
||||
add_button (Stock::CANCEL, RESPONSE_CANCEL);
|
||||
add_button (Stock::OK, RESPONSE_OK);
|
||||
set_default_response (RESPONSE_OK);
|
||||
|
||||
show_all_children();
|
||||
}
|
||||
|
||||
// Configure the dialog
|
||||
v_box->set_spacing(BoxSpacing);
|
||||
set_border_width(BorderPadding);
|
||||
set_resizable(false);
|
||||
|
||||
// Configure the Cancel and Render buttons
|
||||
add_button(Stock::CANCEL, RESPONSE_CANCEL);
|
||||
add_button(Stock::OK, RESPONSE_OK);
|
||||
set_default_response(RESPONSE_OK);
|
||||
|
||||
show_all_children();
|
||||
}
|
||||
|
||||
cuString NameChooser::get_name() const
|
||||
{
|
||||
return name.get_text();
|
||||
}
|
||||
|
||||
} // namespace dialogs
|
||||
} // namespace gui
|
||||
|
||||
|
||||
}} // namespace gui::dialog
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
name-chooser.hpp - Definition of the name chooser dialog object
|
||||
NAME-CHOOSER.hpp - dialog to enter a string name
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
|
||||
|
|
@ -20,52 +20,49 @@
|
|||
|
||||
*/
|
||||
|
||||
/** @file name-chooser.hpp
|
||||
** This file contains the definition of the name chooser dialog
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NAME_CHOOSER_H
|
||||
#define NAME_CHOOSER_H
|
||||
#ifndef GUI_DIALOG_NAME_CHOOSER_H
|
||||
#define GUI_DIALOG_NAME_CHOOSER_H
|
||||
|
||||
#include "gui/gtk-lumiera.hpp"
|
||||
|
||||
|
||||
namespace gui {
|
||||
namespace dialogs {
|
||||
|
||||
/**
|
||||
* The name chooser dialog is a modal dialog box that prompts the user
|
||||
* to choose a string name.
|
||||
*/
|
||||
class NameChooser : public Gtk::Dialog
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Creates a name chooser dialog.
|
||||
* @param parent The window which will be the parent of this dialog.
|
||||
* @param title The string for the title of this dialog.
|
||||
* @param default_name The name that will be shown by default in the
|
||||
* edit box of the dialog.
|
||||
*/
|
||||
NameChooser(Gtk::Window &parent, cuString title,
|
||||
cuString default_name);
|
||||
|
||||
/**
|
||||
* Gets the current name of the chosen in the dialog.
|
||||
* @return Returns the name currently typed into the edit box of the
|
||||
* dialog.
|
||||
* The name chooser dialog is a modal dialog box that prompts the user
|
||||
* to choose a string name.
|
||||
*/
|
||||
cuString get_name() const;
|
||||
|
||||
private:
|
||||
Gtk::HBox hBox;
|
||||
Gtk::Label caption;
|
||||
Gtk::Entry name;
|
||||
};
|
||||
|
||||
} // namespace dialogs
|
||||
} // namespace gui
|
||||
|
||||
#endif // NAME_CHOOSER_H
|
||||
class NameChooser
|
||||
: public Gtk::Dialog
|
||||
{
|
||||
Gtk::HBox hBox;
|
||||
Gtk::Label caption;
|
||||
Gtk::Entry name;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Creates a name chooser dialog.
|
||||
* @param parent The window which will be the parent of this dialog.
|
||||
* @param title The string for the title of this dialog.
|
||||
* @param default_name The name that will be shown by default in the
|
||||
* edit box of the dialog.
|
||||
*/
|
||||
NameChooser(Gtk::Window &parent, cuString title, cuString default_name);
|
||||
|
||||
/**
|
||||
* Gets the current name of the chosen in the dialog.
|
||||
* @return Returns the name currently typed into the edit box of the
|
||||
* dialog.
|
||||
*/
|
||||
cuString
|
||||
get_name() const
|
||||
{
|
||||
return name.get_text();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}} // namespace gui::dialog
|
||||
#endif /*GUI_DIALOG_NAME_CHOOSER_H*/
|
||||
|
|
|
|||
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
preferences-dialog.cpp - Implementation of the application preferences dialog
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2008, 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 "gui/gtk-lumiera.hpp"
|
||||
|
||||
#include "gui/dialogs/preferences-dialog.hpp"
|
||||
#include "gui/dialogs/dialog.hpp"
|
||||
|
||||
using namespace Gtk;
|
||||
|
||||
namespace gui {
|
||||
namespace dialogs {
|
||||
|
||||
PreferencesDialog::PreferencesDialog(Window &parent) :
|
||||
Dialog(_("Preferences"), parent, true)
|
||||
{
|
||||
Box *v_box = get_vbox();
|
||||
REQUIRE(v_box != NULL);
|
||||
|
||||
interfaceBox.pack_start(interfaceThemeCombo, PACK_SHRINK);
|
||||
interfaceBox.set_spacing(4);
|
||||
interfaceBox.set_border_width(5);
|
||||
|
||||
notebook.append_page(interfaceBox, _("Interface"));
|
||||
|
||||
v_box->pack_start(notebook);
|
||||
|
||||
// Configure the dialog
|
||||
v_box->set_spacing(BoxSpacing);
|
||||
set_border_width(BorderPadding);
|
||||
set_resizable(false);
|
||||
|
||||
// Configure the Cancel and OK buttons
|
||||
add_button(Stock::CANCEL, RESPONSE_CANCEL);
|
||||
add_button(Stock::OK, RESPONSE_OK);
|
||||
|
||||
show_all_children();
|
||||
}
|
||||
|
||||
} // namespace dialogs
|
||||
} // namespace gui
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
preferences-dialog.hpp - Definition of the application preferences dialog
|
||||
PREFERENCES-DIALOG.hpp - dialog for application preferences
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
|
||||
|
|
@ -20,39 +20,56 @@
|
|||
|
||||
*/
|
||||
|
||||
/** @file render.hpp
|
||||
** This file contains the definition of the application preferences dialog
|
||||
**
|
||||
*/
|
||||
|
||||
#ifndef GUI_DIALOG_PREFERENCES_DIALOG_H
|
||||
#define GUI_DIALOG_PREFERENCES_DIALOG_H
|
||||
|
||||
#ifndef PREFERENCES_DIALOG_HPP
|
||||
#define PREFERENCES_DIALOG_HPP
|
||||
|
||||
#include "gui/gtk-lumiera.hpp"
|
||||
#include "gui/dialogs/dialog.hpp"
|
||||
|
||||
namespace gui {
|
||||
namespace dialogs {
|
||||
|
||||
/**
|
||||
* The definition of render output dialog class
|
||||
*/
|
||||
class PreferencesDialog : public Gtk::Dialog
|
||||
{
|
||||
public:
|
||||
PreferencesDialog(Gtk::Window &parent);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
protected:
|
||||
Gtk::Notebook notebook;
|
||||
|
||||
Gtk::VBox interfaceBox;
|
||||
Gtk::ComboBox interfaceThemeCombo;
|
||||
};
|
||||
|
||||
} // namespace dialogs
|
||||
} // namespace gui
|
||||
|
||||
#endif // PREFERENCES_DIALOG_HPP
|
||||
|
||||
class PreferencesDialog
|
||||
: public Gtk::Dialog
|
||||
{
|
||||
Gtk::Notebook notebook;
|
||||
|
||||
Gtk::VBox interfaceBox;
|
||||
Gtk::ComboBox interfaceThemeCombo;
|
||||
|
||||
public:
|
||||
PreferencesDialog(Gtk::Window &parent)
|
||||
: Dialog(_("Preferences"), parent, true)
|
||||
{
|
||||
using namespace Gtk;
|
||||
|
||||
Box *v_box = get_vbox();
|
||||
REQUIRE (v_box != NULL);
|
||||
|
||||
interfaceBox.pack_start (interfaceThemeCombo, PACK_SHRINK);
|
||||
interfaceBox.set_spacing(4);
|
||||
interfaceBox.set_border_width(5);
|
||||
|
||||
notebook.append_page (interfaceBox, _("Interface"));
|
||||
|
||||
v_box->pack_start (notebook);
|
||||
|
||||
// Configure the dialog
|
||||
v_box->set_spacing (BoxSpacing);
|
||||
set_border_width (BorderPadding);
|
||||
set_resizable (false);
|
||||
|
||||
// Configure the Cancel and OK buttons
|
||||
add_button (Stock::CANCEL, RESPONSE_CANCEL);
|
||||
add_button (Stock::OK, RESPONSE_OK);
|
||||
|
||||
show_all_children();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}} // namespace gui::dialog
|
||||
#endif /*GUI_DIALOG_PREFERENCES_DIALOG_H*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
render.cpp - Definition of the main workspace window object
|
||||
Render - dialog to define render output
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
|
||||
|
|
@ -32,72 +32,74 @@ using namespace Gtk;
|
|||
|
||||
namespace gui {
|
||||
namespace dialogs {
|
||||
|
||||
Render::Render(Window &parent) :
|
||||
Dialog(_("Render"), parent, true),
|
||||
outputFileLabel(_("Output File:")),
|
||||
browseButtonImage(StockID(Stock::INDEX), ICON_SIZE_BUTTON),
|
||||
outputFileBrowseButton(_("_Browse...")),
|
||||
containerFormatLabel(_("Container Format:")),
|
||||
renderButtonImage(StockID(Stock::OK), ICON_SIZE_BUTTON),
|
||||
audioFrame(_("Audio")),
|
||||
videoFrame(_("Video"))
|
||||
{
|
||||
Box *v_box = get_vbox();
|
||||
REQUIRE(v_box != NULL);
|
||||
|
||||
// The Output File Row
|
||||
outputFileHBox.pack_start(outputFileLabel, PACK_SHRINK);
|
||||
outputFileHBox.pack_start(outputFilePathEntry);
|
||||
|
||||
outputFileBrowseButton.set_image(browseButtonImage);
|
||||
outputFileBrowseButton.signal_clicked().connect(
|
||||
sigc::mem_fun(*this, &Render::on_button_browse));
|
||||
|
||||
outputFileHBox.pack_start(outputFileBrowseButton, PACK_SHRINK);
|
||||
outputFileHBox.set_spacing(4);
|
||||
v_box->pack_start(outputFileHBox, PACK_SHRINK);
|
||||
|
||||
// The Container Format Row
|
||||
containerFormatHBox.pack_start(containerFormatLabel, PACK_SHRINK);
|
||||
containerFormatHBox.pack_start(containerFormat);
|
||||
containerFormatHBox.set_spacing(4);
|
||||
v_box->pack_start(containerFormatHBox, PACK_SHRINK);
|
||||
|
||||
v_box->pack_start(audioFrame);
|
||||
v_box->pack_start(videoFrame);
|
||||
|
||||
// Configure the dialog
|
||||
v_box->set_spacing(BoxSpacing);
|
||||
set_border_width(BorderPadding);
|
||||
set_resizable(false);
|
||||
|
||||
// Configure the Cancel and Render buttons
|
||||
add_button(Stock::CANCEL, RESPONSE_CANCEL);
|
||||
|
||||
Button *render_button = add_button(Stock::OK, RESPONSE_OK);
|
||||
render_button->set_label(_("_Render"));
|
||||
render_button->set_image(renderButtonImage);
|
||||
//render_button->set_flags(Gtk::CAN_DEFAULT);
|
||||
render_button->grab_default();
|
||||
|
||||
show_all_children();
|
||||
}
|
||||
|
||||
void Render::on_button_browse()
|
||||
{
|
||||
FileChooserDialog dialog(*this, _("Select a File Name for Rendering"),
|
||||
FILE_CHOOSER_ACTION_SAVE);
|
||||
|
||||
// Add response buttons the the dialog:
|
||||
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||
dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
|
||||
|
||||
int result = dialog.run();
|
||||
INFO(gui, "%d", result);
|
||||
if(result == RESPONSE_OK)
|
||||
INFO(gui, "%s", "RESPONSE_OK");
|
||||
}
|
||||
|
||||
} // namespace dialogs
|
||||
} // namespace gui
|
||||
Render::Render (Window& parent)
|
||||
: Dialog(_("Render"), parent, true)
|
||||
, outputFileLabel(_("Output File:"))
|
||||
, browseButtonImage(StockID(Stock::INDEX), ICON_SIZE_BUTTON)
|
||||
, outputFileBrowseButton(_("_Browse..."))
|
||||
, containerFormatLabel(_("Container Format:"))
|
||||
, renderButtonImage(StockID(Stock::OK), ICON_SIZE_BUTTON)
|
||||
, audioFrame(_("Audio"))
|
||||
, videoFrame(_("Video"))
|
||||
{
|
||||
Box* v_box = get_vbox();
|
||||
REQUIRE (v_box != NULL);
|
||||
|
||||
// The Output File Row
|
||||
outputFileHBox.pack_start (outputFileLabel, PACK_SHRINK);
|
||||
outputFileHBox.pack_start (outputFilePathEntry);
|
||||
|
||||
outputFileBrowseButton.set_image (browseButtonImage);
|
||||
outputFileBrowseButton.signal_clicked().connect(
|
||||
sigc::mem_fun(*this, &Render::on_button_browse));
|
||||
|
||||
outputFileHBox.pack_start (outputFileBrowseButton, PACK_SHRINK);
|
||||
outputFileHBox.set_spacing(4);
|
||||
v_box->pack_start (outputFileHBox, PACK_SHRINK);
|
||||
|
||||
// The Container Format Row
|
||||
containerFormatHBox.pack_start (containerFormatLabel, PACK_SHRINK);
|
||||
containerFormatHBox.pack_start (containerFormat);
|
||||
containerFormatHBox.set_spacing(4);
|
||||
v_box->pack_start (containerFormatHBox, PACK_SHRINK);
|
||||
|
||||
v_box->pack_start (audioFrame);
|
||||
v_box->pack_start (videoFrame);
|
||||
|
||||
// Configure the dialog
|
||||
v_box->set_spacing (BoxSpacing);
|
||||
set_border_width (BorderPadding);
|
||||
set_resizable (false);
|
||||
|
||||
// Configure the Cancel and Render buttons
|
||||
add_button (Stock::CANCEL, RESPONSE_CANCEL);
|
||||
|
||||
Button* render_button = add_button (Stock::OK, RESPONSE_OK);
|
||||
render_button->set_label (_("_Render"));
|
||||
render_button->set_image (renderButtonImage);
|
||||
//render_button->set_flags(Gtk::CAN_DEFAULT);
|
||||
render_button->grab_default();
|
||||
|
||||
show_all_children();
|
||||
}
|
||||
|
||||
void
|
||||
Render::on_button_browse()
|
||||
{
|
||||
FileChooserDialog dialog (*this,
|
||||
_("Select a File Name for Rendering"),
|
||||
FILE_CHOOSER_ACTION_SAVE);
|
||||
|
||||
// Add response buttons the the dialog:
|
||||
dialog.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||
dialog.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
|
||||
|
||||
int result = dialog.run();
|
||||
INFO (gui, "%d", result);
|
||||
if (result == RESPONSE_OK)
|
||||
INFO(gui, "%s", "RESPONSE_OK");
|
||||
}
|
||||
|
||||
|
||||
}} // namespace gui::dialog
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
render.hpp - Definition of the render output dialog
|
||||
RENDER.hpp - dialog to define render output
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
|
||||
|
|
@ -21,50 +21,50 @@
|
|||
*/
|
||||
|
||||
/** @file render.hpp
|
||||
** This file contains the definition of the render output dialog
|
||||
** definition of the render output dialog
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifndef RENDER_HPP
|
||||
#define RENDER_HPP
|
||||
#ifndef GUI_DIALOG_RENDER_H
|
||||
#define GUI_DIALOG_RENDER_H
|
||||
|
||||
#include "gui/gtk-lumiera.hpp"
|
||||
|
||||
|
||||
namespace gui {
|
||||
namespace dialogs {
|
||||
|
||||
/**
|
||||
* The defintion of render output dialog class
|
||||
*/
|
||||
class Render : public Gtk::Dialog
|
||||
{
|
||||
public:
|
||||
Render(Gtk::Window &parent);
|
||||
|
||||
protected:
|
||||
void on_button_browse();
|
||||
|
||||
protected:
|
||||
Gtk::HBox outputFileHBox;
|
||||
Gtk::Label outputFileLabel;
|
||||
Gtk::Entry outputFilePathEntry;
|
||||
|
||||
Gtk::Image browseButtonImage;
|
||||
Gtk::Button outputFileBrowseButton;
|
||||
|
||||
Gtk::HBox containerFormatHBox;
|
||||
Gtk::Label containerFormatLabel;
|
||||
Gtk::ComboBox containerFormat;
|
||||
|
||||
Gtk::Image renderButtonImage;
|
||||
|
||||
Gtk::Frame audioFrame;
|
||||
Gtk::Frame videoFrame;
|
||||
};
|
||||
|
||||
} // namespace dialogs
|
||||
} // namespace gui
|
||||
|
||||
#endif // RENDER_HPP
|
||||
|
||||
/**
|
||||
* A dialog to choose render output format and name
|
||||
*/
|
||||
class Render
|
||||
: public Gtk::Dialog
|
||||
{
|
||||
Gtk::HBox outputFileHBox;
|
||||
Gtk::Label outputFileLabel;
|
||||
Gtk::Entry outputFilePathEntry;
|
||||
|
||||
Gtk::Image browseButtonImage;
|
||||
Gtk::Button outputFileBrowseButton;
|
||||
|
||||
Gtk::HBox containerFormatHBox;
|
||||
Gtk::Label containerFormatLabel;
|
||||
Gtk::ComboBox containerFormat;
|
||||
|
||||
Gtk::Image renderButtonImage;
|
||||
|
||||
Gtk::Frame audioFrame;
|
||||
Gtk::Frame videoFrame;
|
||||
|
||||
public:
|
||||
Render (Gtk::Window& parent);
|
||||
|
||||
private:
|
||||
void on_button_browse();
|
||||
};
|
||||
|
||||
|
||||
}} // namespace gui::dialog
|
||||
#endif /*GUI_DIALOG_RENDER_H*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
displayer.cpp - Implements the base class for displaying video
|
||||
Displayer - base class for displaying video
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2000, Arne Schirmacher <arne@schirmacher.de>
|
||||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
* *****************************************************/
|
||||
|
||||
|
||||
#include "gui/gtk-lumiera.hpp"
|
||||
#include "gui/output/displayer.hpp"
|
||||
#include "gui/output/xvdisplayer.hpp"
|
||||
|
|
@ -29,41 +30,41 @@
|
|||
|
||||
namespace gui {
|
||||
namespace output {
|
||||
|
||||
bool
|
||||
Displayer::usable()
|
||||
|
||||
bool
|
||||
Displayer::usable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DisplayerInput
|
||||
Displayer::format()
|
||||
|
||||
DisplayerInput
|
||||
Displayer::format()
|
||||
{
|
||||
return DISPLAY_NONE;
|
||||
}
|
||||
|
||||
int
|
||||
Displayer::preferredWidth()
|
||||
|
||||
int
|
||||
Displayer::preferredWidth()
|
||||
{
|
||||
return imageWidth;
|
||||
}
|
||||
|
||||
int
|
||||
Displayer::preferredHeight()
|
||||
|
||||
int
|
||||
Displayer::preferredHeight()
|
||||
{
|
||||
return imageHeight;
|
||||
}
|
||||
|
||||
void
|
||||
Displayer::calculateVideoLayout(
|
||||
int widget_width, int widget_height,
|
||||
int image_width, int image_height,
|
||||
int &video_x, int &video_y, int &video_width, int &video_height )
|
||||
|
||||
void
|
||||
Displayer::calculateVideoLayout(
|
||||
int widget_width, int widget_height,
|
||||
int image_width, int image_height,
|
||||
int &video_x, int &video_y, int &video_width, int &video_height )
|
||||
{
|
||||
REQUIRE(widget_width >= 0);
|
||||
REQUIRE(widget_height >= 0);
|
||||
REQUIRE(image_width >= 0);
|
||||
REQUIRE(image_height >= 0);
|
||||
REQUIRE (widget_width >= 0);
|
||||
REQUIRE (widget_height >= 0);
|
||||
REQUIRE (image_width >= 0);
|
||||
REQUIRE (image_height >= 0);
|
||||
|
||||
double ratio_width = ( double ) widget_width / ( double ) image_width;
|
||||
double ratio_height = ( double ) widget_height / ( double ) image_height;
|
||||
|
|
@ -74,11 +75,11 @@ Displayer::calculateVideoLayout(
|
|||
video_x = ( widget_width - video_width ) / 2;
|
||||
video_y = ( widget_height - video_height ) / 2;
|
||||
|
||||
ENSURE(video_x >= 0 && video_x < widget_width);
|
||||
ENSURE(video_y >= 0 && video_y < widget_height);
|
||||
ENSURE(video_width <= widget_width);
|
||||
ENSURE(video_width <= widget_width);
|
||||
ENSURE (video_x >= 0 && video_x < widget_width);
|
||||
ENSURE (video_y >= 0 && video_y < widget_height);
|
||||
ENSURE (video_width <= widget_width);
|
||||
ENSURE (video_width <= widget_width);
|
||||
}
|
||||
|
||||
} // namespace output
|
||||
} // namespace gui
|
||||
|
||||
|
||||
}} // namespace gui::output
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
displayer.hpp - Defines the base class for displaying video
|
||||
DISPLAYER.hpp - base class for displaying video
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2000, Arne Schirmacher <arne@schirmacher.de>
|
||||
|
|
@ -23,111 +23,101 @@
|
|||
*/
|
||||
|
||||
/** @file displayer.hpp
|
||||
** This file contains the definition of Displayer; the base class
|
||||
** of all video display implementations
|
||||
** @see displayer.cpp
|
||||
** The Displayer serves as base of all video display implementations
|
||||
**
|
||||
*/
|
||||
|
||||
#ifndef DISPLAYER_HPP
|
||||
#define DISPLAYER_HPP
|
||||
|
||||
#ifndef GUI_OUTPUT_DISPLAYER_H
|
||||
#define GUI_OUTPUT_DISPLAYER_H
|
||||
|
||||
|
||||
namespace gui {
|
||||
namespace output {
|
||||
|
||||
/**
|
||||
* Supported Displayer formats
|
||||
*/
|
||||
typedef enum {
|
||||
DISPLAY_NONE,
|
||||
DISPLAY_YUV,
|
||||
DISPLAY_RGB,
|
||||
DISPLAY_BGR,
|
||||
DISPLAY_BGR0,
|
||||
DISPLAY_RGB16
|
||||
}
|
||||
DisplayerInput;
|
||||
|
||||
/**
|
||||
* A Displayer is a class which is responsible for rendering an image
|
||||
* in some way (ie: Xvideo, GDK, OpenGL etc).
|
||||
*
|
||||
* @remarks All Displayer classes must extend the Displayer class and
|
||||
* minimally rewrite:
|
||||
*
|
||||
* + usable() - to indicate if the object can be used,
|
||||
* + format() - to indicate what type of input the put method expects
|
||||
* + put( void * ) - deal with an image of the expected type and size
|
||||
*
|
||||
* By default, all images will be delivered to the put method in a
|
||||
* resolution of IMG_WIDTH * IMG_HEIGHT. If another size is required,
|
||||
* then the rewrite the methods:
|
||||
*
|
||||
* + preferredWidth
|
||||
* + preferredHeight
|
||||
*
|
||||
* If the widget being written to doesn't need a fixed size, then
|
||||
* rewrite the two other put methods as required.
|
||||
*/
|
||||
class Displayer
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Indicates if this object can be used to render images on the
|
||||
* running system.
|
||||
*/
|
||||
virtual bool usable();
|
||||
|
||||
/**
|
||||
* Indicates the format required by the abstract put method.
|
||||
*/
|
||||
virtual DisplayerInput format();
|
||||
|
||||
/**
|
||||
* Expected width of input to put.
|
||||
*/
|
||||
virtual int preferredWidth();
|
||||
|
||||
/**
|
||||
* Expected height of input to put.
|
||||
*/
|
||||
virtual int preferredHeight();
|
||||
|
||||
/**
|
||||
* Put an image of a given width and height with the expected input
|
||||
* format (as indicated by the format method).
|
||||
*/
|
||||
virtual void put( const void* ) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
/** Supported Displayer formats */
|
||||
enum DisplayerInput {
|
||||
DISPLAY_NONE,
|
||||
DISPLAY_YUV,
|
||||
DISPLAY_RGB,
|
||||
DISPLAY_BGR,
|
||||
DISPLAY_BGR0,
|
||||
DISPLAY_RGB16
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Calculates the coordinates for placing a video image inside a
|
||||
* widget
|
||||
* A Displayer is a class which is responsible for rendering an image
|
||||
* in some way (ie: Xvideo, GDK, OpenGL etc).
|
||||
*
|
||||
* @param[in] widget_width The width of the display widget.
|
||||
* @param[in] widget_height The height of the display widget.
|
||||
* @param[in] image_width The width of the video image.
|
||||
* @param[in] image_height The height of the video image.
|
||||
* @param[out] video_x The x-coordinate of the top left
|
||||
* corner of the scaled video image.
|
||||
* @param[out] video_y The y-coordinate of the top left
|
||||
* corner of the scaled video image.
|
||||
* @param[out] video_width The width of the scale video image.
|
||||
* @param[out] video_height The height of the scale video image.
|
||||
* @remarks All Displayer classes must extend the Displayer class and
|
||||
* minimally rewrite:
|
||||
*
|
||||
* + usable() - to indicate if the object can be used,
|
||||
* + format() - to indicate what type of input the put method expects
|
||||
* + put( void * ) - deal with an image of the expected type and size
|
||||
*
|
||||
* By default, all images will be delivered to the put method in a
|
||||
* resolution of IMG_WIDTH * IMG_HEIGHT. If another size is required,
|
||||
* then the rewrite the methods:
|
||||
*
|
||||
* + preferredWidth
|
||||
* + preferredHeight
|
||||
*
|
||||
* If the widget being written to doesn't need a fixed size, then
|
||||
* rewrite the two other put methods as required.
|
||||
*/
|
||||
static void calculateVideoLayout(
|
||||
int widget_width, int widget_height,
|
||||
int image_width, int image_height,
|
||||
int &video_x, int &video_y, int &video_width, int &video_height );
|
||||
|
||||
protected:
|
||||
int imageWidth;
|
||||
int imageHeight;
|
||||
};
|
||||
|
||||
} // namespace output
|
||||
} // namespace gui
|
||||
|
||||
#endif // DISPLAYER_HPP
|
||||
class Displayer
|
||||
{
|
||||
protected:
|
||||
int imageWidth;
|
||||
int imageHeight;
|
||||
|
||||
public:
|
||||
virtual ~Displayer() { }
|
||||
|
||||
|
||||
/** Indicates if this object can be used to render images on the running system. */
|
||||
virtual bool usable();
|
||||
|
||||
/** Indicates the format required by the abstract put method. */
|
||||
virtual DisplayerInput format();
|
||||
|
||||
/** Expected width of input to put. */
|
||||
virtual int preferredWidth();
|
||||
|
||||
/** Expected height of input to put. */
|
||||
virtual int preferredHeight();
|
||||
|
||||
/**
|
||||
* Put an image of a given width and height with the expected input
|
||||
* format (as indicated by the format method).
|
||||
*/
|
||||
virtual void put (void* const) =0;
|
||||
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Calculates the coordinates for placing a video image inside a widget
|
||||
*
|
||||
* @param[in] widget_width The width of the display widget.
|
||||
* @param[in] widget_height The height of the display widget.
|
||||
* @param[in] image_width The width of the video image.
|
||||
* @param[in] image_height The height of the video image.
|
||||
* @param[out] video_x The x-coordinate of the top left
|
||||
* corner of the scaled video image.
|
||||
* @param[out] video_y The y-coordinate of the top left
|
||||
* corner of the scaled video image.
|
||||
* @param[out] video_width The width of the scale video image.
|
||||
* @param[out] video_height The height of the scale video image.
|
||||
*/
|
||||
static void calculateVideoLayout(
|
||||
int widget_width, int widget_height,
|
||||
int image_width, int image_height,
|
||||
int &video_x, int &video_y, int &video_width, int &video_height );
|
||||
};
|
||||
|
||||
|
||||
|
||||
}} // namespace gui::output
|
||||
#endif /*GUI_OUTPUT_DISPLAYER_H*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
gdkdisplayer.cpp - Implements the class for displaying video via GDK
|
||||
GgdkDisplayer - displaying video via GDK
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2000, Arne Schirmacher <arne@schirmacher.de>
|
||||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
* *****************************************************/
|
||||
|
||||
|
||||
#include "gui/gtk-lumiera.hpp"
|
||||
#include "gui/output/gdkdisplayer.hpp"
|
||||
|
||||
|
|
@ -36,54 +37,60 @@ using std::endl;
|
|||
|
||||
namespace gui {
|
||||
namespace output {
|
||||
|
||||
GdkDisplayer::GdkDisplayer( Gtk::Widget *drawing_area, int width, int height ) :
|
||||
drawingArea( drawing_area )
|
||||
{
|
||||
REQUIRE(drawing_area != NULL);
|
||||
REQUIRE(width > 0);
|
||||
REQUIRE(height > 0);
|
||||
|
||||
imageWidth = width, imageHeight = height;
|
||||
}
|
||||
|
||||
bool
|
||||
GdkDisplayer::usable()
|
||||
{
|
||||
return false; /////////////////////////////////////////////////////////////////////////////////////////////TICKET #950 : new solution for video display
|
||||
}
|
||||
|
||||
void
|
||||
GdkDisplayer::put( const void* image )
|
||||
{
|
||||
int video_x = 0, video_y = 0, video_width = 0, video_height = 0;
|
||||
calculateVideoLayout(
|
||||
drawingArea->get_width(),
|
||||
drawingArea->get_height(),
|
||||
preferredWidth(), preferredHeight(),
|
||||
video_x, video_y, video_width, video_height );
|
||||
|
||||
GdkWindow *window = drawingArea->get_window()->gobj();
|
||||
REQUIRE(window != NULL);
|
||||
GdkDisplayer::GdkDisplayer (Gtk::Widget *drawing_area,
|
||||
int width, int height)
|
||||
: drawingArea( drawing_area )
|
||||
{
|
||||
REQUIRE (drawing_area != NULL);
|
||||
REQUIRE (width > 0);
|
||||
REQUIRE (height > 0);
|
||||
|
||||
imageWidth = width,
|
||||
imageHeight = height;
|
||||
}
|
||||
|
||||
bool
|
||||
GdkDisplayer::usable()
|
||||
{
|
||||
return false; /////////////////////////////////////////////////////////////////////////////////////////////TICKET #950 : new solution for video display
|
||||
}
|
||||
|
||||
void
|
||||
GdkDisplayer::put (void* const image)
|
||||
{
|
||||
int video_x = 0,
|
||||
video_y = 0,
|
||||
video_width = 0,
|
||||
video_height = 0;
|
||||
|
||||
#if false ///////////////////////////////////////////////////////////////////////////////////////////////////TICKET #950 : new solution for video display
|
||||
GdkGC *gc = gdk_gc_new( window );
|
||||
REQUIRE(gc != NULL);
|
||||
calculateVideoLayout(
|
||||
drawingArea->get_width(),
|
||||
drawingArea->get_height(),
|
||||
preferredWidth(), preferredHeight(),
|
||||
video_x, video_y, video_width, video_height);
|
||||
|
||||
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data( (const guchar*)image, GDK_COLORSPACE_RGB, FALSE, 8,
|
||||
preferredWidth(), preferredHeight(), preferredWidth() * 3, NULL, NULL );
|
||||
REQUIRE(pixbuf != NULL);
|
||||
GdkWindow *window = drawingArea->get_window()->gobj();
|
||||
REQUIRE (window != NULL);
|
||||
|
||||
#if false ///////////////////////////////////////////////////////////////////////////////////////////////////TICKET #950 : new solution for video display
|
||||
GdkGC *gc = gdk_gc_new( window );
|
||||
REQUIRE(gc != NULL);
|
||||
|
||||
GdkPixbuf *scaled_image = gdk_pixbuf_scale_simple( pixbuf, video_width, video_height, GDK_INTERP_NEAREST );
|
||||
REQUIRE(scaled_image != NULL);
|
||||
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data( (const guchar*)image, GDK_COLORSPACE_RGB, FALSE, 8,
|
||||
preferredWidth(), preferredHeight(), preferredWidth() * 3, NULL, NULL );
|
||||
REQUIRE(pixbuf != NULL);
|
||||
|
||||
GdkPixbuf *scaled_image = gdk_pixbuf_scale_simple( pixbuf, video_width, video_height, GDK_INTERP_NEAREST );
|
||||
REQUIRE(scaled_image != NULL);
|
||||
|
||||
gdk_draw_pixbuf( window, gc, scaled_image, 0, 0, video_x, video_y, -1, -1, GDK_RGB_DITHER_NORMAL, 0, 0 );
|
||||
|
||||
g_object_unref( scaled_image );
|
||||
g_object_unref( pixbuf );
|
||||
g_object_unref( gc );
|
||||
#endif ///////////////////////////////////////////////////////////////////////////////////////////////////TICKET #950 : new solution for video display
|
||||
}
|
||||
|
||||
gdk_draw_pixbuf( window, gc, scaled_image, 0, 0, video_x, video_y, -1, -1, GDK_RGB_DITHER_NORMAL, 0, 0 );
|
||||
|
||||
g_object_unref( scaled_image );
|
||||
g_object_unref( pixbuf );
|
||||
g_object_unref( gc );
|
||||
#endif ///////////////////////////////////////////////////////////////////////////////////////////////////TICKET #950 : new solution for video display
|
||||
}
|
||||
|
||||
} // namespace output
|
||||
} // namespace gui
|
||||
}} // namespace gui::output
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
gdkdisplayer.hpp - Defines the class for displaying video via GDK
|
||||
GDKDISPLAYER.hpp - displaying video via GDK
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2000, Arne Schirmacher <arne@schirmacher.de>
|
||||
|
|
@ -24,9 +24,9 @@
|
|||
|
||||
|
||||
/** @file gdkdisplayer.hpp
|
||||
** This file contains the definition of XvDisplayer, the XVideo
|
||||
** video output implementation
|
||||
** @see gdkdisplayer.cpp
|
||||
** Display video via GDK
|
||||
**
|
||||
** @deprecated obsolete since GTK-3
|
||||
** @see displayer.hpp
|
||||
*/
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ class GdkDisplayer
|
|||
* format (as indicated by the format method).
|
||||
* @param[in] image The video image array to draw.
|
||||
*/
|
||||
void put( const void* image );
|
||||
void put (void* const image);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
@ -94,4 +94,4 @@ class GdkDisplayer
|
|||
|
||||
|
||||
}} // namespace gui::output
|
||||
#endif // GDKDISPLAYER_HPP
|
||||
#endif /*GUI_OUTPUT_GDKDISPLAYER_H*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
xvdisplayer.cpp - Implements the base class for XVideo display
|
||||
XvDisplayer - XVideo display
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2000, Arne Schirmacher <arne@schirmacher.de>
|
||||
|
|
@ -31,199 +31,205 @@
|
|||
|
||||
namespace gui {
|
||||
namespace output {
|
||||
|
||||
XvDisplayer::XvDisplayer( Gtk::Widget *drawing_area, int width, int height ) :
|
||||
gotPort( false ),
|
||||
drawingArea( drawing_area ),
|
||||
xvImage( NULL )
|
||||
{
|
||||
REQUIRE(drawing_area != NULL);
|
||||
REQUIRE(width > 0);
|
||||
REQUIRE(height > 0);
|
||||
|
||||
INFO(gui, "Trying XVideo at %d x %d", width, height);
|
||||
|
||||
imageWidth = width, imageHeight = height;
|
||||
|
||||
shmInfo.shmaddr = NULL;
|
||||
|
||||
Glib::RefPtr<Gdk::Window> area_window = drawing_area->get_window();
|
||||
|
||||
window = GDK_WINDOW_XID (area_window->gobj());
|
||||
display = GDK_WINDOW_XDISPLAY (area_window->gobj());
|
||||
|
||||
unsigned int count;
|
||||
XvAdaptorInfo *adaptorInfo;
|
||||
|
||||
if ( XvQueryAdaptors( display, window, &count, &adaptorInfo ) == Success )
|
||||
XvDisplayer::XvDisplayer(Gtk::Widget *drawing_area,
|
||||
int width, int height)
|
||||
: gotPort(false)
|
||||
, drawingArea(drawing_area)
|
||||
, xvImage(NULL)
|
||||
{
|
||||
|
||||
INFO(gui, "XvQueryAdaptors count: %d", count);
|
||||
for ( unsigned int n = 0; gotPort == false && n < count; ++n )
|
||||
{
|
||||
// Diagnostics
|
||||
INFO(gui, "%s, %lu, %lu", adaptorInfo[ n ].name,
|
||||
adaptorInfo[ n ].base_id, adaptorInfo[ n ].num_ports - 1);
|
||||
|
||||
for ( unsigned int port = adaptorInfo[ n ].base_id;
|
||||
port < adaptorInfo[ n ].base_id + adaptorInfo[ n ].num_ports;
|
||||
port ++ )
|
||||
{
|
||||
if ( XvGrabPort( display, port, CurrentTime ) == Success )
|
||||
{
|
||||
int formats;
|
||||
XvImageFormatValues *list;
|
||||
|
||||
list = XvListImageFormats( display, port, &formats );
|
||||
|
||||
INFO(gui, "formats supported: %d", formats);
|
||||
|
||||
for ( int i = 0; i < formats; i ++ )
|
||||
{
|
||||
INFO(gui, "0x%x (%c%c%c%c) %s",
|
||||
list[ i ].id,
|
||||
( list[ i ].id ) & 0xff,
|
||||
( list[ i ].id >> 8 ) & 0xff,
|
||||
( list[ i ].id >> 16 ) & 0xff,
|
||||
( list[ i ].id >> 24 ) & 0xff,
|
||||
( list[ i ].format == XvPacked ) ? "packed" : "planar" );
|
||||
if ( list[ i ].id == 0x32595559 && !gotPort )
|
||||
gotPort = true;
|
||||
}
|
||||
|
||||
if ( !gotPort )
|
||||
{
|
||||
XvUngrabPort( display, port, CurrentTime );
|
||||
}
|
||||
else
|
||||
{
|
||||
grabbedPort = port;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( gotPort )
|
||||
{
|
||||
int num;
|
||||
unsigned int unum;
|
||||
XvEncodingInfo *enc;
|
||||
|
||||
XvQueryEncodings( display, grabbedPort, &unum, &enc );
|
||||
for ( unsigned int index = 0; index < unum; index ++ )
|
||||
{
|
||||
INFO(gui, "%d: %s, %ldx%ld rate = %d/%d", index, enc->name,
|
||||
enc->width, enc->height, enc->rate.numerator,
|
||||
enc->rate.denominator );
|
||||
}
|
||||
|
||||
XvAttribute *xvattr = XvQueryPortAttributes( display, grabbedPort, &num );
|
||||
for ( int k = 0; k < num; k++ )
|
||||
{
|
||||
if ( xvattr[k].flags & XvSettable )
|
||||
{
|
||||
if ( strcmp( xvattr[k].name, "XV_AUTOPAINT_COLORKEY") == 0 )
|
||||
{
|
||||
Atom val_atom = XInternAtom( display, xvattr[k].name, False );
|
||||
if ( XvSetPortAttribute( display, grabbedPort, val_atom, 1 ) != Success )
|
||||
NOBUG_ERROR(gui, "Couldn't set Xv attribute %s\n", xvattr[k].name);
|
||||
}
|
||||
else if ( strcmp( xvattr[k].name, "XV_COLORKEY") == 0 )
|
||||
{
|
||||
Atom val_atom = XInternAtom( display, xvattr[k].name, False );
|
||||
if ( XvSetPortAttribute( display, grabbedPort, val_atom, 0x010102 ) != Success )
|
||||
NOBUG_ERROR(gui, "Couldn't set Xv attribute %s\n", xvattr[k].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( gotPort )
|
||||
{
|
||||
XGCValues values;
|
||||
memset(&values, 0, sizeof(XGCValues));
|
||||
gc = XCreateGC( display, window, 0, NULL );
|
||||
|
||||
xvImage = ( XvImage * ) XvShmCreateImage( display, grabbedPort, 0x32595559, 0, width, height, &shmInfo );
|
||||
|
||||
shmInfo.shmid = shmget( IPC_PRIVATE, xvImage->data_size, IPC_CREAT | 0777 );
|
||||
if (shmInfo.shmid < 0) {
|
||||
perror("shmget");
|
||||
gotPort = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
shmInfo.shmaddr = ( char * ) shmat( shmInfo.shmid, 0, 0 );
|
||||
xvImage->data = shmInfo.shmaddr;
|
||||
shmInfo.readOnly = 0;
|
||||
|
||||
if ( !XShmAttach( display, &shmInfo ) )
|
||||
{
|
||||
gotPort = false;
|
||||
}
|
||||
|
||||
XSync( display, false );
|
||||
shmctl( shmInfo.shmid, IPC_RMID, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gotPort = false;
|
||||
}
|
||||
}
|
||||
|
||||
XvDisplayer::~XvDisplayer()
|
||||
{
|
||||
NOBUG_ERROR(gui, "Destroying XV Displayer");
|
||||
|
||||
if ( gotPort )
|
||||
{
|
||||
XvUngrabPort( display, grabbedPort, CurrentTime );
|
||||
}
|
||||
|
||||
if ( shmInfo.shmaddr != NULL )
|
||||
{
|
||||
XShmDetach( display, &shmInfo );
|
||||
shmctl( shmInfo.shmid, IPC_RMID, 0 );
|
||||
shmdt( shmInfo.shmaddr );
|
||||
}
|
||||
|
||||
if ( xvImage != NULL )
|
||||
XFree( xvImage );
|
||||
}
|
||||
|
||||
bool
|
||||
XvDisplayer::usable()
|
||||
{
|
||||
return gotPort;
|
||||
}
|
||||
|
||||
void
|
||||
XvDisplayer::put( const void* image )
|
||||
{
|
||||
REQUIRE(image != NULL);
|
||||
REQUIRE(drawingArea != NULL);
|
||||
|
||||
if(xvImage != NULL)
|
||||
{
|
||||
REQUIRE(display != NULL);
|
||||
REQUIRE(drawing_area != NULL);
|
||||
REQUIRE(width > 0);
|
||||
REQUIRE(height > 0);
|
||||
|
||||
int video_x = 0, video_y = 0, video_width = 0, video_height = 0;
|
||||
calculateVideoLayout(
|
||||
drawingArea->get_width(),
|
||||
drawingArea->get_height(),
|
||||
preferredWidth(), preferredHeight(),
|
||||
video_x, video_y, video_width, video_height );
|
||||
|
||||
memcpy( xvImage->data, image, xvImage->data_size );
|
||||
|
||||
XvShmPutImage( display, grabbedPort, window, gc, xvImage,
|
||||
0, 0, preferredWidth(), preferredHeight(),
|
||||
video_x, video_y, video_width, video_height, false );
|
||||
INFO(gui, "Trying XVideo at %d x %d", width, height);
|
||||
|
||||
imageWidth = width;
|
||||
imageHeight = height;
|
||||
|
||||
shmInfo.shmaddr = NULL;
|
||||
|
||||
Glib::RefPtr<Gdk::Window> area_window = drawing_area->get_window();
|
||||
|
||||
window = GDK_WINDOW_XID (area_window->gobj());
|
||||
display = GDK_WINDOW_XDISPLAY (area_window->gobj());
|
||||
|
||||
unsigned int count;
|
||||
XvAdaptorInfo* adaptorInfo;
|
||||
|
||||
if (XvQueryAdaptors (display, window, &count, &adaptorInfo) == Success)
|
||||
{
|
||||
INFO(gui, "XvQueryAdaptors count: %d", count);
|
||||
for (unsigned int n = 0; gotPort == false && n < count; ++n )
|
||||
{
|
||||
// Diagnostics
|
||||
INFO(gui, "%s, %lu, %lu", adaptorInfo[ n ].name,
|
||||
adaptorInfo[ n ].base_id, adaptorInfo[ n ].num_ports - 1);
|
||||
|
||||
for ( unsigned int port = adaptorInfo[ n ].base_id;
|
||||
port < adaptorInfo[ n ].base_id + adaptorInfo[ n ].num_ports;
|
||||
port ++ )
|
||||
{
|
||||
if ( XvGrabPort( display, port, CurrentTime ) == Success )
|
||||
{
|
||||
int formats;
|
||||
XvImageFormatValues *list;
|
||||
|
||||
list = XvListImageFormats( display, port, &formats );
|
||||
|
||||
INFO(gui, "formats supported: %d", formats);
|
||||
|
||||
for ( int i = 0; i < formats; i ++ )
|
||||
{
|
||||
INFO(gui, "0x%x (%c%c%c%c) %s",
|
||||
list[ i ].id,
|
||||
( list[ i ].id ) & 0xff,
|
||||
( list[ i ].id >> 8 ) & 0xff,
|
||||
( list[ i ].id >> 16 ) & 0xff,
|
||||
( list[ i ].id >> 24 ) & 0xff,
|
||||
( list[ i ].format == XvPacked ) ? "packed" : "planar" );
|
||||
if ( list[ i ].id == 0x32595559 && !gotPort )
|
||||
gotPort = true;
|
||||
}
|
||||
|
||||
if ( !gotPort )
|
||||
{
|
||||
XvUngrabPort( display, port, CurrentTime );
|
||||
}
|
||||
else
|
||||
{
|
||||
grabbedPort = port;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( gotPort )
|
||||
{
|
||||
int num;
|
||||
unsigned int unum;
|
||||
XvEncodingInfo *enc;
|
||||
|
||||
XvQueryEncodings( display, grabbedPort, &unum, &enc );
|
||||
for ( unsigned int index = 0; index < unum; index ++ )
|
||||
{
|
||||
INFO (gui, "%d: %s, %ldx%ld rate = %d/%d",
|
||||
index, enc->name,
|
||||
enc->width, enc->height,
|
||||
enc->rate.numerator,
|
||||
enc->rate.denominator);
|
||||
}
|
||||
|
||||
XvAttribute *xvattr = XvQueryPortAttributes (display, grabbedPort, &num);
|
||||
for (int k = 0; k < num; k++ )
|
||||
{
|
||||
if ( xvattr[k].flags & XvSettable )
|
||||
{
|
||||
if ( strcmp( xvattr[k].name, "XV_AUTOPAINT_COLORKEY") == 0 )
|
||||
{
|
||||
Atom val_atom = XInternAtom( display, xvattr[k].name, False );
|
||||
if (XvSetPortAttribute(display, grabbedPort, val_atom, 1 ) != Success )
|
||||
NOBUG_ERROR(gui, "Couldn't set Xv attribute %s\n", xvattr[k].name);
|
||||
}
|
||||
else if ( strcmp( xvattr[k].name, "XV_COLORKEY") == 0 )
|
||||
{
|
||||
Atom val_atom = XInternAtom( display, xvattr[k].name, False );
|
||||
if ( XvSetPortAttribute( display, grabbedPort, val_atom, 0x010102 ) != Success )
|
||||
NOBUG_ERROR(gui, "Couldn't set Xv attribute %s\n", xvattr[k].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gotPort)
|
||||
{
|
||||
XGCValues values;
|
||||
memset(&values, 0, sizeof(XGCValues));
|
||||
gc = XCreateGC( display, window, 0, NULL );
|
||||
|
||||
xvImage = ( XvImage * ) XvShmCreateImage( display, grabbedPort, 0x32595559, 0, width, height, &shmInfo );
|
||||
|
||||
shmInfo.shmid = shmget( IPC_PRIVATE, xvImage->data_size, IPC_CREAT | 0777 );
|
||||
if (shmInfo.shmid < 0) {
|
||||
perror("shmget");
|
||||
gotPort = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
shmInfo.shmaddr = (char *) shmat (shmInfo.shmid, 0, 0);
|
||||
xvImage->data = shmInfo.shmaddr;
|
||||
shmInfo.readOnly = 0;
|
||||
|
||||
if ( !XShmAttach( display, &shmInfo ))
|
||||
{
|
||||
gotPort = false;
|
||||
}
|
||||
|
||||
XSync( display, false );
|
||||
shmctl( shmInfo.shmid, IPC_RMID, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gotPort = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace output
|
||||
} // namespace gui
|
||||
|
||||
|
||||
XvDisplayer::~XvDisplayer()
|
||||
{
|
||||
NOBUG_ERROR(gui, "Destroying XV Displayer");
|
||||
|
||||
if ( gotPort )
|
||||
{
|
||||
XvUngrabPort( display, grabbedPort, CurrentTime );
|
||||
}
|
||||
|
||||
if ( shmInfo.shmaddr != NULL )
|
||||
{
|
||||
XShmDetach( display, &shmInfo );
|
||||
shmctl( shmInfo.shmid, IPC_RMID, 0 );
|
||||
shmdt( shmInfo.shmaddr );
|
||||
}
|
||||
|
||||
if ( xvImage != NULL )
|
||||
XFree( xvImage );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
XvDisplayer::usable()
|
||||
{
|
||||
return gotPort;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XvDisplayer::put (void* const image)
|
||||
{
|
||||
REQUIRE (image != NULL);
|
||||
REQUIRE (drawingArea != NULL);
|
||||
|
||||
if (xvImage != NULL)
|
||||
{
|
||||
REQUIRE(display != NULL);
|
||||
|
||||
int video_x = 0, video_y = 0, video_width = 0, video_height = 0;
|
||||
calculateVideoLayout(
|
||||
drawingArea->get_width(),
|
||||
drawingArea->get_height(),
|
||||
preferredWidth(), preferredHeight(),
|
||||
video_x, video_y, video_width, video_height );
|
||||
|
||||
memcpy (xvImage->data, image, xvImage->data_size);
|
||||
|
||||
XvShmPutImage (display, grabbedPort, window, gc, xvImage,
|
||||
0, 0, preferredWidth(), preferredHeight(),
|
||||
video_x, video_y, video_width, video_height, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}} // namespace gui::output
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
xvdisplayer.hpp - Defines the base class for XVideo display
|
||||
XVDISPLAYER.hpp - XVideo display
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2000, Arne Schirmacher <arne@schirmacher.de>
|
||||
|
|
@ -24,9 +24,8 @@
|
|||
|
||||
|
||||
/** @file xvdisplayer.hpp
|
||||
** This file contains the definition of XvDisplayer, the XVideo
|
||||
** video output implementation
|
||||
** @see xvdisplayer.cpp
|
||||
** Implementation of video output via XVideo
|
||||
**
|
||||
** @see displayer.hpp
|
||||
*/
|
||||
|
||||
|
|
@ -51,90 +50,85 @@ namespace Gtk {
|
|||
|
||||
namespace gui {
|
||||
namespace output {
|
||||
|
||||
/**
|
||||
* XvDisplayer is a class which is responsible for rendering a video
|
||||
* image via XVideo.
|
||||
*/
|
||||
class XvDisplayer
|
||||
: public Displayer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
* @param drawing_area The widget into which the video image will be
|
||||
* drawn. This value must not be NULL.
|
||||
* @param width The width of the video image in pixels. This value
|
||||
* must be greater than zero.
|
||||
* @param height The height of the video image in pixels. This value
|
||||
* must be greater than zero.
|
||||
*/
|
||||
XvDisplayer( Gtk::Widget *drawing_area, int width, int height );
|
||||
|
||||
|
||||
~XvDisplayer();
|
||||
|
||||
/**
|
||||
* Put an image of a given width and height with the expected input
|
||||
* format (as indicated by the format method).
|
||||
* @param[in] image The video image array to draw.
|
||||
*/
|
||||
void put( const void* image );
|
||||
|
||||
/**
|
||||
* Indicates if this object can be used to render images on the
|
||||
* running system.
|
||||
*/
|
||||
bool usable();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Specifies whether the object is currently attached to an XVideo
|
||||
* port.
|
||||
* @remarks This value is false until the constructor has finished
|
||||
* successfully.
|
||||
*/
|
||||
bool gotPort;
|
||||
|
||||
/**
|
||||
* The current port being used.
|
||||
* @remarks This value is meaningless unless gotPort is true.
|
||||
*/
|
||||
unsigned int grabbedPort;
|
||||
|
||||
/**
|
||||
* The widget that video will be drawn into.
|
||||
* @remarks This value must be a valid pointer.
|
||||
*/
|
||||
Gtk::Widget *drawingArea;
|
||||
|
||||
/**
|
||||
* The display that video will be drawn into.
|
||||
*/
|
||||
Display *display;
|
||||
|
||||
/**
|
||||
* The X11 window that video will be drawn into.
|
||||
*/
|
||||
Window window;
|
||||
|
||||
/**
|
||||
* The graphics context which will be used when rendering video.
|
||||
*/
|
||||
GC gc;
|
||||
|
||||
/**
|
||||
* The shared memory image object which video will be written into.
|
||||
*/
|
||||
XvImage *xvImage;
|
||||
|
||||
/**
|
||||
* Info about the shared memory segment.
|
||||
* @remarks shmInfo.shmaddr is set to NULL, when the SHM is detached.
|
||||
*/
|
||||
XShmSegmentInfo shmInfo;
|
||||
};
|
||||
|
||||
/**
|
||||
* XvDisplayer is a class which is responsible for rendering a video
|
||||
* image via XVideo.
|
||||
*/
|
||||
class XvDisplayer
|
||||
: public Displayer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
* @param drawing_area The widget into which the video image will be
|
||||
* drawn. This value must not be NULL.
|
||||
* @param width The width of the video image in pixels. This value
|
||||
* must be greater than zero.
|
||||
* @param height The height of the video image in pixels. This value
|
||||
* must be greater than zero.
|
||||
*/
|
||||
XvDisplayer (Gtk::Widget *drawing_area, int width, int height);
|
||||
|
||||
~XvDisplayer();
|
||||
|
||||
|
||||
/**
|
||||
* Put an image of a given width and height with the expected input
|
||||
* format (as indicated by the format method).
|
||||
* @param[in] image The video image array to draw.
|
||||
*/
|
||||
void put (void* const image);
|
||||
|
||||
/** Indicates if this object can be used to render images on the running system. */
|
||||
bool usable();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Specifies whether the object is currently attached to an XVideo port.
|
||||
* @remarks This value is false until the constructor has finished successfully.
|
||||
*/
|
||||
bool gotPort;
|
||||
|
||||
/**
|
||||
* The current port being used.
|
||||
* @remarks This value is meaningless unless gotPort is true.
|
||||
*/
|
||||
unsigned int grabbedPort;
|
||||
|
||||
/**
|
||||
* The widget that video will be drawn into.
|
||||
* @remarks This value must be a valid pointer.
|
||||
*/
|
||||
Gtk::Widget *drawingArea;
|
||||
|
||||
/**
|
||||
* The display that video will be drawn into.
|
||||
*/
|
||||
Display *display;
|
||||
|
||||
/**
|
||||
* The X11 window that video will be drawn into.
|
||||
*/
|
||||
Window window;
|
||||
|
||||
/**
|
||||
* The graphics context which will be used when rendering video.
|
||||
*/
|
||||
GC gc;
|
||||
|
||||
/**
|
||||
* The shared memory image object which video will be written into.
|
||||
*/
|
||||
XvImage *xvImage;
|
||||
|
||||
/**
|
||||
* Info about the shared memory segment.
|
||||
* @remarks shmInfo.shmaddr is set to NULL, when the SHM is detached.
|
||||
*/
|
||||
XShmSegmentInfo shmInfo;
|
||||
};
|
||||
|
||||
|
||||
}} // namespace gui::output
|
||||
|
|
|
|||
Loading…
Reference in a new issue