bool Core::ncurses_wgetch(int in, int & out) { if(!started) { out = in; return true; } if(in >= KEY_F(1) && in <= KEY_F(8)) { int idx = in - KEY_F(1); // FIXME: copypasta, push into a method! Gui * g = getGui(); if(g->hotkeys && g->df_interface && g->df_menu_state) { t_viewscreen * ws = g->GetCurrentScreen(); // FIXME: put hardcoded values into memory.xml if(ws->getClassName() == "viewscreen_dwarfmodest" && *g->df_menu_state == 0x23) { out = in; return true; } else { t_hotkey & hotkey = (*g->hotkeys)[idx]; setHotkeyCmd(hotkey.name); return false; } } } out = in; return true; }
int main(int argc, char **argv) { Main *main = new Main(); Config config; ImAcq *imAcq = imAcqAlloc(); Gui *gui = new Gui(); main->gui = gui; main->imAcq = imAcq; if(config.init(argc, argv) == PROGRAM_EXIT) { return EXIT_FAILURE; } config.configure(main); srand(main->seed); imAcqInit(imAcq); if(main->showOutput) { gui->init(); } main->doWork(); delete main; return EXIT_SUCCESS; }
void ViewerTab::setInfoBarAndViewerResolution(const RectI& rect, const RectD& canonicalRect, double par, int texIndex) { std::string formatName, infoBarName; Gui* gui = getGui(); if (!gui) { return; } GuiAppInstancePtr app = gui->getApp(); if (!app) { return; } if (!app->getProject()->getFormatNameFromRect(rect, par, &formatName)) { formatName = makeUpFormatName(rect, par); infoBarName = formatName; } else { // If the format has a name, for the info bar also add the resolution std::stringstream ss; ss << formatName; ss << ' '; ss << rect.width(); ss << 'x'; ss << rect.height(); infoBarName = ss.str(); } _imp->infoWidget[texIndex]->setResolution(QString::fromUtf8(infoBarName.c_str())); _imp->viewer->setFormat(formatName, canonicalRect, par, texIndex); }
void updateEditorFrameRanges() { double zoomRight = parent->toTimeLine(parent->width() - 1); gui->getCurveEditor()->getCurveWidget()->centerOn(tlZoomCtx.left - 5, zoomRight - 5); gui->getDopeSheetEditor()->centerOn(tlZoomCtx.left - 5, zoomRight - 5); }
// Called before the first frame bool j1Scene::Start(j1IniReader* conf) { if(App->map->Load(conf->GetString("map")) == true) { int w, h; uchar* data = NULL; if(App->map->CreateWalkabilityMap(w, h, &data)) App->pathfinding->SetMap(w, h, data); RELEASE_ARRAY(data); } debug_tex = App->tex->Load("maps/path.png"); // gui test g = App->gui->CreateImage({408, 166, 231, 70}); g->SetPos(500, 500); gtext = App->gui->CreateText("this is a test"); gtext->SetPos(60, 18); gtext->SetParent(g); Gui* b = App->gui->CreateButton(205, 45, this); b->SetPos(15,10); b->SetParent(g); ginput = App->gui->CreateInput("write something here ...", 200, this); ginput->SetPos(100, 100); return true; }
int main(int argc, char *argv[]) { QApplication a(argc, argv); Gui w; w.show(); return a.exec(); }
void KnobGuiFile::createWidget(QHBoxLayout* layout) { KnobGuiPtr knobUI = getKnobGui(); if (!knobUI) { return; } Gui* gui = knobUI->getGui(); if (!gui) { return; } GuiAppInstancePtr app = gui->getApp(); if (!app) { return; } KnobFilePtr knob = _knob.lock(); if (!knob) { return; } EffectInstancePtr holderIsEffect = toEffectInstance( knob->getHolder() ); if ( holderIsEffect && holderIsEffect->isReader() && (knob->getName() == kOfxImageEffectFileParamName) ) { TimeLinePtr timeline = app->getTimeLine(); QObject::connect( timeline.get(), SIGNAL(frameChanged(SequenceTime,int)), this, SLOT(onTimelineFrameChanged(SequenceTime,int)) ); }
void *runGui(void* v) { struct timeval a, b; long totalb, totala; long diff; Gui* gui; SharedMemory* interfacesDataGui = (SharedMemory*) v; gui = new Gui(interfacesDataGui); while (true) { gettimeofday(&a, NULL); totala = a.tv_sec * 1000000 + a.tv_usec; gui->display(); //Show GUI gettimeofday(&b, NULL); totalb = b.tv_sec * 1000000 + b.tv_usec; diff = (totalb - totala) / 1000; if (diff < 0 || diff > cycle_gui) diff = cycle_gui; else diff = cycle_gui - diff; /*Sleep Algorithm*/ usleep(diff * 1000); if (diff < 33) usleep(33 * 1000); } }
/* The only way to expose classes to JavaScript natively is to wrap the existing object. To properly due this, we have to ensure that the object remains in memory during the execution of script. This responsibility is dictated by the container, which in this case is the active Gui. */ v8::Handle<v8::Object> Element::wrap_tmpl( v8::Handle<v8::FunctionTemplate>* tmpl, Element* e, const Extension_list& extension_list) { v8::HandleScope handle_scope; if (tmpl->IsEmpty()) { (*tmpl) = v8::FunctionTemplate::New(); } (*tmpl)->SetClassName(v8::String::New(e->name)); // We only need to create the template once. generate_fun_tmpl(tmpl, accessors, funs, &extension_list); // The active Gui is all we care about v8::Handle<v8::Function> gui_ctor = (*tmpl)->GetFunction(); v8::Local<v8::Object> obj = gui_ctor->NewInstance(); obj->SetInternalField(0, v8::External::New(e)); e->self = v8::Persistent<v8::Object>::New(handle_scope.Close(obj)); Gui* gui = unwrap_global_pointer<Gui>(0); gui->add_element(e); return e->self; }
ViewerTab::~ViewerTab() { Gui* gui = getGui(); if (gui) { NodeGraph* graph = 0; ViewerNodePtr internalNode = getInternalNode(); ViewerInstancePtr viewerNode = internalNode ? internalNode->getInternalViewerNode() : ViewerInstancePtr(); if (viewerNode) { NodeCollectionPtr collection = viewerNode->getNode()->getGroup(); if (collection) { NodeGroupPtr isGrp = toNodeGroup(collection); if (isGrp) { NodeGraphI* graph_i = isGrp->getNodeGraph(); if (graph_i) { graph = dynamic_cast<NodeGraph*>(graph_i); assert(graph); } } else { graph = gui->getNodeGraph(); } } internalNode->invalidateUiContext(); } else { graph = gui->getNodeGraph(); } assert(graph); GuiAppInstancePtr app = gui->getApp(); if ( app && !app->isClosing() && graph && (graph->getLastSelectedViewer() == this) ) { graph->setLastSelectedViewer(0); } } _imp->nodesContext.clear(); }
void debug_frame(std::vector<SDL_Event>& events) { int mouse_x = gui.mouse_x; int mouse_y = gui.mouse_y; int mouse_buttons = gui.mouse_buttons; for (const auto& ev : events) { switch (ev.type) { case SDL_MOUSEMOTION: mouse_x = ev.motion.x; mouse_y = ev.motion.y; break; case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN: int button_bit = BIT(ev.button.button); mouse_buttons = (mouse_buttons & (~button_bit)) | (ev.button.state == SDL_MOUSEBUTTONDOWN ? button_bit : 0); break; } } events.clear(); gui.update_input(mouse_x, mouse_y, mouse_buttons); fillSurface(3, debug_win.getSurface()); gui.label("HELLO WORLD!", 8, 8); gui.label("HELLO WORLD!", gui.mouse_x, gui.mouse_y, 8); debug_win.present(); }
int main(int argc, char *argv[]){ char key = 'a'; // clef de contrôle du programme Flux_cam flux(-1, 40, 1, 3, 0); // initialisation du flux webcam (/dev/video0) Gui gui; // IHM Transfo transfo; Reco reco; IO_file io; Tracking tracking(40); int compteur = 0; int force_blur = atoi(argv[1]); cv::Size kernel_blur(force_blur, force_blur); // boucle d'exécution : appuyer sur 'q' pour quitter while(key != 'q'){ key = flux.Get_key(); // mettre à jour les images du flux flux.Update(); cv::Mat flou; if(force_blur > 0){cv::blur(flux.Get_cam(), flou, kernel_blur);} else{flux.Get_cam().copyTo(flou);} // détecter le quadrillage reco.Set_img(flou); reco.Detecter_quadrillage(); if(key == 's'){ mkdir(("./output/" + to_string(compteur)).c_str(), S_IRWXU | S_IRWXG | S_IRWXO); vector <cv::Mat> liste_vignettes; vector < vector <cv::Point2i> > liste_quadrillage = reco.Get_quadrillage(); for(int i = 0; i < liste_quadrillage.size(); i++){ // transformation transfo.Set_img(flux.Get_cam()); transfo.Set_pts_redressement(liste_quadrillage[i]); transfo.Appliquer_wrap_from_pts_input(4, cv::Size(200, 200), cv::Size(10, 10)); cv::Mat img_redressee; transfo.Get_img_wrap().copyTo(img_redressee); liste_vignettes.push_back(img_redressee); imwrite("./output/" + to_string(compteur) + "/img_" + to_string(i) + ".png", liste_vignettes[i]); } for(int k = 0; k < compteur; k++){ vector <STRUCT_NOM> liste = io.Lister_fichiers("./output/" + to_string(k), "png"); for(size_t j = 0; j < liste.size(); j++){ cout << liste[j].nom_complet << endl; cv::Mat old_img = cv::imread(liste[j].nom_complet); for(size_t i = 0; i < liste_vignettes.size() ; i++){ tracking.Set_img_prev(old_img); tracking.Set_img_next(liste_vignettes[i]); if(tracking.Try_match(10, 5)){cout << "\tok avec " << k+1 << "-" << i << " avec orientation " << 90*tracking.Get_orientation() << "°" << endl;} } } } key = 'a'; compteur++; } // afficher le résultat gui.Afficher_image("Video quadrillage", reco.Get_img_quadrillage()); } return 0; }
void Gui::dialog(void* object, StrVec args) { //Explicitly cast to a pointer to Gui Gui* self = (Gui*) object; //Call member self->showDialog(args); }
GuiCheckbox::GuiCheckbox(Gui& gui, GuiObject *parent, int x, int y, const std::string& caption, bool state, OnClick on_click, void *on_click_data) : GuiObject(gui, parent, x, y, gui.get_font()->get_text_width(caption) + 9 + 5, gui.get_font()->get_font_height()), caption(caption), state(state), mouse_is_down(false), mouse_is_in_button(false), on_click(on_click), on_click_data(on_click_data), style(CheckBoxStyleQuad) { load_icons(); }
/** * Called when the stage size has changed. * * Calls Gui::resize_actors */ void on_stage_allocation_changed(ClutterActor * /*stage*/, ClutterActorBox * /*box*/, ClutterAllocationFlags * /*flags*/, gpointer user_data) { //g_print("on_stage_allocation_changed\n"); Gui *gui = static_cast<Gui*>(user_data); gui->resize_actors(); }
int main( int argc, char* argv[] ){ QApplication app(argc, argv); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8")); Gui interface; interface.show(); return app.exec(); }
/** * @brief * Main function */ void GuiApplication::Main() { // Run main loop Gui *pGui = Gui::GetSystemGui(); while (pGui->IsActive() && m_bRunning) { // Get GUI messages pGui->ProcessMessages(); } }
int main(int argc, char *argv[]) { QApplication::setOrganizationName("GVSU_CIS467"); QApplication::setOrganizationDomain("maze-solver.cis.gvsu.edu"); QApplication::setApplicationName("Maze Solver"); QApplication a(argc, argv); Gui gui; gui.showMaximized(); return a.exec(); }
void ApplicationWindowSerialization::initialize(bool mainWindow, SerializableWindow* widget) { isMainWindow = mainWindow; widget->getMtSafePosition(x, y); widget->getMtSafeWindowSize(w, h); if (mainWindow) { Gui* gui = dynamic_cast<Gui*>(widget); assert(gui); if (gui) { QWidget* centralWidget = gui->getCentralWidget(); Splitter* isSplitter = dynamic_cast<Splitter*>(centralWidget); TabWidget* isTabWidget = dynamic_cast<TabWidget*>(centralWidget); assert(isSplitter || isTabWidget); if (isSplitter) { child_asSplitter = new SplitterSerialization; child_asSplitter->initialize(isSplitter); } else if (isTabWidget) { child_asPane = new PaneLayout; child_asPane->initialize(isTabWidget); } } } else { FloatingWidget* isFloating = dynamic_cast<FloatingWidget*>(widget); assert(isFloating); if (isFloating) { QWidget* embedded = isFloating->getEmbeddedWidget(); Splitter* isSplitter = dynamic_cast<Splitter*>(embedded); TabWidget* isTabWidget = dynamic_cast<TabWidget*>(embedded); DockablePanel* isPanel = dynamic_cast<DockablePanel*>(embedded); assert(isSplitter || isTabWidget || isPanel); if (isSplitter) { child_asSplitter = new SplitterSerialization; child_asSplitter->initialize(isSplitter); } else if (isTabWidget) { child_asPane = new PaneLayout; child_asPane->initialize(isTabWidget); } else if (isPanel) { ///A named knob holder is a knob holder which has a unique name. NamedKnobHolder* isNamedHolder = dynamic_cast<NamedKnobHolder*>( isPanel->getHolder() ); if (isNamedHolder) { child_asDockablePanel = isNamedHolder->getScriptName_mt_safe(); } else { ///This must be the project settings panel child_asDockablePanel = kNatronProjectSettingsPanelSerializationName; } } } } } // initialize
command_result creat_job (Core * c, vector< string >& parameters) { c->Suspend(); Creatures * cr = c->getCreatures(); Gui * g = c-> getGui(); uint32_t num_cr = 0; int32_t cx,cy,cz; g->getCursorCoords(cx,cy,cz); if(cx == -30000) { c->con.printerr("No cursor.\n"); c->Resume(); return CR_FAILURE; } if(!cr->Start(num_cr) || num_cr == 0) { c->con.printerr("No creatures.\n"); c->Resume(); return CR_FAILURE; } auto iter = cr->creatures->begin(); while (iter != cr->creatures->end()) { df_creature * unit = *iter; if(cx == unit->x && cy == unit->y && cz == unit->z) { c->con.print("%d:%s - address 0x%x - job 0x%x\n" "Soul: 0x%x, likes: 0x%x\n", unit->id, unit->name.first_name.c_str(), unit, uint32_t(unit) + offsetof(df_creature,current_job), uint32_t(unit) + offsetof(df_creature,current_soul), uint32_t(unit->current_soul) + offsetof(df_soul,likes) ); df_soul * s = unit->current_soul; if(s) { c->con.print("LIKES:\n"); int idx = 1; auto iter = s->likes.begin(); while(iter != s->likes.end()) { df_like * l = *iter; c->con.print("%3d: %f\n", idx, float(l->mystery)); iter++; idx++; } } } iter++; } c->Resume(); return CR_OK; };
//----------------------------------------------------------------------------- static int world_destroy_gui(lua_State* L) { LuaStack stack(L); World* world = stack.get_world(1); Gui* gui = stack.get_gui(2); world->destroy_gui(gui->id()); return 0; }
/** * Called when the size of the image to play back has changed. * * Useful to update the layout. Calls Gui::resize_actors. */ void on_playback_texture_size_changed(ClutterTexture *texture, gint /*width*/, gint /*height*/, gpointer user_data) { //g_print("on_playback_texture_size_changed\n"); // TODO:2010-08-06:aalex:Take into account size and ratio of the playback texture Gui *gui = static_cast<Gui*>(user_data); ClutterActor *stage; stage = clutter_actor_get_stage(CLUTTER_ACTOR(texture)); if (stage == NULL) return; gui->resize_actors(); }
void scene_initialization_function() { Gui* pGui = new Gui(); pGui->createScreen(pViewport, "world", "WorldState"); m_pItemBar = new ItemBar(pGui); m_pItemBar->addItem(new ItemBox(pGui, BALL, 25, "item_ball", "item_ball_hover")); m_pItemBar->addItem(new ItemBox(pGui, SMALLBALL, 25, "item_smallball", "item_smallball_hover")); m_pItemBar->addItem(new ItemBox(pGui, UNKNOWN, -1, "item_unknown", "item_unknown_hover")); m_pQuickMenu = new QuickMenu(pGui); m_pPopup = new PopUpBox(pGui); }
void Book::Reader(Gui& gui) { int ypos = 20; // 57 character limit using fixed width font, start at y = 20, 12 pixels spacing per line..., 18 lines per page top screen, max looping is 236 // bottom screen is same, except only 46 characters per line. for (int i = (gui.getBookPage() * 18); i < ((gui.getBookPage() * 18) + 18); i++) { sftd_draw_text(gui.getTextFont(), 0, ypos, RGBA8(0, 0, 0, 255), 12, alltext[i].c_str()); ypos += 12; } }
DFhackCExport command_result bflags (Core * c, vector <string> & parameters) { c->Suspend(); Gui * g = c-> getGui(); Maps* m = c->getMaps(); if(!m->Start()) { c->con.printerr("No map to probe\n"); return CR_FAILURE; } int32_t cx,cy,cz; g->getCursorCoords(cx,cy,cz); if(cx == -30000) { // get map size in blocks uint32_t sx,sy,sz; m->getSize(sx,sy,sz); std::map <uint8_t, df_block *> counts; // for each block for(size_t x = 0; x < sx; x++) for(size_t y = 0; y < sx; y++) for(size_t z = 0; z < sx; z++) { df_block * b = m->getBlock(x,y,z); if(!b) continue; auto iter = counts.find(b->flags.size); if(iter == counts.end()) { counts[b->flags.bits[0]] = b; } } for(auto iter = counts.begin(); iter != counts.end(); iter++) { c->con.print("%2x : 0x%x\n",iter->first, iter->second); } } else { df_block * b = m->getBlock(cx/16,cy/16,cz); if(b) { c->con << "Block flags:" << b->flags << std::endl; } else { c->con.printerr("No block here\n"); return CR_FAILURE; } } c->Resume(); return CR_OK; }
DFhackCExport command_result mapitems (Core * c, vector <string> & parameters) { c->Suspend(); vector <df_item *> vec_items; Gui * g = c-> getGui(); Maps* m = c->getMaps(); Items* it = c->getItems(); if(!m->Start()) { c->con.printerr("No map to probe\n"); return CR_FAILURE; } if(!it->Start() || !it->readItemVector(vec_items)) { c->con.printerr("Failed to get items\n"); return CR_FAILURE; } int32_t cx,cy,cz; g->getCursorCoords(cx,cy,cz); if(cx != -30000) { df_block * b = m->getBlock(cx/16,cy/16,cz); if(b) { c->con.print("Item IDs present in block:\n"); auto iter_b = b->items.begin(); while (iter_b != b->items.end()) { df_item * itmz = it->findItemByID(*iter_b); string s; itmz->getItemDescription(&s); c->con.print("%d = %s\n",*iter_b, s.c_str()); iter_b++; } c->con.print("Items under cursor:\n"); auto iter_it = vec_items.begin(); while (iter_it != vec_items.end()) { df_item * itm = *iter_it; if(itm->x == cx && itm->y == cy && itm->z == cz) { string s; itm->getItemDescription(&s,0); c->con.print("%d = %s\n",itm->id, s.c_str()); } iter_it ++; } } } c->Resume(); return CR_OK; }
void Grid::SetDimension(uint32_t width, uint32_t height) { int cellCountDiff = width * height - dimension.x * dimension.y; // Add cells if (cellCountDiff >= 0) { for (int i = 0; i < cellCountDiff; ++i) { Gui* cell = AddGui(); cell->DisableHover(); cells.push_back(cell); } } else // Remove cells { for (int i = 0; i < -cellCountDiff; ++i) { Gui* cell = cells[cells.size() - 1 - i]; cell->RemoveFromParent(); } cells.resize(cells.size() + cellCountDiff); } Vec2i dimensionDiff = Vec2i(width - dimension.x, height - dimension.y); // Add columns if (dimensionDiff.x >= 0) { for (int i = 0; i < dimensionDiff.x; ++i) columns.push_back(GridColumn(columns.size() + i, this)); } else // Remove columns { columns.resize(columns.size() + dimensionDiff.x); } // Add rows if (dimensionDiff.y >= 0) { for (int i = 0; i < dimensionDiff.y; ++i) rows.push_back(GridRow(rows.size() + i, this)); } else // Remove rows { rows.resize(rows.size() + dimensionDiff.y); } dimension = Vec2u(width, height); }
command_result zoom (Core * c, vector <string> & parameters) { if(parameters.size() < 3) return CR_FAILURE; int x = atoi( parameters[0].c_str()); int y = atoi( parameters[1].c_str()); int z = atoi( parameters[2].c_str()); int xi, yi, zi; CoreSuspender cs (c); Gui * g = c->getGui(); if(g->getCursorCoords(xi, yi, zi)) { g->setCursorCoords(x,y,z); } g->setViewCoords(x,y,z); }
GuiVScroll::GuiVScroll(Gui& gui, GuiObject *parent, int x, int y, int height, int min_value, int max_value, int initial_value, GuiScroll::ValueChanged on_value_changed, void *on_value_changed_data) : GuiScroll(gui, parent, x, y, Size, height, min_value, max_value, initial_value, on_value_changed, on_value_changed_data) { prepare(); up_button = gui.create_button(this, 0, 0, Size, Size, "", static_down_button_clicked, this); up_button->show_bolts(false); gui.create_picture(up_button, 1, 1, up_arrow->get_tile()->get_tilegraphic()); down_button = gui.create_button(this, 0, height - Size, Size, Size, "", static_up_button_clicked, this); down_button->show_bolts(false); gui.create_picture(down_button, 1, 1, down_arrow->get_tile()->get_tilegraphic()); }
GuiHScroll::GuiHScroll(Gui& gui, GuiObject *parent, int x, int y, int width, int min_value, int max_value, int initial_value, GuiScroll::ValueChanged on_value_changed, void *on_value_changed_data) : GuiScroll(gui, parent, x, y, width, Size, min_value, max_value, initial_value, on_value_changed, on_value_changed_data) { prepare(); left_button = gui.create_button(this, 0, 0, Size, Size, "", static_down_button_clicked, this); left_button->show_bolts(false); gui.create_picture(left_button, 1, 1, left_arrow->get_tile()->get_tilegraphic()); right_button = gui.create_button(this, width - Size, 0, Size, Size, "", static_up_button_clicked, this); right_button->show_bolts(false); gui.create_picture(right_button, 1, 1, right_arrow->get_tile()->get_tilegraphic()); }