浏览代码

Merge pull request #22 from kolumb/fullscreen

Add Fullscreen and Restart hotkeys
Alexey Kutepov 4 年之前
父节点
当前提交
85dbbd06e7
共有 4 个文件被更改,包括 36 次插入2 次删除
  1. 2 0
      README.md
  2. 二进制
      demo.gif
  3. 7 2
      docs/sowon.6
  4. 27 0
      main.c

+ 2 - 0
README.md

@@ -57,3 +57,5 @@ $ make
 | <kbd>=</kbd> | Zoom in |
 | <kbd>-</kbd> | Zoom out |
 | <kbd>0</kbd> | Zoom 100% |
+| <kbd>F5</kbd> | Restart |
+| <kbd>F11</kbd> | Fullscreen |

二进制
demo.gif


+ 7 - 2
docs/sowon.6

@@ -12,8 +12,9 @@
 .Nm
 is a graphical countdown/timer program.
 With no arguments provided, it starts in ascending mode. With an amount of
-seconds provided, it starts in descending mode. Clock starts it in clock
-mode, that displays the current time.
+seconds provided, it starts in descending mode. Accepts human readable time
+intervals (1h23m54s). Clock starts it in clock mode, that displays
+the current time.
 .br
 .Sh OPTIONS
 .Bl -tag -width indent
@@ -29,6 +30,10 @@ Zoom in
 Zoom out
 .It 0
 Zoom 100%
+.It F5
+Restart
+.It F11
+Fullscreen
 .Sh FILES
 .Pa /usr/local/bin/sowon
 .br

+ 27 - 0
main.c

@@ -227,6 +227,33 @@ int main(int argc, char **argv)
                 case SDLK_0: {
                     user_scale = 1.0f;
                 } break;
+
+                case SDLK_F5: {
+                    displayed_time = 0.0f;
+                    paused = 0;
+                    for (int i = 1; i < argc; ++i) {
+                        if (strcmp(argv[i], "-p") == 0) {
+                            paused = 1;
+                        } else {
+                            displayed_time = parse_time(argv[i]);
+                        }
+                    }
+                    if (paused) {
+                        secc(SDL_SetTextureColorMod(digits, PAUSE_COLOR_R, PAUSE_COLOR_G, PAUSE_COLOR_B));
+                    } else {
+                        secc(SDL_SetTextureColorMod(digits, MAIN_COLOR_R, MAIN_COLOR_G, MAIN_COLOR_B));
+                    }
+                } break;
+
+                case SDLK_F11: {
+                    Uint32 window_flags;
+                    secc(window_flags = SDL_GetWindowFlags(window));
+                    if(window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) {
+                        secc(SDL_SetWindowFullscreen(window, 0));
+                    } else {
+                        secc(SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP));
+                    }
+                } break;
                 }
             } break;