Skip to main content

aylis_core/
lib.rs

1//! # aylis-core
2//!
3//! Núcleo do aylis: modelo de componentes, árvore, propriedades publicadas, layout no
4//! estilo FMX (Align, Anchors, Margins, Padding), temas e as interfaces (traits) com a
5//! plataforma.
6//!
7//! Este crate **não depende de nada do sistema operacional**. Janela, input, timers e o
8//! desenho de verdade ficam em crates de plataforma e de renderização, que implementam
9//! os traits definidos aqui ([`Canvas`], [`TextService`], [`platform`]).
10//!
11//! ## Conceitos (comparando com o Delphi)
12//!
13//! | Delphi / FMX | aylis |
14//! |---|---|
15//! | `TComponent` | qualquer tipo que implementa [`Component`] |
16//! | `TControl` | um [`Component`] que tem um [`ControlBase`] |
17//! | `inherited` | composição: o componente guarda o "pai" e devolve em [`Component::inner`] |
18//! | `TButton.Create(Self)` + `Parent := X` | [`Ui::add`] / [`Ui::create`] |
19//! | `Free` | [`Ui::free`] (libera os filhos junto) |
20//! | `FindComponent` | [`Ui::find`] / [`Ui::find_in`] / [`Ui::find_path`] (`"frmClientes.btnSalvar"`) |
21//! | `Owner` (nomes únicos por form) | [`Ui::form_of`]: todo form é um escopo de nomes |
22//! | `Show` / `ShowModal` / `Close` | [`Ui::show`] / [`Ui::show_modal`] (resultado numa função) / [`Ui::close`] |
23//! | `SetPropValue` / RTTI | [`Ui::set_prop`] / [`Ui::get_prop`] |
24//! | `OnClick := ...` | [`Ui::on_click`] / [`Ui::on`] ou por nome via [`Ui::register_handler`] |
25
26pub mod activity;
27pub mod automation;
28pub mod background;
29mod busy;
30pub mod align;
31pub mod anim;
32pub mod canvas;
33pub mod clipboard;
34pub mod color;
35pub mod component;
36pub mod devices;
37pub mod error;
38pub mod files;
39pub mod event;
40pub mod exception;
41pub mod fonts;
42pub mod forms;
43/// Os monitores (lista, área útil, taxa) e a posição guardada de cada form.
44pub mod monitors;
45pub mod ndef;
46mod frames;
47// Repintar só o que mudou.
48mod damage;
49pub use damage::{FrameDamage, ScrollMove};
50mod ink;
51mod trace;
52pub mod handles;
53pub mod instances;
54pub mod geometry;
55pub mod gpu;
56pub mod i18n;
57pub mod icons;
58pub mod image;
59pub mod image_cache;
60pub mod keys;
61pub mod memory_panel;
62pub mod messages;
63mod input;
64mod intercept;
65mod keyflow;
66mod layout;
67pub use layout::is_right_to_left_language;
68pub mod pages;
69pub mod paint;
70pub mod palette;
71pub mod path;
72pub mod platform;
73pub mod post;
74pub mod tasks;
75pub mod profile;
76pub mod providers;
77pub mod prop;
78pub mod question;
79pub mod registry;
80mod references;
81mod names;
82mod reveal;
83pub mod text;
84pub mod textcore;
85pub mod textassist;
86pub mod taskbar;
87pub mod theme;
88pub mod bindings;
89pub mod timing;
90pub mod transition;
91pub mod tray;
92pub mod themes;
93mod timers;
94pub mod ui;
95pub mod views;
96pub mod window;
97
98pub use align::{Align, Anchors, SelfAlign};
99pub use i18n::{tr, tr_with};
100pub use anim::{AnimationOptions, ColorAnimation, Easing, FloatAnimation, PropertyAnimation, Trigger};
101pub use canvas::{
102    Brush, Canvas, FontSpec, FontWeight, GpuDevice, GpuSurface, GradientStop, LineCap, LineJoin, Shadow, Stroke, TextAlign,
103    TextService, TextStyle, decorate_line,
104};
105pub use color::Color;
106pub use component::{
107    ArrangeItem, ColorOverride, Component, ComponentId, Connection, ControlBase, ControlState, DesignHooks, FONT_WEIGHTS, FontOverride, MethodInfo, NativeCommand, NativeView, NativeViewSlot, PlatformHooks, WebMessage, navigation_allowed, url_origin,
108    prop_infos_of, read_prop,
109};
110pub use error::{Error, Result};
111pub use ui::DesignChanged;
112pub use input::{DragEnd, DragVisual, HINT_DELAY, ScreenPointer};
113pub use event::{
114    EventArgs, EventCtx, GestureEvent, GesturePhase, Intercepted, Key, KeyEvent, Modifiers, PointerButton, PointerEvent, PointerKind,
115    PopupRequest, ScrollOptions, WHEEL_LINE, WheelEvent,
116};
117pub use forms::{ModalResult, WindowPlacement};
118pub use bindings::Binding;
119pub use timing::TimerPrecision;
120pub use transition::{TRANSITION_MS, Transition};
121pub use taskbar::{JumpTask, TaskbarEvent, TaskbarProgress, TaskbarSpec, ThumbButton};
122pub use tray::{TrayEvent, TrayEventKind, TraySpec};
123pub use window::{ResizeEdge, WindowCommand};
124pub use geometry::{Bounds, PointF, RectF, SizeF};
125pub use icons::Icon;
126pub use keys::{CharCase, CharFilter, mnemonic, parse_shortcut, shortcut_matches, shortcut_text, strip_mnemonic};
127pub use image::{Image, ImageFit, ImageSource, WeakImage};
128pub use image_cache::{ImageCache, ImageCacheLimits, LayerCache, LayerCaching};
129pub use paint::PaintCtx;
130pub use path::{Path, PathCmd};
131pub use platform::CursorShape;
132pub use post::Poster;
133pub use prop::{PropEnum, PropInfo, PropKind, PropValue};
134pub use registry::{ClassInfo, ClassRegistry, VariantInfo, split_variant};
135pub use text::{TextCase, Trimming};
136pub use theme::{ColorRef, Look, Material, Metric, ResolvedStyle, Style, StyleProps, Theme};
137pub use ui::ThemeSource;
138pub use ui::Ui;
139pub use exception::Exception;
140pub use textcore::TextMode;
141pub use question::{Answer, Asked};
142pub use views::{FormView, ViewChange, ViewOrientation};
143pub use ui::{EVENTS_PER_ROUND, LOOP_WARNING, MAX_EVENT_NESTING, MAX_TREE_DEPTH, SAFE_EVENT_NESTING, SAFE_TREE_DEPTH, is_identifier};
144
145/// Uma linha no stderr, como o `eprintln!`, mas sem entrar em pânico se ele estiver fechado:
146/// um app aberto pela IDE escreve num pipe, e com a IDE fechada (ou a execução parada) o
147/// `eprintln!` derrubava o app ("failed printing to stderr").
148#[macro_export]
149macro_rules! stderr_line {
150    ($($arg:tt)*) => {{
151        use ::std::io::Write as _;
152        let _ = ::std::writeln!(::std::io::stderr(), $($arg)*);
153    }};
154}
155
156/// Implementa `class_name`, `control` e `control_mut` para um controle "folha" (que guarda o
157/// próprio `ControlBase` no campo `base`). Fica no núcleo porque os controles moram em vários
158/// crates (`aylis-controls-base`, `aylis-controls-charts`...).
159#[macro_export]
160macro_rules! leaf_control {
161    ($name:literal) => {
162        fn class_name(&self) -> &'static str {
163            $name
164        }
165
166        fn control(&self) -> Option<&$crate::ControlBase> {
167            Some(&self.base)
168        }
169
170        fn control_mut(&mut self) -> Option<&mut $crate::ControlBase> {
171            Some(&mut self.base)
172        }
173    };
174}