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

Add hover effect for buttons #262

Closed
mdenchev opened this issue Feb 6, 2017 · 6 comments
Closed

Add hover effect for buttons #262

mdenchev opened this issue Feb 6, 2017 · 6 comments

Comments

@mdenchev
Copy link

mdenchev commented Feb 6, 2017

It's hard to distinguish buttons currently. I can add a hover effect in the draw step since the context is passed (and can obtain the mouse pos). Something simple like a bg color or text color change.

Let me know if you are interested in such a change and will submit a PR.

@ozkriff
Copy link
Owner

ozkriff commented Feb 7, 2017

Why not? :)

GUI needs complete rework but it's unlikely that I'll find time for it soon.

Though it'll not help on android :(

@mdenchev
Copy link
Author

mdenchev commented Feb 7, 2017

Hmm, I can add the hover feature but it will likely get thrown out since it will just be bolting on functionality without really making it good long term. I suggested it as it's a small feature to get used to the code base a bit so I might still do it. I can try reworking the UI if you would like; I have written a small (and incomplete) Gui framework in Rust before so I have some notion of what is involved, though I'm not yet familiar with gfx and how to build a single vertex list for the ui to render in a single draw call. Do you have a design in mind for the gui? I don't mind trying to implement your design if you have one.

The simplest thing to me seems to be to take the current approach and extend it by adding panel/layout widgets and a Widget trait so you can aggregate different widget types (buttons/images/labels/etc). Then you can likely get rid of ButtonManager.

Maybe something like this?

 // Usage
 let mut panel = Panel::new().layout(Layout::Vertical).build();
 let button_id, button = Button::new().text("Play").color(&[255, 255, 255, 255]).bg_color(..).build();
 panel.add_widget(button); 
 
 // Event handling (same as right now)
 match panel.handle_click(..) {
     button_id => {..}
 }

// Some defs
trait Widget {
    fn draw(context,...);
    fn event(evt: UI::Event) -> Option<WidgetId>;
}

struct Panel {
    widgets: HashMap<ButtonId, Widget>;
}

impl Widget for Panel {...}

struct Button {
   text: String,
   color: ....,  
}

impl Widget for Button {...}

Thoughts?

@mdenchev
Copy link
Author

Submitted a smallish PR that adds an on_hover effect for buttons (changes color) and does some of the things above. I'll finish the work if you agree with the approach.

@ozkriff
Copy link
Owner

ozkriff commented Feb 13, 2017

🐌

Sorry for the slow response - you made me think about ZoC's middle-term plan.

Aaaand I'm leaning towards trying to port ZoC to Amethyst in a few months. Because by that time I'm hoping to start improving the visual part of the game and it makes little sense for me to develop my own "big" graphics engine alone.

A big part of the current ZoC's visualizer code will be thrown away.

Thus serious contributions to the current gui (and anything other than core) doesn't seem like a good idea to me.

@mdenchev
Copy link
Author

Makes sense. Is there anything specific you would like contributions to? I have some free time I'm trying to fill up with Rust in some way :)

@ozkriff
Copy link
Owner

ozkriff commented Feb 14, 2017

Hmmm, let's discuss this in gitter - https://gitter.im/ozkriff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants