Пример #1
0
int main() {
	srand(time(NULL)); // initialize random
    fl_register_images();
	Fl_Window* win = new KitchenFloor();
	win->show();
    return(Fl::run());
}
Пример #2
0
int main(int argc, const char *argv[])
{
	// This lets us load various image formats.
	fl_register_images();
	try
	{
		// Branch to processing code based on first argument
		if (argc > 1 && strcmp(argv[1], "sphrWarp") == 0)
			return SphrWarp(argc, argv);
		else if (argc > 1 && strcmp(argv[1], "alignPair") == 0)
			return AlignPair(argc, argv);
		else if (argc > 1 && strcmp(argv[1], "blendPairs") == 0)
			return BlendPairs(argc, argv);
		else if (argc > 1 && strcmp(argv[1], "script") == 0)
			return Script(argc, argv);
		else {
			printf("usage: \n");
	        printf("	%s sphrWarp input.tga output.tga f [k1 k2]\n", argv[0]);
			printf("	%s alignPair input1.f input2.f matchfile nRANSAC RANSACthresh [sift]\n", argv[0]);
			printf("	%s blendPairs pairlist.txt outimg.tga blendWidth\n", argv[0]);
			printf("	%s script script.cmd\n", argv[0]);
		}
    }
    catch (CError &err) {
        printf(err.message);
        return -1;
    }
    return 0;
}
int main(int	argc, 
		 char**	argv) 
{
	impDoc = new ImpressionistDoc();

	// Create the UI
	impUI = new ImpressionistUI();

	fl_register_images();

	// Set the impDoc which is used as the bridge between UI and brushes
	impUI->setDocument(impDoc);
	impDoc->setUI(impUI);

	Fl::visual(FL_DOUBLE|FL_INDEX);

	impUI->show();

	return Fl::run();
}
Пример #4
0
void Window::init(int c) {
	if(c & WIN_INIT_IMAGES)
		fl_register_images();

	fl_open_display();

	if(c & WIN_INIT_ICON_THEME)
		icon_theme_load_once(IconTheme::default_theme_name());

	/* setup icons for dialogs */
	MessageBox::set_themed_icons(MSGBOX_ICON_INFO, 
								 MSGBOX_ICON_ERROR, 
								 MSGBOX_ICON_QUESTION, 
								 MSGBOX_ICON_QUESTION, 
								 MSGBOX_ICON_PASSWORD);

	/* XSETTINGS stuff */
	xs = new XSettingsClient();
	if(!xs->init(fl_display, fl_screen, xsettings_cb, this)) {
		delete xs;
		xs = NULL;
	}

	/* 
	 * add_handler() does not have parameter for optional data, so global storage must be used 
	 * XXX: does it collide with other Window objects?
	 */
	xcli = xs;

	/*
	 * FLTK keeps internaly list of event handlers that are shared between
	 * windows in one application. If in one app exists two or more Window objects,
	 * handler will be added again without checking if already exists. With that 
	 * behaviour callback can be called multiple times even if only one window matches it.
	 *
	 * Removing (if exists) and re-adding again will assure we have only one callback per Window object.
	 */
	Fl::remove_handler(xevent_handler);
	Fl::add_handler(xevent_handler);
}
Пример #5
0
int main()
{
    fl_register_images();

    g_WilFilePathName       = "";
    g_WorkingPathName       = "";

    g_MainWindow            = new MainWindow();
    g_SelectSettingWindow   = new SelectSettingWindow();
    g_AnimationSelectWindow = new AnimationSelectWindow();
    g_AboutWindow           = new AboutWindow();
    g_AttributeSelectWindow = new AttributeSelectWindow();
    g_AttributeGridWindow   = new AttributeSelectWindow();
    g_ProgressBarWindow     = new ProgressBarWindow();
    g_LayerEditorWindow     = new LayerEditorWindow();
    g_LayerBrowserWindow    = new LayerBrowserWindow();
    g_CropConfigureWindow   = new CropConfigureWindow();

    g_ImageCache.SetPath(".");

    g_MainWindow->ShowAll();
    return Fl::run();
}
Пример #6
0
void Splash::run(void) {
	E_ASSERT(slist != NULL);

	if(!show_splash) {
		while(next_client_nosplash()) 
			;
		return;
	}

	fl_register_images();

	String path, splash_theme_path;

#ifdef USE_LOCAL_CONFIG
	splash_theme_path = "splash-themes/";
#else
	splash_theme_path = Resource::find_data("themes/splash-themes", RES_SYS_ONLY);
	if(splash_theme_path.empty()) {
		E_WARNING(E_STRLOC ": Unable to locate splash themes in $XDG_DATA_DIRS directories\n");
		return;
	}
#endif
	splash_theme_path += E_DIR_SEPARATOR;
	splash_theme_path += *splash_theme;

	if(!file_test(splash_theme_path.c_str(), FILE_TEST_IS_DIR)) {
		E_WARNING(E_STRLOC ": Unable to locate '%s' in '%s' theme directory\n", 
				splash_theme->c_str(), splash_theme_path.c_str());
		return;
	}

	/* setup widgets */
	begin();
		Fl_Box* bimg = new Fl_Box(0, 0, w(), h());
		Fl_Image* splash_img = 0;

		path = build_filename(splash_theme_path.c_str(), "background.png");
		splash_img = Fl_Shared_Image::get(path.c_str());

		if(splash_img) {
			int W = splash_img->w();
			int H = splash_img->h();
			/* update window and Box sizes */
			size(W, H);
			bimg->size(W, H);

			bimg->image(splash_img);
		}

		/*
		 * place message box at the bottom with
		 * nice offset (10 px) from window borders
		 */
		msgbox = new Fl_Box(10, h() - 25 - 10, w() - 20, 25);

		/*
		 * Setup icons positions, based on position of msgbox assuming someone 
		 * will not abuse splash to start hundrets of programs, since icons will 
		 * be placed only in horizontal order, one line, so in case their large
		 * number, some of them will go out of window borders.
		 *
		 * Icon box will be 64x64 so larger icons can fit too.
		 *
		 * This code will use Fl_Group (moving group, later, will move all icons
		 * saving me from code mess), but will not update it's w() for two reasons:
		 * icons does not use it, and will be drawn correctly, and second, setting
		 * width will initiate fltk layout engine which will mess everything up.
		 */
		Fl_Group* icon_group = new Fl_Group(10, msgbox->y() - 10 - 64, 0, 64);
		int X = icon_group->x();
		int Y = icon_group->y();

		/* offset between icons */
		int ioffset = 5;

		/* FIXME: use malloc/something instead this */
		icons = new Fl_Box*[slist->size()];

		icon_group->begin();
			int         i = 0;
			const char* imgpath;
			Fl_Image*   iconimg = 0;

			for(StartupItemListIter it = slist->begin(); it != slist->end(); ++it, ++i) {
				Fl_Box* bb = new Fl_Box(X, Y, 64, 64);

				path = build_filename(splash_theme_path.c_str(), (*it)->icon.c_str());
				imgpath = path.c_str();
				iconimg = Fl_Shared_Image::get(imgpath);

				if(!iconimg) {
					bb->label(_("No image"));
					bb->align(FL_ALIGN_INSIDE | FL_ALIGN_WRAP);
				} else 
					bb->image(iconimg);

				bb->hide();

				X += bb->w() + ioffset;
				icons[i] = bb;
			}
		icon_group->end();

		/* see X as width of all icons */
		int gx = w()/2 - X/2;
		/* gx can be negative */
		gx = (gx > 10) ? gx : 10;
		icon_group->position(gx, Y);
	end();

	clear_border();

	/*
	 * If set_override() is used, message boxes will be
	 * popped behind splash. Using it or not ???
	 */
	set_override();

	// make sure window is centered
	int sw = DisplayWidth(fl_display, fl_screen);
	int sh = DisplayHeight(fl_display, fl_screen);
	position(sw/2 - w()/2, sh/2 - h()/2);

	show();
	Fl::add_timeout(TIMEOUT_START, runner_cb, this);

	// to keep splash at the top
#ifndef EDEWM_HAVE_NET_SPLASH
	global_splash = this;
	XSelectInput(fl_display, RootWindow(fl_display, fl_screen), SubstructureNotifyMask);
	Fl::add_handler(splash_xmessage_handler);
#endif
	
	while(shown())
		Fl::wait();

#ifndef EDEWM_HAVE_NET_SPLASH
	Fl::remove_handler(splash_xmessage_handler);
#endif
}
Пример #7
0
int main(int argc, char **argv)
{
  bool    printUsageFlag = false;
  bool    helpFlag = false;
  try {
    Fl::lock();
    fl_register_images();
    Plus4Emu::setGUIColorScheme(3);
    Plus4FLIConv::FLIConfiguration  config;
    config.resetDefaultSettings();
    std::string infileName = "";
    std::string outfileName = "";
    {
      std::vector< std::string >    args;
      std::map< std::string, std::vector< std::string > >   optionTable;
      optionTable["-mode"].push_back("i:conversionType");
      optionTable["-ymin"].push_back("f:yMin");
      optionTable["-ymax"].push_back("f:yMax");
      optionTable["-scale"].push_back("f:scaleX");
      optionTable["-scale"].push_back("f:scaleY");
      optionTable["-offset"].push_back("f:offsetX");
      optionTable["-offset"].push_back("f:offsetY");
      optionTable["-saturation"].push_back("f:saturationMult");
      optionTable["-saturation"].push_back("f:saturationPow");
      optionTable["-gamma"].push_back("f:gammaCorrection");
      optionTable["-gamma"].push_back("f:monitorGamma");
      optionTable["-dither"].push_back("i:ditherMode");
      optionTable["-dither"].push_back("f:ditherLimit");
      optionTable["-dither"].push_back("f:ditherDiffusion");
      optionTable["-pal"].push_back("b:enablePAL");
      optionTable["-xshift"].push_back("i:xShift0");
      optionTable["-xshift"].push_back("i:xShift1");
      optionTable["-border"].push_back("i:borderColor");
      optionTable["-size"].push_back("i:verticalSize");
      optionTable["-y1bit"].push_back("b:luminance1BitMode");
      optionTable["-nointerp"].push_back("b:disableInterpolation");
      optionTable["-no_li"].push_back("b:noLuminanceInterlace");
      optionTable["-nofx"].push_back("b:disableFLIEffects");
      optionTable["-ci"].push_back("i:colorInterlaceMode");
      optionTable["-searchmode"].push_back("i:luminanceSearchMode");
      optionTable["-searchmode"].push_back("f:luminanceSearchModeParam");
      optionTable["-mcchromaerr"].push_back("f:mcColorErrorScale");
      optionTable["-mcquality"].push_back("i:multiColorQuality");
      optionTable["-c64color0"].push_back("i:c64Color0");
      optionTable["-c64color1"].push_back("i:c64Color1");
      optionTable["-c64color2"].push_back("i:c64Color2");
      optionTable["-c64color3"].push_back("i:c64Color3");
      optionTable["-c64color4"].push_back("i:c64Color4");
      optionTable["-c64color5"].push_back("i:c64Color5");
      optionTable["-c64color6"].push_back("i:c64Color6");
      optionTable["-c64color7"].push_back("i:c64Color7");
      optionTable["-c64color8"].push_back("i:c64Color8");
      optionTable["-c64color9"].push_back("i:c64Color9");
      optionTable["-c64color10"].push_back("i:c64Color10");
      optionTable["-c64color11"].push_back("i:c64Color11");
      optionTable["-c64color12"].push_back("i:c64Color12");
      optionTable["-c64color13"].push_back("i:c64Color13");
      optionTable["-c64color14"].push_back("i:c64Color14");
      optionTable["-c64color15"].push_back("i:c64Color15");
      optionTable["-outfmt"].push_back("i:outputFileFormat");
      optionTable["-compress"].push_back("i:prgCompressionLevel");
      bool    endOfOptions = false;
      size_t  skipCnt = 0;
      for (int i = 1; i < argc; i++) {
        const char  *s = argv[i];
        if (s == (char *) 0 || s[0] == '\0')
          continue;
        if (skipCnt > 0) {
          args.push_back(s);
          skipCnt--;
          continue;
        }
#ifdef __APPLE__
        if (std::strncmp(s, "-psn_", 5) == 0)
          continue;
#endif
        if (s[0] != '-' || endOfOptions) {
          if (infileName == "") {
            infileName = s;
          }
          else if (outfileName == "") {
            outfileName = s;
          }
          else {
            printUsageFlag = true;
            throw Plus4Emu::Exception("too many file name arguments");
          }
          continue;
        }
        if (std::strcmp(s, "--") == 0) {
          endOfOptions = true;
          continue;
        }
        if (std::strcmp(s, "-h") == 0 ||
            std::strcmp(s, "-help") == 0 ||
            std::strcmp(s, "--help") == 0) {
          helpFlag = true;
          throw Plus4Emu::Exception("");
        }
        if (optionTable.find(s) == optionTable.end()) {
          printUsageFlag = true;
          throw Plus4Emu::Exception("invalid command line option");
        }
        args.push_back(s);
        skipCnt = optionTable[s].size();
      }
      if (skipCnt > 0) {
        printUsageFlag = true;
        throw Plus4Emu::Exception("missing argument(s) "
                                  "for command line option");
      }
      if (infileName != "" && outfileName == "") {
        printUsageFlag = true;
        throw Plus4Emu::Exception("missing file name");
      }
      // if there are no file name arguments, run in GUI mode,
      // but still use any command line options specified
      if (infileName == "") {
        try {
          // load configuration
          Plus4Emu::File  f("p4flicfg.dat", true);
          config.registerChunkType(f);
          f.processAllChunks();
        }
        catch (...) {
        }
      }
      for (size_t i = 0; i < args.size(); i++) {
        std::vector< std::string >&   v = optionTable[args[i]];
        for (size_t j = 0; j < v.size(); j++) {
          char        optionType = v[j][0];
          const char  *optionName = v[j].c_str() + 2;
          i++;
          if (optionType == 'b')
            config[optionName] = bool(std::atoi(args[i].c_str()));
          else if (optionType == 'i')
            config[optionName] = int(std::atoi(args[i].c_str()));
          else if (optionType == 'f')
            config[optionName] = double(std::atof(args[i].c_str()));
        }
      }
    }
    if (infileName != "") {
      // run in command line mode
      Plus4FLIConv::FLIConverter  *fliConv = (Plus4FLIConv::FLIConverter *) 0;
      Plus4FLIConv::PRGData       prgData;
      unsigned int  prgEndAddr = 0x1003U;
      int     convType = config["conversionType"];
      try {
        if (convType == 0)
          fliConv = new Plus4FLIConv::P4FLI_Interlace7();
        else if (convType == 1)
          fliConv = new Plus4FLIConv::P4FLI_MultiColor();
        else if (convType == 2)
          fliConv = new Plus4FLIConv::P4FLI_HiResBitmapInterlace();
        else if (convType == 3)
          fliConv = new Plus4FLIConv::P4FLI_MultiColorBitmapInterlace();
        else if (convType == 4)
          fliConv = new Plus4FLIConv::P4FLI_HiResNoInterlace();
        else if (convType == 5)
          fliConv = new Plus4FLIConv::P4FLI_MultiColorNoInterlace();
        else if (convType == 6)
          fliConv = new Plus4FLIConv::P4FLI_HiResNoFLI();
        else if (convType == 7)
          fliConv = new Plus4FLIConv::P4FLI_MultiColorNoFLI();
        else if (convType == 8)
          fliConv = new Plus4FLIConv::P4FLI_MultiColorChar();
        else
          throw Plus4Emu::Exception("invalid conversion type");
        Plus4FLIConv::YUVImageConverter imgConv;
        imgConv.setXYScaleAndOffset(float(double(config["scaleX"])),
                                    float(double(config["scaleY"])),
                                    float(double(config["offsetX"])),
                                    float(double(config["offsetY"])));
        imgConv.setEnableInterpolation(!(bool(config["disableInterpolation"])));
        imgConv.setGammaCorrection(
            float(double(config["gammaCorrection"])),
            float(double(config["monitorGamma"]) * 0.625));
        imgConv.setLuminanceRange(float(double(config["yMin"])),
                                  float(double(config["yMax"])));
        imgConv.setColorSaturation(float(double(config["saturationMult"])),
                                   float(double(config["saturationPow"])));
        float   borderY = 0.0f;
        float   borderU = 0.0f;
        float   borderV = 0.0f;
        Plus4FLIConv::FLIConverter::convertPlus4Color(
            int(config["borderColor"]), borderY, borderU, borderV, 1.0);
        imgConv.setBorderColor(borderY, borderU, borderV);
        imgConv.setC64Color(0, int(config["c64Color0"]));
        imgConv.setC64Color(1, int(config["c64Color1"]));
        imgConv.setC64Color(2, int(config["c64Color2"]));
        imgConv.setC64Color(3, int(config["c64Color3"]));
        imgConv.setC64Color(4, int(config["c64Color4"]));
        imgConv.setC64Color(5, int(config["c64Color5"]));
        imgConv.setC64Color(6, int(config["c64Color6"]));
        imgConv.setC64Color(7, int(config["c64Color7"]));
        imgConv.setC64Color(8, int(config["c64Color8"]));
        imgConv.setC64Color(9, int(config["c64Color9"]));
        imgConv.setC64Color(10, int(config["c64Color10"]));
        imgConv.setC64Color(11, int(config["c64Color11"]));
        imgConv.setC64Color(12, int(config["c64Color12"]));
        imgConv.setC64Color(13, int(config["c64Color13"]));
        imgConv.setC64Color(14, int(config["c64Color14"]));
        imgConv.setC64Color(15, int(config["c64Color15"]));
        prgData.clear();
        prgData.borderColor() =
            (unsigned char) ((int(config["borderColor"]) & 0x7F) | 0x80);
        prgData.lineBlankFXEnabled() =
            (unsigned char) (bool(config["disableFLIEffects"]) ? 0 : 1);
        fliConv->processImage(prgData, prgEndAddr,
                              infileName.c_str(), imgConv, config);
        delete fliConv;
        fliConv = (Plus4FLIConv::FLIConverter *) 0;
      }
      catch (...) {
        if (fliConv)
          delete fliConv;
        throw;
      }
      config.clearConfigurationChangeFlag();
      Plus4FLIConv::writeConvertedImageFile(outfileName.c_str(), prgData,
                                            prgEndAddr, convType,
                                            int(config["outputFileFormat"]),
                                            int(config["prgCompressionLevel"]));
      return 0;
    }
    config.clearConfigurationChangeFlag();
    Plus4FLIConvGUI *gui = new Plus4FLIConvGUI(config);
    gui->run();
    delete gui;
    try {
      // save configuration
      Plus4Emu::File  f;
      config.saveState(f);
      f.writeFile("p4flicfg.dat", true);
    }
    catch (...) {
    }
  }
  catch (std::exception& e) {
    if (printUsageFlag || helpFlag) {
      std::fprintf(stderr, "Usage: %s [OPTIONS...] infile.jpg outfile.prg\n",
                           argv[0]);
      std::fprintf(stderr, "Options:\n");
      std::fprintf(stderr, "    -mode <N>           (0 to 8, default: 0)\n");
      std::fprintf(stderr, "        select video mode (0: interlaced hires "
                           "FLI, 1: interlaced\n        multicolor FLI, 2: "
                           "hires FLI, bitmap interlace only,\n        3: "
                           "multicolor FLI, bitmap interlace only, 4: hires "
                           "FLI,\n        5: multicolor FLI, 6: hires 320x200 "
                           "(no FLI), 7: multicolor\n        160x200 (no "
                           "FLI), 8: Logo Editor 2.0 multicolor (128x64))\n");
      std::fprintf(stderr, "    -ymin <MIN>         (default: -0.02)\n");
      std::fprintf(stderr, "    -ymax <MAX>         (default: 1.03)\n");
      std::fprintf(stderr, "        scale RGB input range from 0..1 to "
                           "MIN..MAX\n");
      std::fprintf(stderr, "    -scale <X> <Y>      (defaults: 1.0, 1.0)\n");
      std::fprintf(stderr, "        scale image size\n");
      std::fprintf(stderr, "    -offset <X> <Y>     (defaults: 0.0, 0.0)\n");
      std::fprintf(stderr, "        set image position offset\n");
      std::fprintf(stderr, "    -nointerp <N>       (0 or 1, default: 0)\n");
      std::fprintf(stderr, "        resize input image without interpolation "
                           "and anti-aliasing\n");
      std::fprintf(stderr, "    -saturation <M> <P> (defaults: 1.0, 0.9)\n");
      std::fprintf(stderr, "        color saturation scale and power\n");
      std::fprintf(stderr, "    -gamma <G> <M>      (defaults: 1.0, 2.2)\n");
      std::fprintf(stderr, "        set gamma correction (G) and assumed "
                           "monitor gamma (M)\n");
      std::fprintf(stderr, "    -dither <M> <L> <S> (defaults: 1, 0.25, "
                           "0.95)\n");
      std::fprintf(stderr, "        dither mode (-1: none, 0: ordered "
                           "(Bayer), 1: ordered\n        (randomized), 2: "
                           "Floyd-Steinberg, 3: Jarvis, 4: Stucki,\n"
                           "        5: Sierra2), limit, and error diffusion "
                           "factor\n");
      std::fprintf(stderr, "    -pal <N>            (0 or 1, default: 1)\n");
      std::fprintf(stderr, "        assume PAL chrominance filtering "
                           "if set to 1\n");
      std::fprintf(stderr, "    -xshift <S0> <S1>   "
                           "(-2 to 7, defaults: -1, -1)\n");
      std::fprintf(stderr, "        set horizontal shift for each field (-2 is "
                           "random, -1 finds\n        optimal values)\n");
      std::fprintf(stderr, "    -border <N>         (0 to 255, default: 0)\n");
      std::fprintf(stderr, "        set border color\n");
      std::fprintf(stderr, "    -nofx <N>           (0 or 1, default: 0)\n");
      std::fprintf(stderr, "        disable FLI image opening/closing "
                           "effects\n");
      std::fprintf(stderr, "    -size <N>           "
                           "(128 to 496, default: 464)\n");
      std::fprintf(stderr, "        set vertical resolution (< 256 implies "
                           "no interlace)\n");
      std::fprintf(stderr, "    -y1bit <N>          (0 or 1, default: 0)\n");
      std::fprintf(stderr, "        use 1 bit (black and white) luminance\n");
      std::fprintf(stderr, "    -no_li <N>          (0 or 1, default: 0)\n");
      std::fprintf(stderr, "        do not interlace luminance attributes\n");
      std::fprintf(stderr, "    -ci <N>             (0 to 2, default: 1)\n");
      std::fprintf(stderr, "        color interlace mode (0: none, 1: hue "
                           "only, 2: hue and\n        saturation)\n");
      std::fprintf(stderr, "    -searchmode <M> <P> (defaults: 2, 4.0)\n");
      std::fprintf(stderr, "        select luminance search algorithm (0 to 6),"
                           " and parameter for\n"
                           "        modes 2, 4, 5, and 6\n");
      std::fprintf(stderr, "    -mcchromaerr <N>    "
                           "(0.05 to 1.0, default: 0.5)\n");
      std::fprintf(stderr, "        scale factor applied to squared "
                           "chrominance error in multicolor\n        modes\n");
      std::fprintf(stderr, "    -mcquality <N>      (1 to 30, default: 6)\n");
      std::fprintf(stderr, "        multicolor conversion quality\n");
      std::fprintf(stderr, "    -c64color<N> <C>    "
                           "(N: 0 to 15, C: 0 to 255)\n");
      std::fprintf(stderr, "        map C64 color N to Plus/4 color C when "
                           "reading C64 image files\n");
      std::fprintf(stderr, "    -outfmt <N>         (0 to 5, default: 0)\n");
      std::fprintf(stderr, "        output file format, 0: PRG with viewer, "
                           "1: raw PRG (compression\n        type 0), 2: "
                           "PixelShop P4S, 3: FED 160x200 multicolor FLI,\n"
                           "        4: raw PRG (compression type 1), 5: raw "
                           "PRG (compression type 2)\n");
      std::fprintf(stderr, "    -compress <N>       (0 to 9, default: 0)\n");
      std::fprintf(stderr, "        compress output file if N is not zero\n");
    }
    if (!helpFlag) {
      const char  *errMsg = e.what();
      if (!errMsg)
        errMsg = "";
      std::fprintf(stderr, " *** p4fliconv error: %s\n", errMsg);
      return -1;
    }
    return 0;
  }
  return 0;
}
Пример #8
0
int
main ( int argc, char **argv )
{
    bool no_ui = false;

    fl_display = 0;

    printf( "%s %s %s -- %s\n", APP_TITLE, VERSION, "", COPYRIGHT );

    Thread::init();

    Thread thread( "UI" );
    thread.set();

    ensure_dirs();

    signal( SIGTERM, sigterm_handler );
    signal( SIGHUP, sigterm_handler );
    signal( SIGINT, sigterm_handler );

    Fl_Tooltip::color( FL_BLACK );
    Fl_Tooltip::textcolor( FL_YELLOW );
    Fl_Tooltip::size( 14 );
    Fl_Tooltip::hoverdelay( 0.1f );


    LOG_REGISTER_CREATE( Mixer_Strip );
    LOG_REGISTER_CREATE( Chain );
    LOG_REGISTER_CREATE( Plugin_Module );
    LOG_REGISTER_CREATE( Gain_Module );
    LOG_REGISTER_CREATE( Spatializer_Module );
    LOG_REGISTER_CREATE( Meter_Module );
    LOG_REGISTER_CREATE( JACK_Module );
    LOG_REGISTER_CREATE( Mono_Pan_Module );
    LOG_REGISTER_CREATE( Meter_Indicator_Module );
    LOG_REGISTER_CREATE( Controller_Module );
    LOG_REGISTER_CREATE( AUX_Module );
    LOG_REGISTER_CREATE( Spatialization_Console );
    LOG_REGISTER_CREATE( Group );

    signal( SIGPIPE, SIG_IGN );


    const char *osc_port = NULL;

    nsm = new NSM_Client;

    instance_name = strdup( APP_NAME );
    bool instance_override = false;

    static struct option long_options[] = 
        {
            { "help", no_argument, 0, '?' },
            { "instance", required_argument, 0, 'i' },
            { "osc-port", required_argument, 0, 'p' },
            { "no-ui", no_argument, 0, 'u' },
            { 0, 0, 0, 0 }
        };

    int option_index = 0;
    int c = 0;
    

    while ( ( c = getopt_long_only( argc, argv, "", long_options, &option_index  ) ) != -1 )
    {
        switch ( c )
        {
            case 'p':
                DMESSAGE( "Using OSC port %s", optarg );
                osc_port = optarg;
                break;
            case 'i':
                DMESSAGE( "Using OSC port %s", optarg );
                free( instance_name );
                instance_name = strdup( optarg );
                instance_override = true;
                break;
            case 'u':
                DMESSAGE( "Disabling user interface" );
                no_ui = true;
                break;
            case '?':
                printf( "\nUsage: %s [--instance instance_name] [--osc-port portnum] [path_to_project]\n\n", argv[0] );
                exit(0);
                break;
        }
    }

    {
        char *name = strdup( argv[0] );
        char *n = basename( name );

        if ( ! strcmp( n, "non-mixer-noui" ) )
            no_ui = true;
        
        free( name );
    }

    if ( ! no_ui )
    {
        Fl::visual( FL_DOUBLE | FL_RGB );
        
        Fl::visible_focus( 0 );

        fl_register_images();
    }

    Fl::lock();

    Fl_Double_Window *main_window;

    
    {
        Fl_Double_Window *o = main_window = new Fl_Double_Window( 800, 600, "Non Mixer" );
        {
            main_window->xclass( APP_NAME );

            { 
                Fl_Widget *o = mixer = new Mixer( 0, 0, main_window->w(), main_window->h(), NULL );
                Fl_Group::current()->resizable(o);
            }
        }
        o->end();

        o->size_range( main_window->w(), mixer->min_h(), 0, 0 );

        o->callback( (Fl_Callback*)cb_main, main_window );

        if ( ! no_ui )
        {
            o->show( 0,0 );
        }
                      
    }

    Plugin_Module::spawn_discover_thread();

    mixer->init_osc( osc_port );

    char *nsm_url = getenv( "NSM_URL" );
        
    if ( nsm_url )
    {
        if ( ! nsm->init( nsm_url ) )
        {
            if ( instance_override )
                WARNING( "--instance option is not available when running under session management, ignoring." );
                
            if ( optind < argc )
                WARNING( "Loading files from the command-line is incompatible with session management, ignoring." );

            nsm->announce( APP_NAME, ":switch:dirty:", argv[0] );

            /* if ( ! no_ui ) */
            /* { */
                // poll so we can keep OSC handlers running in the GUI thread and avoid extra sync
                Fl::add_timeout( NSM_CHECK_INTERVAL, check_nsm, NULL );
            /* } */
        }
    }
    else
    {
        if ( optind < argc )
        {
            MESSAGE( "Waiting for plugins..." );
            Plugin_Module::join_discover_thread();

            MESSAGE( "Loading \"%s\"", argv[optind] );
                
            if ( ! mixer->command_load( argv[optind] ) )
            {
                fl_alert( "Error opening project specified on commandline" );
            }
        }
    }

    Fl::add_timeout( 0.1f, check_sigterm );
    Fl::dnd_text_ops( 0 );

    if ( ! no_ui )
    {
        DMESSAGE( "Running UI..." );

        Fl::run();
    }
    else
    {
        DMESSAGE( "Not Running UI..." );
        while ( ! got_sigterm )
        {
            Fl::check();
            usleep( 200 * 1000 );
        }
    }

    delete main_window;
    main_window = NULL;

    MESSAGE( "Your fun is over" );
}