Skip to content

Commit

Permalink
Merge pull request #231 from Qirky/update/beat-counter
Browse files Browse the repository at this point in the history
Update text box border on focus and make beat counter opt-in from the…
  • Loading branch information
Qirky authored May 10, 2020
2 parents 451f5d1 + 1b58fe6 commit ae2b974
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 12 deletions.
40 changes: 30 additions & 10 deletions FoxDot/lib/Workspace/Console.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,14 @@ def __init__(self, master):
self.drag.grid(row=1, column=0, stick="nsew", columnspan=3)
self.canvas.grid(row=2, column=0, sticky="nsew", columnspan=2)
self.counter.grid(row=3, column=0, sticky="nsew", columnspan=2)
self.counter.hide()

self.queue = Queue.Queue()
self.update()

def __str__(self):
""" str(s) -> string """
return self.text.get(1.0, "end")
return self.canvas.itemcget(self.text, "text")

def clear(self):
""" Clears the console """
Expand Down Expand Up @@ -393,12 +394,32 @@ def __init__(self, parent, *args, **kwargs):
self.metro = self.parent.app.namespace['Clock']
self.font = self.parent.app.console_font
self.bg = colour_map.get('background', "gray30")
self.active = True
# Use 4 beats for now - will update in future?

def hide(self):
self.active = False
self.grid_remove()

def unhide(self):
self.active = True
self.grid()

def toggle(self):
if self.active:
self.hide()
else:
self.unhide()

def redraw(self):
"""
Draw boxes and highlight current beat
"""

if not self.active:

return

cycle = self.metro.meter[0]

# Need to adjust for latency
Expand All @@ -410,15 +431,8 @@ def redraw(self):

self.delete("all")

offset = 10
width = 120

self.create_text(w-offset, 0, anchor="ne",
justify=RIGHT,
text=beat + 1,
font=self.font,
fill="#c9c9c9")

box_width = width / cycle
h_offset = 8
box_height = h - h_offset
Expand All @@ -427,5 +441,11 @@ def redraw(self):
x1, x2 = [(val * box_width) + (w - width - 35) for val in [n, (n + 1)]]
y1, y2 = h_offset / 2, box_height + (h_offset / 2)
bg = "red" if n == beat else self.bg
# self.create_rectangle(x1, y1, x2, y2, fill=bg, outline="gray30", )
self.create_rectangle(x1, y1, x2, y2, fill=bg, outline=self.bg, )
self.create_rectangle(x1, y1, x2, y2, fill=bg, outline="gray30", )
# self.create_rectangle(x1, y1, x2, y2, fill=bg, outline=self.bg, )

self.create_text(x2 + (w - x2)/2, h / 2,
justify=RIGHT,
text=beat + 1,
font=self.font,
fill="#c9c9c9")
10 changes: 9 additions & 1 deletion FoxDot/lib/Workspace/Editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ def check_versions():

self.true_fullscreen_toggled = BooleanVar()
self.true_fullscreen_toggled.set(False)

# Boolean for beat counter

self.show_counter = BooleanVar()
self.show_counter.set(False)

# Boolean for showing auto-complete prompt

Expand Down Expand Up @@ -811,7 +816,7 @@ def toggle_transparency(self, event=None):
if SYSTEM == WINDOWS:
self.root.wm_attributes('-transparentcolor', alpha)
else:
self.root.wm_attributes("-transparent", True)
self.root.wm_attributes("-transdef toggle_prparent", True)
except TclError:
self.using_alpha = True
if self.using_alpha:
Expand All @@ -835,6 +840,9 @@ def toggle_prompt(self, event=None):
self.prompt.toggle()
return "break"

def toggle_counter(self, event=None):
self.console.counter.toggle()
return "break"

# Copy/paste etc

Expand Down
1 change: 1 addition & 0 deletions FoxDot/lib/Workspace/MenuBar.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def __init__(self, master, visible=True):
editmenu.add_command(label="Toggle Menu", command=self.root.toggle_menu, accelerator="Ctrl+M")
editmenu.add_checkbutton(label="Toggle Window Transparency", command=self.root.toggle_transparency, variable=self.root.transparent)
editmenu.add_checkbutton(label="Toggle Auto-fill Prompt", command=self.root.toggle_prompt, variable=self.root.show_prompt)
editmenu.add_checkbutton(label="Toggle Beat Counter", command=self.root.toggle_counter, variable=self.root.show_counter)
self.add_cascade(label="Edit", menu=editmenu)

# Note: Alt renders properly to look like Option, so we don't need a
Expand Down
7 changes: 6 additions & 1 deletion FoxDot/lib/Workspace/TextBox.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ class ThreadedText(Text):
def __init__(self, master, **options):
Text.__init__(self, master, **options)
self.root = master
self.config(highlightbackground=background, selectbackground="Dodger Blue", selectforeground="White")
self.config(
highlightbackground=background,
selectbackground="Dodger Blue",
selectforeground="White",
highlightthickness=0
)
self.height = options.get("height", 20)
self.queue = Queue.Queue()
self.lines = 0 # number of lines in the text
Expand Down

0 comments on commit ae2b974

Please sign in to comment.