-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f91da2a
commit 1a94786
Showing
12 changed files
with
306 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# OOP Events - 3/10/23 | ||
- changed events to be in a more OOP style | ||
- for now old functions are kept for backwards compatibility but may be removed in the future | ||
# Buttons - 3/10/23 | ||
- Fixed the error with the mouse being weird and not sending click events properly, Window was passing X,Y to the mouse instead of mouseX, mouseY. (X,Y are keycodes that were included with the keyboard driver) | ||
- Fixed button releasing error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// | ||
// Created by 98max on 10/10/2023. | ||
// | ||
|
||
#ifndef MAXOS_GUI_WIDGETS_BUTTON_H | ||
#define MAXOS_GUI_WIDGETS_BUTTON_H | ||
|
||
#include <common/types.h> | ||
#include <common/eventHandler.h> | ||
#include <gui/widget.h> | ||
#include <gui/font.h> | ||
|
||
|
||
namespace maxOS { | ||
|
||
namespace gui { | ||
|
||
namespace widgets { | ||
|
||
//forward declaration | ||
class Button; | ||
|
||
enum ButtonEvents{ | ||
BUTTON_PRESSED, | ||
BUTTON_RELEASED | ||
}; | ||
|
||
class ButtonPressedEvent : public common::Event<ButtonEvents>{ | ||
public: | ||
ButtonPressedEvent(Button* source); | ||
~ButtonPressedEvent(); | ||
|
||
Button* source; | ||
}; | ||
|
||
class ButtonReleasedEvent : public common::Event<ButtonEvents>{ | ||
public: | ||
ButtonReleasedEvent(Button* source); | ||
~ButtonReleasedEvent(); | ||
|
||
Button* source; | ||
}; | ||
|
||
class ButtonEventHandler : public common::EventHandler<ButtonEvents>{ | ||
public: | ||
ButtonEventHandler(); | ||
~ButtonEventHandler(); | ||
|
||
virtual void onEvent(common::Event<ButtonEvents>* event); | ||
|
||
virtual void onButtonPressed(Button* source); | ||
virtual void onButtonReleased(Button* source); | ||
}; | ||
|
||
class Button : public Widget, public common::EventManager<ButtonEvents> { | ||
|
||
public: | ||
Button(common::int32_t left, common::int32_t top, common::uint32_t width, common::uint32_t height, common::string text); | ||
~Button(); | ||
|
||
// Widget Stuff | ||
void draw(common::GraphicsContext* gc, common::Rectangle<int>& area); | ||
drivers::peripherals::MouseEventHandler* onMouseButtonPressed(common::uint32_t x, common::uint32_t y, common::uint8_t button); | ||
void onMouseButtonReleased(common::uint32_t x, common::uint32_t y, common::uint8_t button); | ||
|
||
// Button Stuff | ||
common::Colour backgroundColour; | ||
common::Colour borderColour; | ||
gui::AmigaFont font; | ||
common::string text; | ||
|
||
}; | ||
} | ||
} | ||
|
||
} | ||
|
||
#endif //MAXOS_GUI_WIDGETS_BUTTON_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.