Skip to content

Commit

Permalink
Try to fix scroll bars not showing up on teeny baby windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaythebusinessgoose authored and gmjosack committed Dec 18, 2023
1 parent 5d42e8b commit b2d0163
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/modlunky2/ui/levels/custom_levels/custom_level_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,8 @@ def draw_layer(canvas_index, tile_codes):
for index, tileset in enumerate(self.tile_codes):
draw_layer(CanvasIndex(index, 0), tileset)

self.canvas.update_scroll_region()

# Click event on a canvas for either left or right click to replace the tile at the cursor's position with
# the selected tile.
def canvas_click(self, canvas_index, row, column, is_primary):
Expand Down
5 changes: 5 additions & 0 deletions src/modlunky2/ui/levels/shared/multi_canvas_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(

scrollable_frame = tk.Frame(scrollable_canvas, bg="#343434")
scrollable_frame.grid(row=0, column=0, sticky="nswe")
self.scrollable_frame = scrollable_frame

width = scrollable_canvas.winfo_screenwidth()
height = scrollable_canvas.winfo_screenheight()
Expand Down Expand Up @@ -207,6 +208,10 @@ def switch_layer():
)
intro_label.place(relx=0.5, rely=0.5, anchor="center")

def update_scroll_region(self):
self.scrollable_canvas.update_idletasks()
self.scrollable_canvas.config(scrollregion=self.scrollable_frame.bbox("all"))

def _on_mousewheel(self, event, hbar, vbar, canvas):
scroll_dir = None
if event.num == 5 or event.delta == -120:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,8 @@ def draw_chunk(canvas_index, chunk_start_x, chunk_start_y, tile_codes):
room_column_index,
)

self.canvas.update_scroll_region()

def template_item_at(self, map_index, row, col):
for room_row_index, room_row in enumerate(
self.template_draw_map[map_index].rooms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,7 @@ def map_layer(layer):

comment = str(chunk.comment).lstrip("/ ").strip()

return RoomInstance(
comment, settings, foreground_tiles, background_tiles
)
return RoomInstance(comment, settings, foreground_tiles, background_tiles)

def convert_to_chunk(self, room_instance):
bg = []
Expand Down Expand Up @@ -1017,7 +1015,7 @@ def room_select(self, _event): # Loads room when click if not parent node.
x_coord,
y_coord,
)

self.canvas.update_scroll_region()
else:
self.canvas.clear()
self.canvas.hide_canvas(1, True)
Expand Down

0 comments on commit b2d0163

Please sign in to comment.