redox-os/orbtk

foreground and background don't work for Button

Closed this issue · 2 comments

Describe the bug
foreground and background don't work for Button

To Reproduce
Steps to reproduce the behavior:

main_view.rs

use orbtk::prelude::*;

use crate::MainState;

widget!(
  MainView<MainState> {
    title: String
  }
);

impl Template for MainView {
  fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
    self.name("MainView").child(
      Button::new()
        .text(("title", id))
        .background("#db0fb6")
        .foreground("#db0fb6")
        .build(ctx))
  }
}

Expected behavior
Buton with color #db0fb6 on background or foreground

Desktop (please complete the following information):

  • OS: Windows 10
  • Version: 10

Additional context
Cargo.toml

[package]
name = "orb"
version = "0.1.0"
authors = ["usuario"]
edition = "2018"
readme = "README.md"
license = "MIT"

[profile.dev]
opt-level = 1

[features]
debug = ["orbtk/debug"]

[dependencies]
orbtk = { git = "https://github.com/redox-os/orbtk.git", branch= "develop" }

Hi,

The highest priority in OrbTk has the theme. It always overwrites styling properties like foreground and background. What you can do is to extend the current theme (check the calculator example) or you can set no theme and then you can set foreground and background on code, but then nothing of the theme will be loaded.

to do this write like so:

main_view.rs

use orbtk::prelude::*;

use crate::MainState;

widget!(
  MainView<MainState> {
    title: String
  }
);

impl Template for MainView {
  fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
    self.name("MainView").child(
      Button::new()
        .text(("title", id))
        .style("")
        .background("#db0fb6")
        .foreground("#db0fb6")
        .build(ctx))
  }
}