Commit Graph

10604 Commits

Author SHA1 Message Date
Nate Butler
23a97f5b61
Document ColorScaleSteps (#3271)
[[PR Description]]

Adds documentation to ColorScaleSteps:

```rust
/// Returns the specified step in the [`ColorScale`].
    #[inline]
    pub fn step(&self, step: ColorScaleStep) -> Hsla {
        // Steps are one-based, so we need convert to the zero-based vec index.
        self.0[step.0 - 1]
    }

    /// `Step 1` - Used for main application backgrounds.
    ///
    /// This step provides a neutral base for any overlaying components, ideal for applications' main backdrop or empty spaces such as canvas areas.
    ///
    #[inline]
    pub fn step_1(&self) -> Hsla {
        self.step(ColorScaleStep::ONE)
    }

    /// `Step 2` - Used for both main application backgrounds and subtle component backgrounds.
    ///
    /// Like `Step 1`, this step allows variations in background styles, from striped tables, sidebar backgrounds, to card backgrounds.
    #[inline]
    pub fn step_2(&self) -> Hsla {
        self.step(ColorScaleStep::TWO)
    }

    /// `Step 3` - Used for UI component backgrounds in their normal states.
    ///
    /// This step maintains accessibility by guaranteeing a contrast ratio of 4.5:1 with steps 11 and 12 for text. It could also suit hover states for transparent components.
    #[inline]
    pub fn step_3(&self) -> Hsla {
        self.step(ColorScaleStep::THREE)
    }

    /// `Step 4` - Used for UI component backgrounds in their hover states.
    ///
    /// Also suited for pressed or selected states of components with a transparent background.
    #[inline]
    pub fn step_4(&self) -> Hsla {
        self.step(ColorScaleStep::FOUR)
    }

    /// `Step 5` - Used for UI component backgrounds in their pressed or selected states.
    #[inline]
    pub fn step_5(&self) -> Hsla {
        self.step(ColorScaleStep::FIVE)
    }

    /// `Step 6` - Used for subtle borders on non-interactive components.
    ///
    /// Its usage spans from sidebars' borders, headers' dividers, cards' outlines, to alerts' edges and separators.
    #[inline]
    pub fn step_6(&self) -> Hsla {
        self.step(ColorScaleStep::SIX)
    }

    /// `Step 7` - Used for subtle borders on interactive components.
    ///
    /// This step subtly delineates the boundary of elements users interact with.
    #[inline]
    pub fn step_7(&self) -> Hsla {
        self.step(ColorScaleStep::SEVEN)
    }

    /// `Step 8` - Used for stronger borders on interactive components and focus rings.
    ///
    /// It strengthens the visibility and accessibility of active elements and their focus states.
    #[inline]
    pub fn step_8(&self) -> Hsla {
        self.step(ColorScaleStep::EIGHT)
    }

    /// `Step 9` - Used for solid backgrounds.
    ///
    /// `Step 9` is the most saturated step, having the least mix of white or black.
    ///
    /// Due to its high chroma, `Step 9` is versatile and particularly useful for semantic colors such as
    /// error, warning, and success indicators.
    #[inline]
    pub fn step_9(&self) -> Hsla {
        self.step(ColorScaleStep::NINE)
    }

    /// `Step 10` - Used for hovered or active solid backgrounds, particularly when `Step 9` is their normal state.
    #[inline]
    pub fn step_10(&self) -> Hsla {
        self.step(ColorScaleStep::TEN)
    }

    /// `Step 11` - Used for text and icons requiring low contrast or less emphasis.
    #[inline]
    pub fn step_11(&self) -> Hsla {
        self.step(ColorScaleStep::ELEVEN)
    }

    /// `Step 12` - Used for text and icons requiring high contrast or prominence.
    #[inline]
    pub fn step_12(&self) -> Hsla {
        self.step(ColorScaleStep::TWELVE)
    }
```

Release Notes:

- N/A
2023-11-08 16:25:17 -05:00
Nate Butler
208f5f5182
Extend Styled for Zed-specific methods (#3276)
[[PR Description]]

- Adds `StyledExt` for Zed-specific methods like `ui_text`, `v_flex`,
etc.
- Updates components previously using `text_*` methods.

Release Notes:

- N/A
2023-11-08 16:04:46 -05:00
Nate Butler
9cc3ee9674 Update usages of text_size_* to text_ui in ui components
Co-Authored-By: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
2023-11-08 15:28:38 -05:00
Nate Butler
9bdfc7a2e5 Update StyledExt to impl over I & F as well as V for Div
Co-Authored-By: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
2023-11-08 15:25:44 -05:00
Marshall Bowers
acf37804eb
Use a fork of ctor to silence warnings generated by macro (#3275)
This PR switches us over to a fork of `ctor` that contains the fixes
from https://github.com/mmastrac/rust-ctor/pull/295, backported to our
current version of `ctor` (v0.1.20).

Once 1) the `ctor` maintainer publishes a new version with that change
and 2) we're ready to upgrade to the latest version of `ctor` we can
switch back to the mainline version.

Release Notes:

- N/A
2023-11-08 15:05:19 -05:00
Nate Butler
f4abd95866 Remove the Stack trait, update StyledExt to include stacks
Co-Authored-By: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
2023-11-08 15:00:47 -05:00
Nate Butler
cb830a4ce0 Remove unused code in avatar 2023-11-08 14:46:47 -05:00
Nate Butler
4ef2f0b2b9 Update StyledExt to use more idiomatic method naming 2023-11-08 14:42:56 -05:00
Conrad Irwin
e90f6acf5f Silence problem 2023-11-08 12:37:35 -07:00
Conrad Irwin
dbe06fe5fc Merge branch 'main' into add-collab-tests 2023-11-08 12:33:15 -07:00
Nate Butler
6ecf629c63 BROKEN: Checkpoint 2023-11-08 14:29:38 -05:00
Mikayla
1864d37d2e
Fix double borrow in synchronous tests 2023-11-08 11:23:35 -08:00
Max Brunsfeld
2ac28240e4 Merge branch 'main' into picker-actions 2023-11-08 10:49:44 -08:00
Max Brunsfeld
4c31a0c989 Preserve stateless interactivity when assigning elements an id
Co-authored-by: Nathan <nathan@zed.dev>
Co-authored-by: Piotr <piotr@zed.dev>
2023-11-08 10:45:10 -08:00
Mikayla
e1cb993878
Get tests green 2023-11-08 10:38:43 -08:00
Marshall Bowers
ca2cc42800 Remove unused SceneBuilder constructor 2023-11-08 13:30:20 -05:00
Antonio Scandurra
866df770cb Extract a Frame struct from Window
Co-Authored-By: Marshall <marshall@zed.dev>
Co-Authored-By: Nathan <nathan@zed.dev>
Co-Authored-By: Piotr <piotr@zed.dev>
2023-11-08 13:24:11 -05:00
Nate Butler
e4ca2cb20b Update titlebar 2023-11-08 12:57:31 -05:00
Nate Butler
6e11044e9e add ui_text_size functions 2023-11-08 12:57:24 -05:00
Mikayla
9b30f490c7
Merge branch 'main' into add-collab-tests 2023-11-08 09:57:08 -08:00
Mikayla
3050c440f4
Merge branch 'main' into add-collab-tests 2023-11-08 09:41:57 -08:00
Max Brunsfeld
d25f48ed6b Register menu2 actions using actions macro 2023-11-08 09:35:19 -08:00
Antonio Scandurra
0143fa2056
Fix clipping bugs in editor2 (#3269)
Release Notes:

- N/A
2023-11-08 17:51:39 +01:00
Marshall Bowers
761d4fcd49
Port the picker and uniform list (#3248)
This adds a `UniformList` element and partially implements `Picker` as a
component, using `UniformList`. Because editor2 isn't fully implemented
yet, the picker doesn't have filtering logic yet. We want to merge this
for now though, to make the UniformList element available for other
crates.

Release Notes:

- N/A
2023-11-08 17:45:23 +01:00
Marshall Bowers
b6766ba39a
Replace GitStatusColors with StatusColors (#3268)
This PR removes `GitStatusColors` in favor of just using `StatusColors`
instead.

Release Notes:

- N/A
2023-11-08 11:32:32 -05:00
Antonio Scandurra
d71f671476 Fix clipping in Line::draw
Co-Authored-By: Nathan <nathan@zed.dev>
Co-Authored-By: Marshall <marshall@zed.dev>
2023-11-08 17:32:21 +01:00
Antonio Scandurra
727fb4fbff Use a consistent clipping strategy for drawing all the primitives
Co-Authored-By: Nathan <nathan@zed.dev>
2023-11-08 17:29:05 +01:00
Marshall Bowers
e9650c025f Fix overflow in UniformList 2023-11-08 11:26:26 -05:00
Marshall Bowers
fe28d8faea Merge branch 'main' into picker 2023-11-08 11:18:54 -05:00
Joseph T. Lyons
9e5a4ea6c4 v0.113.x dev 2023-11-08 10:53:37 -05:00
Antonio Scandurra
55dca1e3e1 💄 2023-11-08 15:33:11 +01:00
Antonio Scandurra
15d40d6df5 Determine whether the gutter was hovered 2023-11-08 15:30:41 +01:00
Antonio Scandurra
dfc536b4f5 Handle MouseUpEvent in editor2 2023-11-08 15:17:30 +01:00
Antonio Scandurra
e500c05880 Move building of key listeners outside of EditorElement::initialize 2023-11-08 15:12:54 +01:00
Antonio Scandurra
bef3b80bd4 Clear hover background highlights
Co-Authored-By: Piotr <piotr@zed.dev>
2023-11-08 15:08:54 +01:00
Piotr Osiewicz
e5f78ec122 Uncomment mouse_dragged event
Co-authored-by: Antonio <antonio@zed.dev>
2023-11-08 15:02:35 +01:00
Piotr Osiewicz
1b085bd618 Extract mouse event handlers into paint_mouse_listeners
Co-authored-by: Antonio <antonio@zed.dev>
2023-11-08 14:40:08 +01:00
Piotr Osiewicz
dd20032eab Hook up mouse_down function handler
Co-authored-by: Antonio <antonio@zed.dev>
2023-11-08 14:36:05 +01:00
Piotr Osiewicz
e30449e61a Pass text_bounds instead of full editor bounds into mouse_moved.
Co-authored-by: Antonio <antonio@zed.dev>
2023-11-08 14:28:16 +01:00
Piotr Osiewicz
334829f868 uncomment show_hover 2023-11-08 14:24:28 +01:00
Piotr Osiewicz
cd3773531c uncomment mouse moved 2023-11-08 14:24:28 +01:00
Antonio Scandurra
e4bc03217d
gpui2: Type-erase futures. (#3266)
Project2's LLVM IR size is ~33-44% bigger than project1 due to the fact
that in gpui2 we call async_task::spawn(_local) with impl Future instead
of dyn Future, which leads to quite a few more instantiations of
RawTask.

LLVM-IR size for project2:
|  build_type  |  main   |  this branch  | project1 |
|  debug       | 2617795 |    2022814    | 1817866  |
|  release     | 4439033 |    3715086    | 3314489  |

Note that this PR is in line with what was done in GPUI1 (we've also
boxed futures there).
Release Notes:

- N/A
2023-11-08 14:21:40 +01:00
Piotr Osiewicz
2364f6b22e gpui2: Type-erase futures.
Project2's LLVM IR size is ~20-25% bigger than project1 due to the fact that in gpui2 we call async_task::spawn(_local) with impl Future instead of dyn Future, which leads to quite a few more instantiations of RawTask.

LLVM-IR size for project2:
|  build_type  |  main   |  this branch  | project1 |
|  debug       | 2617795 |    2022814    | 1817866  |
|  release     | 4439033 |    3715086    | 3314489  |
2023-11-08 13:06:28 +01:00
Antonio Scandurra
c5d5571ad3 Fix warnings when generating function name for ctor
Co-Authored-By: Piotr <piotr@zed.dev>
2023-11-08 12:31:35 +01:00
Antonio Scandurra
6a0789c88e Don't alpha blend when rasterizing paths
Co-Authored-By: Piotr <piotr@zed.dev>
2023-11-08 12:04:25 +01:00
Antonio Scandurra
8ac8a6f1d9 Re-enable most of the functionalities in editor2 2023-11-08 11:30:32 +01:00
Nate Butler
31bac3dd62 Document ColorScaleSteps 2023-11-08 00:45:05 -05:00
Nathan Sobo
408edaae39 Remove call to removed method 2023-11-07 21:58:46 -07:00
Nathan Sobo
1949fa5147 Merge remote-tracking branch 'origin/main' into register-actions 2023-11-07 21:56:08 -07:00
Nathan Sobo
2a55b0dbfb Simplify actions macro. 2023-11-07 21:48:47 -07:00