Skip to content

ckeen/KiWi

 
 

Repository files navigation

KiWi - The Killer Widgets library

Killer Widgets (KiWi) is a widget-based GUI library for game developers to use in their 2D games. Its widgets are constructed by using a tileset, allowing you to easly customize the looks of your GUI by simply changing its tiles (even in runtime, yay!).

It supports custom (and composed) widgets so that you can implement that beautiful ring chart showing how much network traffic your MMORPG is using, allowing you to impress your boss.

KiWi is built around SDL2 and designed to accompany it (means that if you want to use KiWi, you'll have to use SDL. But hey, SDL is awesome already, no big deal, right? :)

Right now KiWi is under (heavy) development and any help (code patches, money, chat, hug, etc) is hugely appreciated.

Here are some screenshots, though (click on them to see code):

alt text alt text

alt text alt text

alt text

Check the roadmap!

Build and test KiWi:

If you're feeling mighty and want to try KiWi right now, these are (roughly) the steps to do it:

  1. Have a compiler environment ready (GCC, LLVM, MSVC, MinGW, etc);
  2. Have SDL2, SDL2_ttf and SDL2_image available and properly detectable by your compiler;
  3. Have CMake installed;
  4. Download this repository;
  5. Create a build folder inside it;
  6. Run cmake (or cmake-gui), set the binary dir to the newly created build folder and the source dir to the repository folder;
  7. Build it!

You can test the examples inside the build/examples/ folder.

Basic usage

Here is a very basic code that draws a label on screen (taken from the playground example):

#include "SDL.h"
#include "SDL_ttf.h"
#include "SDL_image.h"
#include "KW_gui.h"

int main(int argc, char ** argv) {
  /* init SDL and SDL_ttf */
  SDL_Renderer * renderer;
  SDL_Window * window;
  SDL_Surface * set;
  KW_GUI * gui;
  TTF_Font * font;
  KW_Widget * frame;
  SDL_Rect geometry;
  SDL_Init(SDL_INIT_EVERYTHING);
  SDL_CreateWindowAndRenderer(320, 240, 0, &window, &renderer);
  SDL_SetRenderDrawColor(renderer, 200, 100, 100, 1);
  
  TTF_Init();
  
  /* load tileset surface */
  
  set = IMG_Load("tileset.png");
  
  /* load font */
  font = TTF_OpenFont("Fontin-Regular.ttf", 12);
  
  /* init KiWi */
  gui = KW_Init(renderer, set);
  KW_SetFont(gui, font);
  
  /* create a frame and a label on top of it. */
  geometry.x = geometry.y = 0; geometry.w = 320; geometry.h = 240;
  frame = KW_CreateFrame(gui, NULL, &geometry);
  KW_CreateLabel(gui, frame, "Label", &geometry);
  
  while (!SDL_QuitRequested()) {
    SDL_RenderClear(renderer);
    KW_Paint(gui);
    SDL_Delay(1);
    SDL_RenderPresent(renderer);
  }
  KW_Quit(gui);
  SDL_FreeSurface(set);
  
  return 0;
}

Better documentation is yet to come, but every public method is well documented.

About

KiWi: Killer Widgets

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 89.1%
  • CMake 10.6%
  • Makefile 0.3%