---
layout: presentation
title: Lab 7 Slides
description: Menus
---

# CSE 340 Lab 7 (Winter 2020)
## Week 7: Getting started with Menus

---

# Menus Timeline

- Programming part (Part 0-3) due: Wednesday Feb 26
- Analysis part (Part 4-5) out: Thursday Feb 27 | due: Monday Mar 2

---

# Agenda

- Review key concepts for Menus assignment
  - State Machines
  - Translate
  - Callbacks
- Work time on Menus assignment
- Questions

---

# State Machines

State Machines are used to respond to incoming events and allow us to store state between events.

![:img State Machine Diagram Recap, 50%](img/smrecap.png)

---

# Menus State Machine

![:img Menus State Machine Diagram, 50%](img/menussm.png)

---

# Translate

- Move origin (and everything else) in x and y
![:img a large moon and a large moon moved to the right a few pixels, 15%](img/translate.png)
   
    ```java
    translate(float dx, float dy)
    ```
- How do we use _translate_ in Menus?
---

# Callbacks

- Callbacks handle application response to events
    - Update Application Model
    
    ![:img Picture of interactor hierarchy connected to an interface and a
dotted line indicating application interface and a do_action() call
happening below the line in response to a button_pressed(), 100%](img/callbacks2.png)


---

# Callbacks

- Callbacks handle application response to events
    - Update Application Model
    - Best implemented using custom listeners
    
    ![:img Picture of interactor hierarchy connected to an interface and a
dotted line indicating application interface with do_action() replaced
with an actionListener, 100%](img/callbacks3.png)