mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-17 20:26:30 +01:00
pixbufs instead of pixmaps; function-scope local fd's for reading from a FileSource
git-svn-id: svn://localhost/trunk/ardour2@395 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
ee873ee896
commit
4d2afdd0f7
12 changed files with 138 additions and 149 deletions
|
|
@ -36,7 +36,6 @@
|
||||||
#include <pbd/pathscanner.h>
|
#include <pbd/pathscanner.h>
|
||||||
#include <pbd/failed_constructor.h>
|
#include <pbd/failed_constructor.h>
|
||||||
#include <gtkmm2ext/gtk_ui.h>
|
#include <gtkmm2ext/gtk_ui.h>
|
||||||
#include <gtkmm2ext/pix.h>
|
|
||||||
#include <gtkmm2ext/utils.h>
|
#include <gtkmm2ext/utils.h>
|
||||||
#include <gtkmm2ext/click_box.h>
|
#include <gtkmm2ext/click_box.h>
|
||||||
#include <gtkmm2ext/fastmeter.h>
|
#include <gtkmm2ext/fastmeter.h>
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@
|
||||||
#include <pbd/error.h>
|
#include <pbd/error.h>
|
||||||
#include <pbd/basename.h>
|
#include <pbd/basename.h>
|
||||||
#include <pbd/fastlog.h>
|
#include <pbd/fastlog.h>
|
||||||
#include <gtkmm2ext/pix.h>
|
|
||||||
#include <gtkmm2ext/utils.h>
|
#include <gtkmm2ext/utils.h>
|
||||||
#include <gtkmm2ext/click_box.h>
|
#include <gtkmm2ext/click_box.h>
|
||||||
#include <gtkmm2ext/tearoff.h>
|
#include <gtkmm2ext/tearoff.h>
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@
|
||||||
#include <ardour/dB.h>
|
#include <ardour/dB.h>
|
||||||
|
|
||||||
#include <gtkmm2ext/utils.h>
|
#include <gtkmm2ext/utils.h>
|
||||||
#include <gtkmm2ext/pix.h>
|
|
||||||
#include <gtkmm2ext/fastmeter.h>
|
#include <gtkmm2ext/fastmeter.h>
|
||||||
#include <gtkmm2ext/stop_signal.h>
|
#include <gtkmm2ext/stop_signal.h>
|
||||||
#include <gtkmm2ext/barcontroller.h>
|
#include <gtkmm2ext/barcontroller.h>
|
||||||
|
|
@ -55,18 +54,27 @@ using namespace std;
|
||||||
|
|
||||||
sigc::signal<void> GainMeter::ResetAllPeakDisplays;
|
sigc::signal<void> GainMeter::ResetAllPeakDisplays;
|
||||||
sigc::signal<void,RouteGroup*> GainMeter::ResetGroupPeakDisplays;
|
sigc::signal<void,RouteGroup*> GainMeter::ResetGroupPeakDisplays;
|
||||||
Pix* GainMeter::slider_pix = 0;
|
Glib::RefPtr<Gdk::Pixbuf> GainMeter::slider;
|
||||||
|
Glib::RefPtr<Gdk::Pixbuf> GainMeter::rail;
|
||||||
map<string,Glib::RefPtr<Gdk::Pixmap> > GainMeter::metric_pixmaps;
|
map<string,Glib::RefPtr<Gdk::Pixmap> > GainMeter::metric_pixmaps;
|
||||||
|
|
||||||
int
|
int
|
||||||
GainMeter::setup_slider_pix ()
|
GainMeter::setup_slider_pix ()
|
||||||
{
|
{
|
||||||
if ((slider_pix = get_pix (ARDOUR::find_data_file("pixmaps"), "vslider02", false)) == 0) {
|
string path = ARDOUR::find_data_file("vslider02_slider.xpm", "pixmaps");
|
||||||
error << _("Cannot create slider pixmaps") << endmsg;
|
if (path.empty()) {
|
||||||
|
error << _("cannot find images for fader slider") << endmsg;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
slider = Gdk::Pixbuf::create_from_file (path);
|
||||||
|
|
||||||
|
path = ARDOUR::find_data_file("vslider02_rail.xpm", "pixmaps");
|
||||||
|
if (path.empty()) {
|
||||||
|
error << _("cannot find images for fader rail") << endmsg;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
rail = Gdk::Pixbuf::create_from_file (path);
|
||||||
|
|
||||||
slider_pix->ref ();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,14 +103,14 @@ GainMeter::GainMeter (IO& io, Session& s)
|
||||||
top_table (1, 2)
|
top_table (1, 2)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (slider_pix == 0) {
|
if (slider == 0) {
|
||||||
setup_slider_pix ();
|
setup_slider_pix ();
|
||||||
}
|
}
|
||||||
|
|
||||||
ignore_toggle = false;
|
ignore_toggle = false;
|
||||||
meter_menu = 0;
|
meter_menu = 0;
|
||||||
|
|
||||||
gain_slider = manage (new VSliderController (slider_pix,
|
gain_slider = manage (new VSliderController (slider, rail,
|
||||||
&gain_adjustment,
|
&gain_adjustment,
|
||||||
& _io.midi_gain_control(),
|
& _io.midi_gain_control(),
|
||||||
false));
|
false));
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,6 @@ namespace ARDOUR {
|
||||||
namespace Gtkmm2ext {
|
namespace Gtkmm2ext {
|
||||||
class FastMeter;
|
class FastMeter;
|
||||||
class BarController;
|
class BarController;
|
||||||
class Pix;
|
|
||||||
}
|
}
|
||||||
namespace Gtk {
|
namespace Gtk {
|
||||||
class Menu;
|
class Menu;
|
||||||
|
|
@ -161,7 +160,8 @@ class GainMeter : public Gtk::VBox
|
||||||
static sigc::signal<void> ResetAllPeakDisplays;
|
static sigc::signal<void> ResetAllPeakDisplays;
|
||||||
static sigc::signal<void,ARDOUR::RouteGroup*> ResetGroupPeakDisplays;
|
static sigc::signal<void,ARDOUR::RouteGroup*> ResetGroupPeakDisplays;
|
||||||
|
|
||||||
static Gtkmm2ext::Pix* slider_pix;
|
static Glib::RefPtr<Gdk::Pixbuf> slider;
|
||||||
|
static Glib::RefPtr<Gdk::Pixbuf> rail;
|
||||||
static int setup_slider_pix ();
|
static int setup_slider_pix ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -740,7 +740,7 @@ FileSource::read_header (bool silent)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (::pread (fd, &header.data, sizeof (header.data), info->offset) != sizeof (header.data)) {
|
if (::pread64 (fd, &header.data, sizeof (header.data), info->offset) != sizeof (header.data)) {
|
||||||
error << _("FileSource: can't read data chunk") << endmsg;
|
error << _("FileSource: can't read data chunk") << endmsg;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -757,7 +757,7 @@ FileSource::read_broadcast_data (ChunkInfo& info)
|
||||||
{
|
{
|
||||||
int32_t coding_history_size;
|
int32_t coding_history_size;
|
||||||
|
|
||||||
if (::pread (fd, (char *) &header.bext, sizeof (header.bext), info.offset + sizeof (GenericChunk)) != sizeof (header.bext)) {
|
if (::pread64 (fd, (char *) &header.bext, sizeof (header.bext), info.offset + sizeof (GenericChunk)) != sizeof (header.bext)) {
|
||||||
error << string_compose(_("FileSource: cannot read Broadcast Wave data from existing audio file \"%1\" (%2)"),
|
error << string_compose(_("FileSource: cannot read Broadcast Wave data from existing audio file \"%1\" (%2)"),
|
||||||
_path, strerror (errno)) << endmsg;
|
_path, strerror (errno)) << endmsg;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -773,7 +773,7 @@ FileSource::read_broadcast_data (ChunkInfo& info)
|
||||||
|
|
||||||
char data[coding_history_size];
|
char data[coding_history_size];
|
||||||
|
|
||||||
if (::pread (fd, data, coding_history_size, info.offset + sizeof (BroadcastChunk)) != coding_history_size) {
|
if (::pread64 (fd, data, coding_history_size, info.offset + sizeof (BroadcastChunk)) != coding_history_size) {
|
||||||
error << string_compose(_("FileSource: cannot read Broadcast Wave coding history from audio file \"%1\" (%2)"),
|
error << string_compose(_("FileSource: cannot read Broadcast Wave coding history from audio file \"%1\" (%2)"),
|
||||||
_path, strerror (errno)) << endmsg;
|
_path, strerror (errno)) << endmsg;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -1076,8 +1076,19 @@ FileSource::read_float (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, c
|
||||||
{
|
{
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
ssize_t byte_cnt = (ssize_t) cnt * sizeof (Sample);
|
ssize_t byte_cnt = (ssize_t) cnt * sizeof (Sample);
|
||||||
|
int readfd;
|
||||||
|
|
||||||
if ((nread = pread (fd, (char *) dst, byte_cnt, data_offset + (start * _sample_size))) != byte_cnt) {
|
/* open, read, close */
|
||||||
|
|
||||||
|
if ((readfd = open64 (_path.c_str(), O_RDONLY)) < 0) {
|
||||||
|
error << string_compose(_("FileSource: could not open \"%1\": (%2)"), _path, strerror (errno)) << endmsg;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nread = ::pread64 (readfd, (char *) dst, byte_cnt, data_offset + (start * _sample_size));
|
||||||
|
close (readfd);
|
||||||
|
|
||||||
|
if (nread != byte_cnt) {
|
||||||
|
|
||||||
cerr << "FileSource: \""
|
cerr << "FileSource: \""
|
||||||
<< _path
|
<< _path
|
||||||
|
|
@ -1102,8 +1113,7 @@ FileSource::read_float (Sample *dst, jack_nframes_t start, jack_nframes_t cnt, c
|
||||||
|
|
||||||
if (nread > 0) {
|
if (nread > 0) {
|
||||||
return nread / _sample_size;
|
return nread / _sample_size;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return nread;
|
return nread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1149,8 +1159,19 @@ FileSource::read_pcm_24 (Sample *dst, jack_nframes_t start, jack_nframes_t cnt,
|
||||||
{
|
{
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
ssize_t byte_cnt = (ssize_t) cnt * _sample_size;
|
ssize_t byte_cnt = (ssize_t) cnt * _sample_size;
|
||||||
|
int readfd;
|
||||||
|
|
||||||
if ((nread = pread (fd, (char *) workbuf, byte_cnt, data_offset + (start * _sample_size))) != byte_cnt) {
|
/* open, read, close */
|
||||||
|
|
||||||
|
if ((readfd = open64 (_path.c_str(), O_RDONLY)) < 0) {
|
||||||
|
error << string_compose(_("FileSource: could not open \"%1\": (%2)"), _path, strerror (errno)) << endmsg;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nread = ::pread64 (readfd, (char *) workbuf, byte_cnt, data_offset + (start * _sample_size));
|
||||||
|
close (readfd);
|
||||||
|
|
||||||
|
if (nread != byte_cnt) {
|
||||||
|
|
||||||
cerr << "May be OK - FileSource: \""
|
cerr << "May be OK - FileSource: \""
|
||||||
<< _path
|
<< _path
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,6 @@ fastmeter.cc
|
||||||
gtk_ui.cc
|
gtk_ui.cc
|
||||||
hexentry.cc
|
hexentry.cc
|
||||||
idle_adjustment.cc
|
idle_adjustment.cc
|
||||||
pix.cc
|
|
||||||
pixscroller.cc
|
pixscroller.cc
|
||||||
popup.cc
|
popup.cc
|
||||||
prompter.cc
|
prompter.cc
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,11 @@ using namespace std;
|
||||||
|
|
||||||
string FastMeter::v_image_path;
|
string FastMeter::v_image_path;
|
||||||
string FastMeter::h_image_path;
|
string FastMeter::h_image_path;
|
||||||
RefPtr<Pixmap> FastMeter::v_pixmap;
|
RefPtr<Pixbuf> FastMeter::v_pixbuf;
|
||||||
RefPtr<Bitmap> FastMeter::v_mask;
|
|
||||||
gint FastMeter::v_pixheight = 0;
|
gint FastMeter::v_pixheight = 0;
|
||||||
gint FastMeter::v_pixwidth = 0;
|
gint FastMeter::v_pixwidth = 0;
|
||||||
|
|
||||||
RefPtr<Pixmap> FastMeter::h_pixmap;
|
RefPtr<Pixbuf> FastMeter::h_pixbuf;
|
||||||
RefPtr<Bitmap> FastMeter::h_mask;
|
|
||||||
gint FastMeter::h_pixheight = 0;
|
gint FastMeter::h_pixheight = 0;
|
||||||
gint FastMeter::h_pixwidth = 0;
|
gint FastMeter::h_pixwidth = 0;
|
||||||
|
|
||||||
|
|
@ -58,54 +56,32 @@ FastMeter::FastMeter (long hold, unsigned long dimen, Orientation o)
|
||||||
pixrect.x = 0;
|
pixrect.x = 0;
|
||||||
pixrect.y = 0;
|
pixrect.y = 0;
|
||||||
|
|
||||||
request_width = dimen;
|
if (!v_image_path.empty() && v_pixbuf == 0) {
|
||||||
request_height = dimen;
|
v_pixbuf = Pixbuf::create_from_file (v_image_path);
|
||||||
}
|
v_pixheight = v_pixbuf->get_height();
|
||||||
|
v_pixwidth = v_pixbuf->get_width();
|
||||||
FastMeter::~FastMeter ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
FastMeter::on_realize ()
|
|
||||||
{
|
|
||||||
DrawingArea::on_realize ();
|
|
||||||
|
|
||||||
Glib::RefPtr<Gdk::Drawable> drawable = Glib::RefPtr<Gdk::Window>::cast_dynamic (get_window());
|
|
||||||
Gdk::Color transparent;
|
|
||||||
|
|
||||||
if (!v_image_path.empty() && v_pixmap == 0) {
|
|
||||||
gint w, h;
|
|
||||||
|
|
||||||
v_pixmap = Pixmap::create_from_xpm (drawable, Colormap::get_system(), v_mask, transparent, v_image_path);
|
|
||||||
v_pixmap->get_size(w, h);
|
|
||||||
|
|
||||||
v_pixheight = h;
|
|
||||||
v_pixwidth = w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!h_image_path.empty() && h_pixmap == 0) {
|
if (!h_image_path.empty() && h_pixbuf == 0) {
|
||||||
gint w, h;
|
h_pixbuf = Pixbuf::create_from_file (h_image_path);
|
||||||
|
h_pixheight = h_pixbuf->get_height();
|
||||||
h_pixmap = Pixmap::create_from_xpm (drawable, Colormap::get_system(), h_mask, transparent, h_image_path);
|
h_pixwidth = h_pixbuf->get_width();
|
||||||
h_pixmap->get_size(w, h);
|
|
||||||
|
|
||||||
h_pixheight = h;
|
|
||||||
h_pixwidth = w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orientation == Vertical) {
|
if (orientation == Vertical) {
|
||||||
pixrect.width = min (v_pixwidth, request_width);
|
pixrect.width = min (v_pixwidth, (gint) dimen);
|
||||||
pixrect.height = v_pixheight;
|
pixrect.height = v_pixheight;
|
||||||
} else {
|
} else {
|
||||||
pixrect.width = h_pixwidth;
|
pixrect.width = h_pixwidth;
|
||||||
pixrect.height = min (h_pixheight, request_height);
|
pixrect.height = min (h_pixheight, (gint) dimen);
|
||||||
}
|
}
|
||||||
|
|
||||||
request_width = pixrect.width;
|
request_width = pixrect.width;
|
||||||
request_height= pixrect.height;
|
request_height= pixrect.height;
|
||||||
|
}
|
||||||
|
|
||||||
set_size_request (request_width, request_height);
|
FastMeter::~FastMeter ()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -177,19 +153,21 @@ FastMeter::vertical_expose (GdkEventExpose* ev)
|
||||||
/* draw the part of the meter image that we need. the area we draw is bounded "in reverse" (top->bottom)
|
/* draw the part of the meter image that we need. the area we draw is bounded "in reverse" (top->bottom)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
get_window()->draw_drawable(get_style()->get_fg_gc(get_state()), v_pixmap,
|
get_window()->draw_pixbuf(get_style()->get_fg_gc(get_state()), v_pixbuf,
|
||||||
intersection.x, v_pixheight - top_of_meter,
|
intersection.x, v_pixheight - top_of_meter,
|
||||||
intersection.x, v_pixheight - top_of_meter,
|
intersection.x, v_pixheight - top_of_meter,
|
||||||
intersection.width, intersection.height);
|
intersection.width, intersection.height,
|
||||||
|
Gdk::RGB_DITHER_NONE, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw peak bar */
|
/* draw peak bar */
|
||||||
|
|
||||||
if (hold_state) {
|
if (hold_state) {
|
||||||
get_window()->draw_drawable(get_style()->get_fg_gc(get_state()), v_pixmap,
|
get_window()->draw_pixbuf (get_style()->get_fg_gc(get_state()), v_pixbuf,
|
||||||
intersection.x, v_pixheight - (gint) floor (v_pixheight * current_peak),
|
intersection.x, v_pixheight - (gint) floor (v_pixheight * current_peak),
|
||||||
intersection.x, v_pixheight - (gint) floor (v_pixheight * current_peak),
|
intersection.x, v_pixheight - (gint) floor (v_pixheight * current_peak),
|
||||||
intersection.width, 3);
|
intersection.width, 3,
|
||||||
|
Gdk::RGB_DITHER_NONE, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -209,19 +187,23 @@ FastMeter::horizontal_expose (GdkEventExpose* ev)
|
||||||
/* draw the part of the meter image that we need.
|
/* draw the part of the meter image that we need.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
get_window()->draw_drawable(get_style()->get_fg_gc(get_state()), h_pixmap,
|
get_window()->draw_pixbuf (get_style()->get_fg_gc(get_state()), h_pixbuf,
|
||||||
intersection.x, intersection.y,
|
intersection.x, intersection.y,
|
||||||
intersection.x, intersection.y,
|
intersection.x, intersection.y,
|
||||||
intersection.width, intersection.height);
|
intersection.width, intersection.height,
|
||||||
|
Gdk::RGB_DITHER_NONE, 0, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw peak bar */
|
/* draw peak bar */
|
||||||
|
|
||||||
if (hold_state) {
|
if (hold_state) {
|
||||||
get_window()->draw_drawable(get_style()->get_fg_gc(get_state()), h_pixmap,
|
get_window()->draw_pixbuf (get_style()->get_fg_gc(get_state()), h_pixbuf,
|
||||||
right_of_meter, intersection.y,
|
right_of_meter, intersection.y,
|
||||||
right_of_meter, intersection.y,
|
right_of_meter, intersection.y,
|
||||||
3, intersection.height);
|
3, intersection.height,
|
||||||
|
Gdk::RGB_DITHER_NONE, 0, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#define __gtkmm2ext_fastmeter_h__
|
#define __gtkmm2ext_fastmeter_h__
|
||||||
|
|
||||||
#include <gtkmm/drawingarea.h>
|
#include <gtkmm/drawingarea.h>
|
||||||
#include <gdkmm/pixmap.h>
|
#include <gdkmm/pixbuf.h>
|
||||||
|
|
||||||
namespace Gtkmm2ext {
|
namespace Gtkmm2ext {
|
||||||
|
|
||||||
|
|
@ -52,23 +52,19 @@ class FastMeter : public Gtk::DrawingArea {
|
||||||
protected:
|
protected:
|
||||||
bool on_expose_event (GdkEventExpose*);
|
bool on_expose_event (GdkEventExpose*);
|
||||||
void on_size_request (GtkRequisition*);
|
void on_size_request (GtkRequisition*);
|
||||||
void on_realize ();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::string h_image_path;
|
static std::string h_image_path;
|
||||||
static std::string v_image_path;
|
static std::string v_image_path;
|
||||||
static Glib::RefPtr<Gdk::Pixmap> h_pixmap;
|
static Glib::RefPtr<Gdk::Pixbuf> h_pixbuf;
|
||||||
static Glib::RefPtr<Gdk::Bitmap> h_mask;
|
|
||||||
static gint h_pixheight;
|
static gint h_pixheight;
|
||||||
static gint h_pixwidth;
|
static gint h_pixwidth;
|
||||||
|
|
||||||
static Glib::RefPtr<Gdk::Pixmap> v_pixmap;
|
static Glib::RefPtr<Gdk::Pixbuf> v_pixbuf;
|
||||||
static Glib::RefPtr<Gdk::Bitmap> v_mask;
|
|
||||||
static gint v_pixheight;
|
static gint v_pixheight;
|
||||||
static gint v_pixwidth;
|
static gint v_pixwidth;
|
||||||
|
|
||||||
Orientation orientation;
|
Orientation orientation;
|
||||||
Glib::RefPtr<Gdk::Pixmap> backing;
|
|
||||||
GdkRectangle pixrect;
|
GdkRectangle pixrect;
|
||||||
gint request_width;
|
gint request_width;
|
||||||
gint request_height;
|
gint request_height;
|
||||||
|
|
|
||||||
|
|
@ -5,33 +5,27 @@
|
||||||
#include <gtkmm/adjustment.h>
|
#include <gtkmm/adjustment.h>
|
||||||
#include <gdkmm.h>
|
#include <gdkmm.h>
|
||||||
|
|
||||||
#include <gtkmm2ext/pix.h>
|
|
||||||
|
|
||||||
namespace Gtkmm2ext {
|
namespace Gtkmm2ext {
|
||||||
|
|
||||||
class PixScroller : public Gtk::DrawingArea
|
class PixScroller : public Gtk::DrawingArea
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PixScroller(Gtk::Adjustment& adjustment, Pix&);
|
PixScroller(Gtk::Adjustment& adjustment,
|
||||||
|
Glib::RefPtr<Gdk::Pixbuf> slider,
|
||||||
|
Glib::RefPtr<Gdk::Pixbuf> rail);
|
||||||
|
|
||||||
bool on_expose_event (GdkEventExpose*);
|
bool on_expose_event (GdkEventExpose*);
|
||||||
bool on_motion_notify_event (GdkEventMotion*);
|
bool on_motion_notify_event (GdkEventMotion*);
|
||||||
bool on_button_press_event (GdkEventButton*);
|
bool on_button_press_event (GdkEventButton*);
|
||||||
bool on_button_release_event (GdkEventButton*);
|
bool on_button_release_event (GdkEventButton*);
|
||||||
void on_size_request (GtkRequisition*);
|
void on_size_request (GtkRequisition*);
|
||||||
void on_realize ();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Gtk::Adjustment& adj;
|
Gtk::Adjustment& adj;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Pix& pix;
|
Glib::RefPtr<Gdk::Pixbuf> rail;
|
||||||
|
Glib::RefPtr<Gdk::Pixbuf> slider;
|
||||||
Glib::RefPtr<Gdk::Pixmap> rail;
|
|
||||||
Glib::RefPtr<Gdk::Pixmap> slider;
|
|
||||||
Glib::RefPtr<Gdk::Bitmap> rail_mask;
|
|
||||||
Glib::RefPtr<Gdk::Bitmap> slider_mask;
|
|
||||||
Gdk::Rectangle sliderrect;
|
Gdk::Rectangle sliderrect;
|
||||||
Gdk::Rectangle railrect;
|
Gdk::Rectangle railrect;
|
||||||
GdkWindow* grab_window;
|
GdkWindow* grab_window;
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@ namespace Gtkmm2ext {
|
||||||
class SliderController : public Gtkmm2ext::PixScroller
|
class SliderController : public Gtkmm2ext::PixScroller
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SliderController (Gtkmm2ext::Pix* pixset,
|
SliderController (Glib::RefPtr<Gdk::Pixbuf> slider,
|
||||||
|
Glib::RefPtr<Gdk::Pixbuf> rail,
|
||||||
Gtk::Adjustment* adj,
|
Gtk::Adjustment* adj,
|
||||||
MIDI::Controllable*,
|
MIDI::Controllable*,
|
||||||
bool with_numeric = true);
|
bool with_numeric = true);
|
||||||
|
|
@ -57,6 +58,8 @@ class SliderController : public Gtkmm2ext::PixScroller
|
||||||
Gtk::SpinButton & get_spin_button () { return spin; }
|
Gtk::SpinButton & get_spin_button () { return spin; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Glib::RefPtr<Gdk::Pixbuf> slider;
|
||||||
|
Glib::RefPtr<Gdk::Pixbuf> rail;
|
||||||
Gtk::SpinButton spin;
|
Gtk::SpinButton spin;
|
||||||
Gtk::Frame spin_frame;
|
Gtk::Frame spin_frame;
|
||||||
Gtk::HBox spin_hbox;
|
Gtk::HBox spin_hbox;
|
||||||
|
|
@ -77,7 +80,8 @@ class SliderController : public Gtkmm2ext::PixScroller
|
||||||
class VSliderController : public SliderController
|
class VSliderController : public SliderController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VSliderController (Gtkmm2ext::Pix *pixset,
|
VSliderController (Glib::RefPtr<Gdk::Pixbuf> slider,
|
||||||
|
Glib::RefPtr<Gdk::Pixbuf> rail,
|
||||||
Gtk::Adjustment *adj,
|
Gtk::Adjustment *adj,
|
||||||
MIDI::Controllable *,
|
MIDI::Controllable *,
|
||||||
bool with_numeric = true);
|
bool with_numeric = true);
|
||||||
|
|
@ -86,7 +90,8 @@ class VSliderController : public SliderController
|
||||||
class HSliderController : public SliderController
|
class HSliderController : public SliderController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HSliderController (Gtkmm2ext::Pix *pixset,
|
HSliderController (Glib::RefPtr<Gdk::Pixbuf> slider,
|
||||||
|
Glib::RefPtr<Gdk::Pixbuf> rail,
|
||||||
Gtk::Adjustment *adj,
|
Gtk::Adjustment *adj,
|
||||||
MIDI::Controllable *,
|
MIDI::Controllable *,
|
||||||
bool with_numeric = true);
|
bool with_numeric = true);
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,12 @@ using namespace std;
|
||||||
using namespace Gtk;
|
using namespace Gtk;
|
||||||
using namespace Gtkmm2ext;
|
using namespace Gtkmm2ext;
|
||||||
|
|
||||||
PixScroller::PixScroller (Adjustment& a, Pix& p)
|
PixScroller::PixScroller (Adjustment& a,
|
||||||
|
Glib::RefPtr<Gdk::Pixbuf> s,
|
||||||
|
Glib::RefPtr<Gdk::Pixbuf> r)
|
||||||
: adj (a),
|
: adj (a),
|
||||||
pix (p)
|
rail (r),
|
||||||
|
slider (s)
|
||||||
{
|
{
|
||||||
dragging = false;
|
dragging = false;
|
||||||
add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK|Gdk::SCROLL_MASK);
|
add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK|Gdk::SCROLL_MASK);
|
||||||
|
|
@ -39,30 +42,10 @@ PixScroller::PixScroller (Adjustment& a, Pix& p)
|
||||||
adj.signal_value_changed().connect (mem_fun (*this, &PixScroller::adjustment_changed));
|
adj.signal_value_changed().connect (mem_fun (*this, &PixScroller::adjustment_changed));
|
||||||
default_value = adj.get_value();
|
default_value = adj.get_value();
|
||||||
|
|
||||||
}
|
sliderrect.set_width(slider->get_width());
|
||||||
|
sliderrect.set_height(slider->get_height());
|
||||||
void
|
railrect.set_width(rail->get_width());
|
||||||
PixScroller::on_realize ()
|
railrect.set_height(rail->get_height());
|
||||||
{
|
|
||||||
DrawingArea::on_realize ();
|
|
||||||
|
|
||||||
Glib::RefPtr<Gdk::Drawable> drawable = Glib::RefPtr<Gdk::Window>::cast_dynamic (get_window());
|
|
||||||
|
|
||||||
pix.generate (drawable);
|
|
||||||
|
|
||||||
rail = *(pix.pixmap (0));
|
|
||||||
rail_mask = *(pix.shape_mask (0));
|
|
||||||
slider = *(pix.pixmap (1));
|
|
||||||
slider_mask = *(pix.shape_mask (1));
|
|
||||||
|
|
||||||
int w, h;
|
|
||||||
|
|
||||||
slider->get_size (w, h);
|
|
||||||
sliderrect.set_width(w);
|
|
||||||
sliderrect.set_height(h);
|
|
||||||
rail->get_size (w, h);
|
|
||||||
railrect.set_width(w);
|
|
||||||
railrect.set_height(h);
|
|
||||||
|
|
||||||
railrect.set_y(sliderrect.get_height() / 2);
|
railrect.set_y(sliderrect.get_height() / 2);
|
||||||
sliderrect.set_x(0);
|
sliderrect.set_x(0);
|
||||||
|
|
@ -71,8 +54,6 @@ PixScroller::on_realize ()
|
||||||
|
|
||||||
sliderrect.set_y((int) rint ((overall_height - sliderrect.get_height()) * (adj.get_upper() - adj.get_value())));
|
sliderrect.set_y((int) rint ((overall_height - sliderrect.get_height()) * (adj.get_upper() - adj.get_value())));
|
||||||
railrect.set_x((sliderrect.get_width() / 2) - 2);
|
railrect.set_x((sliderrect.get_width() / 2) - 2);
|
||||||
|
|
||||||
set_size_request (sliderrect.get_width(), overall_height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -96,32 +77,34 @@ PixScroller::on_expose_event (GdkEventExpose* ev)
|
||||||
|
|
||||||
if (gdk_rectangle_intersect (railrect.gobj(), &ev->area, &intersect)) {
|
if (gdk_rectangle_intersect (railrect.gobj(), &ev->area, &intersect)) {
|
||||||
Glib::RefPtr<Gdk::GC> gc(get_style()->get_bg_gc(get_state()));
|
Glib::RefPtr<Gdk::GC> gc(get_style()->get_bg_gc(get_state()));
|
||||||
win->draw_drawable (gc, rail,
|
win->draw_pixbuf (gc, rail,
|
||||||
intersect.x - railrect.get_x(),
|
intersect.x - railrect.get_x(),
|
||||||
intersect.y - railrect.get_y(),
|
intersect.y - railrect.get_y(),
|
||||||
intersect.x,
|
intersect.x,
|
||||||
intersect.y,
|
intersect.y,
|
||||||
intersect.width,
|
intersect.width,
|
||||||
intersect.height);
|
intersect.height,
|
||||||
|
Gdk::RGB_DITHER_NONE, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gdk_rectangle_intersect (sliderrect.gobj(), &ev->area, &intersect)) {
|
if (gdk_rectangle_intersect (sliderrect.gobj(), &ev->area, &intersect)) {
|
||||||
Glib::RefPtr<Gdk::GC> gc(get_style()->get_fg_gc(get_state()));
|
Glib::RefPtr<Gdk::GC> gc(get_style()->get_fg_gc(get_state()));
|
||||||
Glib::RefPtr<Gdk::Bitmap> mask (slider_mask);
|
// Glib::RefPtr<Gdk::Bitmap> mask (slider_mask);
|
||||||
|
|
||||||
GdkGCValues values;
|
GdkGCValues values;
|
||||||
gdk_gc_get_values(gc->gobj(), &values);
|
gdk_gc_get_values(gc->gobj(), &values);
|
||||||
gc->set_clip_origin (sliderrect.get_x(), sliderrect.get_y());
|
gc->set_clip_origin (sliderrect.get_x(), sliderrect.get_y());
|
||||||
gc->set_clip_mask (mask);
|
// gc->set_clip_mask (mask);
|
||||||
win->draw_drawable (gc, slider,
|
win->draw_pixbuf (gc, slider,
|
||||||
intersect.x - sliderrect.get_x(),
|
intersect.x - sliderrect.get_x(),
|
||||||
intersect.y - sliderrect.get_y(),
|
intersect.y - sliderrect.get_y(),
|
||||||
intersect.x,
|
intersect.x,
|
||||||
intersect.y,
|
intersect.y,
|
||||||
intersect.width,
|
intersect.width,
|
||||||
intersect.height);
|
intersect.height,
|
||||||
|
Gdk::RGB_DITHER_NONE, 0, 0);
|
||||||
gc->set_clip_origin (values.clip_x_origin, values.clip_y_origin);
|
gc->set_clip_origin (values.clip_x_origin, values.clip_y_origin);
|
||||||
gdk_gc_set_clip_mask (gc->gobj(), values.clip_mask);
|
// gdk_gc_set_clip_mask (gc->gobj(), values.clip_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,18 +24,19 @@
|
||||||
|
|
||||||
#include <gtkmm2ext/gtk_ui.h>
|
#include <gtkmm2ext/gtk_ui.h>
|
||||||
#include <gtkmm2ext/slider_controller.h>
|
#include <gtkmm2ext/slider_controller.h>
|
||||||
#include <gtkmm2ext/pix.h>
|
#include <gtkmm2ext/pixscroller.h>
|
||||||
|
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
|
||||||
using namespace Gtkmm2ext;
|
using namespace Gtkmm2ext;
|
||||||
|
|
||||||
SliderController::SliderController (Pix *pixset,
|
SliderController::SliderController (Glib::RefPtr<Gdk::Pixbuf> slide,
|
||||||
|
Glib::RefPtr<Gdk::Pixbuf> rail,
|
||||||
Gtk::Adjustment *adj,
|
Gtk::Adjustment *adj,
|
||||||
MIDI::Controllable *mc,
|
MIDI::Controllable *mc,
|
||||||
bool with_numeric)
|
bool with_numeric)
|
||||||
|
|
||||||
: PixScroller (*adj, *pixset),
|
: PixScroller (*adj, slide, rail),
|
||||||
spin (*adj, 0, 2),
|
spin (*adj, 0, 2),
|
||||||
prompter (Gtk::WIN_POS_MOUSE, 30000, false),
|
prompter (Gtk::WIN_POS_MOUSE, 30000, false),
|
||||||
midi_control (mc),
|
midi_control (mc),
|
||||||
|
|
@ -148,12 +149,13 @@ SliderController::midicontrol_unprompt ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VSliderController::VSliderController (Pix *pixset,
|
VSliderController::VSliderController (Glib::RefPtr<Gdk::Pixbuf> slide,
|
||||||
|
Glib::RefPtr<Gdk::Pixbuf> rail,
|
||||||
Gtk::Adjustment *adj,
|
Gtk::Adjustment *adj,
|
||||||
MIDI::Controllable *mcontrol,
|
MIDI::Controllable *mcontrol,
|
||||||
bool with_numeric)
|
bool with_numeric)
|
||||||
|
|
||||||
: SliderController (pixset, adj, mcontrol, with_numeric)
|
: SliderController (slide, rail, adj, mcontrol, with_numeric)
|
||||||
{
|
{
|
||||||
if (with_numeric) {
|
if (with_numeric) {
|
||||||
spin_frame.add (spin);
|
spin_frame.add (spin);
|
||||||
|
|
@ -164,12 +166,13 @@ VSliderController::VSliderController (Pix *pixset,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HSliderController::HSliderController (Pix *pixset,
|
HSliderController::HSliderController (Glib::RefPtr<Gdk::Pixbuf> slide,
|
||||||
|
Glib::RefPtr<Gdk::Pixbuf> rail,
|
||||||
Gtk::Adjustment *adj,
|
Gtk::Adjustment *adj,
|
||||||
MIDI::Controllable *mcontrol,
|
MIDI::Controllable *mcontrol,
|
||||||
bool with_numeric)
|
bool with_numeric)
|
||||||
|
|
||||||
: SliderController (pixset, adj, mcontrol, with_numeric)
|
: SliderController (slide, rail, adj, mcontrol, with_numeric)
|
||||||
{
|
{
|
||||||
if (with_numeric) {
|
if (with_numeric) {
|
||||||
spin_frame.add (spin);
|
spin_frame.add (spin);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue