[SCM] calf/master: + Curve, Keyboard: added API comments

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:37:26 UTC 2013


The following commit has been merged in the master branch:
commit 3cecdeb21579def7cfccf95d3b715c3768496964
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Fri Aug 1 19:29:49 2008 +0000

    + Curve, Keyboard: added API comments
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@246 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/src/calf/ctl_curve.h b/src/calf/ctl_curve.h
index 0c53d4f..978d013 100644
--- a/src/calf/ctl_curve.h
+++ b/src/calf/ctl_curve.h
@@ -33,21 +33,30 @@ G_BEGIN_DECLS
 #define CALF_CURVE_CLASS(klass)  (G_TYPE_CHECK_CLASS_CAST ((klass),  CALF_TYPE_CURVE, CalfCurveClass))
 #define CALF_IS_CURVE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass),  CALF_TYPE_CURVE))
 
+/// Mapping curve editor control. May be used for editing multisegment lines (key mapping,
+/// velocity mapping etc). This version isn't suitable for envelope editing because both
+/// ends (start and end) have fixed X coordinates and it doesn't resize.
 struct CalfCurve
 {
+    /// A point with floating point X and Y coordinates
     typedef std::pair<float, float> point;
+    /// A collection of points
     typedef std::vector<point> point_vector;
     
+    /// User callbacks for handling curve events
     struct EventSink
     {
+        /// Called when a point has been edited, added or removed
         virtual void curve_changed(const point_vector &data) = 0;
     };
 
+    /// Null implementation of EventSink
     struct EventAdapter: public EventSink
     {
         virtual void curve_changed(const point_vector &data) {}
     };
 
+    /// Debug implementation of EventSink
     struct EventTester: public EventAdapter
     {
         virtual void curve_changed(const point_vector &data) {
@@ -56,16 +65,32 @@ struct CalfCurve
         }
     };
 
+    /// Base class instance members
     GtkWidget parent;
+    /// Array of points
     point_vector *points;
+    /// Coordinate ranges (in logical coordinates for top left and bottom right)
     float x0, y0, x1, y1;
+    /// Currently selected point (when dragging/adding), or -1 if none is selected
     int cur_pt;
+    /// If currently selected point is a candidate for deletion (ie. outside of graph+margin range)
     bool hide_current;
+    /// Interface for notification
     EventSink *sink;
-    GdkCursor *hand_cursor, *pencil_cursor;
+    /// Cached hand (drag) cursor
+    GdkCursor *hand_cursor;
+    /// Cached pencil (add point) cursor
+    GdkCursor *pencil_cursor;
 
+    /// Convert logical (mapping) to physical (screen) coordinates
     void log2phys(float &x, float &y);
+    /// Convert physical (screen) to logical (mapping) coordinates
     void phys2log(float &x, float &y);
+    /// Clip function
+    /// @param pt point being clipped
+    /// @param x horizontal logical coordinate
+    /// @param y vertical logical coordinate
+    /// @param hide true if point is outside "valid" range and about to be deleted
     void clip(int pt, float &x, float &y, bool &hide);
 };
 
@@ -74,8 +99,13 @@ struct CalfCurveClass
     GtkWidgetClass parent_class;
 };
 
+/// Create a CalfCurve
 extern GtkWidget *calf_curve_new();
+
+/// Return a GObject type for class CalfCurve
 extern GType calf_curve_get_type();
+
+/// Set points and update the widget
 extern void calf_curve_set_points(GtkWidget *widget, const CalfCurve::point_vector &src);
 
 G_END_DECLS
diff --git a/src/calf/ctl_keyboard.h b/src/calf/ctl_keyboard.h
index f94262e..ce3fc61 100644
--- a/src/calf/ctl_keyboard.h
+++ b/src/calf/ctl_keyboard.h
@@ -33,26 +33,42 @@ G_BEGIN_DECLS
 #define CALF_KEYBOARD_CLASS(klass)  (G_TYPE_CHECK_CLASS_CAST ((klass),  CALF_TYPE_KEYBOARD, CalfKeyboardClass))
 #define CALF_IS_KEYBOARD_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass),  CALF_TYPE_KEYBOARD))
 
+/// Instance-specific data for CalfKeyboard
 struct CalfKeyboard
 {
+    /// Structure with information needed for drawing a single key
     struct KeyInfo
     {
-        double x, y, width, height;
-        int note;
-        bool black;
+        double x; ///< X coordinate of the top-left point of the key
+        double y; ///< Y coordinate of the top-left point of the key
+        double width; ///< key width
+        double height; ///< key height
+        int note; ///< MIDI note number
+        bool black; ///< true if it's a black key, false if it's a white key
     };
     
+    /// Set of user-defined callbacks for customizing display and operation of CalfKeyboard
     struct EventSink
     {
+        /// (will be) called on attachment of sink to CalfKeyboard object
         virtual void set_instance(CalfKeyboard *kb)=0;
+        /// called before drawing key interior
+        /// @retval true do not draw the key
         virtual bool pre_draw(cairo_t *c, KeyInfo &ki)=0;
+        /// @retval true do not draw the outline
+        /// called before drawing key outline of white keys
         virtual bool pre_draw_outline(cairo_t *c, KeyInfo &ki)=0;
+        /// called after key is drawn using standard method (but not if drawing is skipped)
         virtual void post_draw(cairo_t *c, KeyInfo &ki)=0;
+        /// called after key is drawn
         virtual void post_all(cairo_t *c)=0;
+        /// key was pressed
         virtual void note_on(int note, int vel) = 0;
+        /// key was released
         virtual void note_off(int note) = 0;
     };
 
+    /// Null implementation of CalfKeyboard::EventSink
     struct EventAdapter: public EventSink
     {
         CalfKeyboard *kb;
@@ -65,6 +81,7 @@ struct CalfKeyboard
         virtual void note_off(int note) {}
     };
 
+    /// Debug/example implementation of CalfKeyboard::EventSink
     struct EventTester: public EventAdapter
     {
         virtual bool pre_draw(cairo_t *c, KeyInfo &ki) { if (ki.note == 60) cairo_set_source_rgb(c, 1.0, 1.0, 0.5); return false; }
@@ -82,20 +99,28 @@ struct CalfKeyboard
         virtual void note_off(int note) { g_message("note off %d", note); }
     };
 
+    /// Parent instance members
     GtkWidget parent;
+    /// Range (number of white keys = number of octaves * 7 + 1)
     int nkeys;
     EventSink *sink;
+    /// The note currently pressed via mouse selection
     int last_key;
+    /// If true, the keyboard accepts mouse clicks and keys
     bool interactive;
 };
 
+/// Class-specific data for CalfKeyboard
 struct CalfKeyboardClass
 {
+    /// Parent class members
     GtkWidgetClass parent_class;
 };
 
+/// Create new keyboard object;
 extern GtkWidget *calf_keyboard_new();
 
+/// Return a GType for CalfKeyboard
 extern GType calf_keyboard_get_type();
 
 G_END_DECLS

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list