• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

作図ソフト dia の改良版


コミットメタ情報

リビジョン79426dc815202dd2c06d8b31c22178675f314026 (tree)
日時2004-04-01 23:17:36
作者Lars Clausen <lclausen@src....>
コミッターLars Clausen

ログメッセージ

Color and linewidth.

変更サマリ

差分

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
1+2004-04-01 Lars Clausen <lc@pc770.sb.statsbiblioteket.dk>
2+
3+ * app/color_area.c (color_area_create):
4+ * lib/attributes.c:
5+ * app/linewidth_area.c: Also persistent colors and line width.
6+ That was easy. Arrows and line style will take a bit more work,
7+ but not much.
8+
19 2004-04-01 Lars Clausen <lars@raeder.dk>
210
311 * app/preferences.c: All preferences are now
--- a/app/color_area.c
+++ b/app/color_area.c
@@ -27,6 +27,7 @@
2727
2828 #include "color_area.h"
2929 #include "attributes.h"
30+#include "persistence.h"
3031
3132 #define FORE_AREA 0
3233 #define BACK_AREA 1
@@ -453,6 +454,10 @@ color_area_create (int width,
453454 {
454455 GtkWidget *event_box;
455456
457+ // Won't work on Win32, as color_{black,white} aren't defined. Why not?
458+ attributes_set_foreground(persistence_register_color("fg_color", &color_black));
459+ attributes_set_background(persistence_register_color("bg_color", &color_white));
460+
456461 event_box = gtk_event_box_new();
457462 color_area = gtk_drawing_area_new ();
458463 gtk_widget_set_size_request (color_area, width, height);
--- a/app/linewidth_area.c
+++ b/app/linewidth_area.c
@@ -168,12 +168,26 @@ linewidth_area_events (GtkWidget *widget,
168168 }
169169
170170
171+static int
172+linewidth_number_from_width(real width)
173+{
174+ if (fabs(width/BASE_WIDTH-rint(width/BASE_WIDTH)) > 0.0005 ||
175+ (width/BASE_WIDTH > NUMLINES)) {
176+ return 0;
177+ } else {
178+ return width/BASE_WIDTH+1.0005;
179+ }
180+}
181+
171182 GtkWidget *
172183 linewidth_area_create (void)
173184 {
174185 GtkWidget *linewidth_area;
175186 GtkWidget *event_box;
176187
188+ attributes_set_default_linewidth(persistence_register_real("linewidth", 0.1));
189+ active_linewidth = linewidth_number_from_width(attributes_get_default_linewidth());
190+
177191 event_box = gtk_event_box_new();
178192 linewidth_area = gtk_drawing_area_new ();
179193 gtk_drawing_area_size (GTK_DRAWING_AREA (linewidth_area),
@@ -183,7 +197,7 @@ linewidth_area_create (void)
183197 G_CALLBACK(linewidth_area_events),
184198 NULL);
185199
186- attributes_set_default_linewidth(BASE_WIDTH*active_linewidth);
200+ // attributes_set_default_linewidth(BASE_WIDTH*active_linewidth);
187201
188202 linewidth_area_widget = linewidth_area;
189203
@@ -195,12 +209,7 @@ linewidth_area_create (void)
195209 static void
196210 get_current_line_width() {
197211 float newvalue = gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(linewidth_button));
198- if (fabs(newvalue/BASE_WIDTH-rint(newvalue/BASE_WIDTH)) > 0.0005 ||
199- (newvalue/BASE_WIDTH > NUMLINES)) {
200- active_linewidth = 0;
201- } else {
202- active_linewidth = newvalue/BASE_WIDTH+1.0005;
203- }
212+ active_linewidth = linewidth_number_from_width(newvalue);
204213 linewidth_area_draw(GTK_WIDGET(linewidth_area_widget));
205214 attributes_set_default_linewidth(newvalue);
206215 }
--- a/lib/attributes.c
+++ b/lib/attributes.c
@@ -19,6 +19,7 @@
1919
2020 #include "attributes.h"
2121 #include "intl.h"
22+#include "persistence.h"
2223
2324 static Color attributes_foreground = { 0.0f, 0.0f, 0.0f };
2425 static Color attributes_background = { 1.0f, 1.0f, 1.0f };
@@ -52,12 +53,14 @@ void
5253 attributes_set_foreground(Color *color)
5354 {
5455 attributes_foreground = *color;
56+ persistence_set_color("fg_color", color);
5557 }
5658
5759 void
5860 attributes_set_background(Color *color)
5961 {
6062 attributes_background = *color;
63+ persistence_set_color("bg_color", color);
6164 }
6265
6366 void
@@ -65,15 +68,15 @@ attributes_swap_fgbg(void)
6568 {
6669 Color temp;
6770 temp = attributes_foreground;
68- attributes_foreground = attributes_background;
69- attributes_background = temp;
71+ attributes_set_foreground(&attributes_background);
72+ attributes_set_background(&temp);
7073 }
7174
7275 void
7376 attributes_default_fgbg(void)
7477 {
75- attributes_foreground = color_black;
76- attributes_background = color_white;
78+ attributes_set_foreground(&color_black);
79+ attributes_set_background(&color_white);
7780 }
7881
7982 real
@@ -86,6 +89,7 @@ void
8689 attributes_set_default_linewidth(real width)
8790 {
8891 attributes_default_linewidth = width;
92+ persistence_set_real("linewidth", width);
8993 }
9094
9195 Arrow