/*
- System-start-delimiter-engraver.cc -- implement
- System_start_delimiter_engraver
+ This file is part of LilyPond, the GNU music typesetter.
- source file of the GNU LilyPond music typesetter
+ Copyright (C) 2005--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
- (c) 2005--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ LilyPond 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 3 of the License, or
+ (at your option) any later version.
+ LilyPond 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 LilyPond. If not, see <http://www.gnu.org/licenses/>.
*/
#include "engraver.hh"
-
-#include "side-position-interface.hh"
-#include "system-start-delimiter.hh"
-#include "staff-symbol.hh"
-#include "pointer-group-interface.hh"
-#include "paper-column.hh"
#include "output-def.hh"
+#include "paper-column.hh"
+#include "pointer-group-interface.hh"
+#include "side-position-interface.hh"
#include "spanner.hh"
+#include "staff-symbol.hh"
+#include "system-start-delimiter.hh"
struct Bracket_nesting_node
{
public:
- virtual ~Bracket_nesting_node(){}
+ virtual ~Bracket_nesting_node () {}
virtual bool add_staff (Grob *) { return false; }
- virtual void add_support (Grob *) { }
- virtual void set_bound (Direction, Grob *){}
- virtual void set_nesting_support (Grob*) {}
- virtual void create_grobs (Engraver*, SCM) {}
+ virtual void add_support (Grob *) {}
+ virtual void set_bound (Direction, Grob *) {}
+ virtual void set_nesting_support (Grob *) {}
+ virtual void create_grobs (Engraver *, SCM) {}
};
struct Bracket_nesting_group : public Bracket_nesting_node
{
Spanner *delimiter_;
- vector<Bracket_nesting_node*> children_;
+ vector<Bracket_nesting_node *> children_;
SCM symbol_;
- void from_list (SCM );
+ void from_list (SCM);
virtual void add_support (Grob *grob);
virtual bool add_staff (Grob *grob);
- virtual void set_nesting_support (Grob*);
+ virtual void set_nesting_support (Grob *);
virtual void set_bound (Direction, Grob *grob);
- virtual void create_grobs (Engraver*, SCM);
+ virtual void create_grobs (Engraver *, SCM);
~Bracket_nesting_group ();
Bracket_nesting_group ();
};
-
struct Bracket_nesting_staff : public Bracket_nesting_node
{
Grob *staff_;
virtual bool add_staff (Grob *);
};
-
Bracket_nesting_group::Bracket_nesting_group ()
{
symbol_ = SCM_EOL;
Bracket_nesting_group::create_grobs (Engraver *engraver, SCM default_type)
{
SCM type = scm_is_symbol (symbol_) ? symbol_ : default_type;
- delimiter_ = engraver->make_spanner (ly_symbol2string (type).c_str (), SCM_EOL);
+ delimiter_ = engraver->make_spanner (ly_symbol2string (type).c_str (),
+ SCM_EOL);
- for (vsize i = 0 ; i < children_.size (); i++)
- {
- children_[i]->create_grobs (engraver, default_type);
- }
+ for (vsize i = 0; i < children_.size (); i++)
+ children_[i]->create_grobs (engraver, default_type);
}
void
Bracket_nesting_group::add_support (Grob *g)
{
Side_position_interface::add_support (g, delimiter_);
- for (vsize i = 0 ; i < children_.size (); i++)
- {
- children_[i]->add_support (g);
- }
+ for (vsize i = 0; i < children_.size (); i++)
+ children_[i]->add_support (g);
}
Bracket_nesting_group::~Bracket_nesting_group ()
{
- for (vsize i = 0 ; i < children_.size (); i++)
- delete children_[i];
+ junk_pointers (children_);
}
void
Bracket_nesting_group::set_bound (Direction d, Grob *g)
{
delimiter_->set_bound (d, g);
- for (vsize i = 0 ; i < children_.size (); i++)
- {
- children_[i]->set_bound (d, g);
- }
+ for (vsize i = 0; i < children_.size (); i++)
+ children_[i]->set_bound (d, g);
}
void
{
if (parent)
Side_position_interface::add_support (delimiter_, parent);
-
- for (vsize i = 0 ; i < children_.size (); i++)
- {
- children_[i]->set_nesting_support (delimiter_);
- }
-}
+ for (vsize i = 0; i < children_.size (); i++)
+ children_[i]->set_nesting_support (delimiter_);
+}
void
Bracket_nesting_group::from_list (SCM x)
{
SCM entry = scm_car (s);
if (scm_is_pair (entry))
- {
- Bracket_nesting_group *node = new Bracket_nesting_group;
- node->from_list (entry);
- children_.push_back (node);
- }
+ {
+ Bracket_nesting_group *node = new Bracket_nesting_group;
+ node->from_list (entry);
+ children_.push_back (node);
+ }
else if (entry == ly_symbol2scm ("SystemStartBrace")
- || entry == ly_symbol2scm ("SystemStartBracket")
- || entry == ly_symbol2scm ("SystemStartBar")
- || entry == ly_symbol2scm ("SystemStartSquare")
- )
- symbol_ = entry;
+ || entry == ly_symbol2scm ("SystemStartBracket")
+ || entry == ly_symbol2scm ("SystemStartBar")
+ || entry == ly_symbol2scm ("SystemStartSquare"))
+ symbol_ = entry;
else
- {
- children_.push_back (new Bracket_nesting_staff (0));
- }
+ children_.push_back (new Bracket_nesting_staff (0));
}
}
for (vsize i = 0; i < children_.size (); i++)
{
if (children_[i]->add_staff (grob))
- {
- Pointer_group_interface::add_grob (delimiter_, ly_symbol2scm ("elements"), grob);
- return true;
- }
+ {
+ Pointer_group_interface::add_grob (delimiter_,
+ ly_symbol2scm ("elements"), grob);
+ return true;
+ }
}
-
return false;
}
-
-
-
/****************/
class System_start_delimiter_engraver : public Engraver
protected:
Bracket_nesting_group *nesting_;
-
+
DECLARE_ACKNOWLEDGER (system_start_delimiter);
- DECLARE_ACKNOWLEDGER (system_start_text);
DECLARE_ACKNOWLEDGER (staff_symbol);
void process_music ();
nesting_->from_list (hierarchy);
nesting_->create_grobs (this, delimiter_name);
- nesting_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
+ nesting_->set_bound (LEFT,
+ Grob::unsmob (get_property ("currentCommandColumn")));
}
}
if (nesting_)
{
nesting_->set_bound (RIGHT,
- unsmob_grob (get_property ("currentCommandColumn")));
+ Grob::unsmob (get_property ("currentCommandColumn")));
nesting_->set_nesting_support (0);
+
+ delete nesting_;
}
}
void
System_start_delimiter_engraver::acknowledge_staff_symbol (Grob_info inf)
{
- Grob *staff = inf.grob();
+ Grob *staff = inf.grob ();
bool succ = nesting_->add_staff (staff);
if (!succ)
}
}
-
-
-void
-System_start_delimiter_engraver::acknowledge_system_start_text (Grob_info inf)
-{
- nesting_->add_support (inf.grob ());
-}
-
void
System_start_delimiter_engraver::acknowledge_system_start_delimiter (Grob_info inf)
{
ADD_ACKNOWLEDGER (System_start_delimiter_engraver, staff_symbol);
ADD_ACKNOWLEDGER (System_start_delimiter_engraver, system_start_delimiter);
-ADD_ACKNOWLEDGER (System_start_delimiter_engraver, system_start_text);
ADD_TRANSLATOR (System_start_delimiter_engraver,
- /* doc */ "Creates a system start delimiter (ie. SystemStart@{Bar, Brace, Bracket@} spanner",
- /* create */ "SystemStartSquare "
- "SystemStartBrace "
- "SystemStartBracket "
- "SystemStartBar",
- /* read */
- "systemStartDelimiter "
- "systemStartDelimiterHierarchy "
- "currentCommandColumn",
-
- /* write */ "");
+ /* doc */
+ "Create a system start delimiter (i.e., a"
+ " @code{SystemStartBar}, @code{SystemStartBrace},"
+ " @code{SystemStartBracket} or @code{SystemStartSquare}"
+ " spanner).",
+
+ /* create */
+ "SystemStartSquare "
+ "SystemStartBrace "
+ "SystemStartBracket "
+ "SystemStartBar ",
+
+ /* read */
+ "systemStartDelimiter "
+ "systemStartDelimiterHierarchy "
+ "currentCommandColumn ",
+
+ /* write */
+ ""
+ );