Commit 0a3fdcd1 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

pipe through text/border colour

parent 0396d164
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ ReturnCode buildDocument(
    const auto& elem_config = plist[i].child.get();

    std::unique_ptr<Element> elem;
    if (auto rc = buildElement(elem_name, *elem_config, &elem); !rc.isSuccess()) {
    if (auto rc = buildElement(*doc, elem_name, *elem_config, &elem); !rc.isSuccess()) {
      return rc;
    }

+3 −2
Original line number Diff line number Diff line
@@ -33,13 +33,14 @@

namespace plotfx {

using ElementConfigureFn = std::function<ReturnCode (const PropertyList&, ElementRef*)>;
using ElementConfigureFn = std::function<ReturnCode (const Document&, const PropertyList&, ElementRef*)>;

static std::unordered_map<std::string, ElementConfigureFn> elems = {
  {"plot", &plot::configure}
};

ReturnCode buildElement(
    const Document& doc,
    const std::string& name,
    const PropertyList& plist,
    std::unique_ptr<Element>* elem) {
@@ -48,7 +49,7 @@ ReturnCode buildElement(
    return ReturnCode::errorf("NOTFOUND", "no such element: $0", name);
  }

  return elem_entry->second(plist, elem);
  return elem_entry->second(doc, plist, elem);
}

} // namespace plotfx
+2 −0
Original line number Diff line number Diff line
@@ -32,8 +32,10 @@
#include "element.h"

namespace plotfx {
struct Document;

ReturnCode buildElement(
    const Document& doc,
    const std::string& name,
    const plist::PropertyList& plist,
    std::unique_ptr<Element>* elem);
+15 −1
Original line number Diff line number Diff line
@@ -97,8 +97,22 @@ ReturnCode configure_series(const plist::Property& prop, PlotConfig* config) {
  return OK;
}

ReturnCode configure(const plist::PropertyList& plist, ElementRef* elem) {
ReturnCode configure(
    const Document& doc,
    const plist::PropertyList& plist,
    ElementRef* elem) {
  PlotConfig config;

  // FIXME
  config.axis_top.border_colour = doc.border_colour;
  config.axis_top.text_colour = doc.text_colour;
  config.axis_right.border_colour = doc.border_colour;
  config.axis_right.text_colour = doc.text_colour;
  config.axis_bottom.border_colour = doc.border_colour;
  config.axis_bottom.text_colour = doc.text_colour;
  config.axis_left.border_colour = doc.border_colour;
  config.axis_left.text_colour = doc.text_colour;

  static const ParserDefinitions pdefs = {
    {
      "margin",
+2 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include <graphics/viewport.h>
#include <common/domain.h>
#include <common/element.h>
#include <common/document.h>
#include "plot_axis.h"

namespace plotfx {
@@ -60,6 +61,7 @@ struct PlotConfig {
ReturnCode draw(const PlotConfig& config, const Rectangle& clip, Layer* frame);

ReturnCode configure(
    const Document& doc,
    const plist::PropertyList& plist,
    ElementRef* elem);

Loading