Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define a dialog library #81

Open
inexorabletash opened this issue May 3, 2018 · 3 comments
Open

Define a dialog library #81

inexorabletash opened this issue May 3, 2018 · 3 comments
Labels
API request New API within MGTK or DeskTop itself

Comments

@inexorabletash
Copy link
Collaborator

There are hints of this in the common dialogs in DeskTop (used for file copy/delete and selector entry add/edit), but it could be formalized.

Introduce a declarative format like the following:

dialog_resource := num_controls controls...
control := rect | label | push_button | check_box | radio_button | text_input 
rect := pen_mode, left, top, right, bottom
label := left, top, string
push_button := id, left, top, right, bottom, string
check_button := id, state, left, top
radio_button := id, state, left, top
text_input := id, max_length, left, top, right, bottom

A handful of calls would be needed:

  • GetTextInputString(id, pbuffer)
  • SetTextInputString(id, str)
  • GetButtonState(id, pstate)
  • SetButtonState(id, pstate)

... and a custom event loop that provides for clicks on buttons (reporting ids) and keys (Enter, Escape, Apple-x).

@inexorabletash inexorabletash added the feature request User-facing feature additions/enhancements label May 3, 2018
@inexorabletash
Copy link
Collaborator Author

This could follow the Control Manager and linked control list style from the IIgs toolbox.

@inexorabletash inexorabletash added API request New API within MGTK or DeskTop itself and removed feature request User-facing feature additions/enhancements labels Mar 9, 2019
@inexorabletash
Copy link
Collaborator Author

Started this very incrementally in 7f4be7f

inexorabletash added a commit that referenced this issue Jul 12, 2022
This reworks the line edit (text field) control logic from requiring
one instance of the code per control to a re-usable toolkit with an
MLI-style calling interface that operates on LineEditRecord instances.

The code gets somewhat more complicated, but this means that DAs don't
need their own copy of the library, and all instances inside DeskTop
-- rename (etc) dialog plus two in the file dialog -- can all share
the code.

The API itself could use some improvement (e.g. Activate should set
the blink_ip_flag) but this was intended to be a drop-in replacement
at first.

Related to #81.

No (intentional) behavior changes.
inexorabletash added a commit that referenced this issue Jul 21, 2022
This replaces lib/buttons.s with a new MLI-style interface, handling
tracking the mouse when a click is started and flashing the button
when the shortcut key is pressed. It adds a draw command to make
drawing a button a single call, and rolls in disable/enable as well
(currently used only in the file picker).

Like LETK, this means desk accessories don't need their own copy of
the library - they can call into DeskTop's copy of the TK. The LETK
files are moved from //letk/ into //toolkits/ to keep the top level
directory cleaner. MGTK is left alone (for now) since it's pretty
important.

No (intentional) behavior changes. In the future this could enable:

* Contextually disabled buttons in other dialogs.
* Drawing the shortcut label right aligned.
* A dialog manager to handle click and shortcut key dispatching.
* Radio and checkbox buttons could be supported as well.

Related to #81.
inexorabletash added a commit that referenced this issue Nov 10, 2022
Replace bespoke rendering/measuring of radio buttons with support in BTK.

Conceptually part of #81
inexorabletash added a commit that referenced this issue Nov 10, 2022
Replace bespoke rendering/measuring of checkboxes with support in BTK.

Also, make radio/checkbox support optional for modules like Disk Copy
and Selector that don't need them, to keep binary size down.

Conceptually part of #81
@inexorabletash
Copy link
Collaborator Author

Just an update here:

  • Added Button ToolKit (BTK) which provide push buttons, check boxes, and radio buttons, with control records and an MLI-style API.
  • Added LineEdit ToolKit (LETK) which provides single-line text inputs, with control records and an MLI-style API.
  • Added GetNextEvent (a lib) which synthesizes mouse move events.
  • Added OptionPicker (a lib) which handles a grid of options; this requires the client to have members in a well-known namespace rather than defining a control record.
  • Added ListBox (a lib) which provides a scrolling list of options; same namespace requirement as OptionPicker.

To provide a full dialog library we'd need something like:

  • Convert OptionPicker to be implemented with an MLI-style API and control record definition.
  • Convert ListBox to be implemented with an MLI-style API and control record definition.
  • Define a general control struct which has (1) control ID, (2) control type, (3) pointer to next control, followed by the control record, allowing a linked list of controls to be defined.
  • A DialogManager call that takes the linked list of controls and handles all of the basics - hit testing and tracking, key input and filtering, etc.

Doable, but not urgent as doing it by hand isn't that bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API request New API within MGTK or DeskTop itself
Projects
None yet
Development

No branches or pull requests

1 participant