4coder/4ed_delay.cpp

75 lines
2.3 KiB
C++
Raw Normal View History

2016-02-27 17:34:13 +00:00
enum Action_Type{
DACT_OPEN,
DACT_SAVE_AS,
DACT_SAVE,
DACT_NEW,
DACT_SWITCH,
DACT_TRY_KILL,
DACT_KILL,
DACT_CLOSE_MINOR,
DACT_CLOSE_MAJOR,
DACT_THEME_OPTIONS,
DACT_KEYBOARD_OPTIONS,
};
struct Delayed_Action{
Action_Type type;
String string;
Panel* panel;
Editing_File* file;
};
struct Delay{
Delayed_Action* acts;
i32 count;
i32 max;
};
inline Delayed_Action*
2016-02-27 19:33:42 +00:00
delayed_action_(Delay *delay, Action_Type type){
2016-02-27 17:34:13 +00:00
Delayed_Action *result;
Assert(delay->count < delay->max);
result = delay->acts + delay->count++;
*result = {};
result->type = type;
return(result);
}
inline Delayed_Action*
2016-02-27 19:33:42 +00:00
delayed_action_(Delay *delay, Action_Type type, Panel* panel){
2016-02-27 17:34:13 +00:00
Delayed_Action *result;
2016-02-27 19:33:42 +00:00
result = delayed_action_(delay, type);
2016-02-27 17:34:13 +00:00
result->panel = panel;
return(result);
}
inline Delayed_Action*
2016-02-27 19:33:42 +00:00
delayed_action_(Delay *delay, Action_Type type, String string, Panel* panel){
2016-02-27 17:34:13 +00:00
Delayed_Action *result;
2016-02-27 19:33:42 +00:00
result = delayed_action_(delay, type);
2016-02-27 17:34:13 +00:00
result->string = string;
result->panel = panel;
return(result);
}
inline Delayed_Action*
2016-02-27 19:33:42 +00:00
delayed_action_(Delay *delay, Action_Type type, String string, Editing_File* file){
2016-02-27 17:34:13 +00:00
Delayed_Action *result;
2016-02-27 19:33:42 +00:00
result = delayed_action_(delay, type);
2016-02-27 17:34:13 +00:00
result->string = string;
result->file = file;
return(result);
}
2016-02-27 19:33:42 +00:00
#define delayed_open(delay, ...) delayed_action_(delay, DACT_OPEN, __VA_ARGS__)
#define delayed_save_as(delay, ...) delayed_action_(delay, DACT_SAVE_AS, __VA_ARGS__)
#define delayed_save(delay, ...) delayed_action_(delay, DACT_SAVE, __VA_ARGS__)
#define delayed_new(delay, ...) delayed_action_(delay, DACT_NEW, __VA_ARGS__)
#define delayed_switch(delay, ...) delayed_action_(delay, DACT_SWITCH, __VA_ARGS__)
#define delayed_try_kill(delay, ...) delayed_action_(delay, DACT_TRY_KILL, __VA_ARGS__)
#define delayed_kill(delay, ...) delayed_action_(delay, DACT_KILL, __VA_ARGS__)
#define delayed_close_minor(delay, ...) delayed_action_(delay, DACT_CLOSE_MINOR, __VA_ARGS__)
#define delayed_close_major(delay, ...) delayed_action_(delay, DACT_CLOSE_MAJOR, __VA_ARGS__)
#define delayed_theme_options(delay, ...) delayed_action_(delay, DACT_THEME_OPTIONS, __VA_ARGS__)
#define delayed_keyboard_options(delay, ...) delayed_action_(delay, DACT_KEYBOARD_OPTIONS, __VA_ARGS__)