[beast: 5/9] BSE: move Bse.Source.set_pos() into bseapi.idl
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 5/9] BSE: move Bse.Source.set_pos() into bseapi.idl
- Date: Wed, 16 Aug 2017 23:43:15 +0000 (UTC)
commit 767cdb8d65f51dd040ff2b0da071a31fffe7d25c
Author: Tim Janik <timj gnu org>
Date: Wed Jul 26 20:53:57 2017 +0200
BSE: move Bse.Source.set_pos() into bseapi.idl
Signed-off-by: Tim Janik <timj gnu org>
bse/bseapi.idl | 10 +++++++++-
bse/bsesource.cc | 18 ++++++++++++++++++
bse/bsesource.hh | 1 +
bse/bsesource.proc | 43 -------------------------------------------
4 files changed, 28 insertions(+), 44 deletions(-)
---
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index d4fb1ca..23575e4 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -603,13 +603,21 @@ interface Source : Item {
// Error set_automation (String property_name, int32 midi_channel, MidiControlType control_type); ///<
Setup automation parameters for a property.
// Error set_input (String input_channel, Source omodule, String output_channel); ///< Connect a module
input to another module's output.
// Error set_input_by_id (int32 input_channel, Source omodule, int32 output_channel); ///< Connect a
module input to another module's output.
- // void set_pos (float64 x_pos, float64 y_pos); ///< Set the x and y position of a module. In contrast to
setting the position through ordinary object property setters, this function will not update the module
position if the passed in arguments are sufficiently equal to the values already set on the object. As such,
it does not record an extra undo step for setting properties to values they already have and if necessary
turns setting of x and y positions into an atomic undo operation.
// Error unset_input (String input_channel, Source omodule, String output_channel); ///< Disconnect a
module input.
// Error unset_input_by_id (int32 input_channel, Source omodule, int32 output_channel); ///< Disconnect a
module input.
// signal void probes (ProbeSeq a);
// signal void io_changed ();
// float64 pos_x = Range ("Position X", "", STANDARD ":scale");
// float64 pos_y = Range ("Position Y", "", STANDARD ":scale");
+ /** Set the x and y position of a module.
+ * In contrast to setting the position through ordinary object property
+ * setters, this function will not update the module position if the passed
+ * in arguments are sufficiently equal to the values already set on the
+ * object. As such, it does not record an extra undo step for setting
+ * properties to values they already have and if necessary turns setting
+ * of x and y positions into an atomic undo operation.
+ */
+ void set_pos (float64 x_pos, float64 y_pos);
};
/// Source module for merging multiple synthesis contexts, used to implement polyphony.
diff --git a/bse/bsesource.cc b/bse/bsesource.cc
index 7ea6228..f1d28fa 100644
--- a/bse/bsesource.cc
+++ b/bse/bsesource.cc
@@ -2108,4 +2108,22 @@ SourceImpl::n_ochannels()
return BSE_SOURCE_N_OCHANNELS (self);
}
+void
+SourceImpl::set_pos (double x_pos, double y_pos)
+{
+ BseSource *self = as<BseSource*>();
+ const double epsilon = 1e-5;
+
+ if (fabs (x_pos - self->pos_x) > epsilon ||
+ fabs (y_pos - self->pos_y) > epsilon)
+ {
+ BseUndoStack *ustack = bse_item_undo_open (self, "set-xy-pos");
+ bse_item_set (self,
+ "pos_x", x_pos,
+ "pos_y", y_pos,
+ NULL);
+ bse_item_undo_close (ustack);
+ }
+}
+
} // Bse
diff --git a/bse/bsesource.hh b/bse/bsesource.hh
index 9e459e2..53ccb67 100644
--- a/bse/bsesource.hh
+++ b/bse/bsesource.hh
@@ -281,6 +281,7 @@ public:
virtual bool has_outputs () override;
virtual int n_ichannels () override;
virtual int n_ochannels () override;
+ virtual void set_pos (double x_pos, double y_pos) override;
};
} // Bse
diff --git a/bse/bsesource.proc b/bse/bsesource.proc
index 9d8000a..e23a314 100644
--- a/bse/bsesource.proc
+++ b/bse/bsesource.proc
@@ -536,49 +536,6 @@ BODY (BseProcedureClass *proc,
return Bse::Error::NONE;
}
-METHOD (BseSource, set-pos) {
- HELP = "Set the x and y position of a module. In contrast to setting the position "
- "through ordinary object property setters, this function will not update "
- "the module position if the passed in arguments are sufficiently equal to "
- "the values already set on the object. As such, it does not record an extra "
- "undo step for setting properties to values they already have and if necessary "
- "turns setting of x and y positions into an atomic undo operation.";
- IN = bse_param_spec_object ("module", "Module", NULL,
- BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
- IN = sfi_pspec_real ("x-pos", "X Position", NULL,
- 0, -SFI_MAXREAL, SFI_MAXREAL, 1, SFI_PARAM_STANDARD);
- IN = sfi_pspec_real ("y-pos", "Y Position", NULL,
- 0, -SFI_MAXREAL, SFI_MAXREAL, 1, SFI_PARAM_STANDARD);
-}
-BODY (BseProcedureClass *proc,
- const GValue *in_values,
- GValue *out_values)
-{
- /* extract parameter values */
- BseSource *source = (BseSource*) bse_value_get_object (in_values++);
- SfiReal xpos = sfi_value_get_real (in_values++);
- SfiReal ypos = sfi_value_get_real (in_values++);
- SfiReal epsilon = 1e-5;
-
- /* check parameters */
- if (!BSE_IS_SOURCE (source) || BSE_DOUBLE_IS_NANINF (xpos) || BSE_DOUBLE_IS_NANINF (ypos))
- return Bse::Error::PROC_PARAM_INVAL;
-
- /* action */
- if (fabs (xpos - source->pos_x) > epsilon ||
- fabs (ypos - source->pos_y) > epsilon)
- {
- BseUndoStack *ustack = bse_item_undo_open (source, "set-xy-pos");
- bse_item_set (source,
- "pos_x", xpos,
- "pos_y", ypos,
- NULL);
- bse_item_undo_close (ustack);
- }
-
- return Bse::Error::NONE;
-}
-
METHOD (BseSource, set-automation) {
HELP = "Setup automation parameters for a property.";
IN = bse_param_spec_object ("source", NULL, NULL,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]