Skip to content

Commit

Permalink
Add horizontal alignments of box text
Browse files Browse the repository at this point in the history
  • Loading branch information
brunchboy committed Feb 19, 2023
1 parent 0a96d33 commit 6a967c5
Show file tree
Hide file tree
Showing 8 changed files with 894 additions and 870 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ This change log follows the conventions of

Nothing so far.

## [1.8.0] - 2023-02-19

### Added

- It is now possible to change the horizontal alignment of text labels
within `draw-box` using two new box attributes, `:text-anchor` and
`:margin`.

## [1.7.0] - 2022-11-15

### Added
Expand Down Expand Up @@ -157,7 +165,8 @@ This was the first release that actually worked when installed via

Intial early release.

[unreleased]: https://github.com/Deep-Symmetry/bytefield-svg/compare/v1.7.0...HEAD
[unreleased]: https://github.com/Deep-Symmetry/bytefield-svg/compare/v1.8.0...HEAD
[1.8.0]: https://github.com/Deep-Symmetry/bytefield-svg/compare/v1.7.0...v1.8.0
[1.7.0]: https://github.com/Deep-Symmetry/bytefield-svg/compare/v1.6.1...v1.7.0
[1.6.1]: https://github.com/Deep-Symmetry/bytefield-svg/compare/v1.6.0...v1.6.1
[1.6.0]: https://github.com/Deep-Symmetry/bytefield-svg/compare/v1.5.0...v1.6.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ version in `package.json`, tag and push to GitHub, then run:
<a href="http://deepsymmetry.org"><img align="right" alt="Deep Symmetry"
src="doc/assets/DS-logo-github.png" width="250" height="150"></a>

Copyright © 2020–2022 [Deep Symmetry, LLC](http://deepsymmetry.org)
Copyright © 2020–2023 [Deep Symmetry, LLC](http://deepsymmetry.org)

Distributed under the [Eclipse Public License
2.0](https://opensource.org/licenses/EPL-2.0). By using this software
Expand Down
4 changes: 2 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;; Clojure dependency information and source location.
{:deps {thheller/shadow-cljs {:mvn/version "2.17.1"}
org.clojure/clojure {:mvn/version "1.10.3"}
{:deps {thheller/shadow-cljs {:mvn/version "2.20.20"}
org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/tools.reader {:mvn/version "1.3.6"}
analemma/analemma {:mvn/version "1.1.0"}
borkdude/sci {:git/url "https://github.com/borkdude/sci.git"
Expand Down
2 changes: 1 addition & 1 deletion doc/antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ asciidoc:
attributes:
icons: font
experimental: ''
page-copyright: 2020–2022
page-copyright: 2020–2023
page-pagination: ''
nav:
- modules/ROOT/nav.adoc
16 changes: 16 additions & 0 deletions doc/modules/ROOT/pages/funcs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ attributes:
height of the box. Normally it is controlled by the
<<values.adoc#,predefined value>> `row-height`.

|:margin |4 |If you supply a value of `"start"` or `"end"` for the
`:text-anchor` attribute, then `:margin` will control the number of
pixels of margin that separate the text of your label from the
corresponding edge of the box.

|:next-row-height |_n/a_ |If you pass a value here and this box is the
first box to be drawn on a new row, it will set `row-height` to the
specified value after finishing off the old row and before starting
Expand All @@ -322,20 +327,31 @@ attributes:
supply a `:span` value ranging from 1 to the remaining columns in
the row. If you try to go beyond the end of the row, an exception
will be thrown.

|:text-anchor |"middle" |Controls the horizontal alignment of a text
label within the box. By default they are centered horizontally. A
value of `"start"` will cause it to be left-aligned, and `"end"` will
right-align it. The text will start or end 4 pixels from the
corresponding edge of the box unless you specify a different value
for the `:margin` attibute. `:text-anchor` has no effect if you
supply a custom function to render your label.

|===

Here are some sample boxes:

[source,clojure]
(draw-box 1)
(draw-box "two" {:span 2})
(draw-box "left" {:span 2 :text-anchor "start"})
(draw-box nil {:fill "#a0ffa0"})
(draw-box false)

[bytefield]
----
(draw-box 1)
(draw-box "two" {:span 2})
(draw-box "left" {:span 2 :text-anchor "start"})
(draw-box nil {:fill "#a0ffa0"})
(draw-box false)
----
Expand Down
Loading

0 comments on commit 6a967c5

Please sign in to comment.