* lily/context-property.cc (make_item_from_properties): Register grob.
* lily/context.cc (add_context): Register context.
* lily/include/context-selector.hh:
* lily/include/grob-selector.hh:
* lily/context-selector.cc:
* lily/grob-selector.cc: New file.
+2004-11-09 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ * scm/framework-gnome.scm (item-event): Print grob id.
+
+ * lily/context-property.cc (make_item_from_properties): Register grob.
+ * lily/context.cc (add_context): Register context.
+
+ * lily/include/context-selector.hh:
+ * lily/include/grob-selector.hh:
+ * lily/context-selector.cc:
+ * lily/grob-selector.cc: New file.
+
2004-11-08 Han-Wen Nienhuys <hanwen@xs4all.nl>
* lily/slur.cc: add 'positions to interface
}
}
-Spanner*
+Spanner *
Auto_beam_engraver::create_beam ()
{
if (to_boolean (get_property ("skipTypesetting")))
- {
- return 0;
- }
+ return 0;
- Spanner* beam = new Spanner (beam_settings_);
+ Spanner *beam = new Spanner (beam_settings_);
for (int i = 0; i < stems_->size (); i++)
{
/*
scm_gc_unprotect_object (g->self_scm ());
- tg->accepts_list_ = get_accepted (ops);
-
+ tg->accepts_list_ = get_accepted (ops);
+
return tg;
}
SCM
Context_def::clone_scm () const
{
- Context_def * t = new Context_def (*this);
+ Context_def *t = new Context_def (*this);
SCM x = t->self_scm ();
scm_gc_unprotect_object (x);
return x;
SCM
Context_def::make_scm ()
{
- Context_def* t = new Context_def;
+ Context_def *t = new Context_def;
SCM x = t->self_scm ();
scm_gc_unprotect_object (x);
return x;
-/*
- translator-property.cc -- implement manipulation of immutable Grob
+/*
+ context-property.cc -- implement manipulation of immutable Grob
property lists.
source file of the GNU LilyPond music typesetter
(c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
- */
+*/
-#include "main.hh"
#include "context.hh"
-#include "warn.hh"
+#include "grob-selector.hh"
+#include "engraver.hh"
#include "item.hh"
+#include "main.hh"
#include "spanner.hh"
-#include "engraver.hh"
+#include "warn.hh"
/*
Grob descriptions (ie. alists with layout properties) are
else
{
SCM copy = daddy_props;
- SCM * tail = ©
+ SCM *tail = ©
SCM p = scm_car (props);
while (p != based_on)
{
}
}
-Item*
+Item *
make_item_from_properties (Translator *tr, SCM x, SCM cause)
{
- Context *tg = tr->context ();
+ Context *context = tr->context ();
- SCM props = updated_grob_properties (tg, x);
- Item *it= new Item (props);
+ SCM props = updated_grob_properties (context, x);
+ Item *it = new Item (props);
+ Grob_selector::register_grob (context, it);
dynamic_cast<Engraver*>(tr)->announce_grob (it, cause);
-
+
return it;
}
make_spanner_from_properties (Translator *tr, SCM x, SCM cause)
{
Context *tg = tr->context ();
-
+
SCM props = updated_grob_properties (tg, x);
- Spanner *it= new Spanner (props);
+ Spanner *it = new Spanner (props);
dynamic_cast<Engraver*>(tr)->announce_grob (it, cause);
-
+
return it;
}
--- /dev/null
+/*
+ context-selector.cc -- implement Context selection.
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "context-selector.hh"
+#include "context.hh"
+#include "scm-hash.hh"
+
+Scheme_hash_table *Context_selector::contexts_ = 0;
+
+void
+Context_selector::register_context (Context *context)
+{
+ if (!contexts_)
+ contexts_ = new Scheme_hash_table ();
+ int count = 0;
+ if (Context *first = retrieve_context (identify_context (context, 0)))
+ {
+ count = robust_scm2int (first->get_property ("max"), 0);
+ count++;
+ SCM s = scm_int2num (count);
+ first->set_property ("max", s);
+ context->set_property ("count", s);
+ }
+ /* FIXME: must alway set count, for get_property () not to segfault. */
+ context->set_property ("count", scm_int2num (count));
+ contexts_->set (identify_context (context, count), context->self_scm ());
+}
+
+SCM
+Context_selector::identify_context (Context *context, int count)
+{
+ /* TODO: start time, parent-context-at-start */
+ return ly_symbol2scm ((context->context_name ()
+ + ","
+ + to_string (count)).to_str0 ());
+}
+
+SCM
+Context_selector::identify_context (Context *context)
+{
+ return
+ identify_context (context,
+ robust_scm2int (context->get_property ("count"), 0));
+}
+
+Context *
+Context_selector::retrieve_context (SCM key)
+{
+ return unsmob_context (contexts_->get (key));
+}
*/
-#include "translator-group.hh"
#include "context-def.hh"
+#include "context-selector.hh"
#include "context.hh"
-#include "warn.hh"
+#include "ly-smobs.icc"
+#include "main.hh"
#include "output-def.hh"
#include "scm-hash.hh"
-#include "main.hh"
-#include "ly-smobs.icc"
#include "score-context.hh"
+#include "translator-group.hh"
+#include "warn.hh"
bool
Context::is_removable () const
{
for (SCM p = context_list_; scm_is_pair (p); p = scm_cdr (p))
{
- Context *trg = unsmob_context (scm_car (p));
+ Context *trg = unsmob_context (scm_car (p));
trg->check_removal ();
if (trg->is_removable ())
assert (false);
}
-Scheme_hash_table*
+Scheme_hash_table *
Context::properties_dict () const
{
return Scheme_hash_table::unsmob (properties_scm_);
}
void
-Context::add_context (Context*t)
+Context::add_context (Context *t)
{
SCM ts = t->self_scm ();
context_list_ = ly_append2 (context_list_,
if (!t->init_)
{
t->init_ = true;
-
+ Context_selector::register_context (t);
+
scm_gc_unprotect_object (ts);
- Context_def * td = unsmob_context_def (t->definition_);
+ Context_def *td = unsmob_context_def (t->definition_);
/*
this can not move before add_context (), because \override
return where;
}
- Context * found = 0;
+ Context *found = 0;
for (SCM s = where->children_contexts ();
!found && scm_is_pair (s); s = scm_cdr (s))
{
- Context * tr = unsmob_context (scm_car (s));
+ Context *tr = unsmob_context (scm_car (s));
found = find_context_below (tr, type, id);
}
SCM
Context::context_name_symbol () const
{
- Context_def * td = unsmob_context_def (definition_ );
+ Context_def *td = unsmob_context_def (definition_);
return td->get_context_name ();
}
String
Context::context_name () const
{
- return ly_symbol2string (context_name_symbol ());
+ return ly_symbol2string (context_name_symbol ());
}
Score_context*
Context::get_score_context () const
{
- if (Score_context *sc =dynamic_cast<Score_context*> ((Context*) this))
+ if (Score_context *sc = dynamic_cast<Score_context*> ((Context*) this))
return sc;
-
else if (daddy_context_)
return daddy_context_->get_score_context ();
else
Output_def *
Context::get_output_def () const
{
- return (daddy_context_)
- ? daddy_context_->get_output_def () : 0;
+ return daddy_context_ ? daddy_context_->get_output_def () : 0;
}
Context::~Context ()
scm_puts ("#<", port);
scm_puts (classname (sc), port);
- if (Context_def *d=unsmob_context_def (sc->definition_))
+ if (Context_def *d = unsmob_context_def (sc->definition_))
{
scm_puts (" ", port);
scm_display (d->get_context_name (), port);
SCM
Context::mark_smob (SCM sm)
{
- Context * me = (Context*) SCM_CELL_WORD_1 (sm);
+ Context *me = (Context*) SCM_CELL_WORD_1 (sm);
scm_gc_mark (me->context_list_);
scm_gc_mark (me->aliases_);
--- /dev/null
+/*
+ grob-selector.cc -- implement Grob selection.
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "context-selector.hh"
+#include "context.hh"
+#include "grob-selector.hh"
+#include "grob.hh"
+#include "paper-column.hh"
+#include "scm-hash.hh"
+
+Scheme_hash_table *Grob_selector::grobs_ = 0;
+
+void
+Grob_selector::register_grob (Context *context, Grob *grob)
+{
+ if (!grobs_)
+ grobs_ = new Scheme_hash_table ();
+ int count = 0;
+ if (Grob *first = retrieve_grob (identify_grob (context, grob, 0)))
+ {
+ count = robust_scm2int (first->get_property ("max"), 0);
+ count++;
+ SCM s = scm_int2num (count);
+ first->set_property ("max", s);
+ grob->set_property ("count", s);
+ }
+ grob->set_property ("context", context->self_scm ());
+ grobs_->set (identify_grob (context, grob, count), grob->self_scm ());
+}
+
+SCM
+Grob_selector::identify_grob (Context *context, Grob *grob, int count)
+{
+ return ly_symbol2scm ((ly_symbol2string (Context_selector::identify_context (context))
+ + ","
+ + grob->name ()
+#if 0 // "when" not defined yet?
+ + ","
+ + Paper_column::when_mom (((Item*)grob)->get_column ()).to_string (),
+#endif
+ + ","
+ + to_string (count)).to_str0 ());
+}
+
+SCM
+Grob_selector::identify_grob (Grob *grob)
+{
+ return identify_grob (unsmob_context (grob->get_property ("context")),
+ grob,
+ robust_scm2int (grob->get_property ("count"), 0));
+}
+
+Grob *
+Grob_selector::retrieve_grob (SCM key)
+{
+ return unsmob_grob (grobs_->get (key));
+}
+
+LY_DEFINE (ly_grob_id, "ly:grob-id",
+ 1, 0, 0, (SCM grob_scm),
+ "Return grob id.")
+{
+ Grob *grob = unsmob_grob (grob_scm);
+ SCM s = Grob_selector::identify_grob (grob);
+ return s;
+}
--- /dev/null
+/*
+ context-selector.hh -- declare Context_selector
+
+ source file of the LilyPond music typesetter
+
+ (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+#ifndef CONTEXT_SELECTOR_HH
+#define CONTEXT_SELECTOR_HH
+
+#include "lily-guile.hh"
+#include "lily-proto.hh"
+
+/**
+ * Context_selector:
+ * @register_context: register new #CONTEXT.
+ #
+ **/
+class Context_selector
+{
+ static Scheme_hash_table *contexts_;
+
+public:
+ static void register_context (Context *context);
+ static SCM identify_context (Context *context, int count);
+ static SCM identify_context (Context *context);
+ static Context *retrieve_context (SCM key);
+};
+
+#endif /* CONTEXT_SELECTOR_HH */
+
--- /dev/null
+/*
+ grob-selector.hh -- declare Grob_selector
+
+ source file of the LilyPond music typesetter
+
+ (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+#ifndef GROB_SELECTOR_HH
+#define GROB_SELECTOR_HH
+
+#include "lily-guile.hh"
+#include "lily-proto.hh"
+
+/**
+ * Grob_selector:
+ * @register_grob: register new #GROB.
+ #
+ **/
+class Grob_selector
+{
+ static int count_;
+ static Scheme_hash_table *grobs_;
+
+public:
+ static void register_grob (Context *context, Grob *grob);
+ static SCM identify_grob (Context *context, Grob *grob, int count);
+ static SCM identify_grob (Grob *grob);
+ static Grob *retrieve_grob (SCM key);
+};
+
+#endif /* GROB_SELECTOR_HH */
Interval robust_relative_extent (Grob*, Grob*, Axis);
#endif /* GROB_HH */
-
VAR, ARGLIST, DOCSTRING)
#define get_property(x) internal_get_property (ly_symbol2scm (x))
-#define set_property(x,y) internal_set_property (ly_symbol2scm (x), y)
+#define set_property(x, y) internal_set_property (ly_symbol2scm (x), y)
#endif /* LILY_GUILE_HH */
Scheme_hash_table (Scheme_hash_table const &);
SCM to_alist () const;
+
private:
SCM hash_tab_;
unsigned elt_count_;
- DECLARE_SMOBS (Scheme_hash_table,foo);
+ DECLARE_SMOBS (Scheme_hash_table, foo);
};
-/*
-score-context.hh -- declare Score_notation_context
-
-source file of the GNU LilyPond music typesetter
-
-(c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
- */
-
+/*
+ score-context.hh -- declare Score_context
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+*/
#ifndef SCORE_CONTEXT_HH
#define SCORE_CONTEXT_HH
#include "global-context.hh"
-
class Score_context : public Context
{
public:
virtual void one_time_step ();
};
-
-
#endif /* SCORE_CONTEXT_HH */
-/*
+/*
slur.hh -- declare Slur
source file of the GNU LilyPond music typesetter
(c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
-#ifndef NEW_SLUR_HH
-#define NEW_SLUR_HH
+#ifndef SLUR_HH
+#define SLUR_HH
#include "lily-proto.hh"
#include "lily-guile.hh"
static Bezier get_curve (Grob*me);
};
-#endif /* NEW_SLUR_HH */
-
+#endif /* SLUR_HH */
}
Moment
-Paper_column::when_mom (Grob*me)
+Paper_column::when_mom (Grob *me)
{
SCM m = me->get_property ("when");
- Moment s (0);
- if (unsmob_moment (m))
- {
- return *unsmob_moment (m);
- }
- return s;
+ if (Moment *when = unsmob_moment (m))
+ return *when;
+ return Moment (0);
}
bool
source file of the GNU LilyPond music typesetter
(c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
+
#include <stdio.h>
#include "scm-hash.hh"
elt_count_ = copy_scm_hashes (hash_tab_, src.hash_tab_);
}
+Scheme_hash_table::~Scheme_hash_table ()
+{
+}
+
SCM
Scheme_hash_table::mark_smob (SCM s)
{
}
else
return false;
-
}
bool
assert (scm_is_symbol (k));
SCM handle = scm_hashq_create_handle_x (hash_tab_, k, SCM_UNDEFINED);
if (scm_cdr (handle) == SCM_UNDEFINED)
- {
- elt_count_++;
- }
+ elt_count_++;
scm_set_cdr_x (handle, v);
Scheme_hash_table::remove (SCM k)
{
scm_hashq_remove_x (hash_tab_, k);
- /*
- don't decrease elt_count_ , as this may cause underflow. The exact
- value of elt_count_ is not important.
- */
-}
-
-Scheme_hash_table::~Scheme_hash_table ()
-{
+ /* Do not decrease elt_count_ as this may cause underflow. The exact
+ value of elt_count_ is not important. */
}
SCM
Scheme_hash_table::to_alist () const
{
- SCM l = SCM_EOL;
+ SCM lst = SCM_EOL;
for (int i = SCM_VECTOR_LENGTH (hash_tab_); i--;)
- for (SCM s = scm_vector_ref (hash_tab_, scm_int2num (i)); scm_is_pair (s); s = scm_cdr (s))
- {
- l = scm_acons (scm_caar (s), scm_cdar (s), l);
- }
- return l;
+ for (SCM s = scm_vector_ref (hash_tab_, scm_int2num (i)); scm_is_pair (s);
+ s = scm_cdr (s))
+ lst = scm_acons (scm_caar (s), scm_cdar (s), lst);
+ return lst;
}
-
-
-
-
IMPLEMENT_SMOBS (Scheme_hash_table);
IMPLEMENT_DEFAULT_EQUAL_P (Scheme_hash_table);
-/*
- score-context.cc -- implement Score_context
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+/*
+ score-context.cc -- implement Score_context
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
#include "score-context.hh"
length, SCM_ARG3, __FUNCTION__, "number or #f");
- bool is_ragged = ragged == SCM_BOOL_T;
+ bool is_ragged = ragged == SCM_BOOL_T;
Simple_spacer spacer;
for (SCM s = springs; scm_is_pair (s); s = scm_cdr (s))
{
(let ((properties (ly:grob-properties grob))
(basic-properties (ly:grob-basic-properties grob))
+ (id (ly:grob-id grob))
(x (inexact->exact (gdk-event-button:x-root event)))
(y (inexact->exact (gdk-event-button:y-root event))))
(add window vbox)
(connect button 'clicked (lambda (b) (destroy window)))
-
+
(for-each
(lambda (x)
(let ((button (make <gtk-button>
(format #f "~S" (cdr x))))))
(set-size-request button 150 BUTTON-HEIGHT)
(add vbox button)))
- properties)
+ (cons (list id) properties))
(add vbox button)
;; FIXME: how to do window placement?