void CheckBox::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { RID ci = get_canvas_item(); Ref<Texture> on = Control::get_icon(is_radio() ? "radio_checked" : "checked"); Ref<Texture> off = Control::get_icon(is_radio() ? "radio_unchecked" : "unchecked"); Vector2 ofs; ofs.x = 0; ofs.y = int((get_size().height - on->get_height()) / 2); if (is_pressed()) on->draw(ci, ofs); else off->draw(ci, ofs); } }
void CheckBox::_notification(int p_what) { if (p_what == NOTIFICATION_THEME_CHANGED) { _set_internal_margin(MARGIN_LEFT, get_icon_size().width); } else if (p_what == NOTIFICATION_DRAW) { RID ci = get_canvas_item(); Ref<Texture> on = Control::get_icon(is_radio() ? "radio_checked" : "checked"); Ref<Texture> off = Control::get_icon(is_radio() ? "radio_unchecked" : "unchecked"); Ref<StyleBox> sb = get_stylebox("normal"); Vector2 ofs; ofs.x = sb->get_margin(MARGIN_LEFT); ofs.y = int((get_size().height - get_icon_size().height) / 2); if (is_pressed()) on->draw(ci, ofs); else off->draw(ci, ofs); } }