bool ctrlScrollBar::Msg_LeftDown(const MouseCoords& mc) { if (Coll(mc.x, mc.y, GetX(), GetY() + button_height + scrollbar_pos, width_, scrollbar_height)) { // Maus auf dem Scrollbutton move = true; return true; } else if (Coll(mc.x, mc.y, GetX(), GetY(), width_, button_height) || Coll(mc.x, mc.y, GetX(), GetY() + height_ - button_height, width_, button_height)) { // Maus auf einer Schaltflaeche return RelayMouseMessage(&Window::Msg_LeftDown, mc); } else { // Maus auf der Leiste unsigned short diff = scrollbar_height / 2; if (Coll(mc.x, mc.y, GetX(), GetY() + button_height, width_, scrollbar_pos)) { if (scrollbar_pos < diff) scrollbar_pos = 0; else scrollbar_pos -= diff; CalculatePosition(); parent_->Msg_ScrollChange(id_, scroll_pos); return true; } else { unsigned short sbb = button_height + scrollbar_pos + scrollbar_height; if (Coll(mc.x, mc.y, GetX(), GetY() + sbb, width_, height_ - (sbb + button_height))) { scrollbar_pos += diff; if (scrollbar_pos > (scroll_height - scrollbar_height)) scrollbar_pos = scroll_height - scrollbar_height; CalculatePosition(); parent_->Msg_ScrollChange(id_, scroll_pos); return true; } } } return false; }
/* ======================== idMenuWidget_ScrollBar::HandleAction ======================== */ bool idMenuWidget_ScrollBar::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) { widgetAction_t actionType = action.GetType(); switch ( actionType ) { case WIDGET_ACTION_SCROLL_DRAG: { if ( event.parms.Num() != 3 ) { return true; } dragging = true; float x = event.parms[0].ToFloat(); float y = event.parms[1].ToFloat(); bool initial = event.parms[2].ToBool(); if ( initial ) { CalcTopAndBottom(); } CalculatePosition( x, y ); return true; } case WIDGET_ACTION_EVENT_DRAG_STOP: { dragging = false; return true; } } return idMenuWidget::HandleAction( action, event, widget, forceHandled ); }
void MythUIProgressBar::Reset() { m_total = m_start = m_current = 0; CalculatePosition(); emit DependChanged(false); MythUIType::Reset(); }
void MayaCamera::OnUpdate(TimeStep timeStep) { const Application& app = Application::GetApplication(); if (app.IsKeyPressed(GLFW_KEY_LEFT_ALT)) { const vec2& mouse = app.GetMousePos(); vec2 delta = mouse - m_InitialMousePosition; m_InitialMousePosition = mouse; if (app.GetMouseButton() == GLFW_MOUSE_BUTTON_MIDDLE) MousePan(delta); else if (app.GetMouseButton() == GLFW_MOUSE_BUTTON_LEFT) MouseRotate(delta); else if (app.GetMouseButton() == GLFW_MOUSE_BUTTON_RIGHT) MouseZoom(delta.y); } // MouseZoom(window->GetMouseScrollPosition().y); m_Position = CalculatePosition(); Quaternion orientation = GetOrientation(); m_Rotation = orientation.ToEulerAngles() * (180.0f / 3.14f); m_View = mat4::Translate(vec3(0, 0, 1)) * mat4::Rotate(orientation.Conjugate()) * mat4::Translate(-m_Position); }
void MythUIScrollBar::Finalize() { MythUIType *slider = GetChild("slider"); if (slider) m_sliderArea = slider->GetArea(); CalculatePosition(); }
void CChildView::OnTimer(UINT_PTR nIDEvent) { // TODO: 在此添加消息处理程序代码和/或调用默认值 CalculatePosition(); this -> Invalidate(); this -> Invalidate(false); CWnd::OnTimer(nIDEvent); }
void MainScene::CreateMenu() { if(_menu == NULL) { CCSize scrSize = CCDirector::sharedDirector()->getWinSize(); _menu = CCMenu::create(); _menu->setPosition(ccp(0,0)); addChild(_menu); CCMenuItemFont* pItem; CCPoint position; // Create the next/back menu items. for(int page = 0; page < MENU_PAGES; page++) { // Create the Back/Forward buttons for the page. // Back arrow if there is a previous page. if(page > 0) { pItem = CCMenuItemFont::create("Back", this, menu_selector(MainScene::MenuCallback)); pItem->setTag(ARROW_LEFT); position = ccp(page*scrSize.width + scrSize.width*0.1,scrSize.height*0.1); pItem->setPosition(position); pItem->setFontSize(35); pItem->setFontName("Arial"); _menu->addChild(pItem); } if(page < (MENU_PAGES-1)) { pItem = CCMenuItemFont::create("Next", this, menu_selector(MainScene::MenuCallback)); pItem->setTag(ARROW_RIGHT); position = ccp(page*scrSize.width + scrSize.width*0.9,scrSize.height*0.1); pItem->setPosition(position); pItem->setFontSize(35); pItem->setFontName("Arial"); _menu->addChild(pItem); } } // Create the actual items for(int idx = 0; idx < MENU_ITEMS_TOTAL; idx++) { char buffer[256]; sprintf(buffer,"Item #%d",idx); pItem = CCMenuItemFont::create(buffer, this, menu_selector(MainScene::MenuCallback)); pItem->setFontSize(35); pItem->setFontName("Arial"); pItem->setTag(idx); position = CalculatePosition(idx); pItem->setPosition(position); _menu->addChild(pItem); } } }
void MythUIScrollBar::Reset() { m_pageStep = kDefaultPageStep; m_sliderPosition = 0; m_maximum = kDefaultMaxValue; CalculatePosition(); MythUIType::Reset(); }
// {{{ void PropertyTipWindow::Popup(wxWindow *focus) void PropertyTipWindow::Popup(wxWindow *focus) { wxPopupTransientWindow::Popup(focus); CaptureMouse(); Position(CalculatePosition(), wxSize(0, 0)); /* We have to call RecalcSizes() explicitly here to avoid wxGTK * breakage. */ GetSizer()->RecalcSizes(); }
void CalculatePSJF() { struct ListNode *temp=front; int totaltime=0; int total=0; float totalwaitingtime=0; float totalturnaroundtime =0; while(!JobFinished()) { struct ListNode *temptemp = front; int pos = CalculatePosition(totaltime); if(pos<0) { printf("Encountered some error while calculating."); exit(-3); } AddWaitingToRest(pos,totaltime); while(pos--) { temptemp= temptemp->next; //Takes the pointer to the right position } temptemp->rembt -= 1; totaltime += 1; if(temptemp->rembt == 0) { temptemp->tt = totaltime - temptemp->at; } DisplayQueue(); printf("Is job finished? %d\n",JobFinished()); } DisplayQueue(); total = LengthofQueue(); temp = front; while(temp) { totalwaitingtime += temp->wt; totalturnaroundtime += temp->tt; temp = temp->next; } printf("Average Waiting time is: %f \n",totalwaitingtime/total ); printf("Average Turnaround time is: %f \n",totalturnaroundtime/total ); }
void MythUIScrollBar::SetMaximum(int value) { if (value - 1 == m_maximum) return; if (value < 1) value = 1; m_maximum = value - 1; CalculatePosition(); }
void MythUIScrollBar::SetPageStep(int value) { if (value == m_pageStep) return; if (value < 1) value = kDefaultPageStep; m_pageStep = value; CalculatePosition(); }
void Physics::Update(float dt) { for (auto object : ObjectManager::GetInstance().GetObjects()) { auto bodyComponent = object.second->has(Body); if (bodyComponent != nullptr) { CalculatePosition(*object.second); } } }
void MythUIProgressBar::SetUsed(int value) { if (value < m_start) value = m_start; if (value > m_total) value = m_total; m_current = value; CalculatePosition(); }
QRectF Breakpoints::pointBoundingRect(std::map<ElVisFloat, ColorMapBreakpoint>::const_iterator iter) const { qreal w = m_pointSize.width(); qreal h = m_pointSize.height(); double x, y; CalculatePosition((*iter).first, (*iter).second.Col.Alpha(), x, y); x -= w/2.0; y -= h/2.0; return QRectF(x, y, w, h); }
void MythUIScrollBar::SetSliderPosition(int value) { if (value == m_sliderPosition) return; if (value < 0) value = 0; if (value > m_maximum) value = m_maximum; m_sliderPosition = value; CalculatePosition(); }
void SmartCamera::Update() { if (tracking_mode == SF_TRACK_KEYS_PRESS) HandleTrackKeysPress(); else if (tracking_mode == SF_TRACK_MOUSE_CLICKDRAG) click_drag_initial_position = sf::Vector2f(sf::Mouse::getPosition()); else if (tracking_mode == SF_TRACK_MOUSE_EDGE) HandleTrackMouseEdge(); if (need_update) CalculatePosition(); }
///--------------------------------------------------------------------------------- /// ///--------------------------------------------------------------------------------- Image::Image( OpenGLRenderer* renderer, UIElement* parent, Texture* image, const Vector2& size, Anchor anchor /* = BOTTOM_LEFT */, const Vector2& offset /* = Vector2::ZERO */, const float& zVal /* = 1.0f */ ) : UIElement( renderer, parent ) , m_image( image ) { m_zVal = zVal; m_anchor = anchor; m_offset = offset; m_size = size; Vector2 mins = CalculatePosition(); m_bounds.m_mins = mins; m_bounds.m_maxs = mins + m_size; CalcVerts(); }
bool ctrlScrollBar::Msg_MouseMove(const MouseCoords& mc) { if(move) { scrollbar_pos += (mc.y - last_y); if(scrollbar_pos + scrollbar_height > scroll_height) scrollbar_pos = ((mc.y - last_y) < 0 ? 0 : (scroll_height - scrollbar_height)); CalculatePosition(); if(scroll_pos > scroll_range - pagesize) scroll_pos = scroll_range - pagesize; parent_->Msg_ScrollChange(id_, scroll_pos); } last_y = mc.y; // ButtonMessages weiterleiten return RelayMouseMessage(&Window::Msg_MouseMove, mc); }
///--------------------------------------------------------------------------------- /// ///--------------------------------------------------------------------------------- ProgressBar::ProgressBar( OpenGLRenderer* renderer, UIElement* parent, const IntRange& values, Font* font, const Vector2& size, const Rgba& backgroundColor, const Rgba& foregroundColor, Anchor anchor /* = BOTTOM_LEFT */, const Vector2& offset /* = Vector2::ZERO */, const float& zVal /* = 1.0f */, const Rgba& fontColor /* = Rgba() */ ) : UIElement( renderer, parent ) , m_fontColor( fontColor ) , m_backgroundColor( backgroundColor ) , m_foregroundColor( foregroundColor ) , m_percentage( 1.0f ) , m_values( values ) { m_zVal = zVal; m_anchor = anchor; m_offset = offset; m_size = size; Vector2 mins = CalculatePosition(); m_bounds.m_mins = mins; m_bounds.m_maxs = mins + m_size; CalcVerts(); m_textbox = new TextBox( renderer, this, font, 12, CENTER_CENTER, Vector2::ZERO, fontColor, "", zVal - 0.3f ); }
void Projectile::Update(GLfloat deltaTime) { if(fired) { CalculatePosition(deltaTime); UpdateTransformationValues(); timeSinceFired += deltaTime; collisionSphere.ApplyTransformations(transformationValues); //Makes sure we stop drawing the projectile if it's been "airborne" longer then or //equal to the constant PROJECTILE_FLYTIME if(timeSinceFired >= PROJECTILE_FLYTIME) { fired = false; timeSinceFired = 0.0f; } log << INFO << "X: " << position.getX() << " Y: " << position.getY() << " Z: " << position.getZ() << std::endl; } }
void SceneObject::MoveTo(const _3point& position) { CalculatePosition(position); }
void SceneObject::MoveZ(const _point& move) { CalculatePosition(m_Position + _3point(0.0f, 0.0f, move)); }
// Position void SceneObject::Move(const _3point& position) { CalculatePosition(m_Position + position); }
void CommandDisplayClipPropertiesDialog::ExecuteE() { EMMediaType eType(EM_TYPE_UNKNOWN); EMGClip* opClip; EMGTrack* opTrack; EMGUIUtilities* opGUIUtilities = EMGUIUtilities::Instance(); EMCommandRepository* opRepository = EMCommandRepository::Instance(); int32 vClipID(0); int32 vEntryID(-1); int64 vValue(0); int32 vX(0); int32 vY(0); string oFileName; char vTemp[100]; list<EMGClip*>* opClips = EMGClipRepository::Instance() -> GetSelectedClips(); list<EMGClip*>::iterator oClipIterator = opClips -> begin(); if(opClips -> size() == 0) return; while(oClipIterator != opClips -> end()) { opClip = *oClipIterator; eType = opClip -> GetType(); opTrack = opClip -> GetTrack(); switch(eType) { case EM_TYPE_ANY_AUDIO: vClipID = opClip ->GetMediaClipID(); vEntryID = *static_cast<int32*>(opRepository -> ExecuteCommand(MEDIA_INFO_COMMAND_GET_CLIP_ENTRY_ID, &vClipID, NULL, NULL)); m_oAudioDialog.SetNameValue(opClip -> GetLabel()); m_oAudioDialog.SetTypeValue("Audio"); m_oAudioDialog.SetBeginValue(opGUIUtilities -> GetTimeString(opClip -> GetPosition(), EM_SMPTE)); m_oAudioDialog.SetEndValue(opGUIUtilities -> GetTimeString(opClip -> GetPosition() + opClip -> GetLength(), EM_SMPTE)); m_oAudioDialog.SetDurationValue(opGUIUtilities -> GetTimeString(opClip -> GetLength(), EM_SMPTE)); vValue = *static_cast<int64*>(opRepository -> ExecuteCommand(MEDIA_INFO_COMMAND_GET_AUDIO_ENTRY_NUM_CHANNELS, &vEntryID)); m_oAudioDialog.SetChannelsValue(_i64toa(vValue, vTemp, 10)); vValue = *static_cast<int64*>(opRepository -> ExecuteCommand(MEDIA_INFO_COMMAND_GET_AUDIO_ENTRY_NUM_SAMPLES, &vEntryID)); m_oAudioDialog.SetSamplesValue(_i64toa(vValue, vTemp, 10)); oFileName = static_cast<const char*>(EMCommandRepository::Instance() -> ExecuteCommand(MEDIA_INFO_COMMAND_GET_ENTRY_FILENAME, &vEntryID)); //Full path to copied file oFileName.erase(0, oFileName.find_last_of('\\') + 1); //oFileName.erase(oFileName.find_last_of('.')); m_oAudioDialog.SetFileValue(oFileName); vValue = *static_cast<int64*>(opRepository -> ExecuteCommand(MEDIA_INFO_COMMAND_GET_ENTRY_DURATION, &vEntryID)); m_oAudioDialog.SetFileLengthValue(opGUIUtilities -> GetTimeString(vValue, EM_SMPTE)); vValue = *static_cast<int64*>(opRepository -> ExecuteCommand(MEDIA_INFO_COMMAND_GET_CLIP_MARK_IN, &vClipID)); m_oAudioDialog.SetMarkInValue(opGUIUtilities -> GetTimeString(vValue, EM_SMPTE)); vValue = *static_cast<int64*>(opRepository -> ExecuteCommand(MEDIA_INFO_COMMAND_GET_CLIP_MARK_OUT, &vClipID)); m_oAudioDialog.SetMarkOutValue(opGUIUtilities -> GetTimeString(vValue, EM_SMPTE)); m_oAudioDialog.Init(vX, vY, AUDIO); CalculatePosition(vX, vY, opClip, opTrack -> GetTrackInfo(), &m_oAudioDialog); m_oAudioDialog.MoveDialog(vX, vY); m_oAudioDialog.DisplayDialog(); break; case EM_TYPE_MIDI: { char vTemp[100]; uint32 vEvents(0); m_oMidiDialog.SetNameValue(opClip -> GetLabel()); m_oMidiDialog.SetTypeValue("Midi"); m_oMidiDialog.SetBeginValue(opGUIUtilities -> GetTimeString(opClip -> GetPosition(), EM_MEASURES)); m_oMidiDialog.SetEndValue(opGUIUtilities -> GetTimeString(opClip -> GetPosition() + opClip -> GetLength(), EM_MEASURES)); m_oMidiDialog.SetDurationValue(opGUIUtilities -> GetTimeString(opClip -> GetLength(), EM_MEASURES)); int32 vMediaClipID(opClip ->GetMediaClipID()); vEvents = (static_cast<list<EMMediaMIDIEvent*>*>(EMCommandRepository::Instance() -> ExecuteCommand(MEDIA_INFO_COMMAND_GET_MIDI_EVENTS_FOR_CLIP, &vMediaClipID, NULL, NULL))) -> size(); m_oMidiDialog.SetEventValue(string(itoa(vEvents, vTemp, 10))); m_oMidiDialog.Init(vX, vY, MIDI); CalculatePosition(vX, vY, opClip, opTrack -> GetTrackInfo(), &m_oMidiDialog); m_oMidiDialog.MoveDialog(vX, vY); m_oMidiDialog.DisplayDialog(); break; } case EM_TYPE_ANY_VIDEO: vClipID = opClip ->GetMediaClipID(); vEntryID = *static_cast<int32*>(opRepository -> ExecuteCommand(MEDIA_INFO_COMMAND_GET_CLIP_ENTRY_ID, &vClipID, NULL, NULL)); m_oVideoDialog.SetNameValue(opClip -> GetLabel()); m_oVideoDialog.SetTypeValue("Video"); m_oVideoDialog.SetBeginValue(opGUIUtilities -> GetTimeString(opClip -> GetPosition(), EM_SMPTE)); m_oVideoDialog.SetEndValue(opGUIUtilities -> GetTimeString(opClip -> GetPosition() + opClip -> GetLength(), EM_SMPTE)); m_oVideoDialog.SetDurationValue(opGUIUtilities -> GetTimeString(opClip -> GetLength(), EM_SMPTE)); // vValue = *static_cast<int64*>(opRepository -> ExecuteCommand(MEDIA_INFO_COMMAND_GET_VIDEO_ENTRY_NUM_FRAMES, &vEntryID)); // m_oVideoDialog.SetSamplesValue(_i64toa(vValue, vTemp, 10)); oFileName = static_cast<const char*>(EMCommandRepository::Instance() -> ExecuteCommand(MEDIA_INFO_COMMAND_GET_ENTRY_FILENAME, &vEntryID)); //Full path to copied file oFileName.erase(0, oFileName.find_last_of('\\') + 1); //oFileName.erase(oFileName.find_last_of('.')); m_oVideoDialog.SetFileValue(oFileName); m_oVideoDialog.SetDimentionValue(static_cast<const char*>(opRepository -> ExecuteCommand(MEDIA_INFO_COMMAND_GET_VIDEO_DIMENSION, &vEntryID))); vValue = *static_cast<int64*>(opRepository -> ExecuteCommand(MEDIA_INFO_COMMAND_GET_ENTRY_DURATION, &vEntryID)); m_oVideoDialog.SetFileLengthValue(opGUIUtilities -> GetTimeString(vValue, EM_SMPTE)); vValue = *static_cast<int64*>(opRepository -> ExecuteCommand(MEDIA_INFO_COMMAND_GET_CLIP_MARK_IN, &vClipID)); m_oVideoDialog.SetMarkInValue(opGUIUtilities -> GetTimeString(vValue, EM_SMPTE)); vValue = *static_cast<int64*>(opRepository -> ExecuteCommand(MEDIA_INFO_COMMAND_GET_CLIP_MARK_OUT, &vClipID)); m_oVideoDialog.SetMarkOutValue(opGUIUtilities -> GetTimeString(vValue, EM_SMPTE)); m_oVideoDialog.Init(vX, vY, VIDEO); CalculatePosition(vX, vY, opClip, opTrack -> GetTrackInfo(), &m_oVideoDialog); m_oVideoDialog.MoveDialog(vX, vY); m_oVideoDialog.DisplayDialog(); break; case EM_TYPE_TRANSITION: vClipID = opClip ->GetMediaClipID(); // vEntryID = *static_cast<int32*>(opRepository -> ExecuteCommand(MEDIA_INFO_COMMAND_GET_CLIP_ENTRY_ID, &vClipID, NULL, NULL)); m_oTransitionDialog.SetNameValue(opClip -> GetLabel()); m_oTransitionDialog.SetTypeValue("Transition"); m_oTransitionDialog.SetBeginValue(opGUIUtilities -> GetTimeString(opClip -> GetPosition(), EM_SMPTE)); m_oTransitionDialog.SetEndValue(opGUIUtilities -> GetTimeString(opClip -> GetPosition() + opClip -> GetLength(), EM_SMPTE)); m_oTransitionDialog.SetDurationValue(opGUIUtilities -> GetTimeString(opClip -> GetLength(), EM_SMPTE)); m_oTransitionDialog.Init(vX, vY, TRANSITION); CalculatePosition(vX, vY, opClip, opTrack -> GetTrackInfo(), &m_oTransitionDialog); m_oTransitionDialog.MoveDialog(vX, vY); m_oTransitionDialog.DisplayDialog(); break; } vX = 0; vY = 0; oClipIterator++; } }
void MythUIProgressBar::Reset() { m_total = m_start = m_current = 0; CalculatePosition(); MythUIType::Reset(); }
void Breakpoints::paintPoints() { const std::map<ElVisFloat, ColorMapBreakpoint>& breakpoints = m_model->GetBreakpoints(); if( breakpoints.size() == 0) return; QPainter p; p.begin(m_widget); p.setRenderHint(QPainter::Antialiasing); p.setPen(m_connectionPen); QPainterPath path; typedef std::map<ElVisFloat, ColorMapBreakpoint>::const_iterator IterType; IterType iter = breakpoints.begin(); double px = (*iter).first; double py = (*iter).second.Col.Alpha(); double x,y; CalculatePosition(px, py, x, y); path.moveTo( x, y ); for( ; iter != breakpoints.end(); ++iter) { px = (*iter).first; py = (*iter).second.Col.Alpha(); CalculatePosition(px, py, x, y); path.lineTo(x, y); } p.drawPath(path); p.setPen(m_pointPen); p.setBrush(m_pointBrush); for(iter = breakpoints.begin() ; iter != breakpoints.end(); ++iter) { if( iter == m_selectedBreakpoint ) { p.setPen(m_selectedPointPen); } else { p.setPen(m_pointPen); } QRectF bounds = pointBoundingRect(iter); p.drawEllipse(bounds); } //if (m_connectionPen.style() != Qt::NoPen && m_connectionType != NoConnection) //{ // p.setPen(m_connectionPen); // QPainterPath path; // path.moveTo(m_points.at(0)); // for (int i=1; i<m_points.size(); ++i) { // path.lineTo(m_points.at(i)); // } // p.drawPath(path); //} //p.setPen(m_pointPen); //p.setBrush(m_pointBrush); //for (int i=0; i<m_points.size(); ++i) //{ // if( i == m_currentIndex ) continue; // QRectF bounds = pointBoundingRect(i); // p.drawEllipse(bounds); //} //if( m_currentIndex >= 0 && m_currentIndex < m_points.size() ) //{ // p.setPen(m_selectedPointPen); // QRectF bounds = pointBoundingRect(m_currentIndex); // p.drawEllipse(bounds); //} }
void MythUIProgressBar::SetTotal(int value) { m_total = value; CalculatePosition(); }
void MythUIProgressBar::Finalize() { CalculatePosition(); }
void MythUIProgressBar::SetStart(int value) { m_start = value; CalculatePosition(); }