diff --git a/README.md b/README.md new file mode 100644 index 0000000..91f3892 --- /dev/null +++ b/README.md @@ -0,0 +1,61 @@ +# Sharpsoft + +Sharpsoft is a UI engine for the Vex V5 brain. It's based off the way Windows Forms functions in .NET. It is compatible with Pros and (will be) compatible with Vexcode as well. I'm still working on it, it's nowhere close to finished and still quite far from an actual release, but I'll get to it. + +You can use this project for whatever you want. Just credit me. + +## Use + +To use Sharpsoft, copy the sharpsoft folders in both the `include` and the `src` directories. Paste them into your projects. It should just compile. + +In the code, you can use pre-existing window types or create your own. If you make your own, just make the class derive from `sharp::window_base` and add a paint method, like this: + +```c++ +class custom_window : public window_base +{ +protected: + void paint() override + { + // Rendering code goes here. + } + void tick() override + { + // Tick code goes here. + } + +public: + // <Position> <Size> + custom_window() : window_base("Custom", sharp::int2(50, 50), sharp::int2(250, 200)) + { + // Initialization code goes here. + } +}; +``` + +There are lots of ways to customize the windows. You can modify the styles with `style()`, resize, change titles, and more. It's important to note that a window does not refresh every frame by default. To do that, you need to set a specific flag. + +```c++ +custom_window() : window_base("Custom", sharp::int2(50, 50), sharp::int2(250, 200)) +{ + // This doesn't have to be in the constructor but it's probably best there. + set_flag(CONTINUOUS_PAINT, true); + + // You can also change the tick loop here. + set_flag(CONTINUOUS_TICK, false); // Defaults to `true`. +} +``` + +And using the windows is even easier. Here's how Sharpsoft setup usually looks: + +```c++ +void initialize() +{ + sharp::initialize(); + sharp::add_window(custom_window()); + // More windows would go here. + sharp::start(); +} +``` + +Not that bad, right? There are some weird edge cases but I'll iron them out as I find them. +Hope you enjoy using it! diff --git a/src/main.cpp b/src/main.cpp index 6c7fcdb..4ac815f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,7 +23,7 @@ protected: public: test_window() : window_base("Testing", sharp::int2(10, 10), sharp::int2(150, 100)) { - set_flag(sharp::CONTINUOUS_PAINT, true); + set_flag(sharp::CONTINUOUS_TICK, false); } }; diff --git a/src/sharpsoft/rendering.cpp b/src/sharpsoft/rendering.cpp index f66149d..45141f7 100644 --- a/src/sharpsoft/rendering.cpp +++ b/src/sharpsoft/rendering.cpp @@ -26,7 +26,7 @@ void internal::fill_global_rectangle(const color& color, const int_rect& rect) void window_base::paint_header() const { // Draw outline. - internal::draw_global_rectangle(styles.outline_color, int_rect(posX - 1, posY - 1, width + 1, height + 1)); + internal::draw_global_rectangle(styles.outline_color, int_rect(posX - 1, posY - 1, width + 2, height + 2)); } void window_base::paint_content_back() const { diff --git a/src/sharpsoft/window_base.cpp b/src/sharpsoft/window_base.cpp index 3641e0b..21810ae 100644 --- a/src/sharpsoft/window_base.cpp +++ b/src/sharpsoft/window_base.cpp @@ -19,8 +19,8 @@ sharp::window_base::window_base(const string& title, const int2& pos, const int2 posY = pos.y; width = size.x; height = size.y; - flags = (window_flags)0; - int_flags = WINDOW_VISIBLE; + flags = (window_flags)(CONTINUOUS_TICK); + int_flags = (window_internal_flags)WINDOW_VISIBLE; styles = window_styles::defaults; }