CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 19:25:41 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=63446ca6f5ae62bf80e5631cd27800d40f3f6dac4a9d5e6bca912f7cbf3bc546a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%228OyS-XHgLLNjq4FHdeTKasKNIQUVK5n9%22%3B%7D; HttpOnly; Path=/
cf-ray: 98d0beab4ce11eef-BLR
learn_gpui.rs - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::marker::PhantomData;
- use gpui::{
- App, Application, Context, Menu, MenuItem, Window,
- WindowOptions, actions, div, prelude::*, rgb, Global
- };
- pub struct Theme {
- primary: u32,
- secondary: u32,
- }
- impl From<(u32, u32)> for Theme {
- fn from(tup: (u32, u32)) -> Theme {
- Theme { primary: tup.0, secondary: tup.1 }
- }
- }
- pub const SPOTIFY_THEME: Theme = Theme {
- primary: 0x1cd061,
- secondary: 0x121212,
- };
- pub const FIREFOX_THEME: Theme = Theme {
- primary: 0xff5933,
- secondary: 0x421c5f,
- };
- pub const BLUEY_THEME: Theme = Theme {
- primary: 0xf2d787,
- secondary: 0x9acbec,
- };
- pub const SPICY_THEME: Theme = Theme {
- primary: 0x1b1b1b,
- secondary: 0xffa31a,
- };
- pub struct SetMenus;
- pub struct ActiveTheme {
- active_theme: Theme,
- }
- impl Global for ActiveTheme {}
- //what does this macro do exactly
- actions!(set_menus, [Quit]);
- actions!(set_menus, [SpotifyTheme]);
- actions!(set_menus, [FirefoxTheme]);
- actions!(set_menus, [BlueyTheme]);
- actions!(set_menus, [SpicyTheme]);
- impl Render for SetMenus {
- fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
- div()
- .flex()
- .bg(rgb(cx.global::<ActiveTheme>().active_theme.primary))
- .size_full()
- .justify_center()
- .items_center()
- .text_xl()
- .text_color(rgb(cx.global::<ActiveTheme>().active_theme.secondary))
- .child("Set Menus Example")
- }
- }
- fn main() {
- Application::new().run(|cx: &mut App| {
- cx.set_global::<ActiveTheme>(ActiveTheme { active_theme: SPOTIFY_THEME });
- //??? idk what this does exactly
- cx.activate(true);
- cx.on_action(|_: &Quit, cx: &mut App| cx.quit());
- cx.on_action(|_: &FirefoxTheme, cx: &mut App| {
- cx.set_global::<ActiveTheme>(ActiveTheme { active_theme: FIREFOX_THEME });
- cx.notify();
- });
- cx.on_action(|_: &BlueyTheme, cx: &mut App| {
- cx.set_global::<ActiveTheme>(ActiveTheme { active_theme: BLUEY_THEME });
- cx.notify();
- });
- cx.on_action(|_: &SpotifyTheme, cx: &mut App| {
- cx.set_global::<ActiveTheme>(ActiveTheme { active_theme: SPOTIFY_THEME });
- cx.notify();
- });
- cx.on_action(|_: &SpicyTheme, cx: &mut App| {
- cx.set_global::<ActiveTheme>(ActiveTheme { active_theme: SPICY_THEME });
- cx.notify();
- });
- cx.set_menus(vec![
- Menu {
- name: "main".into(),
- items: vec![
- MenuItem::action("Quit", Quit),
- ]},
- Menu {
- name: "themes!!!".into(),
- items: vec![
- MenuItem::action("Spotify theme", SpotifyTheme),
- MenuItem::action("Firefox theme", FirefoxTheme),
- MenuItem::action("Bluey theme", BlueyTheme),
- MenuItem::action("Spicy theme", SpicyTheme),
- ],
- },
- ]);
- let set_menus = cx.new(|_| {SetMenus});
- cx.open_window(WindowOptions::default(), |_, _cx| { set_menus }).unwrap();
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
📝 MAKE $2500 IN 15 MIN ✅ Working
JavaScript | 5 sec ago | 0.24 KB
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 8 sec ago | 0.25 KB
-
⭐⭐⭐Profit Method⭐⭐
Java | 9 sec ago | 0.10 KB
-
💵 Make 3000$ in 20 minutes 💵
JavaScript | 15 sec ago | 0.24 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ P
JavaScript | 17 sec ago | 0.25 KB
-
⭐⭐⭐MAKE $500 IN 15 MIN⭐⭐
Java | 25 sec ago | 0.10 KB
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ G
JavaScript | 27 sec ago | 0.25 KB
-
📌 Swapzone +37% glitch
JavaScript | 30 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand