/* Personalize class */
PersonalizePageComponent::PersonalizePageComponent():
background("lab_back","Background"), icons("lab_icons","Icons management"), opt_back("opt_back",""),
opt_name("opt_name", "Name:"), opt_img("opt_img", "Icon path:"), opt_shell("opt_shell", "Command:"),
add_btn("Add"), apply("Apply"), choose_back("back_box"), edit_back("back_field"),
edit_name("name"), edit_icn("icn"), edit_shell("shell"), config(assetConfigFile("config.json")),
json(JSON::parse(config)), success("suc", "Success !")
{
  bgColor = Colour(0xffd23c6d);
  bgImage = createImageFromFile(assetFile("settingsBackground.png"));
  Font big_font(Font::getDefaultMonospacedFontName(), 25.f, 0);
  background.setFont(big_font);
  icons.setFont(big_font);
  
  Font small_font(Font::getDefaultMonospacedFontName(), 17.5f, 0);
  opt_back.setFont(small_font);
  opt_name.setFont(small_font);
  opt_img.setFont(small_font);
  opt_shell.setFont(small_font);
  success.setFont(big_font);
  
  addAndMakeVisible(background);
  addAndMakeVisible(icons);
  addAndMakeVisible(add_btn);
  addAndMakeVisible(apply);
  addAndMakeVisible(success);
  apply.addListener(this);
  add_btn.addListener(this);
  /* ComboBox */
  choose_back.addItem("Default",1);
  choose_back.addItem("Color",2);
  choose_back.addItem("Image",3);
  choose_back.setSelectedId(1);
  choose_back.addListener(this);
  addAndMakeVisible(choose_back);
  //////////////
  /* + */
  edit_back.setColour(TextEditor::ColourIds::textColourId, Colour::greyLevel(0.f));
  addAndMakeVisible(edit_back);
  addAndMakeVisible(opt_back);
  addAndMakeVisible(opt_name);
  addAndMakeVisible(opt_img);
  addAndMakeVisible(opt_shell);
  addAndMakeVisible(edit_name);
  addAndMakeVisible(edit_icn);
  addAndMakeVisible(edit_shell);
  
  showAddComponents(false);
  success.setVisible(false);
  
  // create back button
  backButton = createImageButton("Back", createImageFromFile(assetFile("backIcon.png")));
  backButton->addListener(this);
  backButton->setAlwaysOnTop(true);
  addAndMakeVisible(backButton);
}
Ejemplo n.º 2
0
RDCartSlot::RDCartSlot(int slotnum,RDRipc *ripc,RDCae *cae,RDStation *station,
		       RDConfig *config,RDListSvcs *svcs_dialog,
		       RDSlotDialog *slot_dialog,RDCartDialog *cart_dialog,
		       RDCueEditDialog *cue_dialog,
		       const QString &caption,RDAirPlayConf *conf,
		       QWidget *parent)
  : QWidget(parent)
{
  slot_number=slotnum;
  slot_ripc=ripc;
  slot_cae=cae;
  slot_station=station;
  slot_config=config;
  slot_svcs_dialog=svcs_dialog;
  slot_slot_dialog=slot_dialog;
  slot_cart_dialog=cart_dialog;
  slot_cue_dialog=cue_dialog;
  slot_caption=caption;
  slot_airplay_conf=conf;

  slot_svc_names=NULL;
  slot_stop_requested=false;
  slot_logline=new RDLogLine();
  slot_pause_enabled=false;
  slot_user=NULL;
  slot_svcname="";
  slot_breakaway_cart=0;
  slot_breakaway_length=0;
  slot_timescaling_active=false;
  slot_temp_cart=false;

  //
  // Fonts
  //
  QFont big_font("helvetica",36,QFont::Bold);
  big_font.setPixelSize(36);
  QFont mid_font("helvetica",14,QFont::Bold);
  mid_font.setPixelSize(14);

  //
  // Palettes
  //
  slot_ready_color=
    QPalette(QColor(BUTTON_STOPPED_BACKGROUND_COLOR),backgroundColor());
  slot_playing_color=
    QPalette(QColor(BUTTON_PLAY_BACKGROUND_COLOR),backgroundColor());

  //
  // Slot Options
  //
  slot_options=new RDSlotOptions(station->name(),slotnum);
  slot_options->load();

  //
  // Play Deck
  //
  slot_deck=new RDPlayDeck(slot_cae,0,this);
  connect(slot_deck,SIGNAL(stateChanged(int,RDPlayDeck::State)),
	  this,SLOT(stateChangedData(int,RDPlayDeck::State)));
  connect(slot_deck,SIGNAL(position(int,int)),
	  this,SLOT(positionData(int,int)));
  connect(slot_deck,SIGNAL(hookEnd(int)),this,SLOT(hookEndData(int)));
  connect(slot_cae,SIGNAL(timescalingSupported(int,bool)),
	  this,SLOT(timescalingSupportedData(int,bool)));

  //
  // Start Button
  //
  slot_start_button=new QPushButton(QString().sprintf("%d",slotnum+1),this);
  slot_start_button->setGeometry(0,0,sizeHint().height(),sizeHint().height());
  slot_start_button->setFont(big_font);
  slot_start_button->setDisabled(true);
  connect(slot_start_button,SIGNAL(clicked()),this,SLOT(startData()));

  //
  // Slot Box
  //
  slot_box=new RDSlotBox(slot_deck,conf,this);
  slot_box->setBarMode(false);
  slot_box->setAllowDrags(station->enableDragdrop());
  slot_box->setAcceptDrops(station->enableDragdrop());
  slot_box->setGeometry(5+sizeHint().height(),0,
			slot_box->sizeHint().width(),
			slot_box->sizeHint().height());
  connect(slot_box,SIGNAL(doubleClicked()),this,SLOT(doubleClickedData()));
  connect(slot_box,SIGNAL(cartDropped(unsigned)),
	  this,SLOT(cartDroppedData(unsigned)));

  //
  // Load Button
  //
  slot_load_button=new QPushButton(tr("Load"),this);
  slot_load_button->
    setGeometry(sizeHint().height()+5+slot_box->sizeHint().width()+5,0,
		sizeHint().height(),sizeHint().height());
  slot_load_button->setFont(mid_font);
  connect(slot_load_button,SIGNAL(clicked()),this,SLOT(loadData()));

  //
  // Options Button
  //
  slot_options_button=new QPushButton(this);
  slot_options_button->
    setGeometry(2*sizeHint().height()+10+slot_box->sizeHint().width()+5,0,
		sizeHint().height(),sizeHint().height());
  slot_options_button->setFont(mid_font);
  connect(slot_options_button,SIGNAL(clicked()),this,SLOT(optionsData()));

  updateOptions();
  InitializeOptions();
}
Ejemplo n.º 3
0
int main(int argc, char** argv) {
    std::cerr << "Startup..." << std::endl;
    
    try {
        GameWindow window = GameWindow(640, 400, false);
        InputManager* input_manager = window.get_input_manager();
        window.use_context();
        glClearColor(0.25f, 0.50f, 1.0f, 1.0f);
        float r, g, b;
        r = g = b = 0.0f;
        Callback<void, KeyboardInputEvent> release_callback([&] (KeyboardInputEvent event) {
                callback_function(".#.", event);
            });
        Callback<void, KeyboardInputEvent> down_callback([&] (KeyboardInputEvent event) {
                callback_function("...", event);
            });
        Callback<void, KeyboardInputEvent> type_callback([&] (KeyboardInputEvent event) {
                callback_function(".*.", event);
            });
        Callback<void, KeyboardInputEvent> press_callback([&] (KeyboardInputEvent event) {
                if (event.key_code == SDLK_ESCAPE) {
                    release_callback.unregister_everywhere();
                    down_callback.unregister_everywhere();
                    type_callback.unregister_everywhere();
                    press_callback.unregister_everywhere();
                }
                else {
                    callback_function("._.", event);
                }
            });
        {
            Lifeline press_lifeline = input_manager->register_key_press_handler([&] (KeyboardInputEvent event) {
                    callback_function("!!!", event);
                });
        }
        input_manager->register_key_release_handler(release_callback);
        input_manager->register_key_down_handler(down_callback);
        input_manager->register_key_type_handler(type_callback);
        input_manager->register_key_press_handler(press_callback);

        Typeface typeface("font.ttf");
        TextFont font(typeface, 12);
        Text text(&window, font, true);
        text.move(100, 1000);
        // text.set_text("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n\nThis_line_is_supposedly_very_long_and_should_not_render_properly! A B C");
        text.set_text(load_file("UTF-8-test.txt"));
        // for (int i = 0; i < 1000; i++) {
        //     text.resize(500, 400 + (i % 2));
        //     text.display();
        // }
        text.resize(800, 1000);
        text.display();
        
        TextFont big_font(typeface, 50);
        Text cursor(&window, big_font, true);
        cursor.move(100, 100);
        cursor.resize(50, 60);
        // Can ya tell what it is yet?
        cursor.set_text({0xe2, 0x99, 0x98, 0x0});
        // Lifeline mouse_lifeline = input_manager->register_mouse_handler(&mouse_callback_function);
        Lifeline mouse_button_lifeline = input_manager->register_mouse_handler(filter({MOUSE_CLICKED}, &mouse_callback_function));
        Lifeline cursor_lifeline = input_manager->register_mouse_handler(filter({MOUSE_MOVE}, [&] (MouseInputEvent event) {cursor.move(event.to.x, event.to.y);}));
        while (window.check_close() == false) {
            // Little basic colour change test.
            r += 0.001;
            g += 0.01;
            b += 0.1;
            if (r >= 1.0f) r = 0.0f;
            if (g >= 1.0f) g = 0.0f;
            if (b >= 1.0f) b = 0.0f;
            glViewport(0, 0, window.get_size().first, window.get_size().second);
            glClearColor(r, g, b, 0.8f);
            glClear(GL_COLOR_BUFFER_BIT);
            text.display();
            cursor.display();
            window.swap_buffers();
            SDL_Delay(0);
            GameWindow::update();
            if (input_manager->is_key_down(SDLK_ESCAPE) && input_manager->is_key_down(SDLK_LSHIFT)) {
                std::cerr << "Shift+Escape pressed!" << std::endl;
                break;
            }
        }
	release_callback.unregister_everywhere();
	down_callback.unregister_everywhere();
	type_callback.unregister_everywhere();
	press_callback.unregister_everywhere();
    }
    catch (GameWindow::InitException e) {
        std::cerr << e.what() << std::endl;
    }

    std::cerr << "Terminate" << std::endl;
    
    return 0;
}