mirror of
git://sourceware.org/git/libabigail.git
synced 2025-01-18 15:20:45 +00:00
Pull out common style type.
* src/abg-viz-common.h: Pull out common style type. * src/abg-viz-dot.cc: Adjust scoping. * src/abg-viz-common.cc: Same. * src/abg-viz-dot.h: Use common style class. * src/abg-viz-svg.h: Same.
This commit is contained in:
parent
1807401e6c
commit
202476207b
@ -53,10 +53,10 @@ const typography source_code_pro_typo = \
|
||||
const typography roboto_typo = \
|
||||
{ "Roboto Light", 12, color::black, R"(text-anchor="middle")"};
|
||||
|
||||
const row::style primary_row_sty = { color::white, color::black, "" };
|
||||
const row::style base_row_sty = { color::white, color::gray75, "" };
|
||||
const row::style member_row_sty = { color::black, color::gray25, "" };
|
||||
const row::style implementation_row_sty = { color::black, color::white, "" };
|
||||
const style primary_row_sty = { color::white, color::black, "" };
|
||||
const style base_row_sty = { color::white, color::gray75, "" };
|
||||
const style member_row_sty = { color::black, color::gray25, "" };
|
||||
const style implementation_row_sty = { color::black, color::white, "" };
|
||||
|
||||
|
||||
// XXX Do not export.
|
||||
@ -147,7 +147,7 @@ typography::to_attribute(anchor __a) const
|
||||
string_replace(strip, size, std::to_string(_M_size));
|
||||
string_replace(strip, anchor, anchor_to_string(__a));
|
||||
|
||||
// NB: Add in extra _M_style if necessary.
|
||||
// NB: Add in extra _M_attributes if necessary.
|
||||
return strip;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,11 @@
|
||||
namespace abigail
|
||||
{
|
||||
|
||||
// Utility function, like regex_replace.
|
||||
void
|
||||
string_replace(std::string&, const std::string&, const std::string&);
|
||||
|
||||
|
||||
/// Measurement abstraction type, conversion function.
|
||||
enum class units
|
||||
{
|
||||
@ -49,19 +54,6 @@ units_to_string(units);
|
||||
typedef unsigned short units_type;
|
||||
|
||||
|
||||
/// Color, conversion function.
|
||||
enum class color
|
||||
{
|
||||
white,
|
||||
gray25, // gainsboro
|
||||
gray75, // slategray
|
||||
black
|
||||
};
|
||||
|
||||
std::string
|
||||
color_to_string(color);
|
||||
|
||||
|
||||
/*
|
||||
Page/Canvas/Drawing area description.
|
||||
Size, origin location in 2D (x,y), heigh, width
|
||||
@ -83,6 +75,19 @@ extern const canvas ansi_letter_canvas;
|
||||
extern const canvas iso_a4_canvas;
|
||||
|
||||
|
||||
/// Color, conversion function.
|
||||
enum class color
|
||||
{
|
||||
white,
|
||||
gray25, // gainsboro
|
||||
gray75, // slategray
|
||||
black
|
||||
};
|
||||
|
||||
std::string
|
||||
color_to_string(color);
|
||||
|
||||
|
||||
/*
|
||||
Character rendering, type, fonts, styles.
|
||||
|
||||
@ -112,9 +117,15 @@ extern const typography arial_typo;
|
||||
extern const typography source_code_pro_typo;
|
||||
extern const typography roboto_light_typo;
|
||||
|
||||
// Utility function, like regex_replace.
|
||||
void
|
||||
string_replace(std::string&, const std::string&, const std::string&);
|
||||
|
||||
/// Datum consolidating style preferences.
|
||||
struct style
|
||||
{
|
||||
color _M_text_color;
|
||||
color _M_fill_color;
|
||||
std::string _M_attributes;
|
||||
};
|
||||
|
||||
|
||||
}// end namespace abigail
|
||||
|
||||
|
@ -35,33 +35,60 @@ using std::ostream;
|
||||
using std::ostringstream;
|
||||
|
||||
// Constants.
|
||||
const parent::style parent_sty = { color::white, color::black, "" };
|
||||
const child::style child_sty = { color::white, color::gray75, "" };
|
||||
|
||||
// DOT element beginning boilerplate.
|
||||
// Variable: units, x=0, y=0, width, height
|
||||
void
|
||||
dot::start_element()
|
||||
{ }
|
||||
|
||||
void
|
||||
dot::finish_element()
|
||||
{ }
|
||||
|
||||
void
|
||||
dot::add_title()
|
||||
{ }
|
||||
const style parent_sty = { color::white, color::black, "" };
|
||||
const style child_sty = { color::white, color::gray75, "" };
|
||||
|
||||
void
|
||||
dot::write()
|
||||
{ }
|
||||
{
|
||||
try
|
||||
{
|
||||
std::string filename(_M_title + ".gv");
|
||||
std::ofstream f(filename);
|
||||
if (!f.is_open() || !f.good())
|
||||
throw std::runtime_error("abigail::dot::write fail");
|
||||
|
||||
f << _M_sstream.str() << std::endl;
|
||||
}
|
||||
catch(std::exception& e)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
// DOT element beginning boilerplate.
|
||||
void
|
||||
dot::start_element()
|
||||
{
|
||||
const std::string start = R"_delimiter_(digraph "__title" {)_delimiter_";
|
||||
_M_sstream << "digraph " << std::endl;
|
||||
add_title();
|
||||
_M_sstream << "{" << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
dot::add_parent(const parent&)
|
||||
{ }
|
||||
dot::finish_element()
|
||||
{
|
||||
_M_sstream << "}" << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
dot::add_child(const child&)
|
||||
{ }
|
||||
dot::add_title()
|
||||
{
|
||||
|
||||
_M_sstream << '"' << _M_title << '"' << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
dot::add_parent(const parent& __p)
|
||||
{
|
||||
_M_sstream << "" << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
dot::add_child(const child& __c)
|
||||
{
|
||||
_M_sstream << "" << std::endl;
|
||||
}
|
||||
|
||||
}//end namespace abigail
|
||||
|
@ -47,14 +47,6 @@ struct node_base
|
||||
*/
|
||||
struct parent
|
||||
{
|
||||
// XXX need type-based mechanism for styles
|
||||
struct style
|
||||
{
|
||||
color _M_text_color;
|
||||
color _M_fill_color;
|
||||
std::string _M_style; // Any other attributes
|
||||
};
|
||||
|
||||
std::string _M_id;
|
||||
const style& _M_style;
|
||||
|
||||
@ -62,7 +54,7 @@ struct parent
|
||||
};
|
||||
|
||||
/// Useful parent constants.
|
||||
extern const parent::style parent_sty;
|
||||
extern const style parent_sty;
|
||||
|
||||
|
||||
/*
|
||||
@ -76,14 +68,6 @@ struct parent
|
||||
*/
|
||||
struct child
|
||||
{
|
||||
// XXX need type-based mechanism for styles
|
||||
struct style
|
||||
{
|
||||
color _M_text_color;
|
||||
color _M_fill_color;
|
||||
std::string _M_style; // Any other attributes
|
||||
};
|
||||
|
||||
std::string _M_id;
|
||||
const style& _M_style;
|
||||
|
||||
@ -91,7 +75,7 @@ struct child
|
||||
};
|
||||
|
||||
/// Useful child constants.
|
||||
extern const child::style child_sty;
|
||||
extern const style child_sty;
|
||||
|
||||
|
||||
/*
|
||||
|
@ -45,14 +45,6 @@ namespace abigail
|
||||
*/
|
||||
struct row
|
||||
{
|
||||
// XXX need type-based mechanism for styles
|
||||
struct style
|
||||
{
|
||||
color _M_text_color;
|
||||
color _M_fill_color;
|
||||
std::string _M_style; // Any other attributes
|
||||
};
|
||||
|
||||
std::string _M_id;
|
||||
const style& _M_style;
|
||||
|
||||
@ -62,10 +54,10 @@ struct row
|
||||
};
|
||||
|
||||
/// Useful row constants. Maybe just do enum->value map.
|
||||
extern const row::style primary_row_sty;
|
||||
extern const row::style base_row_sty;
|
||||
extern const row::style member_row_sty;
|
||||
extern const row::style implementation_row_sty;
|
||||
extern const style primary_row_sty;
|
||||
extern const style base_row_sty;
|
||||
extern const style member_row_sty;
|
||||
extern const style implementation_row_sty;
|
||||
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user