void DisclosureTriangleButton::OnPointerReleased(const PointerPoint& pointerPoint) { if (!isEnabled) { return; } isOn = !isOn; Toggled(isOn); }
void SwitchShadowNode::createView() { Super::createView(); auto toggleSwitch = GetView().as<winrt::ToggleSwitch>(); auto wkinstance = GetViewManager()->GetReactInstance(); toggleSwitch.Toggled([=](auto&&, auto&&) { auto instance = wkinstance.lock(); if (!m_updating && instance != nullptr) OnToggled(*instance, m_tag, toggleSwitch.IsOn()); }); }
void NamedCheckBox::ButtonToggled(bool checked) { emit Toggled(checked, objectName()); }
void ShipCtrl::ExecFrame(double seconds) { Starshatter* stars = Starshatter::GetInstance(); if (stars && stars->GetChatMode()) return; if (!ship) return; const int DELTA_THROTTLE = 5; controller->Acquire(); if (ship->IsStarship() && ship->GetFLCSMode() == Ship::FLCS_HELM) { ship->ApplyHelmPitch(controller->Pitch() * seconds); ship->ApplyHelmYaw(controller->Yaw() * seconds); } else { ship->ApplyRoll(controller->Roll()); ship->ApplyPitch(controller->Pitch()); ship->ApplyYaw(controller->Yaw()); } ship->SetTransX(controller->X() * ship->Design()->trans_x); ship->SetTransY(controller->Y() * ship->Design()->trans_y); ship->SetTransZ(controller->Z() * ship->Design()->trans_z); bool augmenter = false; if (controller->Throttle() > 0.05) { if (throttle_active) { ship->SetThrottle(controller->Throttle() * 100); if (controller->Throttle() >= 0.99) augmenter = true; } else if (!launch_latch || controller->Throttle() > 0.5) { throttle_active = true; launch_latch = false; } } else if (throttle_active) { ship->SetThrottle(0); throttle_active = false; } ship->ExecFLCSFrame(); static double time_til_change = 0.0; if (time_til_change < 0.001) { if (KeyDown(KEY_THROTTLE_UP)) { ship->SetThrottle(ship->Throttle() + DELTA_THROTTLE); time_til_change = 0.05; } else if (KeyDown(KEY_THROTTLE_DOWN)) { ship->SetThrottle(ship->Throttle() - DELTA_THROTTLE); time_til_change = 0.05; } else if (KeyDown(KEY_THROTTLE_ZERO)) { ship->SetThrottle(0); if (ship->GetFLCS()) ship->GetFLCS()->FullStop(); time_til_change = 0.05; } else if (KeyDown(KEY_THROTTLE_FULL)) { ship->SetThrottle(100); time_til_change = 0.05; } else if (KeyDown(KEY_FLCS_MODE_AUTO)) { ship->CycleFLCSMode(); time_til_change = 0.5f; } else if (KeyDown(KEY_CYCLE_PRIMARY)) { HUDSounds::PlaySound(HUDSounds::SND_WEP_MODE); ship->CyclePrimary(); time_til_change = 0.5f; } else if (KeyDown(KEY_CYCLE_SECONDARY)) { HUDSounds::PlaySound(HUDSounds::SND_WEP_MODE); ship->CycleSecondary(); time_til_change = 0.5f; } if (ship->GetShield()) { Shield* shield = ship->GetShield(); double level = shield->GetPowerLevel(); if (KeyDown(KEY_SHIELDS_FULL)) { HUDSounds::PlaySound(HUDSounds::SND_SHIELD_LEVEL); shield->SetPowerLevel(100); time_til_change = 0.5f; } else if (KeyDown(KEY_SHIELDS_ZERO)) { HUDSounds::PlaySound(HUDSounds::SND_SHIELD_LEVEL); shield->SetPowerLevel(0); time_til_change = 0.5f; } else if (KeyDown(KEY_SHIELDS_UP)) { if (level < 25) level = 25; else if (level < 50) level = 50; else if (level < 75) level = 75; else level = 100; HUDSounds::PlaySound(HUDSounds::SND_SHIELD_LEVEL); shield->SetPowerLevel(level); time_til_change = 0.5f; } else if (KeyDown(KEY_SHIELDS_DOWN)) { if (level > 75) level = 75; else if (level > 50) level = 50; else if (level > 25) level = 25; else level = 0; HUDSounds::PlaySound(HUDSounds::SND_SHIELD_LEVEL); shield->SetPowerLevel(level); time_til_change = 0.5f; } } if (ship->GetSensor()) { Sensor* sensor = ship->GetSensor(); if (sensor->GetMode() < Sensor::PST) { if (KeyDown(KEY_SENSOR_MODE)) { int sensor_mode = sensor->GetMode() + 1; if (sensor_mode > Sensor::GM) sensor_mode = Sensor::PAS; sensor->SetMode((Sensor::Mode) sensor_mode); time_til_change = 0.5f; } else if (KeyDown(KEY_SENSOR_GROUND_MODE)) { if (ship->IsAirborne()) { sensor->SetMode(Sensor::GM); time_til_change = 0.5f; } } } else { // manual "return to search" command for starships: if (KeyDown(KEY_SENSOR_MODE)) { ship->DropTarget(); } } if (KeyDown(KEY_SENSOR_RANGE_PLUS)) { sensor->IncreaseRange(); time_til_change = 0.5f; } else if (KeyDown(KEY_SENSOR_RANGE_MINUS)) { sensor->DecreaseRange(); time_til_change = 0.5f; } } if (KeyDown(KEY_EMCON_PLUS)) { ship->SetEMCON(ship->GetEMCON()+1); time_til_change = 0.5f; } else if (KeyDown(KEY_EMCON_MINUS)) { ship->SetEMCON(ship->GetEMCON()-1); time_til_change = 0.5f; } } else time_til_change -= seconds; if (controller->ActionMap(KEY_ACTION_0)) ship->FirePrimary(); if (controller->ActionMap(KEY_ACTION_1)) { if (!pickle_latch) ship->FireSecondary(); pickle_latch = true; } else { pickle_latch = false; } if (controller->ActionMap(KEY_ACTION_3)) { if (!target_latch) ship->LockTarget(SimObject::SIM_SHIP); target_latch = true; } else { target_latch = false; } ship->SetAugmenter(augmenter || (KeyDown(KEY_AUGMENTER) ? true : false)); if (Toggled(KEY_DECOY)) ship->FireDecoy(); if (Toggled(KEY_LAUNCH_PROBE)) ship->LaunchProbe(); if (Toggled(KEY_GEAR_TOGGLE)) ship->ToggleGear(); if (Toggled(KEY_NAVLIGHT_TOGGLE)) ship->ToggleNavlights(); if (Toggled(KEY_LOCK_TARGET)) ship->LockTarget(SimObject::SIM_SHIP, false, true); else if (Toggled(KEY_LOCK_THREAT)) ship->LockTarget(SimObject::SIM_DRONE); else if (Toggled(KEY_LOCK_CLOSEST_SHIP)) ship->LockTarget(SimObject::SIM_SHIP, true, false); else if (Toggled(KEY_LOCK_CLOSEST_THREAT)) ship->LockTarget(SimObject::SIM_DRONE, true, false); else if (Toggled(KEY_LOCK_HOSTILE_SHIP)) ship->LockTarget(SimObject::SIM_SHIP, true, true); else if (Toggled(KEY_LOCK_HOSTILE_THREAT)) ship->LockTarget(SimObject::SIM_DRONE, true, true); else if (Toggled(KEY_CYCLE_SUBTARGET)) ship->CycleSubTarget(1); else if (Toggled(KEY_PREV_SUBTARGET)) ship->CycleSubTarget(-1); if (Toggled(KEY_AUTO_NAV)) { ship->SetAutoNav(true); // careful: this object has just been deleted! return; } if (Toggled(KEY_DROP_ORBIT)) { ship->DropOrbit(); // careful: this object has just been deleted! return; } }
static gboolean expose(GtkWidget *widget, GdkEventExpose *event, void *t) { #if GTK_CHECK_VERSION(2,14,0) GdkWindow *window = gtk_widget_get_window(widget); #else GdkWindow *window = widget->window; #endif cairo_t *cr = gdk_cairo_create(window); if(!pixmap_terminal) { // Rebuild pixmap gint width; gint height; gdk_drawable_get_size(window,&width,&height); pixmap_terminal = gdk_pixmap_new(window,width,height,-1); g_object_set_data_full(G_OBJECT(pixmap_terminal),"cached_gc",gdk_gc_new(GDK_DRAWABLE(pixmap_terminal)),g_object_unref); update_terminal_contents(); } gdk_cairo_set_source_pixmap(cr, pixmap_terminal, 0, 0); gdk_cairo_rectangle(cr, &event->area); cairo_fill(cr); if((cMode & CURSOR_MODE_ENABLED)) { if(!get_cursor_pixmap()) { pixmap_cursor = gdk_pixmap_new(window,rCursor.width,rCursor.height,-1); update_cursor_pixmap(); } if( (cMode & (CURSOR_MODE_BASE|CURSOR_MODE_SHOW)) == (CURSOR_MODE_BASE|CURSOR_MODE_SHOW) ) { gdk_cairo_set_source_pixmap(cr, get_cursor_pixmap(), rCursor.x, rCursor.y); if(Toggled(INSERT)) cairo_rectangle(cr, rCursor.x, rCursor.y, rCursor.width, rCursor.height); else cairo_rectangle(cr, rCursor.x, rCursor.y+terminal_font_info.ascent, rCursor.width, terminal_font_info.descent); cairo_fill(cr); /* GtkStyle *style = gtk_widget_get_style(widget); gdk_draw_drawable( widget->window, style->fg_gc[GTK_STATE_NORMAL], GDK_DRAWABLE(get_cursor_pixmap()), 0,0, rCursor.x,rCursor.y, rCursor.width,rCursor.height); */ } if(cMode & CURSOR_MODE_CROSS) { // Draw cross-hair cursor int width; int height; gdk_drawable_get_size(window,&width,&height); gdk_cairo_set_source_color(cr,color+TERMINAL_COLOR_CROSS_HAIR); cairo_rectangle(cr, rCursor.x, 0, 1, view.top+2+(terminal_font_info.spacing*view.rows)); cairo_rectangle(cr, 0, rCursor.y+fontAscent, width,1); cairo_fill(cr); } } cairo_destroy(cr); return 0; }