diff --git a/res/ui/ui.glade b/res/ui/ui.glade index f8f80a1..cd749a5 100644 --- a/res/ui/ui.glade +++ b/res/ui/ui.glade @@ -1316,7 +1316,6 @@ True False - toolbutton True media-playback-start True @@ -1354,7 +1353,6 @@ True False - __glade_unnamed_11 True media-seek-backward @@ -1386,7 +1384,6 @@ True False - __glade_unnamed_13 True media-seek-forward @@ -1406,6 +1403,32 @@ True + + + True + False + True + zoom-out + + + + False + True + + + + + True + False + True + zoom-in + + + + False + True + + True @@ -1435,7 +1458,7 @@ False - True + False True diff --git a/src/gfx/gfx.c b/src/gfx/gfx.c index 9262d3d..decc000 100644 --- a/src/gfx/gfx.c +++ b/src/gfx/gfx.c @@ -20,7 +20,7 @@ #include "perf.h" #include "render.h" #include "thread.h" -#include "timemgr.h" +#include "toolbar.h" struct GLCtx e_gl_ctx; static GtkGLArea *glarea; @@ -67,7 +67,7 @@ gboolean on_glarea_render(GtkGLArea *area, GdkGLContext *context, gpointer user_ thread_dispatch(THRD_PHYS, NULL); satellites_tic(); render_process(); - timemgr_tic(); + toolbar_tic(); info_tic(); perf_tic(); thread_join(THRD_PHYS); diff --git a/src/phys/phys.c b/src/phys/phys.c index 265ddb2..f5fe6c3 100644 --- a/src/phys/phys.c +++ b/src/phys/phys.c @@ -21,8 +21,9 @@ #include "setting.h" #include "system.h" #include "thread.h" -#include "timemgr.h" +enum Timeflow e_timeflow = TIME_REALTIME; +float e_timescale = 1.f; struct PhysCtx e_phys; static gint64 epoch_ms; static struct PhysCtx phys_ctx_sync; diff --git a/src/phys/phys.h b/src/phys/phys.h index 95eb417..9afe117 100644 --- a/src/phys/phys.h +++ b/src/phys/phys.h @@ -29,6 +29,14 @@ struct PhysCtx { vec3 sun_dir; }; +enum Timeflow { + TIME_REALTIME = 0u, + TIME_PAUSE, + TIME_ARBITRARY, +}; + +extern enum Timeflow e_timeflow; +extern float e_timescale; extern struct PhysCtx e_phys; void phys_init(void); diff --git a/src/ui/timemgr.c b/src/ui/toolbar.c similarity index 84% rename from src/ui/timemgr.c rename to src/ui/toolbar.c index 24ad465..87ad551 100644 --- a/src/ui/timemgr.c +++ b/src/ui/toolbar.c @@ -12,16 +12,16 @@ * GNU General Public License for more details. **/ -#include "timemgr.h" +#include "toolbar.h" +#include "camera.h" #include "phys.h" #include "setting.h" #include "system.h" #include -enum Timeflow e_timeflow = TIME_REALTIME; -float e_timescale = 1.f; +#define ZOOM_DIST 0.2 static GtkToggleToolButton *play_button; static GtkEntry *time_entry; @@ -31,6 +31,8 @@ static void on_play_toggled(GtkToggleToolButton *toggle_tool_button, gpointer us static void on_realtime_clicked(GtkToolButton *toolbutton, gpointer user_data); static void on_decelerate_clicked(GtkToolButton *toolbutton, gpointer user_data); static void on_accelerate_clicked(GtkToolButton *toolbutton, gpointer user_data); +static void on_zoom_out_clicked(GtkToolButton *toolbutton, gpointer user_data); +static void on_zoom_in_clicked(GtkToolButton *toolbutton, gpointer user_data); static void on_time_activate(GtkEntry *entry, gpointer user_data); static void on_speed_activate(GtkEntry *entry, gpointer user_data); static void timeflow_set(enum Timeflow timeflow); @@ -70,6 +72,22 @@ void on_accelerate_clicked(GtkToolButton *toolbutton, gpointer user_data) e_timescale *= 1.05f; } +static void on_zoom_out_clicked(GtkToolButton *toolbutton, gpointer user_data) +{ + (void)toolbutton; + (void)user_data; + + camera_zoom(&e_camera, -ZOOM_DIST); +} + +static void on_zoom_in_clicked(GtkToolButton *toolbutton, gpointer user_data) +{ + (void)toolbutton; + (void)user_data; + + camera_zoom(&e_camera, ZOOM_DIST); +} + void on_time_activate(GtkEntry *entry, gpointer user_data) { (void)entry; @@ -111,7 +129,7 @@ void timeflow_set(enum Timeflow timeflow) gtk_toggle_tool_button_set_active(play_button, (timeflow == TIME_PAUSE) ? FALSE : TRUE); } -void timemgr_init(GtkBuilder *builder) +void toolbar_init(GtkBuilder *builder) { gtk_builder_add_callback_symbols(builder, "on_play_toggled", G_CALLBACK(on_play_toggled), @@ -120,13 +138,15 @@ void timemgr_init(GtkBuilder *builder) "on_accelerate_clicked", G_CALLBACK(on_accelerate_clicked), "on_time_activate", G_CALLBACK(on_time_activate), "on_speed_activate", G_CALLBACK(on_speed_activate), + "on_zoom_in_clicked", G_CALLBACK(on_zoom_in_clicked), + "on_zoom_out_clicked", G_CALLBACK(on_zoom_out_clicked), NULL); play_button = GTK_TOGGLE_TOOL_BUTTON(gtk_builder_get_object(builder, "play")); time_entry = GTK_ENTRY(gtk_builder_get_object(builder, "time")); speed_entry = GTK_ENTRY(gtk_builder_get_object(builder, "speed")); } -void timemgr_tic(void) +void toolbar_tic(void) { if (!gtk_widget_has_focus(GTK_WIDGET(time_entry))) gtk_entry_set_text(time_entry, epoch_to_iso8601(e_phys.epoch_ms, gs_gmt, TRUE)); diff --git a/src/ui/timemgr.h b/src/ui/toolbar.h similarity index 68% rename from src/ui/timemgr.h rename to src/ui/toolbar.h index 7d5b1ff..b72ae81 100644 --- a/src/ui/timemgr.h +++ b/src/ui/toolbar.h @@ -12,21 +12,12 @@ * GNU General Public License for more details. **/ -#ifndef __TIMEMGR_H__ -#define __TIMEMGR_H__ +#ifndef __TOOLBAR_H__ +#define __TOOLBAR_H__ #include "ui.h" -enum Timeflow { - TIME_REALTIME = 0u, - TIME_PAUSE, - TIME_ARBITRARY, -}; +void toolbar_init(GtkBuilder *builder); +void toolbar_tic(void); -extern enum Timeflow e_timeflow; -extern float e_timescale; - -void timemgr_init(GtkBuilder *builder); -void timemgr_tic(void); - -#endif /* __TIMEMGR_H__ */ +#endif /* __TOOLBAR_H__ */ diff --git a/src/ui/ui.c b/src/ui/ui.c index aa35419..d920ce4 100644 --- a/src/ui/ui.c +++ b/src/ui/ui.c @@ -27,7 +27,7 @@ #include "status.h" #include "system.h" #include "thread.h" -#include "timemgr.h" +#include "toolbar.h" const gchar *FILENAME_GUI = "res/ui/ui.glade"; @@ -79,7 +79,7 @@ void ui_init(int argc, char ***argv) gfx_init(builder); input_init(builder); status_init(builder); - timemgr_init(builder); + toolbar_init(builder); catalog_init(builder); setting_init(builder); info_init(builder);