Skip to content

Commit

Permalink
Listbox: Drop 'listbox::kHeight' requirement
Browse files Browse the repository at this point in the history
Actually adds code but this is progress towards a minimal listbox
control block.
  • Loading branch information
inexorabletash committed Oct 8, 2023
1 parent fff2a33 commit d58f05d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion desk.acc/find.files.s
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,6 @@ show_index: .byte $FF

.scope listbox
winfo = winfo_results
kHeight = kResultsHeight
kRows = kResultsRows
num_items = num_entries
item_pos = cur_pos
Expand Down
1 change: 0 additions & 1 deletion desk.acc/sounds.s
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,6 @@ OnListSelectionNoChange := OnListSelectionChange

.scope listbox
winfo = winfo_listbox
kHeight = winfo_listbox::kHeight
kRows = kListRows
num_items = num_sounds
item_pos = itempos
Expand Down
1 change: 0 additions & 1 deletion disk_copy/auxlc.s
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,6 @@ CheckAlpha:

.scope listbox
winfo = winfo_drive_select
kHeight = kListBoxHeight
kRows = kListRows
num_items = num_drives
item_pos = list_entry_pos
Expand Down
1 change: 0 additions & 1 deletion lib/file_dialog.s
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,6 @@ HandleCancel: jmp 0

.scope listbox
winfo = file_dialog_res::winfo_listbox
kHeight = file_dialog_res::winfo_listbox::kHeight
kRows = file_dialog_res::kListRows
num_items = num_file_names
item_pos = file_dialog_res::picker_entry_pos
Expand Down
12 changes: 9 additions & 3 deletions lib/listbox.s
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
;;;
;;; Requires `listbox` scope with:
;;; * `winfo` - winfo of the list control
;;; * `kHeight` - height of the list in pixels
;;; * `kRows` - number of visible rows in the list
;;; * `num_items` - number of items in the list
;;; * `item_pos` - a scratch MGTK::Point
Expand Down Expand Up @@ -455,11 +454,18 @@ skip: lda #SELF_MODIFIED_BYTE
;;; the GrafPort using the client's `SetPortForList`.

.proc _SetPort
maprect := listbox::winfo+MGTK::Winfo::port+MGTK::GrafPort::maprect

;; Set y2 to height
sub16 maprect+MGTK::Rect::y2, maprect+MGTK::Rect::y1, maprect+MGTK::Rect::y2

ldax #kListItemHeight
ldy listbox::winfo+MGTK::Winfo::vthumbpos
jsr Multiply_16_8_16
stax listbox::winfo+MGTK::Winfo::port+MGTK::GrafPort::maprect+MGTK::Rect::y1
addax #listbox::kHeight, listbox::winfo+MGTK::Winfo::port+MGTK::GrafPort::maprect+MGTK::Rect::y2
stax maprect+MGTK::Rect::y1

;; Set y2 to bottom
addax maprect+MGTK::Rect::y2, maprect+MGTK::Rect::y2

jmp SetPortForList
.endproc ; _SetPort
Expand Down

0 comments on commit d58f05d

Please sign in to comment.