Commit 1ddafa3b authored by Paul Asmuth's avatar Paul Asmuth
Browse files

re-define the background and content box areas to the content box

parent 6381339d
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
<svg xmlns="http://www.w3.org/2000/svg" width="1439.000000" height="980.000000" viewBox="0 0 1439.0 980.0">
  <rect width="1439.000000" height="980.000000" fill="#ffffff"/>
  <path stroke-width="4.000000" stroke="#000000" fill="none" d="M0.0 0.0 L1439.0 0.0 "/>
  <path stroke-width="4.000000" stroke="#000000" fill="none" d="M1439.0 0.0 L1439.0 980.0 "/>
  <path stroke-width="4.000000" stroke="#000000" fill="none" d="M0.0 980.0 L1439.0 980.0 "/>
  <path stroke-width="4.000000" stroke="#000000" fill="none" d="M0.0 0.0 L0.0 980.0 "/>
  <path stroke-width="1.333333" stroke="#333333" fill="none" d="M62.666667 230.266667 L453.555556 230.266667 "/>
  <path stroke-width="1.333333" stroke="#333333" fill="none" d="M90.587302 230.266667 L90.587302 224.933333 "/>
  <path stroke-width="1.333333" stroke="#333333" fill="none" d="M146.428571 230.266667 L146.428571 224.933333 "/>
@@ -494,4 +490,8 @@
  <path fill="#4572a7" d="M1265.324125 910.266667 L1265.324125 854.845037 L1304.435236 854.845037 L1304.435236 910.266667 "/>
  <path fill="#4572a7" d="M1298.980573 910.266667 L1298.980573 874.753778 L1338.091684 874.753778 L1338.091684 910.266667 "/>
  <path fill="#4572a7" d="M1332.637021 910.266667 L1332.637021 884.439111 L1371.748132 884.439111 L1371.748132 910.266667 "/>
  <path stroke-width="4.000000" stroke="#000000" fill="none" d="M2.666667 959.555556 L1436.333333 959.555556 "/>
  <path stroke-width="4.000000" stroke="#000000" fill="none" d="M1436.333333 959.555556 L1436.333333 977.333333 "/>
  <path stroke-width="4.000000" stroke="#000000" fill="none" d="M2.666667 977.333333 L1436.333333 977.333333 "/>
  <path stroke-width="4.000000" stroke="#000000" fill="none" d="M2.666667 959.555556 L2.666667 977.333333 "/>
</svg>
 No newline at end of file
+3 −1
Original line number Diff line number Diff line
@@ -118,7 +118,8 @@ ReturnCode layout_element(
ReturnCode layout_elements(
    const Layer& layer,
    const Rectangle& parent_bbox,
    std::vector<ElementPlacement>* elements) {
    std::vector<ElementPlacement>* elements,
    Rectangle* content_box) {
  /* sort elements by z-index */
  std::stable_sort(
      elements->begin(),
@@ -165,6 +166,7 @@ ReturnCode layout_elements(
    e.layout.inner_box = layout_state.content_box;
  }

  *content_box = layout_state.content_box;
  return OK;
}

+2 −1
Original line number Diff line number Diff line
@@ -105,7 +105,8 @@ ReturnCode layout_element(
ReturnCode layout_elements(
    const Layer& layer,
    const Rectangle& parent_bbox,
    std::vector<ElementPlacement>* elements);
    std::vector<ElementPlacement>* elements,
    Rectangle* content_box);

} // namespace plotfx
+29 −27
Original line number Diff line number Diff line
@@ -59,9 +59,22 @@ ReturnCode draw(
      margins[2],
      margins[3]);

  /* layout children */
  std::vector<ElementPlacement> children;
  for (const auto& c : config.children) {
    ElementPlacement e;
    e.element = c;
    children.emplace_back(e);
  }

  Rectangle content_box;
  if (auto rc = layout_elements(*layer, margin_box, &children, &content_box); !rc) {
    return rc;
  }

  /* draw background */
  if (config.background) {
    const auto& bg_box = bbox;
    const auto& bg_box = content_box;
    FillStyle bg_fill;
    bg_fill.color = *config.background;

@@ -73,6 +86,13 @@ ReturnCode draw(
        bg_fill);
  }

  /* draw children */
  for (const auto& c : children) {
    if (auto rc = c.element->draw(c.layout, layer); !rc.isSuccess()) {
      return rc;
    }
  }

  /* draw top border  */
  if (config.borders[0].width > 0) {
    StrokeStyle border_style;
@@ -81,8 +101,8 @@ ReturnCode draw(

    strokeLine(
        layer,
        Point(bbox.x, bbox.y),
        Point(bbox.x + bbox.w, bbox.y),
        Point(content_box.x, content_box.y),
        Point(content_box.x + content_box.w, content_box.y),
        border_style);
  }

@@ -94,8 +114,8 @@ ReturnCode draw(

    strokeLine(
        layer,
        Point(bbox.x + bbox.w, bbox.y),
        Point(bbox.x + bbox.w, bbox.y + bbox.h),
        Point(content_box.x + content_box.w, content_box.y),
        Point(content_box.x + content_box.w, content_box.y + content_box.h),
        border_style);
  }

@@ -107,8 +127,8 @@ ReturnCode draw(

    strokeLine(
        layer,
        Point(bbox.x, bbox.y + bbox.h),
        Point(bbox.x + bbox.w, bbox.y + bbox.h),
        Point(content_box.x, content_box.y + content_box.h),
        Point(content_box.x + content_box.w, content_box.y + content_box.h),
        border_style);
  }

@@ -120,29 +140,11 @@ ReturnCode draw(

    strokeLine(
        layer,
        Point(bbox.x, bbox.y),
        Point(bbox.x, bbox.y + bbox.h),
        Point(content_box.x, content_box.y),
        Point(content_box.x, content_box.y + content_box.h),
        border_style);
  }

  /* layout and draw children */
  std::vector<ElementPlacement> children;
  for (const auto& c : config.children) {
    ElementPlacement e;
    e.element = c;
    children.emplace_back(e);
  }

  if (auto rc = layout_elements(*layer, margin_box, &children); !rc) {
    return rc;
  }

  for (const auto& c : children) {
    if (auto rc = c.element->draw(c.layout, layer); !rc.isSuccess()) {
      return rc;
    }
  }

  return OK;
}

+4 −4
Original line number Diff line number Diff line
<svg xmlns="http://www.w3.org/2000/svg" width="1920.000000" height="1080.000000" viewBox="0 0 1920.0 1080.0">
  <rect width="1920.000000" height="1080.000000" fill="#ffffff"/>
  <path fill="#000000" d="M0.0 0.0 L1920.0 0.0 L1920.0 1080.0 L0.0 1080.0 L0.0 0.0 "/>
  <path fill="#ff0000" d="M19.555556 860.444444 L1900.444444 860.444444 L1900.444444 1060.444444 L19.555556 1060.444444 L19.555556 860.444444 "/>
  <path fill="#000000" d="M19.555556 219.555556 L1900.444444 219.555556 L1900.444444 860.444444 L19.555556 860.444444 L19.555556 219.555556 "/>
  <path fill="#ff0000" d="M439.111111 880.0 L1480.888889 880.0 L1480.888889 1040.888889 L439.111111 1040.888889 L439.111111 880.0 "/>
  <path fill="#000000" d="M39.111111 880.0 L239.111111 880.0 L239.111111 1040.888889 L39.111111 1040.888889 L39.111111 880.0 "/>
  <path fill="#ffffff" d="M239.111111 880.0 L439.111111 880.0 L439.111111 1040.888889 L239.111111 1040.888889 L239.111111 880.0 "/>
  <path fill="#000000" d="M1680.888889 880.0 L1880.888889 880.0 L1880.888889 1040.888889 L1680.888889 1040.888889 L1680.888889 880.0 "/>
  <path fill="#ffffff" d="M1480.888889 880.0 L1680.888889 880.0 L1680.888889 1040.888889 L1480.888889 1040.888889 L1480.888889 880.0 "/>
  <path fill="#ff0000" d="M19.555556 19.555556 L1900.444444 19.555556 L1900.444444 219.555556 L19.555556 219.555556 L19.555556 19.555556 "/>
  <path fill="#ff0000" d="M439.111111 39.111111 L1480.888889 39.111111 L1480.888889 200.0 L439.111111 200.0 L439.111111 39.111111 "/>
  <path fill="#000000" d="M39.111111 39.111111 L239.111111 39.111111 L239.111111 200.0 L39.111111 200.0 L39.111111 39.111111 "/>
  <path fill="#ffffff" d="M239.111111 39.111111 L439.111111 39.111111 L439.111111 200.0 L239.111111 200.0 L239.111111 39.111111 "/>
  <path fill="#000000" d="M1680.888889 39.111111 L1880.888889 39.111111 L1880.888889 200.0 L1680.888889 200.0 L1680.888889 39.111111 "/>
  <path fill="#ffffff" d="M1480.888889 39.111111 L1680.888889 39.111111 L1680.888889 200.0 L1480.888889 200.0 L1480.888889 39.111111 "/>
  <path fill="#00ff00" d="M19.555556 219.555556 L1900.444444 219.555556 L1900.444444 860.444444 L19.555556 860.444444 L19.555556 219.555556 "/>
  <path fill="#00ff00" d="M176.0 376.0 L1744.0 376.0 L1744.0 704.0 L176.0 704.0 L176.0 376.0 "/>
  <path fill="#0000ff" d="M176.0 376.0 L1744.0 376.0 L1744.0 704.0 L176.0 704.0 L176.0 376.0 "/>
  <path fill="#ffffff" d="M176.0 376.0 L676.0 376.0 L676.0 704.0 L176.0 704.0 L176.0 376.0 "/>
</svg>
 No newline at end of file
Loading