-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): 🎸 added
Foreground
builtin widget
- Loading branch information
Showing
16 changed files
with
147 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use crate::{prelude::*, wrap_render::WrapRender}; | ||
|
||
/// A widget that sets the brush for foreground elements. It's can be inherited | ||
/// by its descendants. When meet a color of `background`, the foreground will | ||
/// be overwrite by it. | ||
|
||
#[derive(Default)] | ||
pub struct Foreground { | ||
pub foreground: Brush, | ||
} | ||
|
||
impl Declare for Foreground { | ||
type Builder = FatObj<()>; | ||
#[inline] | ||
fn declarer() -> Self::Builder { FatObj::new(()) } | ||
} | ||
|
||
impl<'c> ComposeChild<'c> for Foreground { | ||
type Child = Widget<'c>; | ||
|
||
fn compose_child(this: impl StateWriter<Value = Self>, child: Self::Child) -> Widget<'c> { | ||
WrapRender::combine_child(this, child) | ||
} | ||
} | ||
|
||
impl WrapRender for Foreground { | ||
fn perform_layout(&self, clamp: BoxClamp, host: &dyn Render, ctx: &mut LayoutCtx) -> Size { | ||
host.perform_layout(clamp, ctx) | ||
} | ||
|
||
fn paint(&self, host: &dyn Render, ctx: &mut PaintingCtx) { | ||
ctx | ||
.painter() | ||
.set_fill_brush(self.foreground.clone()) | ||
.set_stroke_brush(self.foreground.clone()); | ||
host.paint(ctx) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+1.16 KB
test_cases/ribir_widgets/path/tests/circle40_kit_with_default_by_wgpu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.16 KB
test_cases/ribir_widgets/path/tests/circle40_kit_with_material_by_wgpu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.16 KB
test_cases/ribir_widgets/path/tests/circle40_with_default_by_wgpu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.16 KB
test_cases/ribir_widgets/path/tests/circle40_with_material_by_wgpu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.