Skip to content

Commit

Permalink
QoL: Adding polish to pressing buttons.
Browse files Browse the repository at this point in the history
QoL: Cards changing color now is a smoothly eased process.
FIX: The key shortcut to activate a link is now Shift + Enter, since enter alone edits text.
  • Loading branch information
SolarLune committed Nov 24, 2023
1 parent a047e54 commit 5af4829
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 795 deletions.
10 changes: 8 additions & 2 deletions card.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"math"
"math/rand"
"path/filepath"
"sort"
"strconv"
Expand Down Expand Up @@ -330,6 +331,8 @@ type Card struct {
LinkRectPercentage float32

changedProperty *Property
currentColor Color
colorFadeSpeed float64
}

var globalCardID = int64(0)
Expand All @@ -348,6 +351,8 @@ func NewCard(page *Page, contentType string) *Card {
Links: []*LinkEnding{},
ResizeShape: NewShape(8),
DrawHighlighter: true,
currentColor: NewColor(255, 255, 255, 255),
colorFadeSpeed: 0.1 + (rand.Float64() * 0.2),
}

card.Drawable = NewDrawable(card.PostDraw)
Expand Down Expand Up @@ -1313,8 +1318,9 @@ func (card *Card) DrawCard() {
}

if color[3] != 0 {
card.Result.Texture.SetColorMod(color.RGB())
card.Result.Texture.SetAlphaMod(color[3])
card.currentColor = card.currentColor.Mix(color, card.colorFadeSpeed)
card.Result.Texture.SetColorMod(card.currentColor.RGB())
card.Result.Texture.SetAlphaMod(card.currentColor[3])
globals.Renderer.CopyF(card.Result.Texture, nil, tp)
}

Expand Down
7 changes: 6 additions & 1 deletion common.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,12 @@ func (color Color) Equals(other Color) bool {
func (color Color) Mix(other Color, percentage float64) Color {
newColor := NewColor(color.RGBA())
for i := range other {
newColor[i] += uint8((float64(other[i]) - float64(newColor[i])) * percentage)
diff := uint8(math.Ceil((float64(other[i]) - float64(newColor[i])) * percentage))
if diff == 0 {
newColor[i] = other[i]
} else {
newColor[i] += diff
}
}
return newColor
}
Expand Down
5 changes: 5 additions & 0 deletions contents.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ func (cc *CheckboxContents) Update() {
if kb.Pressed(KBCheckboxToggleCompletion) {
prop := cc.Card.Properties.Get("checked")
prop.Set(!prop.AsBool())
if !cc.Checkbox.MultiCheckbox {
cc.Checkbox.IconButton.tween.Reset()
}
} else if kb.Pressed(KBCheckboxEditText) {
kb.Shortcuts[KBCheckboxEditText].ConsumeKeys()
cc.Label.BeginEditing()
Expand All @@ -219,6 +222,8 @@ func (cc *CheckboxContents) Draw() {
dependentCards := cc.DependentCards()
cc.Checkbox.MultiCheckbox = len(dependentCards) > 0

cc.Checkbox.CanPress = !cc.Checkbox.MultiCheckbox

if len(dependentCards) > 0 {

for _, c := range dependentCards {
Expand Down
53 changes: 38 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,44 +1,67 @@
module github.com/solarlune/masterplan

go 1.13
go 1.18

require (
github.com/PuerkitoBio/goquery v1.8.0
github.com/adrg/xdg v0.4.0
github.com/blang/semver v3.5.1+incompatible
github.com/cavaliergopher/grab/v3 v3.0.1
github.com/dsnet/compress v0.0.1 // indirect
github.com/faiface/beep v1.1.0
github.com/frankban/quicktest v1.14.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.0
github.com/gen2brain/beeep v0.0.0-20210529141713-5586760f0cc1
github.com/godbus/dbus/v5 v5.0.6 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gopherjs/gopherjs v0.0.0-20220104163920-15ed2e8cf2bd // indirect
github.com/goware/urlx v0.3.1
github.com/hajimehoshi/go-mp3 v0.3.2 // indirect
github.com/hajimehoshi/oto v1.0.1 // indirect
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b
github.com/jfreymuth/oggvorbis v1.0.3 // indirect
github.com/mewkiz/pkg v0.0.0-20211102230744-16a6ce8f1b77 // indirect
github.com/mholt/archiver v3.1.1+incompatible
github.com/ncruces/zenity v0.8.7
github.com/nwaples/rardecode v1.1.2 // indirect
github.com/otiai10/copy v1.7.0
github.com/phpdave11/gofpdi v1.0.13 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
github.com/signintech/gopdf v0.12.0
github.com/silbinarywolf/preferdiscretegpu v1.0.0
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/tanema/gween v0.0.0-20200427131925-c89ae23cc63c
github.com/tidwall/gjson v1.13.0
github.com/tidwall/sjson v1.2.4
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/veandco/go-sdl2 v0.4.35
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
golang.design/x/clipboard v0.6.0
)

require (
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/akavel/rsrc v0.10.2 // indirect
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/dchest/jsmin v0.0.0-20220218165748-59f39799265f // indirect
github.com/dsnet/compress v0.0.1 // indirect
github.com/frankban/quicktest v1.14.1 // indirect
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 // indirect
github.com/godbus/dbus/v5 v5.0.6 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gopherjs/gopherjs v0.0.0-20220104163920-15ed2e8cf2bd // indirect
github.com/gopherjs/gopherwasm v1.1.0 // indirect
github.com/hajimehoshi/go-mp3 v0.3.2 // indirect
github.com/hajimehoshi/oto v1.0.1 // indirect
github.com/icza/bitio v1.0.0 // indirect
github.com/jfreymuth/oggvorbis v1.0.3 // indirect
github.com/jfreymuth/vorbis v1.0.2 // indirect
github.com/josephspurrier/goversioninfo v1.4.0 // indirect
github.com/mewkiz/flac v1.0.7 // indirect
github.com/mewkiz/pkg v0.0.0-20211102230744-16a6ce8f1b77 // indirect
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
github.com/nwaples/rardecode v1.1.2 // indirect
github.com/phpdave11/gofpdi v1.0.13 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844 // indirect
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
golang.org/x/exp v0.0.0-20220128181451-c853b6ddb95e // indirect
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 // indirect
golang.org/x/mobile v0.0.0-20220112015953-858099ff7816 // indirect
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba // indirect
golang.org/x/text v0.3.7 // indirect
)
Loading

0 comments on commit 5af4829

Please sign in to comment.