Skip to content

Commit

Permalink
Merge pull request #74 from Clemapfel/mac-menubar-docs
Browse files Browse the repository at this point in the history
Merge 3.2 into 3.3
  • Loading branch information
Clemapfel committed Feb 8, 2024
2 parents bdf7524 + d49d8e1 commit c4609b4
Show file tree
Hide file tree
Showing 10 changed files with 337 additions and 117 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ It aims to give developers of all skill levels the tools to start creating compl

> **Note**: Mousetrap is under active development. Consider participating in the development by [opening an issue](https://github.com/clemapfel/mousetrap.jl) when you encounter an error, bug, question, or missing feature.
> **Note**: February 8th, 2024: I've been having some health issues at the moment, it may take me some time to get to open issues. Mousetrap is still usable and (mostly) stable, the repo will be maintained in the immediate future to the best of my abilities. Thank you for your understanding, C.
---

## Table of Contents
Expand Down
2 changes: 1 addition & 1 deletion docs/src/01_manual/02_signals.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ connect_signal_clicked!(button_01, button_02) do button_01::Button, button_02::B
set_signal_clicked_blocked!(button_01, false)
end

connect_signal_clicked!(button_02) do button_02::Button, button_01::Button
connect_signal_clicked!(button_02, button_01) do button_02::Button, button_01::Button
println("02 clicked")

# block self (02)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/01_manual/04_widgets.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ set_margin_horizontal(widget, 10)
set_margin_vertical(widget, 10)

# equivalent to
set_margin(widget, 10)
set_margin!(widget, 10)
```

Where [`set_margin_horizontal!`](@ref), [`set_margin_vertical!`](@ref) set two of the margins at the same time, while [`set_margin!`](@ref) sets all four margins at once.
Expand Down
23 changes: 22 additions & 1 deletion docs/src/01_manual/08_menus.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ The **top-level** menu is `root`. It is used as the argument for the constructor

No direct child of `root` is an "action"-, "widget"-, "icon"- or "section"-type item. This is what is required for `MenuBar`. All top-level items have to be submenus.

!!! Warning
!!! warning
Due to a bug in the backend, as of `v0.3.0`, a menu model used for a `MenuBar` **may not have a "widget"-type item in a submenu of a submenu**.

This means we *can* add a widget to any submenu of `root`, but we may not add
Expand All @@ -269,6 +269,27 @@ No direct child of `root` is an "action"-, "widget"-, "icon"- or "section"-type
This bug does not affect `PopoverMenu`, for whom we can put a widget at any
depth. `PopoverMenu` has no requirement as to the structure of its menu model, while `MenuBar` requires that all top-level items are submenus and that no submenu of a submenu may have a "widget"-type item.

## Main Menu (macOS only)

!!! compat
Features from this section are only available with Mousetrap `v0.3.1` or newer, and should only be used by applications targeting macOS. We can use `Sys.isapple` to verify the user's operating system.

On macOS, applications are able to target the [**main menu**](https://support.apple.com/en-gb/guide/mac-help/mchlp1446/mac), which is the menubar at the very top of the screen (outside the Mousetrap window). This bar contains the Apple menu, as well as a native menubar with application-specific options. To bind a `Mousetrap.MenuModel` to this menubar, we use `set_menubar` on our `Application` instance:

```julia
main() do app::Application

model = MenuModel()
# fill model here

if Sys.isapple()
set_menubar(app, model) # associate model with the Apple main menu
end
end
```

Note that it may be necessary to call `set_menubar` again when the `MenuModel` is modified in order for the main menu to be updated.

---

## Style End Note
Expand Down
4 changes: 2 additions & 2 deletions docs/src/01_manual/09_native_rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ To display the texture on screen, we need to bind it to a shape, and then render
texture_shape::Shape = Rectangle(Vector2f(-1, 1), Vector2f(2, 2))
set_texture!(texture_shape, texture)

add_render_tasK!(render_area, RenderTask(texture_shape))
add_render_task!(render_area, RenderTask(texture_shape))
```

How and where the texture is displayed depends on the shape's vertices **texture coordinate**. These coordinates are in `([0, 1], [0, 1])`, meaning the x- and y- component are in `[0, 1]` each. We will call this coordinate system **texture space**.
Expand Down Expand Up @@ -697,7 +697,7 @@ main() do app::Application
add_render_task!(render_area, RenderTask(shape))

# connect callback, providing our shape as `Data_t` argument
connect_signal_resize!(render_area, on_resize, shape)
connect_signal_resize!(on_resize, render_area, shape)

set_child!(window, render_area)
present!(window)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/01_manual/10_theme_customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ By default, the function used to map the elapsed duration of the `Animation` to

Mousetrap uses [Cascading Style Sheets (CSS)](https://developer.mozilla.org/en-US/docs/Web/CSS) to define the exact look of a widget. A UI theme is nothing more than a huge CSS file from which all widgets take information about how they should be rendered.

!!! Warning "CSS"
!!! warning "CSS"
The rest of this chapter will assume that readers are familiar with the basics of CSS. Readers are encouraged to consult [this documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference) for CSS-related questions.

## Applying CSS Properties to a Widget
Expand Down
Loading

0 comments on commit c4609b4

Please sign in to comment.