Add HeaderBar and background

This commit is contained in:
daleclack 2021-06-21 22:26:47 +08:00
parent b47b7b1a5d
commit babc2fd301
2 changed files with 32 additions and 2 deletions

View File

@ -1,18 +1,43 @@
#include "MyWin.hh"
#include "img7.xpm"
MyWin::MyWin(){
MyWin::MyWin()
:btn_box(Gtk::ORIENTATION_VERTICAL,5),
btn_ver("Xe-Ver")
{
//Initalize window
set_icon_name("org.gtk.daleclack");
set_default_size(640,360);
set_default_size(640,360);
//Add HeaderBar
header.set_title("Xe Release 12");
header.set_show_close_button();
header.set_decoration_layout("close,minimize:menu");
set_titlebar(header);
//Set Background Image
auto pixbuf=Gdk::Pixbuf::create_from_xpm_data(img7);
auto sized=pixbuf->scale_simple(640,360,Gdk::INTERP_BILINEAR);
gtk_image_set_from_pixbuf(background.gobj(),sized->gobj());
overlay.add(background);
//Initalize combobox
combo.append("Longterm");
combo.append("Stable");
combo.append("Development");
combo.set_active(1);
//Add Main Controls
btn_box.set_halign(Gtk::ALIGN_CENTER);
btn_box.set_valign(Gtk::ALIGN_CENTER);
btn_box.pack_start(combo,Gtk::PACK_SHRINK);
btn_box.pack_start(btn_ver,Gtk::PACK_SHRINK);
overlay.add_overlay(btn_box);
//Show everything
add(overlay);
show_all_children();
//Free Memory
pixbuf.reset();
sized.reset();

View File

@ -6,6 +6,11 @@ class MyWin : public Gtk::Window{
public:
MyWin();
private:
//Child Widgets
Gtk::Image background;
Gtk::Overlay overlay;
Gtk::Box btn_box;
Gtk::ComboBoxText combo;
Gtk::Button btn_ver;
Gtk::HeaderBar header;
};