# HG changeset patch # User Ben Abbott # Date 1331420011 18000 # Node ID 7a49519913e3671cb4d5d868e82260a7b3fc974b # Parent c97416a0f657f56a3234ec993e34258463f0da6b Add custom inline set_postion method for text objects which accepts [1x2] and [1x3] vectors. * graphics.h.in (text::properties::set_position): Add custom inline definition for text position property. diff --git a/src/graphics.h.in b/src/graphics.h.in --- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -4235,13 +4235,38 @@ public: double get_fontsize_points (double box_pix_height = 0) const; + void set_position (const octave_value& val) + { + if (! error_state) + { + octave_value new_val (val); + + if (new_val.numel () == 2) + { + dim_vector dv (1, 3); + + new_val = new_val.resize (dv, true); + } + + if (position.set (new_val, false)) + { + set_positionmode ("manual"); + update_position (); + position.run_listeners (POSTSET); + mark_modified (); + } + else + set_positionmode ("manual"); + } + } + // See the genprops.awk script for an explanation of the // properties declarations. BEGIN_PROPERTIES (text) text_label_property string u , "" radio_property units u , "{data}|pixels|normalized|inches|centimeters|points" - array_property position mu , Matrix (1, 3, 0.0) + array_property position smu , Matrix (1, 3, 0.0) double_property rotation mu , 0 radio_property horizontalalignment mu , "{left}|center|right" color_property color u , color_values (0, 0, 0) @@ -4287,7 +4312,6 @@ protected: void init (void) { - position.add_constraint (dim_vector (1, 2)); position.add_constraint (dim_vector (1, 3)); cached_units = get_units (); update_font ();