Update gtk129

This commit is contained in:
daleclack 2022-05-02 13:31:23 +08:00
parent 6abd033e7b
commit 2ca6c286f3
7 changed files with 99 additions and 20 deletions

View File

@ -30,21 +30,23 @@ set(SOURCE_FILE src/main.cc src/drawing.cc)
#Compile Resource
# set(RESOURCE_LIST
# icons/scalable/status/24game.svg
# window.ui)
set(RESOURCE_LIST
icons/scalable/status/circle.svg
icons/scalable/status/freehand.svg
icons/scalable/status/line.svg
icons/scalable/status/rectangle.svg)
# compile_gresources(RESOURCE_FILE
# XML_OUT
# TYPE EMBED_C
# RESOURCES ${RESOURCE_LIST}
# PREFIX "/org/gtk/daleclack"
# SOURCE_DIR ${PROJECT_SOURCE_DIR}/res)
compile_gresources(RESOURCE_FILE
XML_OUT
TYPE EMBED_C
RESOURCES ${RESOURCE_LIST}
PREFIX "/org/gtk/daleclack"
SOURCE_DIR ${PROJECT_SOURCE_DIR}/res)
# Add a custom target to the makefile. Now make builds our resource file.
# It depends on the output RESOURCE_FILE.
# add_custom_target(resource ALL DEPENDS ${RESOURCE_FILE})
add_custom_target(resource ALL DEPENDS ${RESOURCE_FILE})
#For win32 platform,use rc resource and .ico icon
if(WIN32)
@ -53,12 +55,12 @@ if(WIN32)
set_property(SOURCE ../icon.rc APPEND PROPERTY
OBJECT_DEPENDS ${PROJECT_SOURCE_DIR}/../icon.ico
)
add_executable(${PROJECT_NAME} WIN32 ${app_WINRC} ${SOURCE_FILE})
add_executable(${PROJECT_NAME} WIN32 ${app_WINRC} ${SOURCE_FILE} ${RESOURCE_FILE})
add_custom_command( TARGET ${PROJECT_NAME}
COMMAND echo * > ${CMAKE_BINARY_DIR}/.gitignore
COMMAND echo **/* > ${CMAKE_BINARY_DIR}/.hgignore)
else()
add_executable(${PROJECT_NAME} ${SOURCE_FILE})
add_executable(${PROJECT_NAME} ${SOURCE_FILE} ${RESOURCE_FILE})
add_custom_command( TARGET ${PROJECT_NAME}
COMMAND echo \"*\" > ${CMAKE_BINARY_DIR}/.gitignore
COMMAND echo \"**/*\" > ${CMAKE_BINARY_DIR}/.hgignore)

View File

@ -0,0 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#363636;
}
</style>
</defs>
<path style="fill:currentColor;fill-opacity:1;stroke:none"
d="M8 2A6 6 0 0 0 2 8 6 6 0 0 0 8 14 6 6 0 0 0 14 8 6 6 0 0 0 8 2M8 3A5 5 0 0 1 13 8 5 5 0 0 1 8 13 5 5 0 0 1 3 8 5 5 0 0 1 8 3"
class="ColorScheme-Text"
/>
</svg>

After

Width:  |  Height:  |  Size: 460 B

View File

@ -0,0 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#363636;
}
</style>
</defs>
<path style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 9.15625 2 L 2 9.125 L 2 12 C 3.075 12.019 4.84375 12 4.84375 12 L 12 4.84375 L 9.15625 2 z M 8.4375 4.15625 L 9.84375 5.5625 L 6.9980469 8.4375 L 5.5605469 6.9980469 L 8.4375 4.15625 z M 4.84375 7.71875 L 6.28125 9.125 L 5.5625 9.84375 L 4.15625 8.4375 L 4.84375 7.71875 z M 12.123047 9 C 11.927047 9.001 11.392547 9.0455 10.560547 9.5625 C 10.300547 9.7245 10.107547 9.9089531 9.8105469 10.126953 C 9.6525469 10.242953 9.0850469 10.620953 8.8730469 10.751953 C 8.2540469 11.134953 8.0320469 11.231953 7.4980469 11.501953 C 6.9810469 11.762953 6.4395469 12.000453 6.0605469 12.189453 C 4.4685469 12.984453 1.9960937 13.001953 1.9960938 13.001953 L 1.9960938 14.001953 C 1.9960938 14.001953 4.4935469 14.033953 6.3105469 13.126953 C 6.5515469 13.006953 6.9790469 12.808953 7.3730469 12.626953 C 7.3730469 12.626953 8.4920469 12.034203 8.4980469 12.033203 C 8.6940469 11.924203 8.8592969 11.841203 9.1542969 11.658203 C 9.3822969 11.517203 9.9292969 11.166953 10.154297 11.001953 C 10.484297 10.758953 10.697047 10.579703 10.873047 10.470703 C 11.258047 10.168703 11.693047 9.9889531 12.123047 10.001953 C 12.089047 10.001953 12.253297 10.011703 12.404297 10.095703 C 12.555297 10.179703 12.714797 10.329703 12.841797 10.470703 C 13.086797 10.802703 13.198047 11.055953 13.248047 11.501953 C 13.212047 12.808953 11.968047 13.006953 10.998047 13.001953 L 10.998047 14.001953 C 12.977047 14.090953 13.998047 13.167703 13.998047 11.470703 C 13.994047 11.182703 13.947797 10.945953 13.841797 10.626953 C 13.735797 10.307953 13.575797 9.9514531 13.341797 9.6894531 C 12.980797 9.2664531 12.799047 9.0809531 12.123047 9.0019531 L 12.123047 9 z "
class="ColorScheme-Text"
/>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -0,0 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#363636;
}
</style>
</defs>
<path style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 11 2 L 11 4.3125 L 4.3125 11.001953 L 2.0019531 11.001953 L 2.0019531 14.001953 L 5.0019531 14.001953 L 5.0019531 11.6875 L 11.6875 5 L 14 5 L 14 2 L 11 2 z M 12 3 L 13 3 L 13 4 L 12 4 L 12 3 z M 3 12 L 4 12 L 4 13 L 3 13 L 3 12 z "
class="ColorScheme-Text"
/>
</svg>

After

Width:  |  Height:  |  Size: 569 B

View File

@ -0,0 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#363636;
}
</style>
</defs>
<path style="fill:currentColor;fill-opacity:1;stroke:none"
d="m2 2v12h12v-12zm1 1h10v10h-10z"
class="ColorScheme-Text"
/>
</svg>

After

Width:  |  Height:  |  Size: 366 B

View File

@ -4,9 +4,9 @@
Drawing::Drawing()
: main_label("Select a color"),
size_label("Pen Size"),
left_box(Gtk::ORIENTATION_VERTICAL,5),
main_box(Gtk::ORIENTATION_HORIZONTAL, 5),
btn_box(Gtk::ORIENTATION_VERTICAL, 5),
btn_line("Line to"),
btn_clear("Clear Board"),
btn_exit("Exit")
{
@ -15,6 +15,33 @@ Drawing::Drawing()
set_title("Drawing");
set_default_size(640, 480);
// Set the buttons grouped
auto group = btn_free.get_group();
btn_free.set_mode(false);
btn_circle.set_group(group);
btn_circle.set_mode(false);
btn_line.set_group(group);
btn_line.set_mode(false);
btn_rectangle.set_group(group);
btn_rectangle.set_mode(false);
// Add images to the button
btn_free.set_image_from_icon_name("freehand");
btn_free.set_always_show_image();
btn_circle.set_image_from_icon_name("circle");
btn_circle.set_always_show_image();
btn_line.set_image_from_icon_name("line");
btn_line.set_always_show_image();
btn_rectangle.set_image_from_icon_name("rectangle");
btn_rectangle.set_always_show_image();
//Left Panel
left_box.pack_start(btn_free,Gtk::PACK_SHRINK);
left_box.pack_start(btn_circle,Gtk::PACK_SHRINK);
left_box.pack_start(btn_line,Gtk::PACK_SHRINK);
left_box.pack_start(btn_rectangle,Gtk::PACK_SHRINK);
left_box.set_valign(Gtk::ALIGN_START);
// Color set panel
size_adj = Gtk::Adjustment::create(3.0, 1.0, 20.0);
scale.set_adjustment(size_adj);
@ -62,6 +89,7 @@ Drawing::Drawing()
// 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(left_box);
main_box.pack_start(draw_area);
main_box.pack_start(btn_box, Gtk::PACK_SHRINK);
main_box.set_border_width(10);
@ -99,22 +127,18 @@ void Drawing::draw_brush(double x, double y, bool begin)
}
else
{
cr->move_to(x1, y1);
cr->move_to(x1-0.1, y1-0.1);
cr->line_to(x, y);
x1 = x;
y1 = y;
}
// Draw circles to make paint better
cr->arc(x, y, size / 5.0, 0.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->stroke();
cr->fill();
cr.clear();
break;
case DrawMode::Line:

View File

@ -16,8 +16,9 @@ class Drawing : public Gtk::Window
Gtk::DrawingArea draw_area;
Gtk::ColorButton color_btn;
Gtk::Label main_label, size_label;
Gtk::Box main_box, btn_box;
Gtk::Button btn_line, btn_clear, btn_exit;
Gtk::Box left_box, main_box, btn_box;
Gtk::Button btn_clear, btn_exit;
Gtk::RadioButton btn_free, btn_line, btn_circle, btn_rectangle;
Gtk::Scale scale;
// Color Setting