Merge fixes: one Rule, ArtifactKind, CommandRun and abs32 across groups
This commit is contained in:
6 files changed
+6
-37
No files matched your search
@@ -10,15 +10,6 @@ import (
|
|||||||
"mujicaui/theme"
|
"mujicaui/theme"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ArtifactKind is what an artifact holds; zero is ArtifactCode.
|
|
||||||
type ArtifactKind int
|
|
||||||
|
|
||||||
const (
|
|
||||||
ArtifactCode ArtifactKind = iota
|
|
||||||
ArtifactDocument
|
|
||||||
ArtifactWeb
|
|
||||||
)
|
|
||||||
|
|
||||||
// ArtifactCardOptions configure an ArtifactCard. Title is required.
|
// ArtifactCardOptions configure an ArtifactCard. Title is required.
|
||||||
type ArtifactCardOptions struct {
|
type ArtifactCardOptions struct {
|
||||||
Kind ArtifactKind
|
Kind ArtifactKind
|
||||||
|
|||||||
@@ -12,17 +12,6 @@ import (
|
|||||||
"mujicaui/theme"
|
"mujicaui/theme"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CommandRun is a command and its output from the caller.
|
|
||||||
type CommandRun struct {
|
|
||||||
Command string
|
|
||||||
// Output may hold ANSI escapes.
|
|
||||||
Output string
|
|
||||||
ExitCode int
|
|
||||||
Duration time.Duration
|
|
||||||
// Running hides ExitCode and Duration behind a live mark.
|
|
||||||
Running bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// CommandBlockOptions configure a CommandBlock.
|
// CommandBlockOptions configure a CommandBlock.
|
||||||
type CommandBlockOptions struct {
|
type CommandBlockOptions struct {
|
||||||
// Prompt precedes the command; empty means "$".
|
// Prompt precedes the command; empty means "$".
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
package internal
|
|
||||||
|
|
||||||
import "github.com/egoist/mygo/ui"
|
|
||||||
|
|
||||||
// Rule draws a pixel-aligned 1 DIP horizontal line at y.
|
|
||||||
func Rule(p *ui.Painter, x0, x1, y float32, c ui.Color) {
|
|
||||||
yy := ruleY(p, y)
|
|
||||||
p.Line(x0, yy, x1, yy, 1, c)
|
|
||||||
}
|
|
||||||
@@ -189,12 +189,6 @@ func Sector(cx, cy, r0, r1 float32, a0, a1 float64) *ui.Path {
|
|||||||
return &path
|
return &path
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rule draws a pixel-aligned 1 DIP horizontal line at y.
|
|
||||||
func Rule(p *ui.Painter, x0, x1, y float32, c ui.Color) {
|
|
||||||
yy := ruleY(p, y)
|
|
||||||
p.Line(x0, yy, x1, yy, 1, c)
|
|
||||||
}
|
|
||||||
|
|
||||||
// AxisY draws grid lines and tick labels left of plot.
|
// AxisY draws grid lines and tick labels left of plot.
|
||||||
func AxisY(p *ui.Painter, plot ui.Rect, s Linear, ticks []float64, label func(float64) string, size float32, k theme.Tokens) {
|
func AxisY(p *ui.Painter, plot ui.Rect, s Linear, ticks []float64, label func(float64) string, size float32, k theme.Tokens) {
|
||||||
for _, t := range ticks {
|
for _, t := range ticks {
|
||||||
|
|||||||
@@ -6,6 +6,12 @@ import (
|
|||||||
"github.com/egoist/mygo/ui"
|
"github.com/egoist/mygo/ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Rule draws a pixel-aligned 1 DIP horizontal line at y.
|
||||||
|
func Rule(p *ui.Painter, x0, x1, y float32, c ui.Color) {
|
||||||
|
yy := ruleY(p, y)
|
||||||
|
p.Line(x0, yy, x1, yy, 1, c)
|
||||||
|
}
|
||||||
|
|
||||||
// ruleY moves y to where a 1 DIP line fills whole device pixels.
|
// ruleY moves y to where a 1 DIP line fills whole device pixels.
|
||||||
func ruleY(p *ui.Painter, y float32) float32 {
|
func ruleY(p *ui.Painter, y float32) float32 {
|
||||||
s := float64(p.Scale())
|
s := float64(p.Scale())
|
||||||
|
|||||||
@@ -158,5 +158,3 @@ func ScatterChart(c *ui.Context, selected *[]ScatterKey, groups []ScatterGroup,
|
|||||||
func scatterRect(d scatterDrag, ox, oy float32) ui.Rect {
|
func scatterRect(d scatterDrag, ox, oy float32) ui.Rect {
|
||||||
return ui.Rect{X: ox + min(d.x0, d.x1), Y: oy + min(d.y0, d.y1), W: abs32(d.x1 - d.x0), H: abs32(d.y1 - d.y0)}
|
return ui.Rect{X: ox + min(d.x0, d.x1), Y: oy + min(d.y0, d.y1), W: abs32(d.x1 - d.x0), H: abs32(d.y1 - d.y0)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func abs32(v float32) float32 { return max(v, -v) }
|
|
||||||
Reference in new issue
Block a user