Add style for panels

This commit is contained in:
daleclack 2022-02-10 20:22:02 +08:00
parent a30ed0a4ef
commit 53df858b2c
11 changed files with 84 additions and 11 deletions

View File

@ -50,6 +50,9 @@ add_custom_command(
${CMAKE_SOURCE_DIR}/res/toppanel.ui
${CMAKE_SOURCE_DIR}/res/win_size.ui
${CMAKE_SOURCE_DIR}/res/my_gtkui.resource.xml
${CMAKE_SOURCE_DIR}/res/dock_style.css
${CMAKE_SOURCE_DIR}/res/reset.css
${CMAKE_SOURCE_DIR}/res/style.css
)
# Step 3:

12
Gtkmm3/res/dock_style.css Normal file
View File

@ -0,0 +1,12 @@
/*
您可以在这里输入任何 GTK+ 可识别的 CSS 规则
您可以点击上面的暂停按钮来暂时停用这个自定义 CSS
变更会立即应用到全局影响整个应用程序
*/
@import url("resource://org/gtk/daleclack/reset.css");
box{
background-color:alpha(white,0.3);
}

View File

@ -373,6 +373,7 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="baseline-position">top</property>
<child type="center">
<object class="GtkLabel">
<property name="visible">True</property>
@ -382,13 +383,14 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">7</property>
<property name="position">8</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes"> </property>
</object>
<packing>
<property name="expand">False</property>
@ -396,6 +398,18 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="height-request">12</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="btnstart">
<property name="visible">True</property>
@ -416,7 +430,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
<child>
@ -430,7 +444,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
<child>
@ -446,7 +460,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="position">4</property>
</packing>
</child>
<child>
@ -460,7 +474,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
<property name="position">5</property>
</packing>
</child>
<child>
@ -474,7 +488,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
<property name="position">6</property>
</packing>
</child>
<child>
@ -489,7 +503,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
<property name="position">8</property>
</packing>
</child>
</object>

View File

@ -34,6 +34,9 @@
<file>icons/scalable/status/system.svg</file>
<file>gnome-fs-directory.png</file>
<file>gnome-fs-regular.png</file>
<file>dock_style.css</file>
<file>reset.css</file>
<file>style.css</file>
</gresource>
<gresource prefix="GtkUI">
<file preprocess="xml-stripblanks">appmenu.xml</file>

12
Gtkmm3/res/reset.css Normal file
View File

@ -0,0 +1,12 @@
/* @import this colorsheet to get the default values for every property.
* This is useful when writing special CSS tests that should not be
* inluenced by themes - not even the default ones.
* Keep in mind that the output will be very ugly and not look like
* anything GTK.
* Also, when adding new style properties, please add them here.
*/
* {
all: unset;
}

12
Gtkmm3/res/style.css Normal file
View File

@ -0,0 +1,12 @@
/*
您可以在这里输入任何 GTK+ 可识别的 CSS 规则
您可以点击上面的暂停按钮来暂时停用这个自定义 CSS
变更会立即应用到全局影响整个应用程序
*/
@import url("resource://org/gtk/daleclack/reset.css");
box{
background-color:alpha(white,0.7);
}

View File

@ -20,13 +20,14 @@ MyStack::MyStack(Gtk::Window *parent1)
home_btn->signal_clicked().connect(sigc::mem_fun(*this,&MyStack::btnhome_clicked));
login_overlay->add_overlay(*user_box);
//Add LeftPanel
panel2.add_panel(parent1,*main_overlay);
//Add TopPanel
panel1.set_halign(Gtk::ALIGN_FILL);
panel1.set_valign(Gtk::ALIGN_START);
main_overlay->add_overlay(panel1);
//Add LeftPanel
panel2.add_panel(parent1,*main_overlay);
//Bind Parent Window
parent=parent1;
}

View File

@ -48,6 +48,12 @@ LeftPanel::LeftPanel(){
panel_file->signal_clicked().connect(sigc::mem_fun(*this,&LeftPanel::btnfile_clicked));
btnimage->signal_clicked().connect(sigc::mem_fun(*this,&LeftPanel::btnimage_clicked));
panel_image->signal_clicked().connect(sigc::mem_fun(*this,&LeftPanel::btnimage_clicked));
//Add Style for panel
provider = Gtk::CssProvider::create();
provider->load_from_resource("/org/gtk/daleclack/dock_style.css");
auto style = btnbox->get_style_context();
style->add_provider(provider,G_MAXUINT);
}
LeftPanel::~LeftPanel(){
@ -62,7 +68,7 @@ void LeftPanel::file_manager(){
void LeftPanel::add_panel(Gtk::Window *parent1,Gtk::Overlay &overlay){
//Pack the panel
btnbox->set_halign(Gtk::ALIGN_START);
btnbox->set_valign(Gtk::ALIGN_START);
btnbox->set_valign(Gtk::ALIGN_FILL);
overlay.add_overlay(*btnbox);
//Set Parent Window
parent=parent1;

View File

@ -27,6 +27,8 @@ private:
//Parent Window
Gtk::Window *parent;
Game *game1;
//Style for leftpanel
Glib::RefPtr<Gtk::CssProvider> provider;
//Timer for panel monitor
sigc::connection paneltimer;
bool on_timeout();

View File

@ -44,6 +44,12 @@ timer_value(1000)
pack_start(*volume1,Gtk::PACK_SHRINK);
pack_end(menubtn,Gtk::PACK_SHRINK);
//Add Style for TopPanel
provider = Gtk::CssProvider::create();
provider->load_from_resource("/org/gtk/daleclack/style.css");
auto style = get_style_context();
style->add_provider(provider,G_MAXUINT);
}
bool TopPanel::on_timeout(){

View File

@ -16,6 +16,8 @@ private:
Glib::RefPtr<Gtk::Builder> menu_builder;
//Header
Gtk::Label toplabel,midlabel;
//Style for TopPanel
Glib::RefPtr<Gtk::CssProvider> provider;
//Timer
sigc::connection mytimer;
Gtk::MenuButton time_btn;