summaryrefslogtreecommitdiff
path: root/src/user/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/include')
-rw-r--r--src/user/include/cxx/raleigh/util.h16
-rw-r--r--src/user/include/cxx/raleigh/w/button.h26
-rw-r--r--src/user/include/cxx/raleigh/w/label.h9
-rw-r--r--src/user/include/cxx/raleigh/w/padding.h7
-rw-r--r--src/user/include/cxx/raleigh/w/vbox.h22
-rw-r--r--src/user/include/cxx/raleigh/widget.h9
-rw-r--r--src/user/include/cxx/raleigh/window.h10
-rw-r--r--src/user/include/libfont/fonts.h3
-rw-r--r--src/user/include/popups/info.h8
9 files changed, 97 insertions, 13 deletions
diff --git a/src/user/include/cxx/raleigh/util.h b/src/user/include/cxx/raleigh/util.h
index d2ed13d..9142b69 100644
--- a/src/user/include/cxx/raleigh/util.h
+++ b/src/user/include/cxx/raleigh/util.h
@@ -5,11 +5,15 @@
#define RGB(R, G, B) ((_pixel_t){.r = 0x##R, .g = 0x##G, .b = 0x##B})
-struct coord {
- uint32_t x;
- uint32_t y;
- coord(uint32_t x, uint32_t y);
- coord();
-};
+namespace raleigh {
+ struct coord {
+ uint32_t x;
+ uint32_t y;
+ coord(uint32_t x, uint32_t y);
+ coord();
+ };
+
+ void show_error_and_quitf(const char *fmt, ...) __attribute__ ((noreturn));
+}
#endif \ No newline at end of file
diff --git a/src/user/include/cxx/raleigh/w/button.h b/src/user/include/cxx/raleigh/w/button.h
new file mode 100644
index 0000000..1847cf1
--- /dev/null
+++ b/src/user/include/cxx/raleigh/w/button.h
@@ -0,0 +1,26 @@
+#ifndef RALEIGH_W_BUTTON_H
+#define RALEIGH_W_BUTTON_H
+
+#include <raleigh/widget.h>
+
+namespace raleigh {
+ class button : public widget {
+ public:
+ button(widget &inner, void (*on_click)(button &), _pixel_t border_color=RGB(00, 00, 00),
+ _pixel_t bg_color=RGB(bf, bf, bf), _pixel_t pressed_color=RGB(9f, 9f, 9f));
+
+ void notify_window_change() override;
+ void paint(_pixel_t *pixbuf, uint32_t pitch) override;
+ bool try_handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) override;
+ void notify_has_opaque_parent(widget *parent) override;
+ private:
+ widget &inner;
+ void (*on_click)(button &);
+ _pixel_t border_color;
+ _pixel_t bg_color;
+ _pixel_t pressed_color;
+ bool is_pressed;
+ };
+}
+
+#endif \ No newline at end of file
diff --git a/src/user/include/cxx/raleigh/w/label.h b/src/user/include/cxx/raleigh/w/label.h
index 51bf541..d133841 100644
--- a/src/user/include/cxx/raleigh/w/label.h
+++ b/src/user/include/cxx/raleigh/w/label.h
@@ -8,16 +8,19 @@ namespace raleigh {
class label : public widget {
public:
//this pointer is used directly, and the contents of the string should not be changed afterward
- label(const char *value, const char *font="fixed-10",
- _pixel_t bg=RGB(bf, bf, bf), _pixel_t fg=RGB(00, 00, 00));
+ label(const char *value, const char *font="fixed-10", bool bg_transparent=true,
+ _pixel_t fg=RGB(00, 00, 00), _pixel_t bg=RGB(bf, bf, bf));
void notify_window_change() override;
void paint(_pixel_t *pixbuf, uint32_t pitch) override;
+ bool try_handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) override __attribute__ ((const));
+ void notify_has_opaque_parent(widget *parent) override;
private:
const char *const value;
const struct font_info *const fi;
- const _pixel_t bg;
+ bool bg_transparent;
const _pixel_t fg;
+ const _pixel_t bg;
};
}
diff --git a/src/user/include/cxx/raleigh/w/padding.h b/src/user/include/cxx/raleigh/w/padding.h
index 108cd28..216b984 100644
--- a/src/user/include/cxx/raleigh/w/padding.h
+++ b/src/user/include/cxx/raleigh/w/padding.h
@@ -6,14 +6,15 @@
namespace raleigh {
class padding : public widget {
public:
- padding(uint32_t pad_by, _pixel_t color, widget &inner);
+ padding(widget &inner, uint32_t pad_by);
void notify_window_change() override;
void paint(_pixel_t *pixbuf, uint32_t pitch) override;
+ bool try_handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) override;
+ void notify_has_opaque_parent(widget *parent) override;
private:
- uint32_t pad_by;
- _pixel_t color;
widget &inner;
+ uint32_t pad_by;
};
}
diff --git a/src/user/include/cxx/raleigh/w/vbox.h b/src/user/include/cxx/raleigh/w/vbox.h
new file mode 100644
index 0000000..aead128
--- /dev/null
+++ b/src/user/include/cxx/raleigh/w/vbox.h
@@ -0,0 +1,22 @@
+#ifndef RALEIGH_W_VBOX_H
+#define RALEIGH_W_VBOX_H
+
+#include <raleigh/widget.h>
+#include <structs/dllist.h>
+
+namespace raleigh {
+ class vbox : public widget {
+ public:
+ //do not modify this list afterward
+ vbox(dllist<widget &> widgets);
+
+ void notify_window_change() override;
+ void paint(_pixel_t *pixbuf, uint32_t pitch) override;
+ bool try_handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) override;
+ void notify_has_opaque_parent(widget *parent) override;
+ private:
+ dllist<widget &> widgets;
+ };
+}
+
+#endif \ No newline at end of file
diff --git a/src/user/include/cxx/raleigh/widget.h b/src/user/include/cxx/raleigh/widget.h
index 1839333..de6c5a4 100644
--- a/src/user/include/cxx/raleigh/widget.h
+++ b/src/user/include/cxx/raleigh/widget.h
@@ -18,9 +18,18 @@ namespace raleigh {
window *w;
coord window_offset;
+ //fewest steps up that a widget can be redrawn without needing its parents
+ //if a widget is opaque, it will set this to a pointer to itself, and then call
+ // notify_has_opaque_parent on any children, passing itself as an argument.
+ //in notify_has_opaque_parent's handler, it should set this if it isn't already set,
+ // and then call notify_has_opaque_parent on any children (with the opaque parent).
+ widget *closest_opaque;
+
//called by window class (or parent widget)
virtual void notify_window_change() = 0;
virtual void paint(_pixel_t *pixbuf, uint32_t pitch) = 0;
+ virtual bool try_handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) = 0;
+ virtual void notify_has_opaque_parent(widget *parent) = 0;
};
}
diff --git a/src/user/include/cxx/raleigh/window.h b/src/user/include/cxx/raleigh/window.h
index 7e45e22..f82f9a9 100644
--- a/src/user/include/cxx/raleigh/window.h
+++ b/src/user/include/cxx/raleigh/window.h
@@ -5,22 +5,30 @@ namespace raleigh {
class window;
}
+#include <raleigh/runtime.h>
#include <raleigh/widget.h>
#include <pland/syscall.h>
#include <raleigh/util.h>
namespace raleigh {
class window {
+ friend void start_runtime();
public:
- window(widget &root);
+ //pass on_close to specify a close handler. if on_close returns false, the window will not be closed.
+ window(widget &root, _pixel_t bg_color=RGB(bf, bf, bf), bool (*on_close)(window &)=0);
void notify_needs_paint(widget &from);
enum try_actions_return_t {NONE, GOOD, DELETE};
try_actions_return_t try_actions();
+ void show();
private:
_window_handle_t handle;
_pixel_t *pixbuf;
coord size;
widget &root;
+ _pixel_t bg_color;
+ bool needs_repaint;
+ void paint_full();
+ bool (*on_close)(window &);
};
}
diff --git a/src/user/include/libfont/fonts.h b/src/user/include/libfont/fonts.h
index 629ed5a..8c0e949 100644
--- a/src/user/include/libfont/fonts.h
+++ b/src/user/include/libfont/fonts.h
@@ -25,6 +25,9 @@ struct font_info *get_font(const char *name);
//pitch is in pixels
void put_char(const struct font_info *font, char ch, _pixel_t *pb_ptr, uint32_t pb_pitch, _pixel_t bg, _pixel_t fg);
+//pitch is in pixels
+void put_char_no_bg(const struct font_info *font, char ch, _pixel_t *pb_ptr, uint32_t pb_pitch, _pixel_t fg);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/user/include/popups/info.h b/src/user/include/popups/info.h
index 36d557a..de6be57 100644
--- a/src/user/include/popups/info.h
+++ b/src/user/include/popups/info.h
@@ -1,6 +1,10 @@
#ifndef POPUPS_INFO_H
#define POPUPS_INFO_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <popups/popup.h>
#include <pland/syscall.h>
@@ -11,4 +15,8 @@ void info_popup(struct popup *into, const char *text, _pixel_t fg, _pixel_t bg);
void info_popupf(struct popup *into, const char *text, _pixel_t fg, _pixel_t bg, ...);
void info_popupf_v(struct popup *into, const char *text, _pixel_t fg, _pixel_t bg, va_list args);
+#ifdef __cplusplus
+}
+#endif
+
#endif \ No newline at end of file