void DisassemblyView::horizontalScrollBarChanged(int n) { static int old = 0; MoveView(n - old, 0); old = n; emit viewUpdated(); }
bool GUIminimap::MouseUpAction(int x, int y, int button) { if(downInMinimap&&LocalInside(x, y)) { MoveView(x, y, button); downInMinimap=false; return true; } downInMinimap=false; return false; }
int main (int argc, char *argv[]) { HDEVICE device; HVIEW view; if (!(device = OpenDevice(NULL))) { printf("OpenDevice failed!\n"); } if (!(view = CreateView(NULL, 0, 1000, 800))) { printf("CreateView failed!\n"); } MoveView(view, 200, 200); RECT bounds; GetViewBounds(view, &bounds); printf("x: %d\n", bounds.x); printf("y: %d\n", bounds.y); printf("w: %d\n", bounds.width); printf("h: %d\n", bounds.height); // if (!(device = GetDeviceFromView(view))) { // printf("GetDeviceFromView failed!\n"); // } GetViewSurface(device, view); printf("getmessage\n"); // ReleaseDevice(device); TASKMSG msg; memset(&msg, 0, sizeof(msg)); while ((msg.type != TASKMSG_EXIT)) { if (TaskWaitMessage(&msg, -1)) { continue; } printf("msg: %d\n", msg.type); continue; } printf("OK\n"); return 0; }
void DisassemblyView::wheelEvent(QWheelEvent * evt) { int numSteps = evt->delta() / 20; if (evt->orientation() == Qt::Vertical) { if (MoveView(0, -numSteps)) emit viewUpdated(); evt->accept(); return; } QAbstractScrollArea::wheelEvent(evt); }
bool GUIminimap::MouseMoveAction(int x, int y, int xrel, int yrel, int button) { if(parent) { w=parent->w; h=parent->h; } if(!LocalInside(x,y)) return false; MoveView(x, y, -1); if(button!=1&&button!=3) return false; if(downInMinimap&&button) { MoveView(x, y, button); return true; } return false; }
void CMiniMap::MouseMove(int x, int y, int dx, int dy, int button) { if (mouseMove) { xpos += dx; ypos -= dy; xpos = std::max(0, xpos); if (gu->dualScreenMode) { xpos = std::min((2 * gu->viewSizeX) - width, xpos); } else { xpos = std::min(gu->viewSizeX - width, xpos); } ypos = std::max(5, std::min(gu->viewSizeY - height, ypos)); UpdateGeometry(); return; } if (mouseResize) { ypos -= dy; width += dx; height += dy; height = std::min(gu->viewSizeY, height); if (gu->dualScreenMode) { width = std::min(2 * gu->viewSizeX, width); } else { width = std::min(gu->viewSizeX, width); } if (keys[SDLK_LSHIFT]) { width = (height * gs->mapx) / gs->mapy; } width = std::max(5, width); height = std::max(5, height); ypos = std::min(gu->viewSizeY - height, ypos); UpdateGeometry(); return; } if (mouseLook && mapBox.Inside(x, y)) { MoveView(x,y); return; } }
void CMiniMap::MouseMove(int x, int y, int dx, int dy, int button) { if(mouseMove){ xpos+=dx; ypos-=dy; return; } else if(mouseResize){ ypos-=dy; height+=dy; width+=dx; if(keys[SDLK_LSHIFT]) { width = height * gs->mapx/gs->mapy; } return; } else if(mouseLook && (x>xpos) && (x<xpos+width) && (y>gu->screeny-ypos-height) && (y<gu->screeny-ypos)){ MoveView(x,y); return; } }
bool CMiniMap::MousePress(int x, int y, int button) { if(minimized && x<10 && y<10){ minimized=false; return true; } if(minimized) return false; if((x>xpos) && (x<xpos+width) && (y>gu->screeny-ypos-height) && (y<gu->screeny-ypos)){ if(button==SDL_BUTTON_LEFT){ if(x>xpos+width-10 && y>gu->screeny-ypos-10) mouseResize=true; else if (x<xpos+10 && y<gu->screeny-ypos-height+10) mouseMove=true; return true; } else if(button==SDL_BUTTON_RIGHT){ MoveView(x,y); mouseLook=true; return true; } } return false; }
bool CMiniMap::MousePress(int x, int y, int button) { if (minimized) { if ((x < buttonSize) && (y < buttonSize)) { minimized = false; return true; } else { return false; } } const bool inMap = mapBox.Inside(x, y); const bool inButtons = buttonBox.Inside(x, y); if (!inMap && !inButtons) { return false; } if (button == SDL_BUTTON_LEFT) { if (inMap && (guihandler->inCommand >= 0)) { proxyMode = true; ProxyMousePress(x, y, button); return true; } if (showButtons && inButtons) { if (moveBox.Inside(x, y)) { mouseMove = true; return true; } else if (resizeBox.Inside(x, y)) { mouseResize = true; return true; } else if (minimizeBox.Inside(x, y) || maximizeBox.Inside(x, y)) { return true; } } if (inMap && !mouse->buttons[SDL_BUTTON_LEFT].chorded) { selecting = true; return true; } } else if (inMap) { if ((fullProxy && (button == SDL_BUTTON_MIDDLE)) || (!fullProxy && (button == SDL_BUTTON_RIGHT))) { MoveView(x, y); if (maximized) { ToggleMaximized(false); } else { mouseLook = true; } return true; } else if (fullProxy && (button == SDL_BUTTON_RIGHT)) { proxyMode = true; ProxyMousePress(x, y, button); return true; } } return false; }
ConceptionApp::ConceptionApp(InputManager & InputManager) : App(InputManager), m_CurrentProject(), m_TypingModule(new TypingModule()) // Gets cleaned up via unique_ptr when pushed back to m_Widgets { PopulateConcepts(); { auto MainCanvas = new Canvas(Vector2n(0, 0), true, true); //MainCanvas->MoveView(0, 336); MainCanvas->MoveView(1, -64); #if 1 { auto StdIncludesList = new ListWidget<ConceptId>(Vector2n::ZERO, m_CurrentProject.GetStdIncludes(), *m_TypingModule); StdIncludesList->m_TapAction = [=](Vector2n LocalPosition, std::vector<ConceptId> & m_List) { auto Entry = m_TypingModule->TakeString(); if (!Entry.empty()) { auto ConceptId = FindOrCreateConcept(Entry); //Insert(ConceptId); // TEST auto Spot = m_List.begin() + (LocalPosition.Y() / lineHeight); m_List.insert(Spot, ConceptId); } else { auto ListEntry = static_cast<decltype(m_List.size())>(LocalPosition.Y() / lineHeight); if (ListEntry < m_List.size()) { m_TypingModule->SetString(GetConcept(m_List[ListEntry]).GetContent()); m_List.erase(m_List.begin() + ListEntry); } } }; auto LabelledStdIncludesList = new FlowLayoutWidget(Vector2n(-280, -250), { std::shared_ptr<Widget>(new LabelWidget(Vector2n::ZERO, std::string("#include <"), LabelWidget::Background::None)), std::shared_ptr<Widget>(StdIncludesList), std::shared_ptr<Widget>(new LabelWidget(Vector2n::ZERO, std::string(">"), LabelWidget::Background::None)) }, {}); LabelledStdIncludesList->AddBehavior(std::shared_ptr<Behavior>(new DraggablePositionBehavior(*LabelledStdIncludesList))); MainCanvas->AddWidget(LabelledStdIncludesList); } #endif MainCanvas->AddWidget(new ButtonWidget(Vector2n(-100, -350), []() { std::cout << "Hi from anon func.\n"; } )); MainCanvas->AddWidget(new ButtonWidget(Vector2n(-60, -350), []() { std::cout << "Second button.\n"; } )); MainCanvas->AddWidget(new ToggleWidget(Vector2n(-20, -350), [](bool State) { std::cout << "Testing this toggle widget! It's now set to " << State << ".\n"; }, true)); MainCanvas->AddWidget(new LiveFunctionWidget(Vector2n(-100, 100), *m_TypingModule, m_CurrentProject)); MainCanvas->AddWidget(new LiveProgramWidget(Vector2n(-100, -300), *m_TypingModule, m_CurrentProject)); MainCanvas->AddWidget(new LiveProgramWidget(Vector2n(-100, -100), *m_TypingModule, m_CurrentProject)); MainCanvas->AddWidget(new LiveGofmtWidget(Vector2n(-460, 200), *m_TypingModule, m_CurrentProject)); MainCanvas->AddWidget(new TextFieldWidget(Vector2n(-460, 160), *m_TypingModule)); MainCanvas->AddWidget(new ShellWidget(Vector2n(-460, 60), *m_TypingModule)); MainCanvas->AddWidget(new SayWidget(Vector2n(-460, -100), *m_TypingModule)); MainCanvas->AddWidget(new ConceptStringBoxWidget(Vector2n(-400, 100 + 400), *m_TypingModule)); // TEST: Modify some Concept { auto Widget = new TextFieldWidget(Vector2n(-320, 470), *m_TypingModule); Widget->SetContent(GetConcept(47).GetContent()); Widget->m_OnChange = [=]() { static_cast<ConceptBasic &>(ModifyConcept(47)).SetContentTEST(Widget->GetContent()); }; Widget->AddBehavior(std::shared_ptr<Behavior>(new DraggablePositionBehavior(*Widget))); MainCanvas->AddWidget(Widget); } // Label resizing test { auto SourceWidget = new TextFieldWidget(Vector2n::ZERO, *m_TypingModule); auto Content = [=]() -> std::string { return SourceWidget->GetContent(); }; auto LabelWidget = new class LabelWidget(Vector2n::ZERO, Content, LabelWidget::Background::Normal); MainCanvas->AddWidget(new FlowLayoutWidget(Vector2n(-100, -450), { std::shared_ptr<Widget>(SourceWidget), std::shared_ptr<Widget>(LabelWidget) }, {})); } // Time widget { auto Content = []() -> std::string { auto now = std::chrono::system_clock::now(); auto duration = now.time_since_epoch(); auto seconds = std::chrono::duration_cast<std::chrono::seconds>(duration).count(); return std::to_string(seconds); }; auto LabelWidget = new class LabelWidget(Vector2n(360, -340), Content, LabelWidget::Background::Normal); LabelWidget->AddBehavior(std::shared_ptr<Behavior>(new DraggablePositionBehavior(*LabelWidget))); MainCanvas->AddWidget(LabelWidget); } MainCanvas->AddWidget(new TimeWidget(Vector2n(360, -360))); // Time widget #if 0 // "./GenProgram.go" file contents displayed (in real-time) in this Label Widget { auto Content = []() -> std::string { //return FromFileToString("./GenProgram.go"); return FromFileToString("/Users/Dmitri/Desktop/goproj_play/src/gist.github.com/4670289.git/gistfile1.go"); }; auto LabelWidget = new class LabelWidget(Vector2n(-546, -186), Content, LabelWidget::Background::Normal); LabelWidget->AddBehavior(std::shared_ptr<Behavior>(new DraggablePositionBehavior(*LabelWidget))); MainCanvas->AddWidget(LabelWidget); } #endif #if 1 { MainCanvas->AddWidget(new ListWidget<Concept *>(Vector2n(-730 - 450, -250), Concepts, *m_TypingModule)); } #endif m_Widgets.push_back(std::unique_ptr<Widget>(m_TypingModule)); m_Widgets.push_back(std::unique_ptr<Widget>(MainCanvas)); m_Widgets.push_back(std::unique_ptr<Widget>(new DebugOverlayWidget())); // DEBUG: Print debug info } // Prepare and start the thread { m_CurrentProject.StartBackgroundThread(); } { // Load program m_CurrentProject.LoadSampleGenProgram(*static_cast<Canvas *>(m_Widgets[0].get())); } }
bool FullDisassemblyView::MoveCursor(s32 xOffset, s32 yOffset, bool& rInvalidateView) { rInvalidateView = false; auto const& rDoc = m_rCore.GetDocument(); std::lock_guard<MutexType> Lock(m_Mutex); // We start to update the x offset. s32 xNewOffset = m_Cursor.m_xAddressOffset + xOffset; m_Cursor.m_xAddressOffset = (xNewOffset < 0) ? 0 : xNewOffset; // If yOffset is 0, we can return now. if (yOffset == 0) return true; // If we move the cursor in the same cell, we can simply update y offset. u16 CurLineNo = m_PrintData.GetLineNo(m_Cursor.m_Address); if (CurLineNo) { s32 yNewOffset = static_cast<s32>(m_Cursor.m_yAddressOffset) + yOffset; if (yNewOffset >= 0 && yNewOffset < static_cast<s32>(CurLineNo)) { m_Cursor.m_yAddressOffset = static_cast<u16>(yNewOffset); if (m_Cursor.m_yAddressOffset < m_Top.m_yAddressOffset) { m_Top.m_yAddressOffset = m_Cursor.m_yAddressOffset; rInvalidateView = true; } return true; } } Address FirstAddr = rDoc.GetFirstAddress(); Address NewAddr = m_Cursor.m_Address; while (yOffset != 0) { u16 CurLineNo = m_PrintData.GetLineNo(NewAddr); // move view backward if (yOffset < 0) { // If the cursor is at top, we can return true now. if (NewAddr == FirstAddr && m_Cursor.m_yAddressOffset == 0) { m_Top.m_Address = NewAddr; m_Top.m_yAddressOffset = 0; rInvalidateView = true; return true; } // If the current address is out of the view, we must update it. if ( CurLineNo == 0 || m_Cursor.m_yAddressOffset == 0 || m_Cursor.m_yAddressOffset >= CurLineNo) { // Get the previous address. if (!rDoc.MoveAddress(NewAddr, NewAddr, -1)) return false; u16 NewLineNo = 0; // Update the view if needed. if (!m_PrintData.Contains(NewAddr)) { m_Top.m_Address = NewAddr; m_Format(NewAddr, m_FormatFlags, m_Height); NewLineNo = m_PrintData.GetLineNo(NewAddr); if (NewLineNo == 0) return false; m_Top.m_yAddressOffset = NewLineNo - 1; rInvalidateView = true; } if (NewLineNo == 0) if ((NewLineNo = m_PrintData.GetLineNo(NewAddr)) == 0) return false; m_Cursor.m_yAddressOffset = NewLineNo - 1; } else --m_Cursor.m_yAddressOffset; ++yOffset; } // move view forward else { u16 Off; if (!m_PrintData.GetLineOffset(m_Cursor.m_Address, Off)) return false; Off += (m_Cursor.m_yAddressOffset - m_Top.m_yAddressOffset + 2); if (Off > m_Height) { u16 MoveOff = Off - m_Height; if (!MoveView(0, MoveOff)) return false; rInvalidateView = true; } if (m_Cursor.m_yAddressOffset == CurLineNo - 1) { if (!rDoc.MoveAddress(NewAddr, NewAddr, 1)) return false; // Move the view until we reach the new address. while (!m_PrintData.Contains(NewAddr)) { if (!MoveView(0, 1)) return false; rInvalidateView = true; } m_Cursor.m_yAddressOffset = 0; } else ++m_Cursor.m_yAddressOffset; --yOffset; } } m_Cursor.m_Address = NewAddr; if (yOffset == 0) return true; if (yOffset < 0) m_Cursor.m_yAddressOffset = (m_Cursor.m_Address == m_rDoc.GetFirstAddress()) ? 0 : m_PrintData.GetLineNo(NewAddr) - 1; else m_Cursor.m_yAddressOffset = 0; return true; }