void ckvdApp::draw() { ofDisableAlphaBlending(); ofBackground(0,0,0,1.0); mClient.maybeBind(); mClient.getTexture().draw(0, 0); if (_pUI) { ofSetColor(60,60,80); ofRect(getClientWidth(), 0, SIDEBAR_WIDTH, getHeight()); ofSetColor(255,255,255); bool bVisible = _pSelectedGrabber != NULL; _pUI->getWidget("SELECTED FIXTURE")->setVisible(bVisible); _pUI->getWidget("DELETE")->setVisible(bVisible); } mClientImage.grabScreen(0, 0, getClientWidth(), getHeight()); for (auto iter = _supplies.begin(); iter != _supplies.end(); iter++) { (*iter)->clearFixtures(); } for (auto iter = _grabbers.begin(); iter != _grabbers.end(); iter++) { (*iter)->setColorFromFrame(mClientImage); (*iter)->draw(); int nSupply = (*iter)->getParameterInt("SUPPLY") - 1; if (nSupply >= 0 && nSupply < _supplies.size()) { auto fixture = (*iter)->getFixture(); // hack: switch to new protocol if supply contains a tile //if (dynamic_cast<FixtureTile*>(fixture) != NULL) // _supplies[nSupply]->switchToNewProtocol(); _supplies[nSupply]->addFixture(fixture); } } for (auto iter = _supplies.begin(); iter != _supplies.end(); iter++) { if ((*iter)->getFixtureCount() > 0) (*iter)->go(); } }
void D3D12Render::v_init() { m_viewport.Width = getClientWidth(); m_viewport.Height = getClientHeight(); m_viewport.MaxDepth = 1.0f; m_scissorRect.right = static_cast<LONG>(getClientWidth()); m_scissorRect.bottom = static_cast<LONG>(getClientHeight()); loadPipeline(); m_triangle.init(m_pD3D12Device); loadAssets(); }
void ckvdApp::setup() { ofSetWindowTitle("Streetlight // Syphon to LEDs"); mClientImage.setUseTexture(false); ofSetFrameRate(DEFAULT_FRAME_RATE); _pUI = new ofxUICanvas(getClientWidth(), 0, SIDEBAR_WIDTH, getHeight()); _pUI->setFont("GUI/Exo-Regular.ttf", true, true, false, 0.0, OFX_UI_FONT_RESOLUTION); _pUI->addWidgetDown(new ofxUILabel("SYPHON SERVER APP", OFX_UI_FONT_SMALL)); addTextInput(_pUI, "SYPHON_APP", DEFAULT_SYPHON_APP, 180); _pUI->addWidgetDown(new ofxUILabel("SYPHON SERVER NAME", OFX_UI_FONT_SMALL)); addTextInput(_pUI, "SYPHON_SERVER", DEFAULT_SYPHON_SERVER, 180); addTextInput(_pUI, "FRAME_RATE", "30", 40); _pUI->addWidgetRight(new ofxUILabel("FRAMES PER SEC", OFX_UI_FONT_SMALL)); _pUI->addSpacer(1,6)->setDrawFill(false); _pUI->addWidgetDown(new ofxUILabel("CONFIG", OFX_UI_FONT_SMALL)); _pUI->addWidgetRight(new ofxUILabelButton("LOAD", false)); _pUI->addWidgetRight(new ofxUILabelButton("SAVE", false)); _pUI->addSpacer(1,12)->setDrawFill(false); _pUI->addWidgetDown(new ofxUILabel("POWER SUPPLY ADDRESSES", OFX_UI_FONT_SMALL)); addTextInput(_pUI, "PDS_IP_0", DEFAULT_PDS_IP_0, 120); addTextInput(_pUI, "PDS_IP_6", DEFAULT_PDS_IP_6, 120, "", true); addTextInput(_pUI, "PDS_IP_1", DEFAULT_PDS_IP_1, 120); addTextInput(_pUI, "PDS_IP_7", DEFAULT_PDS_IP_7, 120, "", true); addTextInput(_pUI, "PDS_IP_2", DEFAULT_PDS_IP_2, 120); addTextInput(_pUI, "PDS_IP_8", DEFAULT_PDS_IP_8, 120, "", true); addTextInput(_pUI, "PDS_IP_3", DEFAULT_PDS_IP_3, 120); addTextInput(_pUI, "PDS_IP_9", DEFAULT_PDS_IP_9, 120, "", true); addTextInput(_pUI, "PDS_IP_4", DEFAULT_PDS_IP_4, 120); addTextInput(_pUI, "PDS_IP_10", DEFAULT_PDS_IP_10, 120, "", true); addTextInput(_pUI, "PDS_IP_5", DEFAULT_PDS_IP_5, 120); addTextInput(_pUI, "PDS_IP_11", DEFAULT_PDS_IP_11, 120, "", true); _pUI->addSpacer(1,12)->setDrawFill(false); _pUI->addWidgetDown(new ofxUILabelButton("+ PT", false)); _pUI->addWidgetRight(new ofxUILabelButton("+ TILE", false)); _pUI->addWidgetRight(new ofxUILabelButton("DELETE", false)); _pUI->addSpacer(1,12)->setDrawFill(false); _lastStaticWidget = _pUI->addWidgetDown(new ofxUILabel("SELECTED FIXTURE", OFX_UI_FONT_SMALL)); ofAddListener(_pUI->newGUIEvent, this, &ckvdApp::guiEvent); _pGrabberFont = _pUI->getFontSmall(); mClient.initialize("",""); loadSettings(); }
void CTimelineControl::_OnMouseMove( uiMouseEvent mouseEvent, int x, int y ) { if ( m_changeTimeAndValue ) { if ( m_lbuttonDown ) { if ( m_mouseActionState == k_mouseActionChangeTime ) { // drag to change time updateChangeTime( x, y ); } else if ( m_mouseActionState == k_mouseActionChangeValue ) { // drag to change value updateChangeValue( x,y ); } else { // drag m_currentTime = getTimeValue( x - OFFSET_X + m_crollX ); checkSelectTime( x, y ); } update(); } } if ( m_rbuttonDown ) { int nWidth = getClientWidth(); float timeWidth = m_lengthPixel*m_timeLength; int limitW = (int)timeWidth + OFFSET_X * 2; if ( nWidth < limitW ) { int dx = x - m_x; m_crollX -= dx; if ( m_crollX < 0 ) m_crollX = 0; else if ( nWidth + m_crollX > limitW ) { m_crollX = limitW - nWidth; } } update(); } m_x = x; m_y = y; // update cursor icon updateCursor( x, y); }
void ckvdApp::sizeToContent() { int imgW = getWidth(); int imgH = getHeight(); ofSetWindowShape(imgW, imgH); if (_pUI) { _pUI->getRect()->setX(getClientWidth()); _pUI->getRect()->setHeight(getHeight()); } }
void D3D11Render::init_camera() { //view port Information D3D11_VIEWPORT vp; ZeroMemory(&vp, sizeof(D3D11_VIEWPORT)); vp.TopLeftX = 0; vp.TopLeftY = 0; vp.MinDepth = 0.0f; vp.MaxDepth = 1.0f; vp.Width = static_cast<FLOAT>(getClientWidth() ); vp.Height = static_cast<FLOAT>(getClientHeight() ); m_pD3D11DeviceContext->RSSetViewports(1, &vp); }
LRESULT MainWindow::onSize(UINT msg,WPARAM wParam,LPARAM lParam) { CustomWindow::onSize(msg,wParam,lParam); // int w=getClientWidth(); int h=getClientHeight(); int y=getClientBottom(); y-=2+24; // btnEnter->move( w-100- 2,y,100,24); btnPass->move( w-200- 6,y,100,24); btnView->move( w-300-10,y,100,24); for(int i=0;i<n_edtAns;i++){ y-=2+24; edtAns[n_edtAns-1-i]->move( 2,y,w-4,24); } edtQes->move( 2,2,w-4,y-4); return 0L; }
// protected methods of FFileDialog //---------------------------------------------------------------------- void FFileDialog::adjustSize() { int X, Y; std::size_t max_width; std::size_t max_height; std::size_t h; auto root_widget = getRootWidget(); if ( root_widget ) { max_width = root_widget->getClientWidth(); max_height = root_widget->getClientHeight(); } else { // fallback to xterm default size max_width = 80; max_height = 24; } h = max_height - 6; if ( h < 15 ) // minimum h = 15; if ( h > 30 ) // maximum h = 30; setHeight (h, false); X = 1 + int((max_width - getWidth()) / 2); Y = 1 + int((max_height - getHeight()) / 3); setPos(FPoint(X, Y), false); filebrowser.setHeight (h - 8, false); hidden.setY (int(h) - 4, false); cancel.setY (int(h) - 4, false); open.setY (int(h) - 4, false); FDialog::adjustSize(); printPath(directory); }
void D3D12Render::loadPipeline() { HRESULT res; #ifdef _DEBUG //Enable the D3D12 debug layer ComPtr<ID3D12Debug> pDebugController; if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&pDebugController)))) { pDebugController->EnableDebugLayer(); } #endif ComPtr<IDXGIFactory4> pFactory; CreateDXGIFactory1(IID_PPV_ARGS(&pFactory)); bool UseWarpDevice = false; if (UseWarpDevice) { ComPtr<IDXGIAdapter> pWarpAdapter; res = pFactory->EnumWarpAdapter(IID_PPV_ARGS(&pWarpAdapter)); assert(res == S_OK); res = D3D12CreateDevice(pWarpAdapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_pD3D12Device)); assert(res == S_OK); } else { res = D3D12CreateDevice(nullptr, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_pD3D12Device)); assert(res == S_OK); } /////////////////////// //Describe and Create the command queue////////////////////////////////////////////// D3D12_COMMAND_QUEUE_DESC queueDesc ={}; queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; res = m_pD3D12Device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&m_pCommandQueue)); assert(res == S_OK); //Describe and Create the swap chain DXGI_SWAP_CHAIN_DESC swapChainDesc ={}; swapChainDesc.BufferCount = FrameCount; swapChainDesc.BufferDesc.Width = getClientWidth(); swapChainDesc.BufferDesc.Height = getClientHeight(); swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; swapChainDesc.OutputWindow = getHwnd(); swapChainDesc.SampleDesc.Count = 1; swapChainDesc.Windowed = TRUE; ComPtr<IDXGISwapChain> pSwapChain; res = pFactory->CreateSwapChain( m_pCommandQueue.Get(), // Swap chain needs the queue so that it can force a flush on it. &swapChainDesc, &pSwapChain ); assert(res == S_OK); res = pSwapChain.As(&m_pSwapChain); assert(res == S_OK); m_frameIndex = m_pSwapChain->GetCurrentBackBufferIndex(); ///////////////////////// Create Decriptor heaps ///////////////////////////////////////////// { D3D12_DESCRIPTOR_HEAP_DESC rtvHeapDesc ={}; rtvHeapDesc.NumDescriptors = FrameCount; rtvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; rtvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; res = m_pD3D12Device->CreateDescriptorHeap(&rtvHeapDesc, IID_PPV_ARGS(&m_pRTVHeap)); assert(res == S_OK); m_rtvDescSize = m_pD3D12Device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); } //Create frame resources { CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(m_pRTVHeap->GetCPUDescriptorHandleForHeapStart()); // Create a RTV for each frame. for (UINT n = 0; n < FrameCount; n++) { res = m_pSwapChain->GetBuffer(n, IID_PPV_ARGS(&m_pRenderTargets[n])); assert(res == S_OK); m_pD3D12Device->CreateRenderTargetView(m_pRenderTargets[n].Get(), nullptr, rtvHandle); rtvHandle.Offset(1, m_rtvDescSize); } } //The command allocator is going to be used for allocating memory for the list of commands that we send to the GPU each frame to render graphics. res = m_pD3D12Device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&m_pCommandAllocator)); assert(res == S_OK); res = m_pD3D12Device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_BUNDLE, IID_PPV_ARGS(&m_pBundleAllocator)); assert(res == S_OK); }
bool cWindow::isFullscreen() const { return getClientWidth() == ManagerSystem.getScreenWidth() && getClientHeight() == ManagerSystem.getScreenHeight(); }
void CTimelineControl::paintControl( uiGraphics *pG ) { if ( m_needSortValue == true ) { sortValue(m_value); calcMinMax(m_value); m_needSortValue = false; } int nWidth = getClientWidth(); int nHeight = getClientHeight(); uiBrush bgGrey( uiColor(0x9f9f9f) ); uiBrush bgGreyDark( uiColor(0x666666) ); uiFont tahoma(14, L"tahoma"); tahoma.setFontNormal(); uiGraphics *graphics = pG->createBackBuffer( nWidth, nHeight ); // fill background graphics->drawFillRectangle(0,0, nWidth, nHeight, &bgGrey); if ( m_timeLength > 0.0f ) { // draw header & left graphics->drawFillRectangle(0,0, OFFSET_X, nHeight, &bgGreyDark); graphics->drawFillRectangle(0,0, nWidth, OFFSET_Y, &bgGreyDark); float midValue = (m_maxValue + m_minValue)*0.5f; uiPen pen(1, PS_SOLID, uiColor(0x888888)); uiPen penX(2, PS_SOLID, uiColor(0x0000ff)); uiPen penY(2, PS_SOLID, uiColor(0x00ff00)); uiPen penZ(2, PS_SOLID, uiColor(0xff0000)); graphics->selectObject(&pen); // draw center line graphics->drawLine(0, getY(midValue), nWidth, getY(midValue)); // draw limit line graphics->drawLine(0, getY(m_minValue), nWidth, getY(m_minValue)); graphics->drawLine(0, getY(m_maxValue), nWidth, getY(m_maxValue)); graphics->selectObject( &tahoma ); graphics->setTextBkTransparent(true); wchar_t text[512]; graphics->setTextColor( uiColor(0xffffff) ); swprintf(text,512,L"%.2f", m_minValue); graphics->drawText( 5, getY(m_minValue), text ); swprintf(text,512,L"%.2f", m_maxValue); graphics->drawText( 5, getY(m_maxValue), text ); swprintf(text,512,L"%.2f", midValue); graphics->drawText( 5, getY(midValue), text ); // set clipping graphics->setClip(OFFSET_X, 0, nWidth - OFFSET_X, nHeight); int len = (int)m_value.size(); for ( int i = 1; i < len; i++ ) { int x0 = getX( m_value[i-1].time ); int x1 = getX( m_value[i].time ); int y0 = getY( m_value[i-1].x ); int y1 = getY( m_value[i].x ); // draw col graphics->selectObject(&pen); graphics->drawLine(x1,0, x1,nHeight); swprintf(text,512,L"%.2f", m_value[i].time); if ( i == m_selectTimeID ) graphics->setTextColor( uiColor(0x0000ff) ); else graphics->setTextColor( uiColor(0xffffff) ); graphics->drawText( x1, 0, text ); // draw line x graphics->selectObject(&penX); graphics->drawLine(x0, y0, x1, y1); // draw line y y0 = getY( m_value[i-1].y ); y1 = getY( m_value[i].y ); graphics->selectObject(&penY); graphics->drawLine(x0, y0, x1, y1); // draw line z y0 = getY( m_value[i-1].z ); y1 = getY( m_value[i].z ); graphics->selectObject(&penZ); graphics->drawLine(x0, y0, x1, y1); } for ( int i = 0; i < len; i++ ) { int r = 4; int x1 = getX( m_value[i].time ); int y1 = getY( m_value[i].x ); // draw rectX graphics->selectObject(&penX); graphics->drawRectangle( x1-r,y1-r,x1+r,y1+r ); // draw rectY y1 = getY( m_value[i].y ); graphics->selectObject(&penY); graphics->drawRectangle( x1-r,y1-r,x1+r,y1+r ); // draw rectZ y1 = getY( m_value[i].z ); graphics->selectObject(&penZ); graphics->drawRectangle( x1-r,y1-r,x1+r,y1+r ); } graphics->selectObject(&penX); // paint current time uiPen penTime(1, PS_SOLID, uiColor(0x00FFFF)); if ( m_selectTimeID == -1 ) { int xTime = getX( m_currentTime ); graphics->selectObject(&penTime); graphics->drawLine( xTime, 0, xTime, nHeight ); } else { int xTime = getX( m_value[m_selectTimeID].time ); graphics->selectObject(&penTime); graphics->drawLine( xTime, 0, xTime, nHeight ); } } pG->swapBuffer(0,0,nWidth, nHeight, graphics, 0,0,nWidth,nHeight, SRCCOPY); graphics->releaseGraphics(); }
LRESULT toolbarCommand(HWND viewerWnd, HWND toolbar, int id) { int oldWid = getClientWidth(); int oldHyt = getClientHeight(); //This function is completely stupid and //unextendable... (TODO:) switch(id) { case TOOLBAR_OPEN: SendMessage(viewerWnd, WM_CHAR, 'O', 0); break; case TOOLBAR_SAVE: SendMessage(viewerWnd, WM_CHAR, 'S', 0); break; case TOOLBAR_DELETE: SendMessage(viewerWnd, WM_KEYDOWN, VK_DELETE, 0); break; case TOOLBAR_RENAME: SendMessage(viewerWnd, WM_KEYDOWN, VK_F2, 0); break; case TOOLBAR_PREV_IMAGE: SendMessage(viewerWnd, WM_CHAR, '\b', 0); break; case TOOLBAR_NEXT_IMAGE: SendMessage(viewerWnd, WM_CHAR, ' ', 0); break; case TOOLBAR_ZOOM_IN: SendMessage(viewerWnd, WM_CHAR, '+', 0); break; case TOOLBAR_ZOOM_OUT: SendMessage(viewerWnd, WM_CHAR, '-', 0); break; case TOOLBAR_ZOOM_100: SendMessage(viewerWnd, WM_CHAR, '/', 0); break; case TOOLBAR_ZOOM_FIT: SendMessage(viewerWnd, WM_CHAR, '*', 0); break; case TOOLBAR_ZOOM_LOCK: SendMessage(viewerWnd, WM_CHAR, 'L', 0); break; case TOOLBAR_ROTATE_LEFT: SendMessage(viewerWnd, WM_CHAR, 'Q', 0); break; case TOOLBAR_ROTATE_RIGHT: SendMessage(viewerWnd, WM_CHAR, 'W', 0); break; case TOOLBAR_COPY: SendMessage(viewerWnd, WM_CHAR, 3, 0); break; case TOOLBAR_PASTE: SendMessage(viewerWnd, WM_CHAR, 22, 0); break; case TOOLBAR_ALPHA: SendMessage(viewerWnd, WM_CHAR, 'A', 0); break; case TOOLBAR_BLEND: SendMessage(viewerWnd, WM_CHAR, 'B', 0); break; case TOOLBAR_TILE_VIEW: SendMessage(viewerWnd, WM_CHAR, 'M', 0); break; case TOOLBAR_CUBEMAP_VIEW: SendMessage(viewerWnd, WM_CHAR, 'C', 0); break; case TOOLBAR_PREV_LAYER: SendMessage(viewerWnd, WM_KEYDOWN, VK_PRIOR, 0); break; case TOOLBAR_NEXT_LAYER: SendMessage(viewerWnd, WM_KEYDOWN, VK_NEXT, 0); break; case TOOLBAR_NEXT_MIPMAP: SendMessage(viewerWnd, WM_KEYDOWN, VK_RIGHT, 0); break; case TOOLBAR_PREV_MIPMAP: SendMessage(viewerWnd, WM_KEYDOWN, VK_LEFT, 0); break; case TOOLBAR_NEXT_SLICE: SendMessage(viewerWnd, WM_KEYDOWN, VK_DOWN, 0); break; case TOOLBAR_PREV_SLICE: SendMessage(viewerWnd, WM_KEYDOWN, VK_UP, 0); break; case TOOLBAR_OPTIONS: //show register file types dialog until //a "real" options dialog is implemented SendMessage(viewerWnd, WM_CHAR, 'R', 0); break; case TOOLBAR_ALWAYS_ON_TOP: SendMessage(viewerWnd, WM_CHAR, 'T', 0); break; case TOOLBAR_LOAD_TIMES: SendMessage(viewerWnd, WM_CHAR, 'D', 0); break; case TOOLBAR_HELP: SendMessage(viewerWnd, WM_CHAR, 'H', 0); break; } //keep cursor in icons that change window size if(getClientWidth() != oldWid || getClientHeight() != oldHyt) { int index = id - TOOLBAR_FIRST_ICON; RECT r; if(SendMessage(toolbar, TB_GETITEMRECT, index, (LPARAM)&r) == TRUE) { POINT p = { (r.left + r.right)/2, (r.top + r.bottom)/2 }; ClientToScreen(toolbar, &p); int screenWid = GetSystemMetrics(SM_CXSCREEN); int screenHyt = GetSystemMetrics(SM_CYSCREEN); mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, (p.x*65535)/screenWid, (p.y*65535)/screenHyt, //dx, dy are normalized to [0, 65535] 0, 0); } } return 0; }
PrefsDialog::PrefsDialog( Window *frame, Window *parent ) : Dialog( frame, parent, Strings::get( 168 ), AWindow::CENTER | AWindow::ISMODAL | AWindow::ADJUSTSIZE, 0, 0, 500, 365 ) { char *namestr = "PrefsDialog"; name = new char[strlen(namestr)+1]; strcpy( name, namestr ); getGraphics()->setDialogFont(); int margin = 10, fontHeight = Graphics::dialogDesignFontHeight, yStart = getClientHeight() - fontHeight*2 - 20, interSpace = fontHeight + fontHeight / 2; prevUseBigFont = AGraphics::useBigFont; Notebook *notebook = new Notebook( this, 0, 50, getClientWidth(), getClientHeight() - 50, Color::BKGR, 0 ); asciiDialog = new AsciiDialog( notebook, notebook ); ascii2Dialog = new Ascii2Dialog( notebook, notebook ); hexDialog = new HexDialog( notebook, notebook ); editorDialog = new EditorDialog( notebook, notebook ); displayDialog = new DisplayDialog( notebook, notebook ); miscDialog = new MiscDialog( notebook, notebook ); notebook->add( editorDialog, Strings::get(188) ); notebook->add( displayDialog, Strings::get(190) ); notebook->add( asciiDialog, Strings::get(166) ); notebook->add( ascii2Dialog, Strings::get(209) ); notebook->add( hexDialog, Strings::get(179) ); notebook->add( miscDialog, Strings::get(196) ); OKButton = new Button( this, Strings::get(8), AWindow::ISDEFAULT|ISTABSTOP, 10, 10, 70, 30 ); OKButton->setYMove( FOLLOW ); cancelButton = new Button( this, Strings::get(9), ISTABSTOP, 90, 10, 70, 30 ); cancelButton->setYMove( FOLLOW ); setControlsVisible(); notebook->setTab( 0 ); OKButton->addButtonListener( this ); cancelButton->addButtonListener( this ); adjustForFontSize(); // Save/restore window position initSize(); int x = getX(), y = getY(), width = getWidth(), height = getHeight(); WinProperties::retrieveProperty( name, x, y, width, height ); setSize( width, height ); center( x, y ); setPos( x, y ); }
int ckvdApp::getWidth() { return getClientWidth() + SIDEBAR_WIDTH; }