From 4ccae57c08db69d394e28e92668135ec6f4f7c6a Mon Sep 17 00:00:00 2001 From: daleclack Date: Sun, 10 Oct 2021 15:09:33 +0800 Subject: [PATCH] Add Drawing App --- Gtkmm3/CMakeLists.txt | 4 +- .../res/icons/16x16/actions/drawing_app.png | Bin 0 -> 676 bytes .../res/icons/48x48/actions/drawing_app.png | Bin 0 -> 2199 bytes .../48x48/actions/drawing_app_running.png | Bin 0 -> 10478 bytes Gtkmm3/res/leftpanel.ui | 62 +++++++-- Gtkmm3/res/my_gtkui.resource.xml | 3 + Gtkmm3/src/LeftPanel.cc | 33 +++++ Gtkmm3/src/LeftPanel.hh | 6 +- Gtkmm3/src/drawing.cc | 119 ++++++++++++++++++ Gtkmm3/src/drawing.hh | 34 +++++ 10 files changed, 247 insertions(+), 14 deletions(-) create mode 100644 Gtkmm3/res/icons/16x16/actions/drawing_app.png create mode 100644 Gtkmm3/res/icons/48x48/actions/drawing_app.png create mode 100644 Gtkmm3/res/icons/48x48/actions/drawing_app_running.png create mode 100644 Gtkmm3/src/drawing.cc create mode 100644 Gtkmm3/src/drawing.hh diff --git a/Gtkmm3/CMakeLists.txt b/Gtkmm3/CMakeLists.txt index 77758ac..180d305 100644 --- a/Gtkmm3/CMakeLists.txt +++ b/Gtkmm3/CMakeLists.txt @@ -51,11 +51,11 @@ if(WIN32) OBJECT_DEPENDS ${PROJECT_SOURCE_DIR}/icon.ico ) add_executable(My_GtkUI WIN32 ${app_WINRC} src/main.cc src/MyWin.cc src/MyStack.cc src/Runner.cc - src/Game.cc src/TopPanel.cc src/LeftPanel.cc src/winconf.cc src/TextEditor.cc + src/Game.cc src/TopPanel.cc src/LeftPanel.cc src/winconf.cc src/TextEditor.cc src/drawing.cc ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}) else() add_executable(My_GtkUI src/main.cc src/MyWin.cc src/MyStack.cc src/Game.cc src/Runner.cc - src/TopPanel.cc src/LeftPanel.cc src/winconf.cc src/TextEditor.cc + src/TopPanel.cc src/LeftPanel.cc src/winconf.cc src/TextEditor.cc src/drawing.cc ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}) endif(WIN32) diff --git a/Gtkmm3/res/icons/16x16/actions/drawing_app.png b/Gtkmm3/res/icons/16x16/actions/drawing_app.png new file mode 100644 index 0000000000000000000000000000000000000000..9c1bba75c7cfbd38160b5c3b2416c2fede396505 GIT binary patch literal 676 zcmV;V0$crwP)_4W*|yoYjt8EQ*>o%Ze?;HcW-iQgef>*0005YNkljgh`th<4kzr?V9+;D~|Gmbi-W?B*V&lrD$}06JHERm^+BbR=3O zBMer_<{31yMM8;m761?tf>Z%BY;I^X@J1IaeJ+G{8P5hmGnvd(6GlYcnTAv$v?>^& z3&pEponpyDjHqQy6JC3Q^(5<=5UJh(XjM2@u(_dX5JB=li31uE+A>Wu)-ta3bS~nZ z{i5)*U}1n#b5B`MSf(k`64El#2BZ!&?P(Tp{6wwc|%IidfZ^W-e8$0jANom z&q@Xwfm_$Wc{u%cO0Bhoar`mCQlT?sOpFp4YhpDHtR%B6iFwJ~zHZ#PaTn)29}eCv z*QM^UzwYB9b_4W*|yoYjt8EQ*>o%Ze?;HcW-iQgef>*000NRNklV0Kq z_EKe95@QTKTCdjJ0B}=xn{Qp>s%M zJKsA!7?^FPp zc`VXAe1Pd8n&8z8>!1XiM42_v3b#GThS>^o57EF@WClSX>x4vDCj!z6@ZfDEjIDRE1jz;GPl7Bn0uX=wLw zM3Zn6eZJR$E~A;TXGX|S8sUx!_kC7C4iF*XsEz9!-m`sWa>Br+sVL^`DM4-F=1x3 zCNdNEC6L5bz}sY@3${3ohO6UhbQ(?0icZqVbin6l)%ZOPS0YYINM}n(AxM>8sNL)c z18&HLdEnM|pfhU^5(i9PpGU*J;iJ*$n4E5nL8r@E;ge;f$w-8o;WGS04Ln0aDxkB) zXnN^Q2+cks9)b$swGkhEMPjjg=X~NKFQC#`1e9+(paw z91>C<#ScT(aRf{G?t<7cP}jK!-W=D!XrNX*Hi0+H8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pjan}GALRl<|Rr|)Gk?Q&?w z@6lOBvCqiJlJ-{NL}k)RT}Om%spF1JWeGQAd2hGHO_+kJA9b;WINv9q({>}WaFD7$C6&V_TE)cT^xIL(yR2b6GUE4bzlHK}5cQGhdw%{`t nBe{v^{X!u>fVuIaX~#7>WBv3vg|icP^T*S=qpwz?VjKED7@JTL literal 0 HcmV?d00001 diff --git a/Gtkmm3/res/leftpanel.ui b/Gtkmm3/res/leftpanel.ui index 89d712b..e7abfe2 100644 --- a/Gtkmm3/res/leftpanel.ui +++ b/Gtkmm3/res/leftpanel.ui @@ -13,6 +13,17 @@ gedit 6 + + True + False + drawing_app + + + True + False + drawing_app + 6 + True False @@ -203,6 +214,22 @@ True False vertical + + + About + True + True + True + win.about + image3 + none + + + False + True + 0 + + Guess Game @@ -216,22 +243,22 @@ False True - 0 + 1 - - Simple Text Editor + + Drawing True True True - image8 + image11 none False True - 1 + 2 @@ -246,23 +273,22 @@ False True - 2 + 3 - - About + + Simple Text Editor True True True - win.about - image3 + image8 none False True - 3 + 4 @@ -355,5 +381,19 @@ 3 + + + True + True + True + image12 + none + + + False + True + 4 + + diff --git a/Gtkmm3/res/my_gtkui.resource.xml b/Gtkmm3/res/my_gtkui.resource.xml index 3155c66..add25a2 100644 --- a/Gtkmm3/res/my_gtkui.resource.xml +++ b/Gtkmm3/res/my_gtkui.resource.xml @@ -12,6 +12,7 @@ icons/16x16/actions/game.png icons/16x16/actions/window-close.png icons/16x16/actions/window-minimize.png + icons/16x16/actions/drawing_app.png icons/48x48/actions/game.png icons/48x48/actions/game_running.png icons/48x48/actions/My_GtkUI.png @@ -19,6 +20,8 @@ icons/48x48/actions/my_user.png icons/48x48/actions/gedit.png icons/48x48/actions/gedit_running.png + icons/48x48/actions/drawing_app.png + icons/48x48/actions/drawing_app_running.png icons/scalable/status/graphics.svg icons/scalable/status/log_out.svg icons/scalable/status/system.svg diff --git a/Gtkmm3/src/LeftPanel.cc b/Gtkmm3/src/LeftPanel.cc index 98741d7..5873add 100644 --- a/Gtkmm3/src/LeftPanel.cc +++ b/Gtkmm3/src/LeftPanel.cc @@ -17,6 +17,8 @@ LeftPanel::LeftPanel(){ panel_builder->get_widget("btnrun",btnrun); panel_builder->get_widget("btneditor",btneditor); panel_builder->get_widget("panel_editor",panel_editor); + panel_builder->get_widget("btndraw",btndraw); + panel_builder->get_widget("panel_draw",panel_draw); //Add timer paneltimer=Glib::signal_timeout().connect(sigc::mem_fun(*this,&LeftPanel::on_timeout),100); @@ -32,6 +34,8 @@ LeftPanel::LeftPanel(){ btnrun->signal_clicked().connect(sigc::mem_fun(*this,&LeftPanel::btnrun_clicked)); btneditor->signal_clicked().connect(sigc::mem_fun(*this,&LeftPanel::btnedit_clicked)); panel_editor->signal_clicked().connect(sigc::mem_fun(*this,&LeftPanel::btnedit_clicked)); + btndraw->signal_clicked().connect(sigc::mem_fun(*this,&LeftPanel::btndraw_clicked)); + panel_draw->signal_clicked().connect(sigc::mem_fun(*this,&LeftPanel::btndraw_clicked)); } void LeftPanel::add_panel(Gtk::Window *parent1,Gtk::Overlay &overlay){ @@ -43,6 +47,7 @@ void LeftPanel::add_panel(Gtk::Window *parent1,Gtk::Overlay &overlay){ parent=parent1; runner1.set_transient_for(*parent1); editor1.set_transient_for(*parent1); + drawing_app.set_transient_for(*parent1); } void LeftPanel::btnaud_clicked(){ @@ -109,6 +114,11 @@ bool LeftPanel::on_timeout(){ }else{ panel_editor->set_image_from_icon_name("gedit",Gtk::ICON_SIZE_DIALOG); } + if(drawing_app.running){ + panel_draw->set_image_from_icon_name("drawing_app_running",Gtk::ICON_SIZE_DIALOG); + }else{ + panel_draw->set_image_from_icon_name("drawing_app",Gtk::ICON_SIZE_DIALOG); + } return true; } @@ -139,3 +149,26 @@ void LeftPanel::btnedit_clicked(){ } popover->popdown(); } + +void LeftPanel::btndraw_clicked(){ + //Simulate the panel by Gdk::Window Proprties + auto draw_win=drawing_app.get_window(); + if(draw_win){ + auto state=draw_win->get_state(); + switch(state){ + case Gdk::WINDOW_STATE_ICONIFIED: + drawing_app.deiconify(); + break; + case Gdk::WINDOW_STATE_WITHDRAWN: + drawing_app.show(); + drawing_app.running=true; + break; + default: + drawing_app.iconify(); + } + }else{ + drawing_app.show(); + drawing_app.running=true; + } + popover->popdown(); +} diff --git a/Gtkmm3/src/LeftPanel.hh b/Gtkmm3/src/LeftPanel.hh index 5a60b9b..feef84b 100644 --- a/Gtkmm3/src/LeftPanel.hh +++ b/Gtkmm3/src/LeftPanel.hh @@ -4,6 +4,7 @@ #include "Game.hh" #include "Runner.hh" #include "TextEditor.hh" +#include "drawing.hh" class LeftPanel{ public: @@ -16,7 +17,7 @@ private: Gtk::Box *btnbox; Gtk::Popover *popover; Gtk::Button *btnaud,*btngedit,*btnvlc,*btnnote,*btnvlc_win32,*btngame, - *panelgame,*btnrun,*btneditor,*panel_editor; + *panelgame,*btnrun,*btneditor,*panel_editor,*btndraw,*panel_draw; //Parent Window Gtk::Window *parent; Game game1; @@ -27,6 +28,8 @@ private: GtkRunner runner1; //Text Editor TextEditor editor1; + //Drawing App + Drawing drawing_app; //Signal Handlers for application start void btnaud_clicked(); void btngedit_clicked(); @@ -36,4 +39,5 @@ private: void btngame_clicked(); void btnrun_clicked(); void btnedit_clicked(); + void btndraw_clicked(); }; diff --git a/Gtkmm3/src/drawing.cc b/Gtkmm3/src/drawing.cc new file mode 100644 index 0000000..0d25fe7 --- /dev/null +++ b/Gtkmm3/src/drawing.cc @@ -0,0 +1,119 @@ +#include "drawing.hh" + +bool Drawing::draw_event(const Cairo::RefPtr &context){ + //Show context + context->set_source(surface,0,0); + context->paint(); + return true; +} + +void Drawing::draw_brush(double x,double y){ + //Create Draw Brush with specificed size + double size=scale.get_value(); + auto cr=Cairo::Context::create(surface); + cr->arc(x, y, size, 0, 2 * G_PI); + + //Set Color + cr->set_source_rgba(m_color.get_red(),m_color.get_green(), + m_color.get_blue(),m_color.get_alpha()); + + //Fill Color and Delete the brush + cr->fill(); + cr.clear(); + + draw_area.queue_draw(); +} + +void Drawing::button_press(){ + if(surface){ + //Clear the content in draw area + auto cr=Cairo::Context::create(surface); + cr->set_source_rgb(1,1,1); + cr->paint(); + cr.clear(); + draw_area.queue_draw(); + } + +} + +void Drawing::drag_begin(double x,double y){ + //The Begin + start_x=x;start_y=y; + draw_brush(x,y); +} + +void Drawing::drag_progress(double x,double y){ + //Progress and end + draw_brush(x+start_x,y+start_y); +} + +void Drawing::color_set(){ + m_color=color_btn.get_rgba(); +} + +Drawing::Drawing() +:main_label("Select a color"), +size_label("Pen Size"), +main_box(Gtk::ORIENTATION_HORIZONTAL,5), +btn_box(Gtk::ORIENTATION_VERTICAL,5), +btn_clear("Clear Board"), +btn_exit("Exit") +{ + //Ininalize window + set_icon_name("org.gtk.daleclack"); + set_title("Drawing"); + set_default_size(640,480); + + //Color set panel + size_adj=Gtk::Adjustment::create(3.0,1.0,20.0); + scale.set_adjustment(size_adj); + scale.set_value_pos(Gtk::POS_BOTTOM); + btn_box.pack_start(main_label,Gtk::PACK_SHRINK); + btn_box.pack_start(color_btn,Gtk::PACK_SHRINK); + btn_box.pack_start(size_label,Gtk::PACK_SHRINK); + btn_box.pack_start(scale,Gtk::PACK_SHRINK); + btn_box.pack_start(btn_clear,Gtk::PACK_SHRINK); + btn_box.pack_start(btn_exit,Gtk::PACK_SHRINK); + btn_box.set_halign(Gtk::ALIGN_CENTER); + btn_box.set_valign(Gtk::ALIGN_CENTER); + + //Add Gesture + btn_clear.signal_clicked().connect(sigc::mem_fun(*this,&Drawing::button_press)); + btn_exit.signal_clicked().connect(sigc::mem_fun(*this,&Drawing::hide)); + + drag=Gtk::GestureDrag::create(draw_area); + drag->set_button(GDK_BUTTON_PRIMARY); + drag->signal_drag_begin().connect(sigc::mem_fun(*this,&Drawing::drag_begin)); + drag->signal_drag_update().connect(sigc::mem_fun(*this,&Drawing::drag_progress)); + drag->signal_drag_end().connect(sigc::mem_fun(*this,&Drawing::drag_progress)); + + //Create a Surface + surface=Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32,600,480); + + //Set Default Color + m_color.set_blue(0); + m_color.set_green(0); + m_color.set_red(0); + m_color.set_alpha(1); + color_btn.set_rgba(m_color); + color_btn.signal_color_set().connect(sigc::mem_fun(*this,&Drawing::color_set)); + + //Initalial draw + auto cr=Cairo::Context::create(surface); + cr->set_source_rgb(1,1,1); + cr->paint(); + cr.clear(); + draw_area.queue_draw(); + + //Initalize main widget + draw_area.set_size_request(600,480); + draw_area.signal_draw().connect(sigc::mem_fun(*this,&Drawing::draw_event)); + main_box.pack_start(draw_area); + main_box.pack_start(btn_box,Gtk::PACK_SHRINK); + main_box.set_border_width(10); + add(main_box); + show_all_children(); + + //Default Mode + running=false; +} diff --git a/Gtkmm3/src/drawing.hh b/Gtkmm3/src/drawing.hh new file mode 100644 index 0000000..7d161db --- /dev/null +++ b/Gtkmm3/src/drawing.hh @@ -0,0 +1,34 @@ +#pragma once + +#include + +class Drawing : public Gtk::Window{ + public: + Drawing(); + bool running; + private: + //Child Widgets + Gtk::DrawingArea draw_area; + Gtk::ColorButton color_btn; + Gtk::Label main_label,size_label; + Gtk::Box main_box,btn_box; + Gtk::Button btn_clear,btn_exit; + Gtk::Scale scale; + + //Color Setting + Gdk::RGBA m_color; + Cairo::RefPtr surface; + + //Gesture to draw + Glib::RefPtr drag; + Glib::RefPtr size_adj; + double start_x,start_y; + + //Signal Handlers + bool draw_event(const Cairo::RefPtr &context); + void draw_brush(double x,double y); + void button_press(); + void drag_begin(double x,double y); + void drag_progress(double x,double y); + void color_set(); +};