Пример #1
0
/** update everything about mapping, leaving the viewport alone */
void
Canvas::update_mapping ( void )
{
    _update_row_mapping();

    m.mapping_drawn = false;

    resize();

    int old_margin = m.margin_left;

    m.margin_left = 0;

    m.draw = false;

    m.grid->draw_row_names( this );

    if ( m.margin_left != old_margin )
    {
        signal_resize();
        signal_draw();
    }
    else
        signal_draw();
}
Пример #2
0
/**
 * Draw the current frame
 */
static void ps_draw() {
    GFraMe_event_draw_begin();
#ifdef DEBUG
        _drwCalls++;
#endif
        map_draw(m);
        rg_drawBullets();
        rg_drawObjects();
        rg_drawMobs();
        if (gv_nIsZero(SWITCH_MAP))
            transition_draw();
        ui_draw();
        player_draw(p2);
        player_draw(p1);
        if (gv_isZero(SWITCH_MAP))
            signal_draw();
        #ifdef QT_DEBUG_DRAW
            if (GFraMe_keys.f1 ||
                (GFraMe_controller_max > 0 && GFraMe_controllers[0].l2))
                qt_drawRootDebug();
        #endif 
        if (_ps_pause) {
            ps_drawPause();
        }
        if (_ps_isSpeedrun)
            timer_draw();
        if (_ps_text) {
            textWnd_draw();
        }
    GFraMe_event_draw_end();
}
Пример #3
0
Graph_disp::Graph_disp(const sf::VideoMode & mode, const int size_request, const sf::ContextSettings & context_settings):
    SFMLWidget(mode, size_request, context_settings),
    draw_cursor_flag(true), draw_axes_flag(true), use_orbit_cam(true),
    cam_light(glm::vec3(1.0f), 0.2f, glm::vec3(0.0f), 1.0f, 0.5f, 0.0f),
    dir_light(glm::vec3(0.5f), 0.2f, glm::vec3(-1.0f)),
    bkg_color(0.25f, 0.25f, 0.25f), ambient_color(0.4f, 0.4f, 0.4f),
    _cam(glm::vec3(0.0f, -10.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f)),
    _orbit_cam({10.0f, 0.0f, (float)M_PI / 2.0f}), _scale(1.0f), _perspective(1.0f),
    _active_graph(nullptr)
{
    // All OpenGL initialization has to wait until the drawing context actually exists
    // we do this in the initialize method
    // connect it to the draw signal, to be run only on the first drawing request
    _draw_connection = signal_draw().connect(sigc::mem_fun(*this, &Graph_disp::initiaize));

    // connect event signals
    signal_size_allocate().connect(sigc::mem_fun(*this, &Graph_disp::resize));
    signal_key_press_event().connect(sigc::mem_fun(*this, &Graph_disp::key_press));

    // input is checked every 10ms
    Glib::signal_timeout().connect(sigc::mem_fun(*this, &Graph_disp::input), 10);

    set_can_focus();
    set_can_default();
}
Пример #4
0
/** change grid to /g/, returns TRUE if new grid size differs from old */
void
Canvas::grid ( Grid *g )
{
    m.grid = g;

    if ( ! g )
        return;

    m.vp = &g->viewport;

    char *s = m.vp->dump();
    DMESSAGE( "viewport: %s", s );
    free( s );

    m.ruler_drawn = false;

    resize_grid();

    update_mapping();

    m.shape = m.grid->draw_shape();

    /* connect signals */
    /* FIXME: what happens when we do this twice? */
    g->signal_events_change.connect( mem_fun( this, &Canvas::handle_event_change ) );
    g->signal_settings_change.connect( signal_settings_change.make_slot() );

    signal_draw();
    signal_settings_change();
}
Пример #5
0
void
Canvas::unset ( int x, int y )
{
    if ( y - m.origin_y < m.margin_top )
        /* looks like a click on the ruler */
    {
        if ( x - m.margin_left - m.origin_x >= 0 )
        {
            m.p2 = m.vp->x + ((x - m.margin_left - m.origin_x) / m.div_w);
            m.ruler_drawn = false;

            m.p3 = m.p4 = 0;
        }

        _lr();

        signal_draw();

        return;
    }

    if ( ! grid_pos( &x, &y ) )
        return;

    m.grid->del( x, y );
}
Пример #6
0
/** draw only the playhead--without reexamining the grid */
int
Canvas::draw_playhead ( void )
{
    int x = m.grid->ts_to_x( m.grid->index() );

    if ( m.playhead == x )
        return 0;

    m.playhead = x;

    if ( m.playhead < m.vp->x || m.playhead >= m.vp->x + m.vp->w )
    {
        if ( config.follow_playhead )
        {
            m.vp->x = m.playhead / m.vp->w * m.vp->w;

            m.ruler_drawn = false;

            signal_draw();

            return 0;
        }
    }

    copy();

    for ( uint x = m.vp->w; x-- ; )
        for ( uint y = m.vp->h; y-- ; )
            m.current[ x ][ y ].flags &= ~ (F_PLAYHEAD | F_P1 | F_P2 );

    flip();

    return 1;
}
Пример #7
0
void
Canvas::handle_event_change ( void )
{
    /* mark the song as dirty and pass the signal on */
    song.set_dirty();

    signal_draw();
}
Пример #8
0
void
Canvas::pan ( int dir, int n )
{

    switch ( dir )
    {
        case LEFT: case RIGHT: case TO_PLAYHEAD: case TO_NEXT_NOTE: case TO_PREV_NOTE:
            /* handle horizontal movement specially */
            n *= m.grid->division();
            m.ruler_drawn = false;
            break;
        default:
            n *= 5;
            m.mapping_drawn = false;
            break;
    }

    switch ( dir )
    {
        case LEFT:
            m.vp->x = max( m.vp->x - n, 0 );
            break;
        case RIGHT:
            m.vp->x += n;
            break;
        case TO_PLAYHEAD:
            m.vp->x = m.playhead - (m.playhead % m.grid->division());
            break;
        case UP:
            m.vp->y = max( m.vp->y - n, 0 );
            break;
        case DOWN:
            m.vp->y = min( m.vp->y + n, m.maxh - m.vp->h );
            break;
        case TO_NEXT_NOTE:
        {
            int x = m.grid->next_note_x( m.vp->x );
            m.vp->x = x - (x % m.grid->division() );
            break;
        }
        case TO_PREV_NOTE:
        {
            int x = m.grid->prev_note_x( m.vp->x );
            m.vp->x = x - (x % m.grid->division() );
            break;
        }
    }

    signal_draw();
}
Пример #9
0
void
Canvas::end_cursor ( int x, int y )
{
    if ( ! grid_pos( &x, &y ) )
        return;

    m.ruler_drawn = false;

    m.p2 = x;
    m.p4 = ntr( y );

    _lr();

    signal_draw();
}
Пример #10
0
ImageWidget::ImageWidget() :
	_isInitialized(false),
	_initializedWidth(0),
	_initializedHeight(0),
	_showOriginalMask(true),
	_showAlternativeMask(true),
	_colorMap(BWMap),
	_image(),
	_highlighting(false),
	_startHorizontal(0.0),
	_endHorizontal(1.0),
	_startVertical(0.0),
	_endVertical(1.0),
	_segmentedImage(),
	_horiScale(0),
	_vertScale(0),
	_colorScale(0),
	_plotTitle(0),
	_scaleOption(NormalScale),
	_showXYAxes(true),
	_showColorScale(true),
	_showXAxisDescription(true),
	_showYAxisDescription(true),
	_showZAxisDescription(true),
	_showTitle(true),
	_max(1.0), _min(0.0),
	_range(Winsorized),
	_cairoFilter(Cairo::FILTER_BEST),
	_manualTitle(false),
	_manualXAxisDescription(false),
	_manualYAxisDescription(false),
	_manualZAxisDescription(false),
	_mouseIsIn(false)
{
	_highlightConfig = new ThresholdConfig();
	_highlightConfig->InitializeLengthsSingleSample();

	add_events(Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_RELEASE_MASK |
		   Gdk::BUTTON_PRESS_MASK | Gdk::LEAVE_NOTIFY_MASK);
	signal_motion_notify_event().connect(sigc::mem_fun(*this, &ImageWidget::onMotion));
	signal_leave_notify_event().connect(sigc::mem_fun(*this, &ImageWidget::onLeave));
	signal_button_release_event().connect(sigc::mem_fun(*this, &ImageWidget::onButtonReleased));
	signal_draw().connect(sigc::mem_fun(*this, &ImageWidget::onDraw) );
}
Пример #11
0
void MyArea::set_pixbuf(Gdk::Pixbuf* data) {
	priv->pixbuf = Glib::RefPtr<Gdk::Pixbuf>(data);
	signal_draw().connect( sigc::mem_fun(
		*priv, &MyArea_private::on_draw) );
}
Пример #12
0
// called when OpenGL context is ready and GTK widget is ready
bool Graph_disp::initiaize(const Cairo::RefPtr<Cairo::Context> & unused)
{
    // clear the screen
    glClearColor(bkg_color.r, bkg_color.g, bkg_color.b, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    display();

    // init glew
    if(glewInit() != GLEW_OK)
    {
        Gtk::MessageDialog error_dialog("Error loading Glew", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
        error_dialog.set_transient_for(*dynamic_cast<Gtk::Window *>(get_toplevel()));
        error_dialog.set_title("Fatal Error");
        error_dialog.set_secondary_text("Aborting...");
        error_dialog.run();

        std::cerr<<"Error loading glew. Aborting"<<std::endl;
        dynamic_cast<Gtk::Window *>(get_toplevel())->hide();
        return_code = EXIT_FAILURE;
        return true;
    }

    // check for required OpenGL version
    if(!GLEW_VERSION_3_3)
    {
        Gtk::MessageDialog error_dialog("OpenGL version too low", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
        error_dialog.set_transient_for(*dynamic_cast<Gtk::Window *>(get_toplevel()));
        error_dialog.set_title("Fatal Error");
        error_dialog.set_secondary_text("Version 3.3 required\nInstalled version is: " +
            std::string((const char *)glGetString(GL_VERSION)) + "\nAborting...");
        error_dialog.run();

        std::cerr<<"OpenGL version too low. Version 3.3 required"<<std::endl;
        std::cerr<<"Installed version is: "<<glGetString(GL_VERSION)<<std::endl;
        dynamic_cast<Gtk::Window *>(get_toplevel())->hide();
        return_code = EXIT_FAILURE;
        return true;
    }

    std::cerr<<"OpenGL version is: "<<glGetString(GL_VERSION)<<std::endl;

    // init GL state vars
    glEnable(GL_DEPTH_TEST);
    glDepthRangef(0.0f, 1.0f);
    glLineWidth(5.0f);

    glEnable(GL_POLYGON_SMOOTH);
    glHint(GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE);
    glEnable(GL_LINE_SMOOTH);
    glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glBlendColor(1.0f, 1.0f, 1.0f, 0.1f);
    glEnable(GL_BLEND);

    // build shader programs
    GLuint graph_vert = compile_shader(check_in_pwd("shaders/graph.vert"), GL_VERTEX_SHADER);
    GLuint line_vert = compile_shader(check_in_pwd("shaders/line.vert"), GL_VERTEX_SHADER);
    GLuint common_frag = compile_shader(check_in_pwd("shaders/common.frag"), GL_FRAGMENT_SHADER);
    GLuint tex_frag = compile_shader(check_in_pwd("shaders/tex.frag"), GL_FRAGMENT_SHADER);
    GLuint color_frag = compile_shader(check_in_pwd("shaders/color.frag"), GL_FRAGMENT_SHADER);
    GLuint flat_color_frag = compile_shader(check_in_pwd("shaders/flat_color.frag"), GL_FRAGMENT_SHADER);

    if(graph_vert == 0 || line_vert == 0 || tex_frag == 0 || color_frag == 0 || flat_color_frag == 0)
    {
        // error messages are displayed by the compile_shader function
        Gtk::MessageDialog error_dialog("Error compiling shaders", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
        error_dialog.set_transient_for(*dynamic_cast<Gtk::Window *>(get_toplevel()));
        error_dialog.set_title("Fatal Error");
        error_dialog.set_secondary_text("See console output for details.\nAborting...");
        error_dialog.run();

        dynamic_cast<Gtk::Window *>(get_toplevel())->hide();
        return_code = EXIT_FAILURE;
        return true;
    }

    // link shaders
    _prog_tex.prog = link_shader_prog(std::vector<GLuint> {graph_vert, tex_frag, common_frag});
    _prog_color.prog = link_shader_prog(std::vector<GLuint> {graph_vert, color_frag, common_frag});
    _prog_line.prog = link_shader_prog(std::vector<GLuint> {line_vert, flat_color_frag});

    if(_prog_tex.prog == 0 || _prog_color.prog == 0 || _prog_line.prog == 0)
    {
        // error messages are displayed by the link_shader_prog function
        Gtk::MessageDialog error_dialog("Error linking shaders", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
        error_dialog.set_transient_for(*dynamic_cast<Gtk::Window *>(get_toplevel()));
        error_dialog.set_title("Fatal Error");
        error_dialog.set_secondary_text("See console output for details.\nAborting...");
        error_dialog.run();

        dynamic_cast<Gtk::Window *>(get_toplevel())->hide();
        return_code = EXIT_FAILURE;
        return true;
    }

    check_error("build shaders");

    // free shader objects
    glDeleteShader(graph_vert);
    glDeleteShader(line_vert);
    glDeleteShader(common_frag);
    glDeleteShader(tex_frag);
    glDeleteShader(color_frag);
    glDeleteShader(flat_color_frag);

    // get uniform locations for each shader
    bool uniform_success = true;
    uniform_success &= _prog_tex.add_uniform("view_model_perspective");
    uniform_success &= _prog_tex.add_uniform("view_model");
    uniform_success &= _prog_tex.add_uniform("normal_transform");
    uniform_success &= _prog_tex.add_uniform("material.shininess");
    uniform_success &= _prog_tex.add_uniform("material.specular");
    uniform_success &= _prog_tex.add_uniform("ambient_color");
    uniform_success &= _prog_tex.add_uniform("cam_light.base.color");
    uniform_success &= _prog_tex.add_uniform("cam_light.base.strength");
    uniform_success &= _prog_tex.add_uniform("cam_light.pos_eye");
    uniform_success &= _prog_tex.add_uniform("cam_light.const_atten");
    uniform_success &= _prog_tex.add_uniform("cam_light.linear_atten");
    uniform_success &= _prog_tex.add_uniform("cam_light.quad_atten");
    uniform_success &= _prog_tex.add_uniform("dir_light.base.color");
    uniform_success &= _prog_tex.add_uniform("dir_light.base.strength");
    uniform_success &= _prog_tex.add_uniform("dir_light.dir");
    uniform_success &= _prog_tex.add_uniform("dir_light.half_vec");
    uniform_success &= _prog_tex.add_uniform("light_forward");
    check_error("_prog_tex GetUniformLocation");

    if(!uniform_success)
    {
        std::string missing_uniforms;

        for(auto const & uniform: _prog_tex.uniforms)
        {
            if(uniform.second == -1)
            {
                missing_uniforms += uniform.first + "\n";
            }
        }

        std::cerr<<"Error finding texture shader uniforms:\n"<<missing_uniforms<<std::endl;

        Gtk::MessageDialog error_dialog("Error finding texture shader uniforms", false,
            Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
        error_dialog.set_transient_for(*dynamic_cast<Gtk::Window *>(get_toplevel()));
        error_dialog.set_title("Fatal Error");
        error_dialog.set_secondary_text(missing_uniforms + "Aborting...");
        error_dialog.run();

        dynamic_cast<Gtk::Window *>(get_toplevel())->hide();
        return_code = EXIT_FAILURE;
        return true;
    }

    uniform_success = true;
    uniform_success &= _prog_color.add_uniform("view_model_perspective");
    uniform_success &= _prog_color.add_uniform("view_model");
    uniform_success &= _prog_color.add_uniform("normal_transform");
    uniform_success &= _prog_color.add_uniform("material.shininess");
    uniform_success &= _prog_color.add_uniform("material.specular");
    uniform_success &= _prog_color.add_uniform("color");
    uniform_success &= _prog_color.add_uniform("ambient_color");
    uniform_success &= _prog_color.add_uniform("cam_light.base.color");
    uniform_success &= _prog_color.add_uniform("cam_light.base.strength");
    uniform_success &= _prog_color.add_uniform("cam_light.pos_eye");
    uniform_success &= _prog_color.add_uniform("cam_light.const_atten");
    uniform_success &= _prog_color.add_uniform("cam_light.linear_atten");
    uniform_success &= _prog_color.add_uniform("cam_light.quad_atten");
    uniform_success &= _prog_color.add_uniform("dir_light.base.color");
    uniform_success &= _prog_color.add_uniform("dir_light.base.strength");
    uniform_success &= _prog_color.add_uniform("dir_light.dir");
    uniform_success &= _prog_color.add_uniform("dir_light.half_vec");
    uniform_success &= _prog_color.add_uniform("light_forward");
    check_error("_prog_color GetUniformLocation");

    if(!uniform_success)
    {
        std::string missing_uniforms;

        for(auto const & uniform: _prog_color.uniforms)
        {
            if(uniform.second == -1)
            {
                missing_uniforms += uniform.first + "\n";
            }
        }

        std::cerr<<"Error finding color shader uniforms:\n"<<missing_uniforms<<std::endl;

        Gtk::MessageDialog error_dialog("Error finding color shader uniforms", false,
            Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
        error_dialog.set_transient_for(*dynamic_cast<Gtk::Window *>(get_toplevel()));
        error_dialog.set_title("Fatal Error");
        error_dialog.set_secondary_text(missing_uniforms + "Aborting...");
        error_dialog.run();

        dynamic_cast<Gtk::Window *>(get_toplevel())->hide();
        return_code = EXIT_FAILURE;
        return true;
    }

    uniform_success = true;
    uniform_success &= _prog_line.add_uniform("perspective");
    uniform_success &= _prog_line.add_uniform("view_model");
    uniform_success &= _prog_line.add_uniform("color");
    check_error("_prog_line GetUniformLocation");

    if(!uniform_success)
    {
        std::string missing_uniforms;

        for(auto const & uniform: _prog_line.uniforms)
        {
            if(uniform.second == -1)
            {
                missing_uniforms += uniform.first + "\n";
            }
        }

        std::cerr<<"Error finding line shader uniforms:\n"<<missing_uniforms<<std::endl;

        Gtk::MessageDialog error_dialog("Error finding line shader uniforms", false,
            Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
        error_dialog.set_transient_for(*dynamic_cast<Gtk::Window *>(get_toplevel()));
        error_dialog.set_title("Fatal Error");
        error_dialog.set_secondary_text(missing_uniforms + "Aborting...");
        error_dialog.run();

        dynamic_cast<Gtk::Window *>(get_toplevel())->hide();
        return_code = EXIT_FAILURE;
        return true;
    }

    // set up un-changing lighting values (in eye space)
    glm::vec3 cam_light_pos_eye(0.0f);
    glm::vec3 light_forward(0.0f, 0.0f, 1.0f);

    glUseProgram(_prog_tex.prog);
    glUniform3fv(_prog_tex.uniforms["cam_light.pos_eye"], 1, &cam_light_pos_eye[0]);
    glUniform3fv(_prog_tex.uniforms["light_forward"], 1, &light_forward[0]);
    check_error("_prog_tex uniforms static");

    glUseProgram(_prog_color.prog);
    glUniform3fv(_prog_color.uniforms["cam_light.pos_eye"], 1, &cam_light_pos_eye[0]);
    glUniform3fv(_prog_color.uniforms["light_forward"], 1, &light_forward[0]);
    check_error("_prog_color uniforms static");

    // create static geometry objects - cursor, axes
    try
    {
        _cursor.build(check_in_pwd("img/cursor.png"));
    }
    catch(Glib::Exception &e)
    {
        std::cerr<<"Error reading cursor image file:"<<std::endl<<e.what()<<std::endl;

        Gtk::MessageDialog error_dialog("Error reading cursor image_file", false,
            Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
        error_dialog.set_transient_for(*dynamic_cast<Gtk::Window *>(get_toplevel()));
        error_dialog.set_title("Fatal Error");
        error_dialog.set_secondary_text(e.what() + std::string("\nAborting..."));
        error_dialog.run();

        dynamic_cast<Gtk::Window *>(get_toplevel())->hide();
        return_code = EXIT_FAILURE;
        return true;
    }

    _axes.build();

    _draw_connection.disconnect();
    _draw_connection = signal_draw().connect(sigc::mem_fun(*this, &Graph_disp::draw));

    // explicitly setup the window size (since resize is automatically called before initialization
    Gtk::Allocation allocation(0, 0, get_allocated_width(), get_allocated_height());
    resize(allocation);

    _signal_initialized.emit();
    return draw(unused);
}
TransparentSlider::TransparentSlider() :
    _redInit(0.5),
    _greenInit(1),
    _blueInit(0.5),
    _alphaInit(0.5),
	_buttonLabel("Close"),
	_box(Gtk::ORIENTATION_VERTICAL),
	_inner_box(Gtk::ORIENTATION_HORIZONTAL),
	_alignment(Gtk::ALIGN_END, Gtk::ALIGN_END, 0.0, 0.0),
    _button(_buttonLabel),
    _adjustmentRed(Gtk::Adjustment::create(_redInit, 0, 1.0, 0.1, 0.1, 0)),
    _adjustmentGreen(Gtk::Adjustment::create(_greenInit, 0, 1.0, 0.1, 0.1, 0)),
    _adjustmentBlue(Gtk::Adjustment::create(_blueInit, 0, 1.0, 0.1, 0.1, 0)),
    _adjustmentAlpha(Gtk::Adjustment::create(_alphaInit, 0, 1.0, 0.1, 0.1, 0)),
    _scaleRed(_adjustmentRed, Gtk::ORIENTATION_VERTICAL),
    _scaleGreen(_adjustmentGreen, Gtk::ORIENTATION_VERTICAL),
    _scaleBlue(_adjustmentBlue, Gtk::ORIENTATION_VERTICAL),
    _scaleAlpha(_adjustmentAlpha, Gtk::ORIENTATION_VERTICAL)
{

    // Set up the top-level window.
	set_border_width(10);
    set_title("Color Slider Test");
    set_default_size(400,400);
    set_decorated(false);
    add_events(Gdk::BUTTON_PRESS_MASK);
    set_position(Gtk::WIN_POS_CENTER);
    set_app_paintable(true);

    // Signal handlers
    signal_draw().connect(sigc::mem_fun(*this, &TransparentSlider::on_draw));
    signal_screen_changed().connect(sigc::mem_fun(*this, &TransparentSlider::on_screen_changed));
    signal_button_press_event().connect(sigc::mem_fun(*this, &TransparentSlider::on_window_clicked));
    _button.signal_clicked().connect(sigc::mem_fun(*this, &TransparentSlider::on_button_clicked));

    // Widgets

    // Add the box and pack it.
    add(_box);
    _box.pack_start(_inner_box);
    _box.pack_start(_alignment);

    // Pack the inner box
    _inner_box.set_homogeneous();
    _inner_box.pack_start(_scaleRed);
    _inner_box.pack_start(_scaleGreen);
    _inner_box.pack_start(_scaleBlue);
    _inner_box.pack_start(_scaleAlpha);

    // Set up the scales:
    _scaleRed.set_digits(3);
    _scaleRed.set_inverted();
    _scaleGreen.set_digits(3);
    _scaleGreen.set_inverted();
    _scaleBlue.set_digits(3);
    _scaleBlue.set_inverted();
    _scaleAlpha.set_digits(3);
    _scaleAlpha.set_inverted();

    // Set up the close button
    _alignment.add(_button);
    _button.set_size_request(100, 10);

    // Initialize the process of drawing the colored part.
    on_screen_changed(get_screen());

    // Show the window and all its children.
    show_all_children();
}