Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve flat theme, colours #237

Merged
merged 25 commits into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
286a4dd
Gallery: default to flat theme
dhardy Aug 9, 2021
7ad29af
Flat theme: adjust button frame
dhardy Aug 9, 2021
b5abd32
Adjust text colours
dhardy Aug 9, 2021
5fb0b3e
TextButton: align self
dhardy Aug 9, 2021
ab16d92
FlatTheme::button: use border colour for nav highlight
dhardy Aug 9, 2021
21b4a88
FlatTheme: nicer checkbox and radiobox
dhardy Aug 9, 2021
352d597
Adjust colour categories
dhardy Aug 9, 2021
f847418
Update light theme definition
dhardy Aug 9, 2021
7d7732a
Update dark and blue theme definitions
dhardy Aug 9, 2021
e9be947
FlatTheme::button: colour whole button on nav focus
dhardy Aug 10, 2021
886afa2
kas_theme::dim: make checkbox inner size configurable
dhardy Aug 10, 2021
fff62f7
Rename vertex shaders: give specific names
dhardy Aug 10, 2021
2a3d898
DrawPipe: do not pass (dummy) size on window construction
dhardy Aug 10, 2021
2de01d7
Change flat/shaded round antialias pattern
dhardy Aug 10, 2021
cd6dec7
Fix circle inner radius and FlatTheme::radiobox
dhardy Aug 10, 2021
88e52d8
FlatTheme::slider: draw circular handle
dhardy Aug 10, 2021
0e359fa
FlatTheme::slider: colour first part of track
dhardy Aug 10, 2021
6771be0
FlatTheme::editbox: new graphics
dhardy Aug 11, 2021
63449a8
FlatTheme::scrollbar: update appearance
dhardy Aug 11, 2021
65ba213
ScrollBar: limit thickness
dhardy Aug 11, 2021
dd6c526
ScrollBars<ScrollRegion<W>>: draw contents under scrollbars
dhardy Aug 11, 2021
45205b7
Update README regarding Rust version
dhardy Aug 11, 2021
38a6ba1
Update progress bar appearance
dhardy Aug 11, 2021
be5df43
FlatTheme::editbox: do not draw underline when not focussed
dhardy Aug 11, 2021
778acb5
Add margins to frames and separators
dhardy Aug 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ Installation and dependencies

#### Rust

KAS requires [Rust] version 1.52 or greater (currently in **beta**: *usually*
we maintain compatibility with the latest stable release).
Using the **nightly** channel does have a couple of advantages:
KAS requires a recent [Rust] compiler. Currently, version 1.52 or greater is
required. Using the **nightly** channel does have a few advantages:

- Proceedural macros emit better diagnostics. In some cases, diagnostics are
missed without nightly rustc, hence **nightly is recommended for development**.
- Documentation generated via `cargo doc` requires nightly for links
- A few minor option things: see [Feature flags](#feature-flags) below.
- The `nightly` (`min_spec`) feature allows some visual improvements (see below).
- The `doc_cfg` feature may be used for API docs.

### Quick-start

Expand Down Expand Up @@ -137,8 +136,9 @@ The `kas` crate has the following feature flags:
Additionally, the following flags require a nightly compiler:

- `nightly`: enables "more stable" unstable features
- `min_spec` (enabled by `nightly`): use `min_specialization` to draw
underlines in `AccelLabel`
- `min_spec` (enabled by `nightly`): use `min_specialization` for some visual
improvements: scrolled regions are drawn under scrollbars,
underlines on checkbox accelerator keys show with the <kbd>Alt</kbd> key.
- `spec`: use `specialization` to enable `TryFormat`
- `gat`: compatibility with `kas-text/gat`

Expand Down
14 changes: 12 additions & 2 deletions crates/kas-core/src/draw/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@ impl Rgba {
Self::rgba(s, s, s, a)
}

/// Get the sum of the three colour components
pub fn sum(self) -> f32 {
self.r + self.g + self.b
}

/// Average three colour components (desaturate)
pub fn average(self) -> Self {
Self::ga((self.r + self.g + self.b) * (1.0 / 3.0), self.a)
Self::ga(self.sum() * (1.0 / 3.0), self.a)
}

/// Multiply and clamp three colour components
Expand Down Expand Up @@ -131,9 +136,14 @@ impl Rgb {
Self::rgb(s, s, s)
}

/// Get the sum of the three colour components
pub fn sum(self) -> f32 {
self.r + self.g + self.b
}

/// Average three colour components (desaturate)
pub fn average(self) -> Self {
Self::grey((self.r + self.g + self.b) * (1.0 / 3.0))
Self::grey(self.sum() * (1.0 / 3.0))
}

/// Multiply and clamp three colour components
Expand Down
8 changes: 8 additions & 0 deletions crates/kas-core/src/draw/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ pub trait SizeHandle {
fn pixels_from_em(&self, em: f32) -> f32;

/// Size of a frame around child widget(s)
///
/// This already includes the margins specified by [`Self::frame_margins`].
fn frame(&self, vert: bool) -> FrameRules;

/// Frame/margin around a menu entry
Expand All @@ -160,6 +162,9 @@ pub trait SizeHandle {
/// Widgets must not draw in outer margins.
fn outer_margins(&self) -> Margins;

/// The margin around frames and separators
fn frame_margins(&self) -> Margins;

/// The margin around text elements
///
/// Similar to [`Self::outer_margins`], but intended for things like text
Expand Down Expand Up @@ -467,6 +472,9 @@ impl<S: SizeHandle + ?Sized, R: Deref<Target = S>> SizeHandle for R {
fn outer_margins(&self) -> Margins {
self.deref().outer_margins()
}
fn frame_margins(&self) -> Margins {
self.deref().frame_margins()
}
fn text_margins(&self) -> Margins {
self.deref().text_margins()
}
Expand Down
11 changes: 11 additions & 0 deletions crates/kas-core/src/geom/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ macro_rules! impl_vec2 {
/// Zero
pub const ZERO: $T = $T::splat(0.0);

/// One
pub const ONE: $T = $T::splat(1.0);

/// Positive infinity
pub const INFINITY: $T = $T::splat(<$f>::INFINITY);

Expand Down Expand Up @@ -335,6 +338,14 @@ macro_rules! impl_vec2 {
}
}

impl Div<$T> for $f {
type Output = $T;
#[inline]
fn div(self, rhs: $T) -> Self::Output {
$T(self / rhs.0, self / rhs.1)
}
}

impl From<($f, $f)> for $T {
#[inline]
fn from(arg: ($f, $f)) -> Self {
Expand Down
Loading