Skip to content

Commit

Permalink
Refactor text_box code.
Browse files Browse the repository at this point in the history
  • Loading branch information
FloVanGH committed Mar 6, 2020
1 parent abd8f78 commit d06a6e7
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 147 deletions.
6 changes: 3 additions & 3 deletions crates/theme/src/dark.css
Expand Up @@ -126,7 +126,7 @@ combo_box_item:selected, combo_box_item:active {
font-size: 24;
}

text-box {
text_box {
height: 32;
color: #ccdeed;
background: #3b434a;
Expand Down Expand Up @@ -154,11 +154,11 @@ menuitem {
font-size: 12;
}

text-box:empty {
text_box:empty {
color: #9E9E9E
}

text-box:focus {
text_box:focus {
border-color: #f8de4c;
}

Expand Down
4 changes: 2 additions & 2 deletions crates/theme/src/light.css
Expand Up @@ -68,12 +68,12 @@ container {
background: transparent;
}

text-box {
text_box {
background: white;
border-color: #d1d1d1;
}

text-box:focus {
text_box:focus {
border-color: #efd035;
}

Expand Down
6 changes: 3 additions & 3 deletions crates/theme/src/pop.css
Expand Up @@ -88,7 +88,7 @@ container {
font-size: 24;
}

text-box {
text_box {
color: #dfebf5;
background: #3b434a;
border-color: #647b91;
Expand All @@ -108,11 +108,11 @@ menuitem {
font-size: 12;
}

text-box:empty {
text_box:empty {
color: #9E9E9E
}

text-box:focus {
text_box:focus {
border-color: #f8de4c;
}

Expand Down
20 changes: 13 additions & 7 deletions crates/widgets/src/slider.rs
@@ -1,7 +1,13 @@
use crate::prelude::*;

static THUMB: &'static str = "thumb";
static TRACK: &'static str = "track";
// --- KEYS --

pub static ELEMENT_SLIDER: &'static str = "slider";

static ID_THUMB: &'static str = "id_thumb";
static ID_TRACK: &'static str = "id_track";

// --- KEYS --

#[derive(Copy, Clone)]
enum SliderAction {
Expand Down Expand Up @@ -94,10 +100,10 @@ impl SliderState {
impl State for SliderState {
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
self.thumb = ctx
.entity_of_child(THUMB)
.entity_of_child(ID_THUMB)
.expect("SliderState.init: Thumb child could not be found.");
self.track = ctx
.entity_of_child(TRACK)
.entity_of_child(ID_TRACK)
.expect("SliderState.init: Track child could not be found.");
}

Expand Down Expand Up @@ -178,15 +184,15 @@ widget!(
impl Template for Slider {
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
self.name("Slider")
.element("slider")
.element(ELEMENT_SLIDER)
.minimum(0.0)
.maximum(100.0)
.value(0.0)
.height(24.0)
.border_radius(2.0)
.child(
Grid::create()
.id(TRACK)
.id(ID_TRACK)
.margin((8.0, 0.0, 8.0, 0.0))
.child(
Container::create()
Expand All @@ -199,7 +205,7 @@ impl Template for Slider {
.child(
Button::create()
.element("thumb")
.id(THUMB)
.id(ID_THUMB)
.vertical_alignment("center")
.horizontal_alignment("start")
.max_width(24.0)
Expand Down

0 comments on commit d06a6e7

Please sign in to comment.