Skip to content

Commit

Permalink
Commit one more WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhanshuguptagit committed Jul 1, 2024
1 parent ec76968 commit e9182ab
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/bean/frames.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
sheet))

(defn add-labels [sheet frame-name addresses dirn]
(reduce #(add-label %1 frame-name %2 dirn (util/random-color-hex)) sheet addresses))
(reduce #(add-label %1 frame-name %2 dirn
(case dirn
:top (util/random-color-hex (str (first %2) dirn))
:left (util/random-color-hex (str (second %2) dirn))
(util/random-color-hex))) sheet addresses))

(defn remove-labels [sheet frame-name addresses]
(reduce #(update-in % [:frames frame-name :labels] dissoc %2) sheet addresses))
Expand Down
1 change: 0 additions & 1 deletion src/bean/ui/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@

(rf/reg-event-fx
::renaming-frame
(undoable)
(fn edit-frame [{:keys [db]} [_ frame-name]]
{:db (assoc-in db [:ui :renaming-frame] frame-name)
:fx [[:dispatch [::select-frame frame-name]]]}))
Expand Down
2 changes: 1 addition & 1 deletion src/bean/ui/styles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
:frame-name-padding 3})

(def cell-background-colors
[nil 0xcccccc 0xffc9c9 0xb2f2bb 0xa5d8ff 0xffec99])
[nil 0xcccccc 0xb2f2bb 0xa5d8ff 0xffec99])
15 changes: 11 additions & 4 deletions src/bean/util.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,17 @@
(for [c (range start-c (inc end-c))]
[r c])))

(defn random-color-hex []
(+ (bit-shift-left (rand-int 256) 16)
(bit-shift-left (rand-int 256) 8)
(rand-int 256)))
(defn random-color-hex
([]
(random-color-hex (rand-int 1000000)))
([seed]
(let [hash (hash seed)
r (mod (bit-shift-right hash 16) 256)
g (mod (bit-shift-right hash 8) 256)
b (mod hash 256)]
(+ (bit-shift-left r 16)
(bit-shift-left g 8)
b))))

(defn merged-or-self [[r c] sheet]
(or (get-in sheet [:grid r c :style :merged-with]) [r c]))
Expand Down

0 comments on commit e9182ab

Please sign in to comment.