pub struct ChessGui { /* private fields */ }Expand description
GUI for the Chess game.
Implementations
sourceimpl ChessGui
impl ChessGui
sourcepub fn new(chess: Chess, theme: Theme, buttons: Vec<Button>) -> Self
pub fn new(chess: Chess, theme: Theme, buttons: Vec<Button>) -> Self
Create a new instance of ChessGui.
sourcepub fn set_theme(&mut self, theme: Theme)
pub fn set_theme(&mut self, theme: Theme)
Set the theme for the GUI.
Examples
use chess::{ChessGui, THEME_SANDCASTLE};
let mut game = ChessGui::default();
game.set_theme(THEME_SANDCASTLE);sourcepub unsafe fn next_theme(&mut self)
pub unsafe fn next_theme(&mut self)
Add a button in the GUI.
Trait Implementations
sourceimpl EventHandler<GameError> for ChessGui
impl EventHandler<GameError> for ChessGui
sourcefn update(&mut self, _ctx: &mut Context) -> GameResult
fn update(&mut self, _ctx: &mut Context) -> GameResult
Update will happen on every frame before it is drawn.
sourcefn draw(&mut self, ctx: &mut Context) -> GameResult
fn draw(&mut self, ctx: &mut Context) -> GameResult
Render the game’s current state.
Called every time a mouse button gets pressed
sourcefn mouse_motion_event(
&mut self,
ctx: &mut Context,
x: f32,
y: f32,
_dx: f32,
_dy: f32
)
fn mouse_motion_event(
&mut self,
ctx: &mut Context,
x: f32,
y: f32,
_dx: f32,
_dy: f32
)
Change the [ggez::input::mouse::CursorIcon] when the mouse is on a button.
sourcefn key_down_event(
&mut self,
ctx: &mut Context,
keycode: KeyCode,
keymod: KeyMods,
_repeat: bool
)
fn key_down_event(
&mut self,
ctx: &mut Context,
keycode: KeyCode,
keymod: KeyMods,
_repeat: bool
)
Called every time a key gets pressed.
Keys
| Keys | Actions |
|---|---|
| Escape | Quit the game |
| R | Reset the game and buttons |
| CTRL+Z | Undo |
A mouse button was released
sourcefn mouse_enter_or_leave(&mut self, _ctx: &mut Context, _entered: bool)
fn mouse_enter_or_leave(&mut self, _ctx: &mut Context, _entered: bool)
mouse entered or left window area
sourcefn mouse_wheel_event(&mut self, _ctx: &mut Context, _x: f32, _y: f32)
fn mouse_wheel_event(&mut self, _ctx: &mut Context, _x: f32, _y: f32)
The mousewheel was scrolled, vertically (y, positive away from and negative toward the user)
or horizontally (x, positive to the right and negative to the left). Read more
sourcefn key_up_event(
&mut self,
_ctx: &mut Context,
_keycode: VirtualKeyCode,
_keymods: KeyMods
)
fn key_up_event(
&mut self,
_ctx: &mut Context,
_keycode: VirtualKeyCode,
_keymods: KeyMods
)
A keyboard button was released.
sourcefn text_input_event(&mut self, _ctx: &mut Context, _character: char)
fn text_input_event(&mut self, _ctx: &mut Context, _character: char)
A unicode character was received, usually from keyboard input.
This is the intended way of facilitating text input. Read more
A gamepad button was pressed;
id identifies which gamepad.
Use input::gamepad() to get more info about
the gamepad. Read moreA gamepad button was released;
id identifies which gamepad.
Use input::gamepad() to get more info about
the gamepad. Read moresourcefn gamepad_axis_event(
&mut self,
_ctx: &mut Context,
_axis: Axis,
_value: f32,
_id: GamepadId
)
fn gamepad_axis_event(
&mut self,
_ctx: &mut Context,
_axis: Axis,
_value: f32,
_id: GamepadId
)
A gamepad axis moved;
id identifies which gamepad.
Use input::gamepad() to get more info about
the gamepad. Read moresourcefn focus_event(&mut self, _ctx: &mut Context, _gained: bool)
fn focus_event(&mut self, _ctx: &mut Context, _gained: bool)
Called when the window is shown or hidden.
sourcefn quit_event(&mut self, _ctx: &mut Context) -> bool
fn quit_event(&mut self, _ctx: &mut Context) -> bool
Called upon a quit event. If it returns true,
the game does not exit (the quit event is cancelled). Read more
sourcefn resize_event(&mut self, _ctx: &mut Context, _width: f32, _height: f32)
fn resize_event(&mut self, _ctx: &mut Context, _width: f32, _height: f32)
Called when the user resizes the window, or when it is resized
via
graphics::set_mode(). Read moreAuto Trait Implementations
impl RefUnwindSafe for ChessGui
impl Send for ChessGui
impl Sync for ChessGui
impl Unpin for ChessGui
impl UnwindSafe for ChessGui
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more