summaryrefslogtreecommitdiff
path: root/fluid/Fl_Widget_Type.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2022-12-10 23:22:24 +0100
committerGitHub <noreply@github.com>2022-12-10 23:22:24 +0100
commita5adbd99ca073ecb9d6153b089543b23a673c9b5 (patch)
tree0e1bdebff56e5e0b23369b91b68a90fa42da4f65 /fluid/Fl_Widget_Type.cxx
parent8dcd121d44f1b5041c83081277e2633745fa376d (diff)
Add option to bind images to a widget (#589)
Adding image binding to FLUID as well
Diffstat (limited to 'fluid/Fl_Widget_Type.cxx')
-rw-r--r--fluid/Fl_Widget_Type.cxx52
1 files changed, 50 insertions, 2 deletions
diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx
index cafd56ea4..ffa9b1803 100644
--- a/fluid/Fl_Widget_Type.cxx
+++ b/fluid/Fl_Widget_Type.cxx
@@ -210,6 +210,8 @@ Fl_Widget_Type::Fl_Widget_Type() {
xclass = 0;
o = 0;
public_ = 1;
+ bind_image_ = 0;
+ bind_deimage_ = 0;
}
Fl_Widget_Type::~Fl_Widget_Type() {
@@ -475,6 +477,26 @@ void image_browse_cb(Fl_Button* b, void *v) {
}
}
+void bind_image_cb(Fl_Button* b, void *v) {
+ if (v == LOAD) {
+ if (current_widget->is_widget() && !current_widget->is_window()) {
+ b->activate();
+ b->value(current_widget->bind_image_);
+ } else {
+ b->deactivate();
+ }
+ } else {
+ int mod = 0;
+ for (Fl_Type *o = Fl_Type::first; o; o = o->next) {
+ if (o->selected && o->is_widget()) {
+ ((Fl_Widget_Type*)o)->bind_image_ = b->value();
+ mod = 1;
+ }
+ }
+ if (mod) set_modflag(1);
+ }
+}
+
static Fl_Input *inactive_input;
void inactive_cb(Fl_Input* i, void *v) {
@@ -517,6 +539,26 @@ void inactive_browse_cb(Fl_Button* b, void *v) {
}
}
+void bind_deimage_cb(Fl_Button* b, void *v) {
+ if (v == LOAD) {
+ if (current_widget->is_widget() && !current_widget->is_window()) {
+ b->activate();
+ b->value(current_widget->bind_deimage_);
+ } else {
+ b->deactivate();
+ }
+ } else {
+ int mod = 0;
+ for (Fl_Type *o = Fl_Type::first; o; o = o->next) {
+ if (o->selected && o->is_widget()) {
+ ((Fl_Widget_Type*)o)->bind_deimage_ = b->value();
+ mod = 1;
+ }
+ }
+ if (mod) set_modflag(1);
+ }
+}
+
void tooltip_cb(Fl_Input* i, void *v) {
if (v == LOAD) {
if (current_widget->is_widget()) {
@@ -2917,8 +2959,8 @@ void Fl_Widget_Type::write_widget_code() {
write_color("color", o->color());
if (o->selection_color() != tplate->selection_color() || subclass())
write_color("selection_color", o->selection_color());
- if (image) image->write_code(var);
- if (inactive) inactive->write_code(var, 1);
+ if (image) image->write_code(bind_image_, var);
+ if (inactive) inactive->write_code(bind_deimage_, var, 1);
if (o->labeltype() != tplate->labeltype() || subclass())
write_c("%s%s->labeltype(FL_%s);\n", indent(), var,
item_name(labeltypemenu, o->labeltype()));
@@ -3044,10 +3086,12 @@ void Fl_Widget_Type::write_properties() {
write_string("image");
write_word(image_name());
}
+ if (bind_image_) write_string("bind_image 1");
if (inactive_name() && *inactive_name()) {
write_string("deimage");
write_word(inactive_name());
}
+ if (bind_deimage_) write_string("bind_deimage 1");
write_string("xywh {%d %d %d %d}", o->x(), o->y(), o->w(), o->h());
Fl_Widget* tplate = ((Fl_Widget_Type*)factory)->o;
if (is_spinner() && ((Fl_Spinner*)o)->type() != ((Fl_Spinner*)tplate)->type()) {
@@ -3168,8 +3212,12 @@ void Fl_Widget_Type::read_property(const char *c) {
tooltip(read_word());
} else if (!strcmp(c,"image")) {
image_name(read_word());
+ } else if (!strcmp(c,"bind_image")) {
+ bind_image_ = (int)atol(read_word());
} else if (!strcmp(c,"deimage")) {
inactive_name(read_word());
+ } else if (!strcmp(c,"bind_deimage")) {
+ bind_deimage_ = (int)atol(read_word());
} else if (!strcmp(c,"type")) {
if (is_spinner())
((Fl_Spinner*)o)->type(item_number(subtypes(), read_word()));