Debian Codegraph @

src/bubble.rs

raw symbols SCIP
1 /*
2 * Copyright 2020-2024 Andrey Kutejko <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
16 *
17 * For more details see the file COPYING.
18 */
19
20 use craterust-analyzer cargo gnome-robots 50.0.0 crate/::imagerust-analyzer cargo gnome-robots 50.0.0 image/::Imagerust-analyzer cargo gnome-robots 50.0.0 image/Image#;
21 use gtkrust-analyzer cargo gtk4 0.11.1 crate/::{gdkrust-analyzer cargo gdk4 0.11.1 crate/, graphenerust-analyzer cargo graphene-rs 0.22.0 crate/, preluderust-analyzer cargo gtk4 0.11.1 prelude/::*};
22 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#;
23 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#;
24
25 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
26 pub struct Bubblerust-analyzer cargo gnome-robots 50.0.0 bubble/Bubble# {
27 paintablerust-analyzer cargo gnome-robots 50.0.0 bubble/Bubble#paintable.: gdkrust-analyzer cargo gdk4 0.11.1 crate/::Paintablerust-analyzer cargo gdk4 0.11.1 auto/paintable/Paintable#,
28 }
29
30 impl Bubblerust-analyzer cargo gnome-robots 50.0.0 bubble/Bubble# {
31 pub fn from_filerust-analyzer cargo gnome-robots 50.0.0 bubble/impl#[Bubble]from_file().(filename: &Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo gnome-robots 50.0.0 bubble/impl#[Bubble], Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> {
32 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo gnome-robots 50.0.0 bubble/impl#[Bubble] {
33 paintablerust-analyzer cargo gnome-robots 50.0.0 bubble/Bubble#paintable.: Imagerust-analyzer cargo gnome-robots 50.0.0 image/Image#::from_filerust-analyzer cargo gnome-robots 50.0.0 image/impl#[Image]from_file().(filename)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..to_paintablerust-analyzer cargo gnome-robots 50.0.0 image/impl#[Image]to_paintable().(),
34 })
35 }
36
37 pub fn drawrust-analyzer cargo gnome-robots 50.0.0 bubble/impl#[Bubble]draw().(&self, snapshot: &gtkrust-analyzer cargo gtk4 0.11.1 crate/::Snapshotrust-analyzer cargo gtk4 0.11.1 auto/snapshot/Snapshot#, x: f64, y: f64) {
38 let x = x as f32;
39 let y = y as f32;
40 let width = self.paintablerust-analyzer cargo gnome-robots 50.0.0 bubble/Bubble#paintable..intrinsic_widthrust-analyzer cargo gdk4 0.11.1 auto/paintable/PaintableExt#intrinsic_width().() as f32;
41 let height = self.paintablerust-analyzer cargo gnome-robots 50.0.0 bubble/Bubble#paintable..intrinsic_heightrust-analyzer cargo gdk4 0.11.1 auto/paintable/PaintableExt#intrinsic_height().() as f32;
42
43 let bubble_width = width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().2.0;
44 let bubble_height = height rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().2.0;
45
46 let clip_rect = graphenerust-analyzer cargo graphene-rs 0.22.0 crate/::Rectrust-analyzer cargo graphene-rs 0.22.0 auto/rect/Rect#::newrust-analyzer cargo graphene-rs 0.22.0 rect/impl#[Rect]new().(
47 if x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]lt().bubble_width {
48 x
49 } else {
50 x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().bubble_width
51 },
52 if y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]lt().bubble_height {
53 y
54 } else {
55 y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().bubble_height
56 },
57 bubble_width,
58 bubble_height,
59 );
60
61 snapshot.push_cliprust-analyzer cargo gtk4 0.11.1 auto/snapshot/SnapshotExt#push_clip().(&clip_rect);
62 snapshot.saverust-analyzer cargo gtk4 0.11.1 auto/snapshot/SnapshotExt#save().();
63 snapshot.translaterust-analyzer cargo gtk4 0.11.1 auto/snapshot/SnapshotExt#translate().(&graphenerust-analyzer cargo graphene-rs 0.22.0 crate/::Pointrust-analyzer cargo graphene-rs 0.22.0 auto/point/Point#::newrust-analyzer cargo graphene-rs 0.22.0 point/impl#[Point]new().(x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().bubble_width, y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Sub<Self>`]sub().bubble_height));
64 self.paintablerust-analyzer cargo gnome-robots 50.0.0 bubble/Bubble#paintable.
65 .snapshotrust-analyzer cargo gdk4 0.11.1 auto/paintable/PaintableExt#snapshot().(snapshot, width as f64, height as f64);
66 snapshot.restorerust-analyzer cargo gtk4 0.11.1 auto/snapshot/SnapshotExt#restore().();
67 snapshot.poprust-analyzer cargo gtk4 0.11.1 auto/snapshot/SnapshotExt#pop().();
68 }
69 }