Skip to content

Commit

Permalink
Fix up auto complete prompt for OS without known fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
Qirky committed Apr 12, 2020
1 parent 3f56478 commit 77ec25a
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 140 deletions.
58 changes: 36 additions & 22 deletions FoxDot/lib/Workspace/Console.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, master):

self.app = master
self.root = master.root

self.y_scroll = Scrollbar(self.root)
self.y_scroll.grid(row=2, column=2, sticky='nsew', rowspan=3)
self.scrollable = False
Expand All @@ -33,8 +33,20 @@ def __init__(self, master):

# Create a bar for changing console size and displaying info about beat number

self.drag = Frame(self.root , bg="white", height=2, cursor="sb_v_double_arrow")
self.counter = Counter(self, self.root, bd=0, bg=colour_map['background'], height=25,)
self.drag = Frame(
self.root,
bg="white",
height=2,
cursor="sb_v_double_arrow"
)
self.counter = Counter(
self,
self.root,
bd=0,
bg='black',
height=25,
highlightthickness=0
)

# Create canvas

Expand All @@ -58,7 +70,7 @@ def __init__(self, master):

self.padx = 5
self.pady = 5

self.text_y = 0

self.text_height = 0
Expand All @@ -81,14 +93,14 @@ def __init__(self, master):

# Allow for resizing
self.mouse_down = False
self.drag.bind("<Button-1>", self.drag_mouseclick)
self.drag.bind("<Button-1>", self.drag_mouseclick)
self.drag.bind("<ButtonRelease-1>", self.drag_mouserelease)
self.drag.bind("<B1-Motion>", self.drag_mousedrag)

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.queue = Queue.Queue()
self.update()

Expand Down Expand Up @@ -118,7 +130,7 @@ def drag_mouseclick(self, event):
self.mouse_down = True
self.root.grid_propagate(False)
return

def drag_mouserelease(self, event):
self.mouse_down = False
self.app.text.focus_set()
Expand All @@ -132,7 +144,7 @@ def drag_mousedrag(self, event):
if textbox_line_h is not None:

self.app.text.height = int(self.app.text.winfo_height() / textbox_line_h[3])

self.root_h = self.height + self.app.text.height

widget_y = self.canvas.winfo_rooty()
Expand All @@ -159,7 +171,7 @@ def update(self):
self.canvas.insert( self.text, "end", string )

# Get the text bounding box

bbox = self.canvas.bbox(self.text)

# Text box height
Expand Down Expand Up @@ -221,18 +233,18 @@ def canvas_mouseclick(self, event):
# Calculate current mouse pos
x = self.canvas.canvasx(event.x)
y = self.canvas.canvasx(event.y)

self.text_cursor = "@%d,%d" % (x, y)

return

def canvas_mousedrag(self, event):
""" Changes selection """
x = self.canvas.canvasx(event.x)
y = self.canvas.canvasx(event.y)

xy = "@%d,%d" % (x, y)

self.canvas.select_from(self.text, self.text_cursor)
self.canvas.select_to(self.text, xy)
return
Expand Down Expand Up @@ -269,11 +281,11 @@ def scroll_text(self, *args):

def move_text(self, delta):
""" Moves the text up (negative) or down (positive) """

if SYSTEM != MAC_OS:

delta /= 100

x, y = self.canvas.coords(self.text)

self.text_y = max(min(self.pady, y + delta), self.max_offset)
Expand All @@ -283,9 +295,9 @@ def move_text(self, delta):
self.update_scrollbar()

return

def on_scroll(self, event):
if self.scrollable: self.move_text(event.delta)
if self.scrollable: self.move_text(event.delta)
return "break"

def get_scrollbar_size(self):
Expand All @@ -301,7 +313,7 @@ def update_scrollbar(self, point=None):
a = point
else:
a = (float(self.text_y) / self.max_offset) * (1-size)
b = a + size
b = a + size
self.y_scroll.set(a, b)
return a, b

Expand Down Expand Up @@ -347,7 +359,7 @@ def draw_logo(self):

# Shuffle the widths and use a mirrored version for red
random.shuffle(grn_widths)

red_widths = reversed(grn_widths)

start_x = random.choice([50,100,150,200])
Expand Down Expand Up @@ -379,7 +391,8 @@ def __init__(self, parent, *args, **kwargs):
Canvas.__init__(self, *args, **kwargs)
self.parent = parent
self.metro = self.parent.app.namespace['Clock']
self.font = self.parent.app.codefont
self.font = self.parent.app.console_font
self.bg = colour_map.get('background', "gray30")
# Use 4 beats for now - will update in future?

def redraw(self):
Expand Down Expand Up @@ -413,5 +426,6 @@ def redraw(self):
for n in range(cycle):
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 "gray30"
self.create_rectangle(x1, y1, x2, y2, fill=bg, outline="gray30")
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, )
Loading

0 comments on commit 77ec25a

Please sign in to comment.