fix whitespace/indentation and compiler warnings
This commit is contained in:
parent
03dbf7857e
commit
e6b4c9f610
@ -1,21 +1,21 @@
|
||||
/*
|
||||
Copyright (C) 2014 Waves Audio Ltd.
|
||||
Copyright (C) 2014 Waves Audio Ltd.
|
||||
|
||||
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 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.
|
||||
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.
|
||||
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.
|
||||
|
||||
$Id: fastmeter.h 570 2006-06-07 21:21:21Z sampo $
|
||||
$Id: fastmeter.h 570 2006-06-07 21:21:21Z sampo $
|
||||
*/
|
||||
|
||||
|
||||
@ -44,40 +44,29 @@ using namespace std;
|
||||
static void get_closest_point_on_line(double xa, double ya, double xb, double yb, double xp, double yp, double& xl, double& yl )
|
||||
{
|
||||
// Storing vector A->B
|
||||
double a_to_b_x = xb - xa;
|
||||
double a_to_b_x = xb - xa;
|
||||
double a_to_b_y = yb - ya;
|
||||
|
||||
// Storing vector A->P
|
||||
double a_to_p_x = xp - xa;
|
||||
double a_to_p_x = xp - xa;
|
||||
double a_to_p_y = yp - ya;
|
||||
|
||||
|
||||
// Basically finding the squared magnitude
|
||||
// of a_to_b
|
||||
double atb2 = a_to_b_x * a_to_b_x + a_to_b_y * a_to_b_y;
|
||||
// Basically finding the squared magnitude
|
||||
// of a_to_b
|
||||
double atb2 = a_to_b_x * a_to_b_x + a_to_b_y * a_to_b_y;
|
||||
|
||||
// The dot product of a_to_p and a_to_b
|
||||
double atp_dot_atb = a_to_p_x * a_to_b_x + a_to_p_y * a_to_b_y;
|
||||
// The dot product of a_to_p and a_to_b
|
||||
double atp_dot_atb = a_to_p_x * a_to_b_x + a_to_p_y * a_to_b_y;
|
||||
|
||||
// The normalized "distance" from a to
|
||||
// your closest point
|
||||
double t = atp_dot_atb / atb2;
|
||||
// The normalized "distance" from a to
|
||||
// your closest point
|
||||
double t = atp_dot_atb / atb2;
|
||||
|
||||
// The vector perpendicular to a_to_b;
|
||||
// This step can also be combined with the next
|
||||
double perpendicular_x = -a_to_b_y;
|
||||
double perpendicular_y = a_to_b_x;
|
||||
|
||||
// Finding Q, the point "in the right direction"
|
||||
// If you want a mess, you can also combine this
|
||||
// with the next step.
|
||||
double xq = xp + perpendicular_x;
|
||||
double yq = yp + perpendicular_y;
|
||||
|
||||
// Add the distance to A, moving
|
||||
// towards B
|
||||
double x = xa + a_to_b_x * t;
|
||||
double y = ya + a_to_b_y * t;
|
||||
// Add the distance to A, moving
|
||||
// towards B
|
||||
double x = xa + a_to_b_x * t;
|
||||
double y = ya + a_to_b_y * t;
|
||||
|
||||
if ((xa != xb)) {
|
||||
if ((x < xa) && (x < xb)) {
|
||||
@ -122,16 +111,16 @@ static void get_closest_point_on_line(double xa, double ya, double xb, double yb
|
||||
}
|
||||
|
||||
Fader::Fader (Gtk::Adjustment& adj,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& face_pixbuf,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& active_face_pixbuf,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& underlay_pixbuf,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& handle_pixbuf,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& active_handle_pixbuf,
|
||||
int min_pos_x,
|
||||
int min_pos_y,
|
||||
int max_pos_x,
|
||||
int max_pos_y,
|
||||
bool read_only)
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& face_pixbuf,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& active_face_pixbuf,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& underlay_pixbuf,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& handle_pixbuf,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& active_handle_pixbuf,
|
||||
int min_pos_x,
|
||||
int min_pos_y,
|
||||
int max_pos_x,
|
||||
int max_pos_y,
|
||||
bool read_only)
|
||||
: adjustment (adj)
|
||||
, _face_pixbuf (face_pixbuf)
|
||||
, _active_face_pixbuf (active_face_pixbuf)
|
||||
@ -142,11 +131,11 @@ Fader::Fader (Gtk::Adjustment& adj,
|
||||
, _min_pos_y (min_pos_y)
|
||||
, _max_pos_x (max_pos_x)
|
||||
, _max_pos_y (max_pos_y)
|
||||
, _default_value (adjustment.get_value())
|
||||
, _dragging (false)
|
||||
, _read_only (read_only)
|
||||
, _grab_window (0)
|
||||
, _touch_cursor (0)
|
||||
, _dragging (false)
|
||||
, _default_value (adjustment.get_value())
|
||||
, _read_only (read_only)
|
||||
{
|
||||
update_unity_position ();
|
||||
|
||||
@ -156,7 +145,7 @@ Fader::Fader (Gtk::Adjustment& adj,
|
||||
|
||||
adjustment.signal_value_changed().connect (mem_fun (*this, &Fader::adjustment_changed));
|
||||
adjustment.signal_changed().connect (mem_fun (*this, &Fader::adjustment_changed));
|
||||
CairoWidget::set_size_request(_face_pixbuf->get_width(), _face_pixbuf->get_height());
|
||||
CairoWidget::set_size_request(_face_pixbuf->get_width(), _face_pixbuf->get_height());
|
||||
}
|
||||
|
||||
Fader::~Fader ()
|
||||
@ -178,36 +167,36 @@ Fader::render (cairo_t* cr, cairo_rectangle_t*)
|
||||
get_handle_position (_last_drawn_x, _last_drawn_y);
|
||||
|
||||
if (_underlay_pixbuf != 0) {
|
||||
cairo_rectangle (cr, 0, 0, get_width(), get_height());
|
||||
cairo_rectangle (cr, 0, 0, get_width(), get_height());
|
||||
gdk_cairo_set_source_pixbuf (cr,
|
||||
_underlay_pixbuf->gobj(),
|
||||
_last_drawn_x - (int)(_underlay_pixbuf->get_width()/2.0 + 0.5),
|
||||
_last_drawn_y - (int)(_underlay_pixbuf->get_height()/2.0 + 0.5));
|
||||
cairo_fill (cr);
|
||||
_underlay_pixbuf->gobj(),
|
||||
_last_drawn_x - (int)(_underlay_pixbuf->get_width()/2.0 + 0.5),
|
||||
_last_drawn_y - (int)(_underlay_pixbuf->get_height()/2.0 + 0.5));
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
cairo_rectangle (cr, 0, 0, get_width(), get_height());
|
||||
gdk_cairo_set_source_pixbuf (cr,
|
||||
((get_state () == Gtk::STATE_ACTIVE) && (_active_face_pixbuf != 0)) ?
|
||||
_active_face_pixbuf->gobj() :
|
||||
_face_pixbuf->gobj(),
|
||||
0,
|
||||
0);
|
||||
((get_state () == Gtk::STATE_ACTIVE) && (_active_face_pixbuf != 0)) ?
|
||||
_active_face_pixbuf->gobj() :
|
||||
_face_pixbuf->gobj(),
|
||||
0,
|
||||
0);
|
||||
cairo_fill (cr);
|
||||
|
||||
cairo_rectangle (cr, 0, 0, get_width(), get_height());
|
||||
cairo_rectangle (cr, 0, 0, get_width(), get_height());
|
||||
if (_dragging) {
|
||||
gdk_cairo_set_source_pixbuf (cr,
|
||||
_active_handle_pixbuf->gobj(),
|
||||
_last_drawn_x - (int)(_active_handle_pixbuf->get_width()/2.0 + 0.5),
|
||||
_last_drawn_y - (int)(_active_handle_pixbuf->get_height()/2.0 + 0.5));
|
||||
_active_handle_pixbuf->gobj(),
|
||||
_last_drawn_x - (int)(_active_handle_pixbuf->get_width()/2.0 + 0.5),
|
||||
_last_drawn_y - (int)(_active_handle_pixbuf->get_height()/2.0 + 0.5));
|
||||
} else {
|
||||
gdk_cairo_set_source_pixbuf (cr,
|
||||
_handle_pixbuf->gobj(),
|
||||
_last_drawn_x - (int)(_handle_pixbuf->get_width()/2.0 + 0.5),
|
||||
_last_drawn_y - (int)(_handle_pixbuf->get_height()/2.0 + 0.5));
|
||||
_handle_pixbuf->gobj(),
|
||||
_last_drawn_x - (int)(_handle_pixbuf->get_width()/2.0 + 0.5),
|
||||
_last_drawn_y - (int)(_handle_pixbuf->get_height()/2.0 + 0.5));
|
||||
}
|
||||
cairo_fill (cr);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
void
|
||||
@ -220,21 +209,21 @@ Fader::on_size_request (GtkRequisition* req)
|
||||
void
|
||||
Fader::on_size_allocate (Gtk::Allocation& alloc)
|
||||
{
|
||||
CairoWidget::on_size_allocate(alloc);
|
||||
CairoWidget::on_size_allocate(alloc);
|
||||
update_unity_position ();
|
||||
}
|
||||
|
||||
bool
|
||||
Fader::on_button_press_event (GdkEventButton* ev)
|
||||
{
|
||||
focus_handler();
|
||||
focus_handler();
|
||||
|
||||
if (_read_only) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ev->type != GDK_BUTTON_PRESS) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ev->button != 1 && ev->button != 2) {
|
||||
@ -260,19 +249,19 @@ Fader::on_button_press_event (GdkEventButton* ev)
|
||||
double ev_pos_y;
|
||||
|
||||
get_closest_point_on_line(_min_pos_x, _min_pos_y,
|
||||
_max_pos_x, _max_pos_y,
|
||||
ev->x, ev->y,
|
||||
ev_pos_x, ev_pos_y );
|
||||
_max_pos_x, _max_pos_y,
|
||||
ev->x, ev->y,
|
||||
ev_pos_x, ev_pos_y );
|
||||
add_modal_grab ();
|
||||
|
||||
_grab_window = ev->window;
|
||||
_dragging = true;
|
||||
|
||||
gdk_pointer_grab(ev->window,false,
|
||||
GdkEventMask (Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK),
|
||||
NULL,
|
||||
NULL,
|
||||
ev->time);
|
||||
GdkEventMask (Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK),
|
||||
NULL,
|
||||
NULL,
|
||||
ev->time);
|
||||
|
||||
queue_draw();
|
||||
|
||||
@ -306,37 +295,37 @@ Fader::on_scroll_event (GdkEventScroll* ev)
|
||||
return false;
|
||||
}
|
||||
|
||||
int step_factor = 1;
|
||||
int step_factor = 1;
|
||||
|
||||
switch (ev->direction) {
|
||||
case GDK_SCROLL_RIGHT:
|
||||
case GDK_SCROLL_UP:
|
||||
#ifdef __APPLE__
|
||||
if ( ev->state & GDK_SHIFT_MASK ) {
|
||||
step_factor = -1;
|
||||
} else {
|
||||
step_factor = 1;
|
||||
}
|
||||
if ( ev->state & GDK_SHIFT_MASK ) {
|
||||
step_factor = -1;
|
||||
} else {
|
||||
step_factor = 1;
|
||||
}
|
||||
#else
|
||||
step_factor = 1;
|
||||
step_factor = 1;
|
||||
#endif
|
||||
break;
|
||||
case GDK_SCROLL_LEFT:
|
||||
case GDK_SCROLL_DOWN:
|
||||
#ifdef __APPLE__
|
||||
if ( ev->state & GDK_SHIFT_MASK ) {
|
||||
step_factor = 1;
|
||||
} else {
|
||||
step_factor = -1;
|
||||
}
|
||||
if ( ev->state & GDK_SHIFT_MASK ) {
|
||||
step_factor = 1;
|
||||
} else {
|
||||
step_factor = -1;
|
||||
}
|
||||
#else
|
||||
step_factor = -1;
|
||||
step_factor = -1;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
adjustment.set_value (adjustment.get_value() + step_factor * (adjustment.get_step_increment() ));
|
||||
adjustment.set_value (adjustment.get_value() + step_factor * (adjustment.get_step_increment() ));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -357,14 +346,14 @@ Fader::on_motion_notify_event (GdkEventMotion* ev)
|
||||
}
|
||||
|
||||
get_closest_point_on_line(_min_pos_x, _min_pos_y,
|
||||
_max_pos_x, _max_pos_y,
|
||||
_grab_start_handle_x + (ev->x - _grab_start_mouse_x), _grab_start_handle_y + (ev->y - _grab_start_mouse_y),
|
||||
ev_pos_x, ev_pos_y );
|
||||
_max_pos_x, _max_pos_y,
|
||||
_grab_start_handle_x + (ev->x - _grab_start_mouse_x), _grab_start_handle_y + (ev->y - _grab_start_mouse_y),
|
||||
ev_pos_x, ev_pos_y );
|
||||
|
||||
double const fract = sqrt((ev_pos_x - _min_pos_x) * (ev_pos_x - _min_pos_x) +
|
||||
(ev_pos_y - _min_pos_y) * (ev_pos_y - _min_pos_y)) /
|
||||
sqrt((_max_pos_x - _min_pos_x) * (_max_pos_x - _min_pos_x) +
|
||||
(_max_pos_y - _min_pos_y) * (_max_pos_y - _min_pos_y));
|
||||
(ev_pos_y - _min_pos_y) * (ev_pos_y - _min_pos_y)) /
|
||||
sqrt((_max_pos_x - _min_pos_x) * (_max_pos_x - _min_pos_x) +
|
||||
(_max_pos_y - _min_pos_y) * (_max_pos_y - _min_pos_y));
|
||||
|
||||
adjustment.set_value (adjustment.get_lower() + (adjustment.get_upper() - adjustment.get_lower()) * fract);
|
||||
}
|
||||
@ -374,7 +363,7 @@ Fader::on_motion_notify_event (GdkEventMotion* ev)
|
||||
void
|
||||
Fader::adjustment_changed ()
|
||||
{
|
||||
double handle_x;
|
||||
double handle_x;
|
||||
double handle_y;
|
||||
get_handle_position (handle_x, handle_y);
|
||||
|
||||
|
@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright (C) 2006 Paul Davis
|
||||
Copyright (C) 2006 Paul Davis
|
||||
|
||||
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 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.
|
||||
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.
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
@ -37,17 +37,17 @@ namespace Gtkmm2ext {
|
||||
class LIBGTKMM2EXT_API Fader : public CairoWidget
|
||||
{
|
||||
public:
|
||||
Fader (Gtk::Adjustment& adjustment,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& face_pixbuf,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& active_face_pixbuf,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& underlay_pixbuf,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& handle_pixbuf,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& active_handle_pixbuf,
|
||||
int min_pos_x,
|
||||
int min_pos_y,
|
||||
int max_pos_x,
|
||||
int max_pos_y,
|
||||
bool read_only);
|
||||
Fader (Gtk::Adjustment& adjustment,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& face_pixbuf,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& active_face_pixbuf,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& underlay_pixbuf,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& handle_pixbuf,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>& active_handle_pixbuf,
|
||||
int min_pos_x,
|
||||
int min_pos_y,
|
||||
int max_pos_x,
|
||||
int max_pos_y,
|
||||
bool read_only);
|
||||
|
||||
virtual ~Fader ();
|
||||
|
||||
@ -74,22 +74,18 @@ class LIBGTKMM2EXT_API Fader : public CairoWidget
|
||||
BindingProxy binding_proxy;
|
||||
|
||||
private:
|
||||
|
||||
const Glib::RefPtr<Gdk::Pixbuf> _face_pixbuf;
|
||||
const Glib::RefPtr<Gdk::Pixbuf> _face_pixbuf;
|
||||
const Glib::RefPtr<Gdk::Pixbuf> _active_face_pixbuf;
|
||||
const Glib::RefPtr<Gdk::Pixbuf> _underlay_pixbuf;
|
||||
const Glib::RefPtr<Gdk::Pixbuf> _handle_pixbuf;
|
||||
const Glib::RefPtr<Gdk::Pixbuf> _active_handle_pixbuf;
|
||||
const Glib::RefPtr<Gdk::Pixbuf> _handle_pixbuf;
|
||||
const Glib::RefPtr<Gdk::Pixbuf> _active_handle_pixbuf;
|
||||
int _min_pos_x;
|
||||
int _min_pos_y;
|
||||
int _max_pos_x;
|
||||
int _max_pos_y;
|
||||
|
||||
bool _hovering;
|
||||
|
||||
GdkWindow* _grab_window;
|
||||
Gdk::Cursor *_touch_cursor;
|
||||
|
||||
double _grab_start_mouse_x;
|
||||
double _grab_start_mouse_y;
|
||||
double _grab_start_handle_x;
|
||||
@ -98,7 +94,6 @@ class LIBGTKMM2EXT_API Fader : public CairoWidget
|
||||
double _last_drawn_y;
|
||||
bool _dragging;
|
||||
float _default_value;
|
||||
int _unity_loc;
|
||||
bool _read_only;
|
||||
|
||||
void adjustment_changed ();
|
||||
@ -108,4 +103,4 @@ class LIBGTKMM2EXT_API Fader : public CairoWidget
|
||||
|
||||
} /* namespace */
|
||||
|
||||
#endif /* __gtkmm2ext_fader_h__ */
|
||||
#endif /* __gtkmm2ext_fader_h__ */
|
||||
|
Loading…
Reference in New Issue
Block a user